Added copyright lines for files I've edited this year.
[synfig.git] / synfig-studio / trunk / src / synfigapp / actions / layermove.cpp
index 2e7839f..f72afa4 100644 (file)
@@ -2,19 +2,21 @@
 /*!    \file layermove.cpp
 **     \brief Template File
 **
-**     $Id: layermove.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
+**     $Id$
 **
 **     \legal
-**     Copyright (c) 2002 Robert B. Quattlebaum Jr.
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2008 Chris Moore
 **
-**     This software and associated documentation
-**     are CONFIDENTIAL and PROPRIETARY property of
-**     the above-mentioned copyright holder.
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
 **
-**     You may not copy, print, publish, or in any
-**     other way distribute this software without
-**     a prior written agreement with
-**     the copyright holder.
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
 **     \endlegal
 */
 /* ========================================================================= */
@@ -31,6 +33,8 @@
 #include "layermove.h"
 #include <synfigapp/canvasinterface.h>
 
+#include <synfigapp/general.h>
+
 #endif
 
 using namespace std;
@@ -41,14 +45,14 @@ using namespace Action;
 
 /* === M A C R O S ========================================================= */
 
-ACTION_INIT(Action::LayerMove);
+ACTION_INIT_NO_GET_LOCAL_NAME(Action::LayerMove);
 ACTION_SET_NAME(Action::LayerMove,"layer_move");
-ACTION_SET_LOCAL_NAME(Action::LayerMove,_("Move Layer"));
+ACTION_SET_LOCAL_NAME(Action::LayerMove,N_("Move Layer"));
 ACTION_SET_TASK(Action::LayerMove,"move");
 ACTION_SET_CATEGORY(Action::LayerMove,Action::CATEGORY_LAYER);
 ACTION_SET_PRIORITY(Action::LayerMove,0);
 ACTION_SET_VERSION(Action::LayerMove,"0.0");
-ACTION_SET_CVS_ID(Action::LayerMove,"$Id: layermove.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
+ACTION_SET_CVS_ID(Action::LayerMove,"$Id$");
 
 /* === G L O B A L S ======================================================= */
 
@@ -63,11 +67,20 @@ Action::LayerMove::LayerMove():
 {
 }
 
+synfig::String
+Action::LayerMove::get_local_name()const
+{
+       if (layer)
+               return strprintf("%s '%s'", _("Move Layer"), layer->get_non_empty_description().c_str());
+       else
+               return _("Move Layer");
+}
+
 Action::ParamVocab
 Action::LayerMove::get_param_vocab()
 {
        ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-       
+
        ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
                .set_local_name(_("Layer"))
                .set_desc(_("Layer to be moved"))
@@ -83,14 +96,14 @@ Action::LayerMove::get_param_vocab()
                .set_desc(_("The canvas the layer is to be moved to"))
                .set_optional()
        );
-       
+
        return ret;
 }
 
 bool
-Action::LayerMove::is_canidate(const ParamList &x)
+Action::LayerMove::is_candidate(const ParamList &x)
 {
-       return canidate_check(get_param_vocab(),x);
+       return candidate_check(get_param_vocab(),x);
 }
 
 bool
@@ -100,21 +113,21 @@ Action::LayerMove::set_param(const synfig::String& name, const Action::Param &pa
        {
 
                layer=param.get_layer();
-               
+
                return true;
        }
 
        if(name=="new_index" && param.get_type()==Param::TYPE_INTEGER)
        {
                new_index=param.get_integer();
-               
+
                return true;
        }
 
        if(name=="dest_canvas" && param.get_type()==Param::TYPE_CANVAS)
        {
                dest_canvas=param.get_canvas();
-               
+
                return true;
        }
 
@@ -124,7 +137,7 @@ Action::LayerMove::set_param(const synfig::String& name, const Action::Param &pa
 bool
 Action::LayerMove::is_ready()const
 {
-       synfig::info(__FILE__":%d: layer->count()=%d",__LINE__,layer.count());
+       // synfig::info(__FILE__":%d: layer->count()=%d",__LINE__,layer.count());
        if(!layer || (unsigned)new_index==0xdeadbeef)
                return false;
        return Action::CanvasSpecific::is_ready();
@@ -132,22 +145,22 @@ Action::LayerMove::is_ready()const
 
 void
 Action::LayerMove::perform()
-{              
-       synfig::info(__FILE__":%d: layer->count()=%d",__LINE__,layer.count());
+{
+       // synfig::info(__FILE__":%d: layer->count()=%d",__LINE__,layer.count());
 
        Canvas::Handle subcanvas(layer->get_canvas());
        src_canvas=subcanvas;
        if(!dest_canvas)
                dest_canvas=subcanvas;
-               
+
        // Find the iterator for the layer
        Canvas::iterator iter=find(src_canvas->begin(),src_canvas->end(),layer);
-       
+
        // If we couldn't find the layer in the canvas, then bail
        if(*iter!=layer)
                throw Error(_("This layer doesn't exist anymore."));
 
-       synfig::info(__FILE__":%d: layer->count()=%d",__LINE__,layer.count());
+       // synfig::info(__FILE__":%d: layer->count()=%d",__LINE__,layer.count());
 
        // If the subcanvas isn't the same as the canvas,
        // then it had better be an inline canvas. If not,
@@ -155,38 +168,38 @@ Action::LayerMove::perform()
        //if(get_canvas()!=subcanvas && !subcanvas->is_inline())
        if(get_canvas()->get_root()!=dest_canvas->get_root() || get_canvas()->get_root()!=src_canvas->get_root())
                throw Error(_("You cannot directly move layers across compositions"));
-       
+
        old_index=iter-src_canvas->begin();
        int depth;
-       
+
        if(new_index<0)
                depth=dest_canvas->size()+new_index+1;
        else
                depth=new_index;
-       
+
        set_dirty(layer->active());
 
-       synfig::info(__FILE__":%d: layer->count()=%d",__LINE__,layer.count());
+       // synfig::info(__FILE__":%d: layer->count()=%d",__LINE__,layer.count());
 
        // If we were to move it to where it is
        if(old_index==depth && src_canvas==dest_canvas)
                return;
-       
+
        if(depth>dest_canvas->size())
                depth=dest_canvas->size();
        if(depth<0)
                depth=0;
-               
+
        src_canvas->erase(iter);
-       
-       dest_canvas->insert(dest_canvas->begin()+depth,layer);          
+
+       dest_canvas->insert(dest_canvas->begin()+depth,layer);
        layer->set_canvas(dest_canvas);
-       
+
        layer->changed();
        dest_canvas->changed(); if(dest_canvas!=src_canvas) src_canvas->changed();
-       
-       synfig::info(__FILE__":%d: layer->count()=%d",__LINE__,layer.count());
-       
+
+       // synfig::info(__FILE__":%d: layer->count()=%d",__LINE__,layer.count());
+
        if(get_canvas_interface())
        {
                if(src_canvas==dest_canvas)
@@ -207,7 +220,7 @@ Action::LayerMove::perform()
        }
        else synfig::warning("CanvasInterface not set on action");
 
-       synfig::info(__FILE__":%d: layer->count()=%d",__LINE__,layer.count());
+       // synfig::info(__FILE__":%d: layer->count()=%d",__LINE__,layer.count());
 }
 
 void
@@ -215,11 +228,11 @@ Action::LayerMove::undo()
 {
        // Find the iterator for the layer
        Canvas::iterator iter=find(dest_canvas->begin(),dest_canvas->end(),layer);
-       
+
        // If we couldn't find the layer in the canvas, then bail
        if(*iter!=layer || (get_canvas()!=dest_canvas && !dest_canvas->is_inline()))
                throw Error(_("This layer doesn't exist anymore."));
-       
+
        // If we were to move it to where it is
        if(old_index==new_index && src_canvas==dest_canvas)
                return;
@@ -228,13 +241,13 @@ Action::LayerMove::undo()
        set_dirty(layer->active());
 
        dest_canvas->erase(iter);
-       
+
        src_canvas->insert(src_canvas->begin()+old_index,layer);
        layer->set_canvas(src_canvas);
 
        layer->changed();
        dest_canvas->changed(); if(dest_canvas!=src_canvas) src_canvas->changed();
-       
+
        // Execute any signals
        if(get_canvas_interface())
        {
@@ -252,7 +265,7 @@ Action::LayerMove::undo()
                else
                {
                        get_canvas_interface()->signal_layer_moved()(layer,old_index,src_canvas);
-                       //get_canvas_interface()->signal_layer_removed()(layer);        
+                       //get_canvas_interface()->signal_layer_removed()(layer);
                        //get_canvas_interface()->signal_layer_inserted()(layer,old_index);
                }
        }