Added a gui checkbox rather than using a #define to switch the quadrant limiting...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sat, 9 Feb 2008 00:34:53 +0000 (00:34 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sat, 9 Feb 2008 00:34:53 +0000 (00:34 +0000)
git-svn-id: http://svn.voria.com/code@1634 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-studio/trunk/src/gtkmm/app.cpp
synfig-studio/trunk/src/gtkmm/app.h
synfig-studio/trunk/src/gtkmm/dialog_setup.cpp
synfig-studio/trunk/src/gtkmm/dialog_setup.h
synfig-studio/trunk/src/gtkmm/duckmatic.cpp
synfig-studio/trunk/src/gtkmm/duckmatic.h
synfig-studio/trunk/src/gtkmm/renderer_ducks.cpp

index 26153f8..03b854d 100644 (file)
@@ -262,6 +262,7 @@ std::list< etl::handle< studio::Module > > module_list_;
 
 bool studio::App::use_colorspace_gamma=true;
 bool studio::App::single_threaded=false;
+bool studio::App::restrict_radius_ducks=true;
 
 static int max_recent_files_=25;
 int studio::App::get_max_recent_files() { return max_recent_files_; }
@@ -482,6 +483,11 @@ public:
                        value=strprintf("%i",App::auto_recover->get_timeout());
                        return true;
                }
+               if(key=="restrict_radius_ducks")
+               {
+                       value=strprintf("%i",(int)App::restrict_radius_ducks);
+                       return true;
+               }
 
                return synfigapp::Settings::get_value(key,value);
        }
@@ -538,6 +544,12 @@ public:
                        App::single_threaded=i;
                        return true;
                }
+               if(key=="restrict_radius_ducks")
+               {
+                       int i(atoi(value.c_str()));
+                       App::restrict_radius_ducks=i;
+                       return true;
+               }
 
                return synfigapp::Settings::set_value(key,value);
        }
@@ -552,6 +564,7 @@ public:
                ret.push_back("use_colorspace_gamma");
                ret.push_back("single_threaded");
                ret.push_back("auto_recover_backup_interval");
+               ret.push_back("restrict_radius_ducks");
                return ret;
        }
 };
@@ -1452,6 +1465,7 @@ App::reset_initial_window_configuration()
        synfigapp::Main::settings().set_value("pref.distance_system","pt");
        synfigapp::Main::settings().set_value("pref.use_colorspace_gamma","1");
        synfigapp::Main::settings().set_value("pref.single_threaded","0");
+       synfigapp::Main::settings().set_value("pref.restrict_radius_ducks","1");
        synfigapp::Main::settings().set_value("window.toolbox.pos","4 4");
 }
 
index 48dd091..d1ff274 100644 (file)
@@ -193,6 +193,8 @@ public:
 
        static bool single_threaded;
 
+       static bool restrict_radius_ducks;
+
        /*
  -- ** -- S I G N A L S -------------------------------------------------------
        */
index 17c0ea4..879b4da 100644 (file)
@@ -69,7 +69,8 @@ Dialog_Setup::Dialog_Setup():
        adj_recent_files(15,1,50,1,1,1),
        adj_undo_depth(100,10,5000,1,1,1),
        toggle_use_colorspace_gamma(_("Visually Linear Color Selection")),
-       toggle_single_threaded(_("Use Only a Single Thread"))
+       toggle_single_threaded(_("Use Only a Single Thread")),
+       toggle_restrict_radius_ducks(_("Restrict Real-Valued Ducks to Top Right Quadrant"))
 {
        // Setup the buttons
 
@@ -191,6 +192,9 @@ Dialog_Setup::Dialog_Setup():
        misc_table->attach(*manage(new Gtk::Label(_("Auto Backup Interval (0 to disable)"))), 0, 1, 5, 6, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
        misc_table->attach(auto_backup_interval, 1, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
 
+       // Misc - restrict_radius_ducks
+       misc_table->attach(toggle_restrict_radius_ducks, 0, 2, 6, 7, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+
        show_all_children();
 }
 
@@ -226,6 +230,9 @@ Dialog_Setup::on_apply_pressed()
 
        App::distance_system=Distance::System(widget_enum->get_value());
 
+       // Set the restrict_radius_ducks flag
+       App::restrict_radius_ducks=toggle_restrict_radius_ducks.get_active();
+
        App::save_settings();
 }
 
@@ -304,6 +311,9 @@ Dialog_Setup::refresh()
 
        // Refresh the value of the auto backup interval
        auto_backup_interval.set_value(App::auto_recover->get_timeout() / 1000);
+
+       // Refresh the status of the restrict_radius_ducks flag
+       toggle_restrict_radius_ducks.set_active(App::restrict_radius_ducks);
 }
 
 GammaPattern::GammaPattern():
index c83597a..86d9694 100644 (file)
@@ -171,6 +171,8 @@ class Dialog_Setup : public Gtk::Dialog
        Widget_Enum *widget_enum;
 
        Widget_Time auto_backup_interval;
+
+       Gtk::CheckButton toggle_restrict_radius_ducks;
 public:
 
        void set_time_format(synfig::Time::Format time_format);
index a8b4219..740f9d7 100644 (file)
@@ -556,8 +556,8 @@ Duckmatic::signal_edited_selected_ducks()
                                throw String("Bad edit");
                        }
                }
-#ifdef RESTRICT_RADIUS_DUCKS_TO_ONE_QUARTER
-               else if ((*iter)->is_radius())
+               else if (App::restrict_radius_ducks &&
+                                (*iter)->is_radius())
                {
                        Point point((*iter)->get_point());
                        bool changed = false;
@@ -581,7 +581,6 @@ Duckmatic::signal_edited_selected_ducks()
                                throw String("Bad edit");
                        }
                }
-#endif
                else
                {
                        if(!(*iter)->signal_edited()((*iter)->get_point()))
index c50a3a6..2b160cf 100644 (file)
@@ -78,11 +78,6 @@ public:
 #include <map>
 #endif
 
-//! If defined, only allow radius ducks to be in the top right
-//! quadrant of the plane.  This makes it very easy to set the
-//! corresponding parameter to zero (by dragging down and left)
-#define RESTRICT_RADIUS_DUCKS_TO_ONE_QUARTER
-
 /* === T Y P E D E F S ===================================================== */
 
 /* === C L A S S E S & S T R U C T S ======================================= */
index 21c17af..cab4d95 100644 (file)
@@ -228,13 +228,12 @@ Renderer_Ducks::render_vfunc(
                origin[0]=(origin[0]-window_startx)/pw;
                origin[1]=(origin[1]-window_starty)/ph;
 
-#ifdef RESTRICT_RADIUS_DUCKS_TO_ONE_QUARTER
-               if((*iter)->is_radius())
+               if (App::restrict_radius_ducks &&
+                       (*iter)->is_radius())
                {
                        if (point[0] < origin[0]) point[0] = origin[0];
                        if (point[1] > origin[1]) point[1] = origin[1];
                }
-#endif
 
                bool selected(get_work_area()->duck_is_selected(*iter));
                bool hover(*iter==hover_duck);
@@ -381,17 +380,21 @@ Renderer_Ducks::render_vfunc(
 
                        if(hover)
                        {
-#ifdef RESTRICT_RADIUS_DUCKS_TO_ONE_QUARTER
-                               Point point2((*iter)->get_trans_point());
-                               Point origin2((*iter)->get_trans_origin());
+                               Real mag;
+                               if (App::restrict_radius_ducks)
+                               {
+                                       Point point((*iter)->get_trans_point());
+                                       Point origin((*iter)->get_trans_origin());
 
-                               if ((point2[0] - origin2[0]) * pw < 0) point2[0] = origin2[0];
-                               if ((point2[1] - origin2[1]) * ph > 0) point2[1] = origin2[1];
+                                       if ((point[0] - origin[0]) * pw < 0) point[0] = origin[0];
+                                       if ((point[1] - origin[1]) * ph > 0) point[1] = origin[1];
 
-                               Distance real_mag((point2-origin2).mag(),Distance::SYSTEM_UNITS);
-#else
-                               Distance real_mag(((*iter)->get_trans_point()-(*iter)->get_trans_origin()).mag(),Distance::SYSTEM_UNITS);
-#endif
+                                       mag = (point-origin).mag();
+                               }
+                               else
+                                       mag = ((*iter)->get_trans_point()-(*iter)->get_trans_origin()).mag();
+
+                               Distance real_mag(mag, Distance::SYSTEM_UNITS);
                                real_mag.convert(App::distance_system,get_work_area()->get_rend_desc());
                                layout->set_text(real_mag.get_string());