Remove settings in normal tool
[synfig.git] / synfig-studio / src / gtkmm / state_normal.cpp
index 7eea702..e5cfd0a 100644 (file)
@@ -113,24 +113,25 @@ class studio::StateNormal_Context : public sigc::trackable
 {
        CanvasView* canvas_view_;
 
-       synfigapp::Settings& settings;
-
        etl::handle<DuckDrag_Combo> duck_dragger_;
 
        Gtk::Table options_table;
 
 public:
 
+       void refresh_cursor();
+
        bool get_rotate_flag()const { if(duck_dragger_) return duck_dragger_->rotate; else return false; }
-       void set_rotate_flag(bool x) { if(duck_dragger_ && x!=duck_dragger_->rotate) duck_dragger_->rotate=x; }
+       void set_rotate_flag(bool x) { if(duck_dragger_ && x!=duck_dragger_->rotate)
+                                              {duck_dragger_->rotate=x; refresh_cursor();} }
 
        bool get_scale_flag()const { if(duck_dragger_) return duck_dragger_->scale; else return false; }
-       void set_scale_flag(bool x) { if(duck_dragger_ && x!=duck_dragger_->scale) duck_dragger_->scale=x; }
+       void set_scale_flag(bool x) { if(duck_dragger_ && x!=duck_dragger_->scale)
+                                             {duck_dragger_->scale=x; refresh_cursor();} }
 
        bool get_constrain_flag()const { if(duck_dragger_) return duck_dragger_->constrain; else return false; }
-       void set_constrain_flag(bool x) { if(duck_dragger_ && x!=duck_dragger_->constrain) duck_dragger_->constrain=x; }
-
-       void refresh_cursor();
+       void set_constrain_flag(bool x) { if(duck_dragger_ && x!=duck_dragger_->constrain)
+                                                 {duck_dragger_->constrain=x; refresh_cursor();} }
 
        StateNormal_Context(CanvasView* canvas_view);
 
@@ -141,9 +142,6 @@ public:
        synfig::Canvas::Handle get_canvas()const{return canvas_view_->get_canvas();}
        WorkArea * get_work_area()const{return canvas_view_->get_work_area();}
 
-       void load_settings();
-       void save_settings();
-
        Smach::event_result event_stop_handler(const Smach::event& x);
        Smach::event_result event_refresh_handler(const Smach::event& x);
        Smach::event_result event_refresh_ducks_handler(const Smach::event& x);
@@ -187,11 +185,7 @@ void StateNormal_Context::refresh_cursor()
        // Check the current state and return when applicable
        synfig::String sname;
        sname=get_canvas_view()->get_smach().get_state_name();
-       if (sname=="smooth_move"||sname=="zoom"||sname=="width" ||
-               sname=="text"||sname=="stroke"||sname=="star"||sname=="sketch"||
-               sname=="scale"||sname=="zoom"||sname=="rotate"||sname=="rectangle"||
-               sname=="polygon"||sname=="gradient"||sname=="fill"||sname=="draw"||
-               sname=="circle")
+       if (sname!="normal")
                        return;
 
        // Change the cursor based on key flags
@@ -210,51 +204,14 @@ void StateNormal_Context::refresh_cursor()
                get_work_area()->set_cursor(Gdk::CROSSHAIR);
                return;
        }
-       // If we are in BLine state and there is not key pressed return to
-       // the bline cursor.
-       if (sname=="bline")
-       {
-               get_work_area()->set_cursor(Gdk::CROSSHAIR);
-               return;
-       }
+
        // Default cursor for Transform tool
        get_work_area()->set_cursor(Gdk::ARROW);
 
 }
 
-void
-StateNormal_Context::load_settings()
-{
-       String value;
-
-       if(settings.get_value("normal.rotate",value) && value=="1")
-               set_rotate_flag(true);
-       else
-               set_rotate_flag(false);
-
-       if(settings.get_value("normal.scale",value) && value=="1")
-               set_scale_flag(true);
-       else
-               set_scale_flag(false);
-
-       if(settings.get_value("normal.constrain",value) && value=="1")
-               set_constrain_flag(true);
-       else
-               set_constrain_flag(false);
-
-}
-
-void
-StateNormal_Context::save_settings()
-{
-       settings.set_value("normal.rotate",get_rotate_flag()?"1":"0");
-       settings.set_value("normal.scale",get_scale_flag()?"1":"0");
-       settings.set_value("normal.constrain",get_constrain_flag()?"1":"0");
-}
-
 StateNormal_Context::StateNormal_Context(CanvasView* canvas_view):
        canvas_view_(canvas_view),
-       settings(synfigapp::Main::get_selected_input_device()->settings()),
        duck_dragger_(new DuckDrag_Combo())
 {
        duck_dragger_->canvas_view_=get_canvas_view();
@@ -278,8 +235,6 @@ StateNormal_Context::StateNormal_Context(CanvasView* canvas_view):
 //     get_work_area()->reset_cursor();
 
        App::toolbox->refresh();
-
-       load_settings();
 }
 
 void
@@ -295,8 +250,6 @@ StateNormal_Context::refresh_tool_options()
 
 StateNormal_Context::~StateNormal_Context()
 {
-       save_settings();
-
        get_work_area()->clear_duck_dragger();
        get_work_area()->reset_cursor();
 
@@ -308,7 +261,7 @@ StateNormal_Context::~StateNormal_Context()
 DuckDrag_Combo::DuckDrag_Combo():
        scale(false),
        rotate(false),
-       constrain(false) // Lock aspect for scale; smooth move for translate
+       constrain(false) // Lock aspect for scale
 {
 }
 
@@ -448,8 +401,12 @@ DuckDrag_Combo::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)
                        }
                else
                {
-                       //vect[0]=vect[1]=vect.mag()*0.707106781;
-                       Real amount(vect.mag()/(drag_offset-center).mag());
+                       Real amount;
+                       if((drag_offset-center).mag() < EPSILON)
+                               amount = 1;
+                       else
+                               amount = vect.mag()/(drag_offset-center).mag();
+
                        vect[0]=vect[1]=amount;
                }
 
@@ -480,6 +437,7 @@ DuckDrag_Combo::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)
                        p+=center;
                        (*iter)->set_trans_point(p, time);
                }
+
        }
 
        // then patch up the tangents for the vertices we've moved