Author: Carlos Lopez <genet...@gmail.com> Date: Thu Oct 20 21:56:47 2011 +0200
Add new member to get the boundarized position. Add code to correct the hover text on duck and the ValueDescSet action. --- synfig-core/src/synfig/widthpoint.cpp | 11 +++++++++-- synfig-core/src/synfig/widthpoint.h | 2 ++ .../src/gui/workarearenderer/renderer_ducks.cpp | 7 +++++-- .../src/synfigapp/actions/valuedescset.cpp | 7 +++++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/synfig-core/src/synfig/widthpoint.cpp b/synfig-core/src/synfig/widthpoint.cpp index 8144f9b..2624a2d 100644 --- a/synfig-core/src/synfig/widthpoint.cpp +++ b/synfig-core/src/synfig/widthpoint.cpp @@ -78,7 +78,13 @@ WidthPoint::get_position()const Real WidthPoint::get_norm_position(bool wplistloop)const { - Real ret(get_position()-lower_bound_); + return (get_bound_position(wplistloop)-lower_bound_)/(upper_bound_-lower_bound_); +} + +Real +WidthPoint::get_bound_position(bool wplistloop)const +{ + Real ret(position_-lower_bound_); Real range(upper_bound_-lower_bound_); if(!wplistloop) { @@ -90,9 +96,10 @@ WidthPoint::get_norm_position(bool wplistloop)const ret=fmod(ret, range); ret=ret>=0.0?ret:(range+ret); } - return ret/range; + return ret+lower_bound_; } + void WidthPoint::normalize(bool loop) { diff --git a/synfig-core/src/synfig/widthpoint.h b/synfig-core/src/synfig/widthpoint.h index da41a5a..429b206 100644 --- a/synfig-core/src/synfig/widthpoint.h +++ b/synfig-core/src/synfig/widthpoint.h @@ -69,6 +69,8 @@ public: void set_position(const Real& x); // gets the normalised position: converts it to be inside [0,1] Real get_norm_position(bool wplistloop)const; + // gets the postion inside the lower and upper boundaries + Real get_bound_position(bool wplistloop)const; // changes the widthpoint's position to be inside [0,1) void normalize(bool loop); diff --git a/synfig-studio/src/gui/workarearenderer/renderer_ducks.cpp b/synfig-studio/src/gui/workarearenderer/renderer_ducks.cpp index 147fe69..b180f99 100644 --- a/synfig-studio/src/gui/workarearenderer/renderer_ducks.cpp +++ b/synfig-studio/src/gui/workarearenderer/renderer_ducks.cpp @@ -524,6 +524,7 @@ Renderer_Ducks::render_vfunc( // change drastically. // First normalise the current position Real value_old(wp.get_norm_position(wplistloop)); + Real value_old_b(wp.get_bound_position(wplistloop)); // If it is homogeneous then convert it to standard value_old=homogeneous?hom_to_std((*bline)(time), value_old, wplistloop, blineloop):value_old; // grab a new position given by duck's position on the bline @@ -537,8 +538,10 @@ Renderer_Ducks::render_vfunc( new_value=value_old+difference; // restore the homogeneous value if needed new_value = homogeneous?std_to_hom((*bline)(time), new_value, wplistloop, blineloop):new_value; - // convert the new_value in terms of current boundaries - new_value = wp.get_lower_bound()+new_value*(wp.get_upper_bound()-wp.get_lower_bound()); + // this is the difference between the new value and the old value inside the boundaries + Real bound_diff((wp.get_lower_bound() + new_value*(wp.get_upper_bound()-wp.get_lower_bound()))-value_old_b); + // add the new diff to the current value + new_value = wp.get_position() + bound_diff; } else { diff --git a/synfig-studio/src/synfigapp/actions/valuedescset.cpp b/synfig-studio/src/synfigapp/actions/valuedescset.cpp index 9cda937..0fe3239 100644 --- a/synfig-studio/src/synfigapp/actions/valuedescset.cpp +++ b/synfig-studio/src/synfigapp/actions/valuedescset.cpp @@ -567,6 +567,7 @@ Action::ValueDescSet::prepare() // outside the range of 0-1, so make sure that the position doesn't // change drastically. Real amount_old(wp.get_norm_position(wplistloop)); + Real amount_old_b(wp.get_bound_position(wplistloop)); // If it is homogeneous then convert it to standard amount_old=homogeneous?hom_to_std((*bline)(time), amount_old, wplistloop, blineloop):amount_old; // grab a new position given by duck's position on the bline @@ -580,8 +581,10 @@ Action::ValueDescSet::prepare() new_amount=amount_old+difference; // restore the homogeneous value if needed new_amount = homogeneous?ValueBase(std_to_hom((*bline)(time), new_amount, wplistloop, blineloop)):new_amount; - // convert the new_value in terms of current boundaries - new_amount = wp.get_lower_bound()+new_amount*(wp.get_upper_bound()-wp.get_lower_bound()); + // this is the difference between the new amount and the old amount inside the boundaries + Real bound_diff((wp.get_lower_bound() + new_amount*(wp.get_upper_bound()-wp.get_lower_bound()))-amount_old_b); + // add the new diff to the current amount + new_amount = wp.get_position() + bound_diff; } else { ------------------------------------------------------------------------------ The demand for IT networking professionals continues to grow, and the demand for specialized networking skills is growing even more rapidly. Take a complimentary Learning@Cisco Self-Assessment and learn about Cisco certifications, training, and career opportunities. http://p.sf.net/sfu/cisco-dev2dev _______________________________________________ Synfig-devl mailing list Synfig-devl@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/synfig-devl