Added copyright lines for files I've edited this year.
[synfig.git] / synfig-studio / trunk / src / gtkmm / state_circle.cpp
index f4e0768..fb06cd5 100644 (file)
@@ -6,6 +6,7 @@
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2008 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
@@ -50,6 +51,8 @@
 #include "widget_enum.h"
 #include <synfigapp/main.h>
 
+#include "general.h"
+
 #endif
 
 /* === U S I N G =========================================================== */
@@ -242,7 +245,10 @@ StateCircle_Context::increment_id()
        if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
        {
                // figure out how many digits it is
-               for(digits=0;(int)id.size()-1>=digits && id[id.size()-1-digits]<='9' && id[id.size()-1-digits]>='0';digits++)while(false);
+               for (digits = 0;
+                        (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
+                        digits++)
+                       ;
 
                String str_number;
                str_number=String(id,id.size()-digits,id.size());
@@ -469,6 +475,7 @@ StateCircle_Context::event_mouse_click_handler(const Smach::event& x)
                point2_duck->set_radius(true);
                point2_duck->set_scalar(-1);
                point2_duck->set_type(Duck::TYPE_RADIUS);
+               point2_duck->set_hover(true);
                get_work_area()->add_duck(point2_duck);
 
                return Smach::RESULT_ACCEPT;
@@ -483,7 +490,15 @@ StateCircle_Context::event_mouse_click_handler(const Smach::event& x)
 
        if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_UP && event.button==BUTTON_LEFT)
        {
-               make_circle(point_holder, get_work_area()->snap_point_to_grid(event.pos));
+               Point point(get_work_area()->snap_point_to_grid(event.pos));
+
+               if (App::restrict_radius_ducks)
+               {
+                       if ((point[0] - point_holder[0]) * get_work_area()->get_pw() < 0) point[0] = point_holder[0];
+                       if ((point[1] - point_holder[1]) * get_work_area()->get_ph() > 0) point[1] = point_holder[1];
+               }
+
+               make_circle(point_holder, point);
                get_work_area()->clear_ducks();
                return Smach::RESULT_ACCEPT;
        }