Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-studio / trunk / src / gtkmm / mod_mirror / state_mirror.cpp
index fde9912..b9688d0 100644 (file)
@@ -2,7 +2,7 @@
 /*!    \file state_mirror.cpp
 **     \brief Template File
 **
-**     $Id: state_mirror.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
+**     $Id$
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
@@ -49,6 +49,8 @@
 #include "../duck.h"
 #include <synfigapp/main.h>
 
+#include "../general.h"
+
 #endif
 
 /* === U S I N G =========================================================== */
@@ -76,8 +78,7 @@ class DuckDrag_Mirror : public DuckDrag_Base
        synfig::Vector center;
 
        std::vector<synfig::Vector> positions;
-       
-       
+
 public:
        Axis axis;
 
@@ -87,21 +88,19 @@ public:
        void duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector);
 };
 
-
 class studio::StateMirror_Context : public sigc::trackable
 {
        etl::handle<CanvasView> canvas_view_;
-               
+
        synfigapp::Settings& settings;
 
        etl::handle<DuckDrag_Mirror> duck_dragger_;
 
        Gtk::Table options_table;
-       
-       
+
        Gtk::CheckButton checkbutton_axis_x;
        Gtk::CheckButton checkbutton_axis_y;
-       
+
 public:
 
        Axis get_axis()const { return checkbutton_axis_x.get_active()?AXIS_X:AXIS_Y; }
@@ -117,10 +116,10 @@ public:
                        checkbutton_axis_y.set_active(true);
                        checkbutton_axis_x.set_active(false);
                }
-                       
+
                duck_dragger_->axis=get_axis();
        }
-       
+
        void update_axis_y()
        {
                checkbutton_axis_x.set_active(!checkbutton_axis_y.get_active());
@@ -143,7 +142,7 @@ public:
        etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const{return canvas_view_->canvas_interface();}
        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();
 };     // END of class StateMirror_Context
@@ -154,7 +153,7 @@ StateMirror::StateMirror():
        Smach::state<StateMirror_Context>("mirror")
 {
        insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateMirror_Context::event_refresh_tool_options));
-}      
+}
 
 StateMirror::~StateMirror()
 {
@@ -162,7 +161,7 @@ StateMirror::~StateMirror()
 
 void
 StateMirror_Context::load_settings()
-{      
+{
        String value;
 
        settings.get_value("mirror.axis",value);
@@ -171,7 +170,7 @@ StateMirror_Context::load_settings()
 
 void
 StateMirror_Context::save_settings()
-{      
+{
        settings.set_value("mirror.lock_aspect",strprintf("%d",(int)get_axis()));
 }
 
@@ -181,20 +180,20 @@ StateMirror_Context::StateMirror_Context(CanvasView* canvas_view):
        duck_dragger_(new DuckDrag_Mirror()),
        checkbutton_axis_x(_("Horizontal")),
        checkbutton_axis_y(_("Vertical"))
-{      
+{
        // Set up the tool options dialog
-       options_table.attach(*manage(new Gtk::Label(_("Mirror Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);        
+       options_table.attach(*manage(new Gtk::Label(_("Mirror Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
        options_table.attach(checkbutton_axis_x, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
        options_table.attach(checkbutton_axis_y, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
 
        checkbutton_axis_x.signal_toggled().connect(sigc::mem_fun(*this,&StateMirror_Context::update_axis_x));
        checkbutton_axis_y.signal_toggled().connect(sigc::mem_fun(*this,&StateMirror_Context::update_axis_y));
-               
+
        options_table.show_all();
        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;
-
-               Vector p(positions[i]);
-               //Point p((*iter)->get_trans_point());
-               
-               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);
-       }
+               if ((*iter)->get_type() == Duck::TYPE_VERTEX ||
+                       (*iter)->get_type() == Duck::TYPE_POSITION)
+               {
+                       Vector p(positions[i]);
+
+                       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);
+               }
+
+       // 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;
-
-               Vector p(positions[i]);
-               //Point p((*iter)->get_trans_point());
-               
-               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);
-       }
+               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]);
+
+                       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);
+               }
 }
 
 bool