Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-studio / trunk / src / gtkmm / mod_mirror / state_mirror.cpp
index 9382235..b9688d0 100644 (file)
@@ -49,6 +49,8 @@
 #include "../duck.h"
 #include <synfigapp/main.h>
 
+#include "../general.h"
+
 #endif
 
 /* === U S I N G =========================================================== */
@@ -77,7 +79,6 @@ class DuckDrag_Mirror : public DuckDrag_Base
 
        std::vector<synfig::Vector> positions;
 
-
 public:
        Axis axis;
 
@@ -87,7 +88,6 @@ public:
        void duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector);
 };
 
-
 class studio::StateMirror_Context : public sigc::trackable
 {
        etl::handle<CanvasView> canvas_view_;
@@ -98,7 +98,6 @@ class studio::StateMirror_Context : public sigc::trackable
 
        Gtk::Table options_table;
 
-
        Gtk::CheckButton checkbutton_axis_x;
        Gtk::CheckButton checkbutton_axis_y;
 
@@ -194,7 +193,7 @@ StateMirror_Context::StateMirror_Context(CanvasView* canvas_view):
        refresh_tool_options();
        App::dialog_tool_options->present();
 
-       get_work_area()->allow_layer_clicks=true;
+       get_work_area()->set_allow_layer_clicks(true);
        get_work_area()->set_duck_dragger(duck_dragger_);
 
 //     get_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR);
@@ -216,7 +215,7 @@ StateMirror_Context::refresh_tool_options()
 }
 
 Smach::event_result
-StateMirror_Context::event_refresh_tool_options(const Smach::event& x)
+StateMirror_Context::event_refresh_tool_options(const Smach::event& /*x*/)
 {
        refresh_tool_options();
        return Smach::RESULT_ACCEPT;
@@ -234,9 +233,6 @@ StateMirror_Context::~StateMirror_Context()
        App::toolbox->refresh();
 }
 
-
-
-
 DuckDrag_Mirror::DuckDrag_Mirror():
        axis(AXIS_X)
 {
@@ -247,10 +243,8 @@ DuckDrag_Mirror::DuckDrag_Mirror():
 #endif
 
 void
-DuckDrag_Mirror::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& offset)
+DuckDrag_Mirror::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& /*offset*/)
 {
-
-
        const DuckList selected_ducks(duckmatic->get_selected_ducks());
        DuckList::const_iterator iter;
 
@@ -264,43 +258,44 @@ DuckDrag_Mirror::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& off
 
 }
 
-
 void
 DuckDrag_Mirror::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)
 {
        center=vector;
        int i;
 
-               const DuckList selected_ducks(duckmatic->get_selected_ducks());
-               DuckList::const_iterator iter;
+       const DuckList selected_ducks(duckmatic->get_selected_ducks());
+       DuckList::const_iterator iter;
+
+       // do the Vertex and Position ducks first
        for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
-       {
-               if(((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION))continue;
+               if ((*iter)->get_type() == Duck::TYPE_VERTEX ||
+                       (*iter)->get_type() == Duck::TYPE_POSITION)
+               {
+                       Vector p(positions[i]);
 
-               Vector p(positions[i]);
-               //Point p((*iter)->get_trans_point());
+                       if              (axis==AXIS_X) p[0] = -(p[0]-center[0]) + center[0];
+                       else if (axis==AXIS_Y) p[1] = -(p[1]-center[1]) + center[1];
 
-               if(axis==AXIS_X)
-                       p[0]=-(p[0]-center[0])+center[0];
-               if(axis==AXIS_Y)
-                       p[1]=-(p[1]-center[1])+center[1];
+                       (*iter)->set_trans_point(p);
+               }
 
-               (*iter)->set_trans_point(p);
-       }
+       // then do the other ducks
        for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
-       {
-               if(!((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION))continue;
+               if ((*iter)->get_type() != Duck::TYPE_VERTEX &&
+                       (*iter)->get_type() != Duck::TYPE_POSITION)
+               {
+                       // we don't need to mirror radius ducks - they're one-dimensional
+                       if ((*iter)->is_radius())
+                               continue;
 
-               Vector p(positions[i]);
-               //Point p((*iter)->get_trans_point());
+                       Vector p(positions[i]);
 
-               if(axis==AXIS_X)
-                       p[0]=-(p[0]-center[0])+center[0];
-               if(axis==AXIS_Y)
-                       p[1]=-(p[1]-center[1])+center[1];
+                       if              (axis==AXIS_X) p[0] = -(p[0]-center[0]) + center[0];
+                       else if (axis==AXIS_Y) p[1] = -(p[1]-center[1]) + center[1];
 
-               (*iter)->set_trans_point(p);
-       }
+                       (*iter)->set_trans_point(p);
+               }
 }
 
 bool