Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-studio / trunk / src / synfigapp / actions / waypointadd.cpp
index c29d8b9..5b03edf 100644 (file)
@@ -2,10 +2,11 @@
 /*!    \file waypointadd.cpp
 **     \brief Template File
 **
-**     $Id: waypointadd.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
+**     $Id$
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**  Copyright (c) 2008 Chris Moore
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
@@ -33,6 +34,8 @@
 #include <synfigapp/canvasinterface.h>
 #include <synfigapp/main.h>
 
+#include <synfigapp/general.h>
+
 #endif
 
 using namespace std;
@@ -44,13 +47,13 @@ using namespace Action;
 /* === M A C R O S ========================================================= */
 
 ACTION_INIT(Action::WaypointAdd);
-ACTION_SET_NAME(Action::WaypointAdd,"waypoint_add");
-ACTION_SET_LOCAL_NAME(Action::WaypointAdd,"Add Waypoint");
+ACTION_SET_NAME(Action::WaypointAdd,"WaypointAdd");
+ACTION_SET_LOCAL_NAME(Action::WaypointAdd,N_("Add Waypoint"));
 ACTION_SET_TASK(Action::WaypointAdd,"add");
 ACTION_SET_CATEGORY(Action::WaypointAdd,Action::CATEGORY_WAYPOINT);
 ACTION_SET_PRIORITY(Action::WaypointAdd,0);
 ACTION_SET_VERSION(Action::WaypointAdd,"0.0");
-ACTION_SET_CVS_ID(Action::WaypointAdd,"$Id: waypointadd.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
+ACTION_SET_CVS_ID(Action::WaypointAdd,"$Id$");
 
 /* === G L O B A L S ======================================================= */
 
@@ -69,7 +72,7 @@ Action::ParamVocab
 Action::WaypointAdd::get_param_vocab()
 {
        ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-       
+
        ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
                .set_local_name(_("Destination ValueNode (Animated)"))
        );
@@ -92,16 +95,11 @@ Action::WaypointAdd::get_param_vocab()
 bool
 Action::WaypointAdd::is_candidate(const ParamList &x)
 {
-       if(candidate_check(get_param_vocab(),x))
-       {
-               if(!ValueNode_Animated::Handle::cast_dynamic(x.find("value_node")->second.get_value_node()))
-                       return false;
-
-               // We need either a waypoint or a time.
-               if(x.count("waypoint") || x.count("time"))
-                       return true;
-       }
-       return false;
+       return (candidate_check(get_param_vocab(),x) &&
+                       // We need an animated valuenode.
+                       ValueNode_Animated::Handle::cast_dynamic(x.find("value_node")->second.get_value_node()) &&
+                       // We need either a waypoint or a time.
+                       (x.count("waypoint") || x.count("time")));
 }
 
 bool
@@ -112,13 +110,13 @@ Action::WaypointAdd::set_param(const synfig::String& name, const Action::Param &
                value_node=ValueNode_Animated::Handle::cast_dynamic(param.get_value_node());
                if(time_set)
                        calc_waypoint();
-               
+
                return static_cast<bool>(value_node);
        }
        if(name=="waypoint" && param.get_type()==Param::TYPE_WAYPOINT && !time_set)
        {
                waypoint=param.get_waypoint();
-               
+
                return true;
        }
        if(name=="time" && param.get_type()==Param::TYPE_TIME && waypoint.get_time()==Time::begin()-1)
@@ -128,7 +126,7 @@ Action::WaypointAdd::set_param(const synfig::String& name, const Action::Param &
 
                if(value_node)
                        calc_waypoint();
-               
+
                return true;
        }
 
@@ -143,15 +141,15 @@ Action::WaypointAdd::is_ready()const
        return Action::CanvasSpecific::is_ready();
 }
 
-// This function is called if a time is specified, but not 
+// This function is called if a time is specified, but not
 // a waypoint. In this case, we need to calculate the value
 // of the waypoint
 void
 Action::WaypointAdd::calc_waypoint()
-{      
+{
        Time time=waypoint.get_time();
        Waypoint original(waypoint);
-       waypoint=value_node->new_waypoint_at_time(time);        
+       waypoint=value_node->new_waypoint_at_time(time);
        waypoint.mimic(original);
        waypoint.set_before(synfigapp::Main::get_interpolation());
        waypoint.set_after(synfigapp::Main::get_interpolation());
@@ -159,7 +157,7 @@ Action::WaypointAdd::calc_waypoint()
 /*
        ValueNode_Animated::WaypointList &waypoint_list(value_node->waypoint_list());
        ValueNode_Animated::WaypointList::iterator iter;
-       
+
        if(waypoint_list.empty())
        {
                waypoint.set_value((*value_node)(time));
@@ -167,7 +165,7 @@ Action::WaypointAdd::calc_waypoint()
        }
 
        ValueNode_Animated::WaypointList::iterator closest=waypoint_list.begin();
-               
+
        for(iter=waypoint_list.begin();iter!=waypoint_list.end();++iter)
        {
                const Real dist(abs(iter->get_time()-time));
@@ -183,15 +181,15 @@ Action::WaypointAdd::calc_waypoint()
 
 void
 Action::WaypointAdd::perform()
-{              
+{
        try { value_node->find(waypoint.get_time()); throw Error(_("A Waypoint already exists at this point in time (%s)"),waypoint.get_time().get_string().c_str());}
-       catch(synfig::Exception::NotFound) { }  
+       catch(synfig::Exception::NotFound) { }
 
        try { if(value_node->find(waypoint)!=value_node->waypoint_list().end()) throw Error(_("This waypoint is already in the ValueNode"));}
-       catch(synfig::Exception::NotFound) { }  
-       
+       catch(synfig::Exception::NotFound) { }
+
        value_node->add(waypoint);
-       
+
        value_node->changed();
 /*_if(get_canvas_interface())
        {
@@ -204,7 +202,7 @@ void
 Action::WaypointAdd::undo()
 {
        value_node->erase(waypoint);
-       
+
        value_node->changed();
 /*_if(get_canvas_interface())
        {