X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fstate_circle.cpp;h=fb06cd54b287721f294e326feebcdbe892b61210;hb=3e255bcee92e6c1773081af46c3feff67aa34f55;hp=791b555110646405c6656b34270c3b61808daa72;hpb=11c0abb278300f2c4439b538b300433078a19a78;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/state_circle.cpp b/synfig-studio/trunk/src/gtkmm/state_circle.cpp index 791b555..fb06cd5 100644 --- a/synfig-studio/trunk/src/gtkmm/state_circle.cpp +++ b/synfig-studio/trunk/src/gtkmm/state_circle.cpp @@ -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 +#include "general.h" + #endif /* === U S I N G =========================================================== */ @@ -147,10 +150,10 @@ public: void save_settings(); void reset(); void increment_id(); - bool no_egress_on_selection_change; + bool egress_on_selection_change; Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/) { - if(!no_egress_on_selection_change) + if(egress_on_selection_change) throw Smach::egress_exception(); return Smach::RESULT_OK; } @@ -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()); @@ -279,7 +285,7 @@ StateCircle_Context::StateCircle_Context(CanvasView* canvas_view): spin_feather(adj_feather,0.1,3), check_invert(_("Invert")) { - no_egress_on_selection_change=false; + egress_on_selection_change=true; // Set up the tool options dialog //options_table.attach(*manage(new Gtk::Label(_("Circle Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); options_table.attach(entry_id, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); @@ -437,10 +443,10 @@ StateCircle_Context::make_circle(const Point& _p1, const Point& _p2) layer->set_description(get_id()); get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description()); - no_egress_on_selection_change=true; + egress_on_selection_change=false; get_canvas_interface()->get_selection_manager()->clear_selected_layers(); get_canvas_interface()->get_selection_manager()->set_selected_layer(layer); - no_egress_on_selection_change=false; + egress_on_selection_change=true; } reset(); @@ -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; }