From d33059aae9748036c993c319e998b078124705d1 Mon Sep 17 00:00:00 2001 From: dooglus Date: Sat, 9 Feb 2008 00:01:10 +0000 Subject: [PATCH] Restrict 'radius' ducks to the top right corner of the plane. This allows us to easily set their value to zero by dragging down and left. Thanks to Zelgadis on IRC for the suggestion. git-svn-id: http://svn.voria.com/code@1632 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-studio/trunk/src/gtkmm/duckmatic.cpp | 26 ++++++++++++++++++++++++ synfig-studio/trunk/src/gtkmm/duckmatic.h | 2 ++ synfig-studio/trunk/src/gtkmm/renderer_ducks.cpp | 17 ++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/synfig-studio/trunk/src/gtkmm/duckmatic.cpp b/synfig-studio/trunk/src/gtkmm/duckmatic.cpp index 110a356..a8b4219 100644 --- a/synfig-studio/trunk/src/gtkmm/duckmatic.cpp +++ b/synfig-studio/trunk/src/gtkmm/duckmatic.cpp @@ -556,6 +556,32 @@ Duckmatic::signal_edited_selected_ducks() throw String("Bad edit"); } } +#ifdef RESTRICT_RADIUS_DUCKS_TO_ONE_QUARTER + else if ((*iter)->is_radius()) + { + Point point((*iter)->get_point()); + bool changed = false; + + if (point[0] * (flip_x_ ? -1 : 1) < 0) + { + point[0] = 0; + changed = true; + } + if (point[1] * (flip_y_ ? -1 : 1) < 0) + { + point[1] = 0; + changed = true; + } + + if (changed) (*iter)->set_point(point); + + if(!(*iter)->signal_edited()(point)) + { + selected_ducks=old_set; + throw String("Bad edit"); + } + } +#endif else { if(!(*iter)->signal_edited()((*iter)->get_point())) diff --git a/synfig-studio/trunk/src/gtkmm/duckmatic.h b/synfig-studio/trunk/src/gtkmm/duckmatic.h index 2b160cf..3b6137e 100644 --- a/synfig-studio/trunk/src/gtkmm/duckmatic.h +++ b/synfig-studio/trunk/src/gtkmm/duckmatic.h @@ -78,6 +78,8 @@ public: #include #endif +#define RESTRICT_RADIUS_DUCKS_TO_ONE_QUARTER + /* === T Y P E D E F S ===================================================== */ /* === C L A S S E S & S T R U C T S ======================================= */ diff --git a/synfig-studio/trunk/src/gtkmm/renderer_ducks.cpp b/synfig-studio/trunk/src/gtkmm/renderer_ducks.cpp index ed7a744..21c17af 100644 --- a/synfig-studio/trunk/src/gtkmm/renderer_ducks.cpp +++ b/synfig-studio/trunk/src/gtkmm/renderer_ducks.cpp @@ -228,6 +228,13 @@ Renderer_Ducks::render_vfunc( origin[0]=(origin[0]-window_startx)/pw; origin[1]=(origin[1]-window_starty)/ph; +#ifdef RESTRICT_RADIUS_DUCKS_TO_ONE_QUARTER + if((*iter)->is_radius()) + { + if (point[0] < origin[0]) point[0] = origin[0]; + if (point[1] > origin[1]) point[1] = origin[1]; + } +#endif bool selected(get_work_area()->duck_is_selected(*iter)); bool hover(*iter==hover_duck); @@ -374,7 +381,17 @@ Renderer_Ducks::render_vfunc( if(hover) { +#ifdef RESTRICT_RADIUS_DUCKS_TO_ONE_QUARTER + Point point2((*iter)->get_trans_point()); + Point origin2((*iter)->get_trans_origin()); + + if ((point2[0] - origin2[0]) * pw < 0) point2[0] = origin2[0]; + if ((point2[1] - origin2[1]) * ph > 0) point2[1] = origin2[1]; + + Distance real_mag((point2-origin2).mag(),Distance::SYSTEM_UNITS); +#else Distance real_mag(((*iter)->get_trans_point()-(*iter)->get_trans_origin()).mag(),Distance::SYSTEM_UNITS); +#endif real_mag.convert(App::distance_system,get_work_area()->get_rend_desc()); layout->set_text(real_mag.get_string()); -- 2.7.4