Author: Carlos Lopez <genet...@gmail.com> Date: Mon Oct 10 21:21:08 2011 +0200
When drawing a width point position duck, print its position value near the duck. --- .../src/gui/workarearenderer/renderer_ducks.cpp | 66 ++++++++++++++++++++ 1 files changed, 66 insertions(+), 0 deletions(-) diff --git a/synfig-studio/src/gui/workarearenderer/renderer_ducks.cpp b/synfig-studio/src/gui/workarearenderer/renderer_ducks.cpp index ded5468..4dabbe2 100644 --- a/synfig-studio/src/gui/workarearenderer/renderer_ducks.cpp +++ b/synfig-studio/src/gui/workarearenderer/renderer_ducks.cpp @@ -40,6 +40,9 @@ #include <ETL/misc> #include "widgets/widget_color.h" #include <synfig/distance.h> +#include <synfig/valuenode_wplist.h> +#include <synfig/valuenode_bline.h> +#include <synfig/valuenode_composite.h> #include "app.h" #include "general.h" @@ -477,6 +480,69 @@ Renderer_Ducks::render_vfunc( } + if((*iter)->get_type()&&Duck::TYPE_WIDTHPOINT_POSITION) + { + if(hover) + { + synfig::Canvas::Handle canvas_h(get_work_area()->get_canvas()); + synfig::Time time(canvas_h?canvas_h->get_time():synfig::Time(0)); + synfigapp::ValueDesc value_desc((*iter)->get_value_desc()); + synfig::ValueNode_WPList::Handle wplist=NULL; + ValueNode_Composite::Handle wpoint_composite=NULL; + Real radius=0.0; + Real new_value; + Point p((*iter)->get_trans_point()); + if(value_desc.parent_is_value_node()) + wplist=synfig::ValueNode_WPList::Handle::cast_dynamic(value_desc.get_parent_value_node()); + if(wplist) + { + synfig::ValueNode_BLine::Handle bline(synfig::ValueNode_BLine::Handle::cast_dynamic(wplist->get_bline())); + wpoint_composite=ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()); + if(bline && wpoint_composite) + { + + if (wplist->get_loop()) + { + // The wplist is looped. This may require a position parameter + // outside the range of 0-1, so make sure that the position doesn't + // change drastically. + Real value_old((*(wpoint_composite->get_link("position")))(time).get(Real())); + Real value_new = synfig::find_closest_point((*bline)(time), p , radius, bline->get_loop()); + Real difference = fmod( fmod(value_new - value_old, 1.0) + 1.0 , 1.0); + //fmod is called twice to avoid negative values + if (difference > 0.5) + difference=difference-1.0; + new_value = value_old+difference; + } + else + new_value = synfig::find_closest_point((*bline)(time), p , radius, bline->get_loop()); + + cr->save(); + layout->set_text(strprintf("%2.3f", new_value)); + + cr->set_source_rgb(0,0,0); // DUCK_COLOR_WIDTH_TEXT_1 + cr->move_to( + point[0]+1+6, + point[1]+1-18 + ); + layout->show_in_cairo_context(cr); + cr->stroke(); + + + cr->set_source_rgb(1,0,1); // DUCK_COLOR_WIDTH_TEXT_2 + cr->move_to( + point[0]+6, + point[1]-18 + ); + layout->show_in_cairo_context(cr); + cr->stroke(); + + cr->restore(); + } + } + } + } + } ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 _______________________________________________ Synfig-devl mailing list Synfig-devl@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/synfig-devl