From: dooglus Date: Thu, 6 Mar 2008 20:37:48 +0000 (+0000) Subject: Tidy up some is_candidate() methods. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=fcf1f2a99d715f39ca71469145d286d74a8af159;p=synfig.git Tidy up some is_candidate() methods. git-svn-id: http://svn.voria.com/code@1864 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-studio/trunk/src/synfigapp/actions/activepointadd.cpp b/synfig-studio/trunk/src/synfigapp/actions/activepointadd.cpp index 2840796..b6f04a5 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/activepointadd.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/activepointadd.cpp @@ -93,17 +93,16 @@ Action::ActivepointAdd::get_param_vocab() bool Action::ActivepointAdd::is_candidate(const ParamList &x) { - if(candidate_check(get_param_vocab(),x)) - { - ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); - if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())) - return false; + if (!candidate_check(get_param_vocab(),x)) + return false; - // We need either a activepoint or a time. - if(x.count("activepoint") || x.count("time")) - return true; - } - return false; + ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); + + return (value_desc.parent_is_value_node() && + // We need a dynamic list. + ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()) && + // We need either an activepoint or a time. + (x.count("activepoint") || x.count("time"))); } bool diff --git a/synfig-studio/trunk/src/synfigapp/actions/activepointremove.cpp b/synfig-studio/trunk/src/synfigapp/actions/activepointremove.cpp index 7626eb0..d43a64a 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/activepointremove.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/activepointremove.cpp @@ -85,15 +85,14 @@ Action::ActivepointRemove::get_param_vocab() bool Action::ActivepointRemove::is_candidate(const ParamList &x) { - if(candidate_check(get_param_vocab(),x)) - { - ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); - if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())) - return false; + if (!candidate_check(get_param_vocab(),x)) + return false; - return true; - } - return false; + ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); + + return (value_desc.parent_is_value_node() && + // We need a dynamic list. + ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())); } bool diff --git a/synfig-studio/trunk/src/synfigapp/actions/activepointset.cpp b/synfig-studio/trunk/src/synfigapp/actions/activepointset.cpp index 904b556..f3a5323 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/activepointset.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/activepointset.cpp @@ -85,15 +85,14 @@ Action::ActivepointSet::get_param_vocab() bool Action::ActivepointSet::is_candidate(const ParamList &x) { - if(candidate_check(get_param_vocab(),x)) - { - ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); - if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())) - return false; + if (!candidate_check(get_param_vocab(),x)) + return false; - return true; - } - return false; + ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); + + return (value_desc.parent_is_value_node() && + // We need a dynamic list. + ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())); } bool diff --git a/synfig-studio/trunk/src/synfigapp/actions/activepointsetoff.cpp b/synfig-studio/trunk/src/synfigapp/actions/activepointsetoff.cpp index b1c7156..15bfe14 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/activepointsetoff.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/activepointsetoff.cpp @@ -99,22 +99,22 @@ Action::ActivepointSetOff::get_param_vocab() bool Action::ActivepointSetOff::is_candidate(const ParamList &x) { - if(candidate_check(get_param_vocab(),x)) - { - ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); - if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())) - return false; + if (!candidate_check(get_param_vocab(),x)) + return false; - // We are only a candidate if this canvas is animated. - Canvas::Handle canvas(x.find("canvas")->second.get_canvas()); - if(canvas->rend_desc().get_time_start()==canvas->rend_desc().get_time_end()) - return false; + ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); - // We need either a activepoint or a time. - if(x.count("activepoint") || x.count("time")) - return true; - } - return false; + if (!(value_desc.parent_is_value_node() && + // We need a dynamic list. + ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()))) + return false; + + Canvas::Handle canvas(x.find("canvas")->second.get_canvas()); + + // We are only a candidate if this canvas is animated. + return (canvas->rend_desc().get_time_start() != canvas->rend_desc().get_time_end() && + // We need either an activepoint or a time. + (x.count("activepoint") || x.count("time"))); } bool diff --git a/synfig-studio/trunk/src/synfigapp/actions/activepointseton.cpp b/synfig-studio/trunk/src/synfigapp/actions/activepointseton.cpp index 3f48f05..217eb8a 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/activepointseton.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/activepointseton.cpp @@ -99,22 +99,22 @@ Action::ActivepointSetOn::get_param_vocab() bool Action::ActivepointSetOn::is_candidate(const ParamList &x) { - if(candidate_check(get_param_vocab(),x)) - { - ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); - if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())) - return false; + if (!candidate_check(get_param_vocab(),x)) + return false; - // We are only a candidate if this canvas is animated. - Canvas::Handle canvas(x.find("canvas")->second.get_canvas()); - if(canvas->rend_desc().get_time_start()==canvas->rend_desc().get_time_end()) - return false; + ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); - // We need either a activepoint or a time. - if(x.count("activepoint") || x.count("time")) - return true; - } - return false; + if (!(value_desc.parent_is_value_node() && + // We need a dynamic list. + ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()))) + return false; + + Canvas::Handle canvas(x.find("canvas")->second.get_canvas()); + + // We are only a candidate if this canvas is animated. + return (canvas->rend_desc().get_time_start() != canvas->rend_desc().get_time_end() && + // We need either an activepoint or a time. + (x.count("activepoint") || x.count("time"))); } bool diff --git a/synfig-studio/trunk/src/synfigapp/actions/activepointsetsmart.cpp b/synfig-studio/trunk/src/synfigapp/actions/activepointsetsmart.cpp index 8358f33..3713e04 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/activepointsetsmart.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/activepointsetsmart.cpp @@ -100,17 +100,16 @@ Action::ActivepointSetSmart::get_param_vocab() bool Action::ActivepointSetSmart::is_candidate(const ParamList &x) { - if(candidate_check(get_param_vocab(),x)) - { - ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); - if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())) - return false; + if (!candidate_check(get_param_vocab(),x)) + return false; - // We need either a activepoint or a time. - if(x.count("activepoint") || x.count("time")) - return true; - } - return false; + ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); + + return (value_desc.parent_is_value_node() && + // We need a dynamic list. + ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()) && + // We need either an activepoint or a time. + (x.count("activepoint") || x.count("time"))); } bool diff --git a/synfig-studio/trunk/src/synfigapp/actions/valuedescdisconnect.cpp b/synfig-studio/trunk/src/synfigapp/actions/valuedescdisconnect.cpp index 0501f8f..91c58ca 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/valuedescdisconnect.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/valuedescdisconnect.cpp @@ -101,28 +101,27 @@ Action::ValueDescDisconnect::get_param_vocab() bool Action::ValueDescDisconnect::is_candidate(const ParamList &x) { - if(candidate_check(get_param_vocab(),x)) - { - ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); - - // don't allow the Index parameter of the Duplicate layer to be disconnected - if(value_desc.parent_is_layer_param() && value_desc.get_layer()->get_name() == "duplicate" && value_desc.get_param_name() == "index") - return false; - if(!value_desc.parent_is_canvas() && value_desc.is_value_node() && value_desc.get_value_node()->rcount()>1) - return true; - if(value_desc.is_const()) - return false; - if(value_desc.is_value_node() && ValueNode_Const::Handle::cast_dynamic(value_desc.get_value_node())) - return false; - // don't allow Duplicate ValueNodes in the Children dialog to be disconnected - if(value_desc.is_value_node() && - ValueNode_Duplicate::Handle::cast_dynamic(value_desc.get_value_node()) && - !value_desc.parent_is_layer_param() && - !value_desc.parent_is_value_node()) - return false; + if (!candidate_check(get_param_vocab(),x)) + return false; + + ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); + + // don't allow the Index parameter of the Duplicate layer to be disconnected + if(value_desc.parent_is_layer_param() && value_desc.get_layer()->get_name() == "duplicate" && value_desc.get_param_name() == "index") + return false; + if(!value_desc.parent_is_canvas() && value_desc.is_value_node() && value_desc.get_value_node()->rcount()>1) return true; - } - return false; + if(value_desc.is_const()) + return false; + if(value_desc.is_value_node() && ValueNode_Const::Handle::cast_dynamic(value_desc.get_value_node())) + return false; + // don't allow Duplicate ValueNodes in the Children dialog to be disconnected + if(value_desc.is_value_node() && + ValueNode_Duplicate::Handle::cast_dynamic(value_desc.get_value_node()) && + !value_desc.parent_is_layer_param() && + !value_desc.parent_is_value_node()) + return false; + return true; } bool diff --git a/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistinsert.cpp b/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistinsert.cpp index 46078ab..d962dbe 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistinsert.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistinsert.cpp @@ -94,15 +94,14 @@ Action::ValueNodeDynamicListInsert::get_param_vocab() bool Action::ValueNodeDynamicListInsert::is_candidate(const ParamList &x) { - if(candidate_check(get_param_vocab(),x)) - { - ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); - if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())) - return false; + if (!candidate_check(get_param_vocab(),x)) + return false; - return true; - } - return false; + ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); + + return (value_desc.parent_is_value_node() && + // We need a dynamic list. + ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())); } bool diff --git a/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistinsertsmart.cpp b/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistinsertsmart.cpp index 0e0dbe4..889aa87 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistinsertsmart.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistinsertsmart.cpp @@ -92,15 +92,14 @@ Action::ValueNodeDynamicListInsertSmart::get_param_vocab() bool Action::ValueNodeDynamicListInsertSmart::is_candidate(const ParamList &x) { - if(candidate_check(get_param_vocab(),x)) - { - ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); - if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())) - return false; + if (!candidate_check(get_param_vocab(),x)) + return false; - return true; - } - return false; + ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); + + return (value_desc.parent_is_value_node() && + // We need a dynamic list. + ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())); } bool diff --git a/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistloop.cpp b/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistloop.cpp index 8b618d1..c3cecbe 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistloop.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistloop.cpp @@ -78,21 +78,21 @@ Action::ValueNodeDynamicListLoop::get_param_vocab() bool Action::ValueNodeDynamicListLoop::is_candidate(const ParamList &x) { - if(candidate_check(get_param_vocab(),x)) - { - 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) - return false; - return true; - } - return false; + if (!candidate_check(get_param_vocab(),x)) + return false; + + 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(); + + // We need a dynamic list. + return (ValueNode_DynamicList::Handle::cast_dynamic(value_node) && + // We need the list not to be looped. + !ValueNode_DynamicList::Handle::cast_dynamic(value_node)->get_loop()); } bool diff --git a/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistremove.cpp b/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistremove.cpp index 1c4f1b0..a4c4d5f 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistremove.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistremove.cpp @@ -80,15 +80,14 @@ Action::ValueNodeDynamicListRemove::get_param_vocab() bool Action::ValueNodeDynamicListRemove::is_candidate(const ParamList &x) { - if(candidate_check(get_param_vocab(),x)) - { - ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); - if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())) - return false; + if (!candidate_check(get_param_vocab(),x)) + return false; - return true; - } - return false; + ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); + + return (value_desc.parent_is_value_node() && + // We need a dynamic list. + ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())); } bool diff --git a/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistremovesmart.cpp b/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistremovesmart.cpp index e7b315c..f479de5 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistremovesmart.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistremovesmart.cpp @@ -91,15 +91,14 @@ Action::ValueNodeDynamicListRemoveSmart::get_param_vocab() bool Action::ValueNodeDynamicListRemoveSmart::is_candidate(const ParamList &x) { - if(candidate_check(get_param_vocab(),x)) - { - ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); - if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())) - return false; + if (!candidate_check(get_param_vocab(),x)) + return false; - return true; - } - return false; + ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); + + return (value_desc.parent_is_value_node() && + // We need a dynamic list. + ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())); } bool diff --git a/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistrotateorder.cpp b/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistrotateorder.cpp index a9d1ff6..4e1c40a 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistrotateorder.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistrotateorder.cpp @@ -80,15 +80,14 @@ Action::ValueNodeDynamicListRotateOrder::get_param_vocab() bool Action::ValueNodeDynamicListRotateOrder::is_candidate(const ParamList &x) { - if(candidate_check(get_param_vocab(),x)) - { - ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); - if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())) - return false; + if (!candidate_check(get_param_vocab(),x)) + return false; - return true; - } - return false; + ValueDesc value_desc(x.find("value_desc")->second.get_value_desc()); + + return (value_desc.parent_is_value_node() && + // We need a dynamic list. + ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())); } bool diff --git a/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistunloop.cpp b/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistunloop.cpp index ff3056f..3269e12 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistunloop.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/valuenodedynamiclistunloop.cpp @@ -78,21 +78,21 @@ Action::ValueNodeDynamicListUnLoop::get_param_vocab() bool Action::ValueNodeDynamicListUnLoop::is_candidate(const ParamList &x) { - if(candidate_check(get_param_vocab(),x)) - { - 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) - return false; - return true; - } - return false; + if (!candidate_check(get_param_vocab(),x)) + return false; + + 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(); + + // We need a dynamic list. + return (ValueNode_DynamicList::Handle::cast_dynamic(value_node) && + // We need the list to be looped. + ValueNode_DynamicList::Handle::cast_dynamic(value_node)->get_loop()); } bool diff --git a/synfig-studio/trunk/src/synfigapp/actions/waypointadd.cpp b/synfig-studio/trunk/src/synfigapp/actions/waypointadd.cpp index 8912b3a..f080910 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/waypointadd.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/waypointadd.cpp @@ -94,16 +94,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 diff --git a/synfig-studio/trunk/src/synfigapp/actions/waypointsetsmart.cpp b/synfig-studio/trunk/src/synfigapp/actions/waypointsetsmart.cpp index 26c86cb..23a0ea2 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/waypointsetsmart.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/waypointsetsmart.cpp @@ -108,16 +108,11 @@ Action::WaypointSetSmart::get_param_vocab() bool Action::WaypointSetSmart::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 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