Fix 1455310: add 'loop' and 'unloop' to the right-click action of all bline vertices...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sun, 25 Feb 2007 05:43:55 +0000 (05:43 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sun, 25 Feb 2007 05:43:55 +0000 (05:43 +0000)
git-svn-id: http://svn.voria.com/code@254 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-studio/trunk/src/gtkmm/state_bline.cpp
synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistloop.cpp
synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistunloop.cpp

index 68aa318..d21ad9e 100644 (file)
@@ -104,6 +104,7 @@ class studio::StateBLine_Context : public sigc::trackable
        void bline_delete_vertex(synfig::ValueNode_Const::Handle value_node);
        void bline_insert_vertex(synfig::ValueNode_Const::Handle value_node,float origin=0.5);
        void loop_bline();
+       void unloop_bline();
 
        void refresh_ducks(bool x=true);
        
@@ -1055,12 +1056,24 @@ StateBLine_Context::loop_bline()
 }
 
 void
+StateBLine_Context::unloop_bline()
+{
+       loop_=false;
+
+       refresh_ducks(false);
+}
+
+void
 StateBLine_Context::popup_vertex_menu(synfig::ValueNode_Const::Handle value_node)
 {
        menu.items().clear();
 
-       if(!loop_ && value_node==bline_point_list.front())
+       if(loop_)
        {
+               menu.items().push_back(Gtk::Menu_Helpers::MenuElem("Unloop BLine",
+                               sigc::mem_fun(*this,&studio::StateBLine_Context::unloop_bline)
+               ));
+       } else {
                menu.items().push_back(Gtk::Menu_Helpers::MenuElem("Loop BLine",
                                sigc::mem_fun(*this,&studio::StateBLine_Context::loop_bline)
                ));
index 66f147c..daa8b82 100644 (file)
@@ -78,7 +78,12 @@ Action::ValueNodeDynamicListLoop::is_canidate(const ParamList &x)
 {
        if(canidate_check(get_param_vocab(),x))
        {
-               ValueNode::Handle value_node(x.find("value_node")->second.get_value_node());
+               ValueNode::Handle value_node;
+               ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());
+               if(value_desc.parent_is_value_node())
+                       value_node = value_desc.get_parent_value_node();
+               else
+                       value_node = x.find("value_node")->second.get_value_node();
                if(!ValueNode_DynamicList::Handle::cast_dynamic(value_node))
                        return false;
                if(ValueNode_DynamicList::Handle::cast_dynamic(value_node)->get_loop()==true)
@@ -91,7 +96,22 @@ Action::ValueNodeDynamicListLoop::is_canidate(const ParamList &x)
 bool
 Action::ValueNodeDynamicListLoop::set_param(const synfig::String& name, const Action::Param &param)
 {
-       if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
+       if(!value_node && name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
+       {
+               ValueDesc value_desc(param.get_value_desc());
+
+               if(!value_desc.parent_is_value_node())
+                       return false;
+
+               value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
+
+               if (!value_node)
+                       return false;
+
+               return true;
+       }
+
+       if(!value_node && name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
        {               
                value_node=ValueNode_DynamicList::Handle::cast_dynamic(param.get_value_node());
                
index 2d04245..9b107a2 100644 (file)
@@ -78,7 +78,12 @@ Action::ValueNodeDynamicListUnLoop::is_canidate(const ParamList &x)
 {
        if(canidate_check(get_param_vocab(),x))
        {
-               ValueNode::Handle value_node(x.find("value_node")->second.get_value_node());
+               ValueNode::Handle value_node;
+               ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());
+               if(value_desc.parent_is_value_node())
+                       value_node = value_desc.get_parent_value_node();
+               else
+                       value_node = x.find("value_node")->second.get_value_node();
                if(!ValueNode_DynamicList::Handle::cast_dynamic(value_node))
                        return false;
                if(ValueNode_DynamicList::Handle::cast_dynamic(value_node)->get_loop()==false)
@@ -91,7 +96,22 @@ Action::ValueNodeDynamicListUnLoop::is_canidate(const ParamList &x)
 bool
 Action::ValueNodeDynamicListUnLoop::set_param(const synfig::String& name, const Action::Param &param)
 {
-       if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
+       if(!value_node && name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
+       {
+               ValueDesc value_desc(param.get_value_desc());
+
+               if(!value_desc.parent_is_value_node())
+                       return false;
+
+               value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
+
+               if (!value_node)
+                       return false;
+
+               return true;
+       }
+
+       if(!value_node && name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
        {               
                value_node=ValueNode_DynamicList::Handle::cast_dynamic(param.get_value_node());