X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fsynfigapp%2Factions%2Fvaluedescset.cpp;h=a7ca4cfd94642d3ac3aaf64af45bbe763b4b8f3a;hb=63e709f66d50c124cc0ece2325f4773ac4ae7b20;hp=6720a4e8d27086c9a35dd2c1e2802fc17f736e56;hpb=837b63e9fb829d66d43f4f169861f8979f76820d;p=synfig.git diff --git a/synfig-studio/trunk/src/synfigapp/actions/valuedescset.cpp b/synfig-studio/trunk/src/synfigapp/actions/valuedescset.cpp index 6720a4e..a7ca4cf 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/valuedescset.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/valuedescset.cpp @@ -6,6 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007 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 @@ -41,6 +42,8 @@ #include #include +#include + #endif using namespace std; @@ -50,13 +53,10 @@ using namespace synfigapp; using namespace Action; /* === M A C R O S ========================================================= */ -#define ACTION_INIT2(class) \ - Action::Base* class::create() { return new class(); } \ - synfig::String class::get_name()const { return name__; } -ACTION_INIT2(Action::ValueDescSet); +ACTION_INIT_NO_GET_LOCAL_NAME(Action::ValueDescSet); ACTION_SET_NAME(Action::ValueDescSet,"value_desc_set"); -ACTION_SET_LOCAL_NAME(Action::ValueDescSet,"Set ValueDesc"); +ACTION_SET_LOCAL_NAME(Action::ValueDescSet,N_("Set ValueDesc")); ACTION_SET_TASK(Action::ValueDescSet,"set"); ACTION_SET_CATEGORY(Action::ValueDescSet,Action::CATEGORY_VALUEDESC); ACTION_SET_PRIORITY(Action::ValueDescSet,0); @@ -83,31 +83,24 @@ Action::ValueDescSet::get_local_name()const { } else if(value_desc.parent_is_layer_param()) - { - if(value_desc.get_layer()->get_description().empty()) - name=value_desc.get_layer()->get_local_name(); - else - name=value_desc.get_layer()->get_description(); - name+="->"+value_desc.get_param_name(); - } + name = strprintf(_("'%s' -> %s"), + value_desc.get_layer()->get_non_empty_description().c_str(), + value_desc.get_param_name().c_str()); else if(value_desc.parent_is_value_node()) { synfig::LinkableValueNode::Handle value_node(synfig::LinkableValueNode::Handle::cast_reinterpret(value_desc.get_parent_value_node())); - name=value_node->link_local_name(value_desc.get_index()); - synfig::Node* node; for(node=value_node.get();!node->parent_set.empty() && !dynamic_cast(node);node=*node->parent_set.begin()); Layer::Handle parent_layer(dynamic_cast(node)); if(parent_layer) - { - if(parent_layer->get_description().empty()) - name=parent_layer->get_local_name()+"=>"+name; - else - name=parent_layer->get_description()+"=>"+name; - } + name = strprintf(_("'%s' => %s"), + parent_layer->get_non_empty_description().c_str(), + value_node->link_local_name(value_desc.get_index()).c_str()); + else + name = value_node->link_local_name(value_desc.get_index()); } - return strprintf(_("Set %s"),name.c_str()); + return strprintf(_("Set %s"), name.c_str()); } Action::ParamVocab @@ -181,33 +174,46 @@ Action::ValueDescSet::prepare() // our first tangent is being manipulated, // then we also need to adjust the other // tangent. - if( value_desc.parent_is_value_node() - && value_desc.get_parent_value_node()->get_type()==ValueBase::TYPE_BLINEPOINT - && value_desc.get_index()==4 - && (*value_desc.get_parent_value_node())(time).get(BLinePoint()).get_split_tangent_flag()==false - ) + if( value_desc.parent_is_value_node() && + value_desc.get_parent_value_node()->get_type()==ValueBase::TYPE_BLINEPOINT && + (value_desc.get_index()==4 || value_desc.get_index()==5) && + (*value_desc.get_parent_value_node())(time).get(BLinePoint()).get_split_tangent_flag()==false) { - DEBUGPOINT(); - ValueNode_Composite::Handle parent_value_node; - parent_value_node=parent_value_node.cast_dynamic(value_desc.get_parent_value_node()); + printf("a tangent got changed - #%d\n", value_desc.get_index()-3); - assert(parent_value_node); + { + ValueNode_Composite::Handle parent_value_node; + parent_value_node=parent_value_node.cast_dynamic(value_desc.get_parent_value_node()); + assert(parent_value_node); - Action::Handle action(Action::create("value_desc_set")); + Vector t1((*parent_value_node->get_link("t1"))(time)); + Vector t2((*parent_value_node->get_link("t2"))(time)); + printf("current values are: t1(%.2f, %2.f) t2(%.2f, %.2f)\n", t1[0], t1[1], t2[0], t2[1]); + } - if(!action) - throw Error(_("Unable to find action value_desc_set (bug)")); + if (value_desc.get_index()==4) { + printf("copying change to tangent 2\n"); + ValueNode_Composite::Handle parent_value_node; + parent_value_node=parent_value_node.cast_dynamic(value_desc.get_parent_value_node()); - action->set_param("canvas",get_canvas()); - action->set_param("canvas_interface",get_canvas_interface()); - action->set_param("time",time); - action->set_param("new_value",value); - action->set_param("value_desc",ValueDesc(parent_value_node,5)); + assert(parent_value_node); - if(!action->is_ready()) - throw Error(Error::TYPE_NOTREADY); + Action::Handle action(Action::create("value_desc_set")); - add_action(action); + if(!action) + throw Error(_("Unable to find action value_desc_set (bug)")); + + action->set_param("canvas",get_canvas()); + action->set_param("canvas_interface",get_canvas_interface()); + action->set_param("time",time); + action->set_param("new_value",value); + action->set_param("value_desc",ValueDesc(parent_value_node,5)); + + if(!action->is_ready()) + throw Error(Error::TYPE_NOTREADY); + + add_action(action); + } } // If we are a reference value node, then @@ -277,7 +283,7 @@ Action::ValueDescSet::prepare() break; } default: - throw Error("Bad type for composite (%s)",ValueBase::type_name(value.get_type()).c_str()); + throw Error(_("Bad type for composite (%s)"),ValueBase::type_local_name(value.get_type()).c_str()); break; } @@ -317,9 +323,14 @@ Action::ValueDescSet::prepare() { case ValueBase::TYPE_VECTOR: { + Angle old_angle = (*(ValueNode_RadialComposite::Handle::cast_dynamic( + value_desc.get_value_node())->get_link_vfunc(1)))(time).get(Angle()); Vector vect(value.get(Vector())); components[0]=vect.mag(); - components[1]=Angle(Angle::tan(vect[1],vect[0])); + Angle change = Angle(Angle::tan(vect[1],vect[0])) - old_angle; + while (change < Angle::deg(-180)) change += Angle::deg(360); + while (change > Angle::deg(180)) change -= Angle::deg(360); + components[1]=old_angle + change; n_components=2; } break; @@ -331,7 +342,7 @@ Action::ValueDescSet::prepare() n_components=4; break; default: - throw Error("Bad type for radial composite (%s)",ValueBase::type_name(value.get_type()).c_str()); + throw Error(_("Bad type for radial composite (%s)"),ValueBase::type_local_name(value.get_type()).c_str()); break; } for(int i=0;iget_type()==ValueBase::TYPE_BLINEPOINT - && value_desc.get_index()==3 -// && value.get(bool())==false // Actually, we want to do this any time the split flag is tweaked with - ) + if (value_desc.parent_is_value_node() && + value_desc.get_parent_value_node()->get_type()==ValueBase::TYPE_BLINEPOINT && + value_desc.get_index()==3) { ValueNode_Composite::Handle parent_value_node; parent_value_node=parent_value_node.cast_dynamic(value_desc.get_parent_value_node()); assert(parent_value_node); - Action::Handle action(Action::create("value_desc_set")); + // are we splitting or merging the tangents? + if (value.get(bool())) + { + // we are splitting tangents - if(!action) - throw Error(_("Unable to find action value_desc_set (bug)")); + Action::Handle action(Action::create("value_desc_set")); - action->set_param("canvas",get_canvas()); - action->set_param("canvas_interface",get_canvas_interface()); - action->set_param("time",time); - action->set_param("new_value",(*parent_value_node->get_link(4))(time)); - action->set_param("value_desc",ValueDesc(parent_value_node,5)); + if(!action) + throw Error(_("Unable to find action value_desc_set (bug)")); - if(!action->is_ready()) - throw Error(Error::TYPE_NOTREADY); + action->set_param("canvas",get_canvas()); + action->set_param("canvas_interface",get_canvas_interface()); + action->set_param("time",time); + action->set_param("new_value",(*parent_value_node->get_link(4))(time)); + action->set_param("value_desc",ValueDesc(parent_value_node,5)); + + if(!action->is_ready()) + throw Error(Error::TYPE_NOTREADY); + + add_action(action); + } + else + { + // we are merging tangents + + // the merged tangent should be the average of the 2 tangents we're merging + ValueBase average(((Vector)((*parent_value_node->get_link("t1"))(time)) + + (Vector)((*parent_value_node->get_link("t2"))(time))) / 2); + + { + Action::Handle action(Action::create("value_desc_set")); + + if(!action) + throw Error(_("Unable to find action value_desc_set (bug)")); + + action->set_param("canvas",get_canvas()); + action->set_param("canvas_interface",get_canvas_interface()); + action->set_param("time",time); + action->set_param("new_value",average); + action->set_param("value_desc",ValueDesc(parent_value_node,4)); + + if(!action->is_ready()) + throw Error(Error::TYPE_NOTREADY); + + add_action(action); + } + + { + Action::Handle action(Action::create("value_desc_set")); + + if(!action) + throw Error(_("Unable to find action value_desc_set (bug)")); + + action->set_param("canvas",get_canvas()); + action->set_param("canvas_interface",get_canvas_interface()); + action->set_param("time",time); + action->set_param("new_value",average); + action->set_param("value_desc",ValueDesc(parent_value_node,5)); + + if(!action->is_ready()) + throw Error(Error::TYPE_NOTREADY); + + add_action(action); + } + } - add_action(action); } /* DEBUGPOINT(); @@ -450,7 +510,6 @@ Action::ValueDescSet::prepare() if(!action->is_ready()) throw Error(Error::TYPE_NOTREADY); - DEBUGPOINT(); add_action_front(action); } else @@ -458,7 +517,6 @@ Action::ValueDescSet::prepare() value_node=value_node.cast_dynamic(value_desc.get_value_node()); } - DEBUGPOINT(); if(!value_node) throw Error(_("Direct manipulation of this ValueNode type is not yet supported")); @@ -480,7 +538,6 @@ Action::ValueDescSet::prepare() if(!action->is_ready()) throw Error(Error::TYPE_NOTREADY); - DEBUGPOINT(); add_action(action); return;