Skip to content

Commit

Permalink
Reorganize code. Now interpolation option isn't lost when parameter i…
Browse files Browse the repository at this point in the history
…s changed.
  • Loading branch information
morevnaproject authored and genete committed Aug 14, 2013
1 parent 6dc75c5 commit 7f43d77
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
8 changes: 8 additions & 0 deletions synfig-core/src/synfig/value.cpp
Expand Up @@ -245,6 +245,14 @@ ValueBase::is_valid()const
return type>TYPE_NIL && type<TYPE_END && ref_count;
}

void
ValueBase::copy_properties_of(const ValueBase& x)
{
loop_=x.loop_;
static_=x.static_;
interpolation_=x.interpolation_;
}

bool
ValueBase::empty()const
{
Expand Down
2 changes: 2 additions & 0 deletions synfig-core/src/synfig/value.h
Expand Up @@ -218,6 +218,8 @@ class ValueBase
//! Sets the interpolation.
void set_interpolation(Interpolation x) { interpolation_=x; }

void copy_properties_of(const ValueBase& x);

//! True if the Value is not valid or is type LIST and is empty
bool empty()const;

Expand Down
19 changes: 3 additions & 16 deletions synfig-studio/src/synfigapp/actions/valuedescset.cpp
Expand Up @@ -756,17 +756,7 @@ Action::ValueDescSet::prepare()
}

}
// if the value desc is layer param or Value Node Const then use local_value
// to store the static option to eventually avoid the animation mode.
ValueBase local_value;
local_value.set_static(false);
if(!value_desc.is_value_node() || ValueNode_Const::Handle::cast_dynamic(value_desc.get_value_node()))
{
if(value_desc.is_value_node())
local_value=ValueNode_Const::Handle::cast_dynamic(value_desc.get_value_node())->get_value();
else
local_value=value_desc.get_value();
}

// if value desc has parent value node and parent is composite widthpoint type and index is 4 or 5
// then we are changing the value of a widthpoint boundary.
// It is needed to check that we aren't doing the boundary range zero
Expand All @@ -793,7 +783,8 @@ Action::ValueDescSet::prepare()
}
}
// If we are in animate editing mode
if(get_edit_mode()&MODE_ANIMATE && !local_value.get_static())
// TODO: Can we replace local_value to value after all parameters will be converted into ValueBase type?
if(get_edit_mode()&MODE_ANIMATE && !value.get_static())
{
ValueNode_Animated::Handle& value_node(value_node_animated);
// If this value isn't a ValueNode_Animated, but
Expand Down Expand Up @@ -869,8 +860,6 @@ Action::ValueDescSet::prepare()
if(ValueNode_Const::Handle::cast_dynamic(value_desc.get_value_node()))
{
Action::Handle action(ValueNodeConstSet::create());
synfig::ValueNode_Const::Handle localvaluenode(ValueNode_Const::Handle::cast_dynamic(value_desc.get_value_node()));
value.set_static(localvaluenode->get_static());
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_node",value_desc.get_value_node());
Expand All @@ -890,8 +879,6 @@ Action::ValueDescSet::prepare()
if(value_desc.parent_is_layer_param() && !value_desc.is_value_node())
{
Action::Handle layer_param_set(LayerParamSet::create());
synfig::ValueBase localvalue(value_desc.get_value());
value.set_static(local_value.get_static());
layer_param_set->set_param("canvas",get_canvas());
layer_param_set->set_param("canvas_interface",get_canvas_interface());
layer_param_set->set_param("layer",value_desc.get_layer());
Expand Down
8 changes: 7 additions & 1 deletion synfig-studio/src/synfigapp/canvasinterface.cpp
Expand Up @@ -892,10 +892,16 @@ CanvasInterface::auto_export(const ValueDesc& /*value_desc*/)
bool
CanvasInterface::change_value(synfigapp::ValueDesc value_desc,synfig::ValueBase new_value)
{
ValueBase old_value;
old_value = value_desc.get_value(get_time());

// If this isn't really a change, then don't bother
if(new_value==value_desc.get_value(get_time()))
if(new_value==old_value)
return true;

// New value should inherit all properties of original ValueBase (static, etc...)
new_value.copy_properties_of(old_value);

// If this change needs to take place elsewhere, then so be it.
if(value_desc.get_canvas())
{
Expand Down

0 comments on commit 7f43d77

Please sign in to comment.