Add a separator between toggle ducks and low res dials
[synfig.git] / synfig-studio / trunk / src / gtkmm / canvasview.cpp
index e8e3a4d..5f3e389 100644 (file)
@@ -41,6 +41,7 @@
 #include <gtkmm/messagedialog.h>
 #include <gtkmm/treemodelsort.h>
 #include <gtkmm/buttonbox.h>
+#include <gtkmm/separator.h>
 
 #include <gtk/gtktreestore.h>
 #include <gtk/gtkversion.h>
@@ -705,6 +706,7 @@ CanvasView::CanvasView(etl::loose_handle<Instance> instance,etl::handle<synfigap
        children_tree=0;
        duck_refresh_flag=true;
        toggling_ducks_=false;
+       changing_resolution_=false;
 
        smach_.set_default_state(&state_normal);
 
@@ -1098,7 +1100,8 @@ CanvasView::create_status_bar()
 Gtk::Widget*
 CanvasView::create_display_bar()
 {
-       displaybar = manage(new class Gtk::Table(1, 1, false));
+       displaybar = manage(new class Gtk::Table(1, 3, false));
+
        // Setup the ToggleDuckDial widget
        toggleducksdial = Gtk::manage(new class ToggleDucksDial());
 
@@ -1125,7 +1128,25 @@ CanvasView::create_display_bar()
                        );
        toggleducksdial->show();
 
+       // Set up the ResolutionDial widget
+       resolutiondial=Gtk::manage(new class ResolutionDial());
+
+       resolutiondial->update_lowres(work_area->get_low_resolution_flag());
+       resolutiondial->signal_increase_resolution().connect(
+                       sigc::mem_fun(*this, &studio::CanvasView::decrease_low_res_pixel_size));
+       resolutiondial->signal_decrease_resolution().connect(
+                       sigc::mem_fun(*this, &studio::CanvasView::increase_low_res_pixel_size));
+       resolutiondial->signal_use_low_resolution().connect(
+                       sigc::mem_fun(*this, &studio::CanvasView::toggle_low_res_pixel_flag));
+       resolutiondial->show();
+
+       // Set up a separator
+       Gtk::VSeparator *separator = Gtk::manage(new class Gtk::VSeparator());
+       separator->show();
+
+       displaybar->attach(*resolutiondial, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
        displaybar->attach(*toggleducksdial, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
+       displaybar->attach(*separator, 1, 2, 0, 1, Gtk::FILL, Gtk::FILL);
        displaybar->show();
 
        return displaybar;
@@ -1452,7 +1473,7 @@ CanvasView::init_menus()
 
                action = Gtk::ToggleAction::create("toggle-low-res", _("Use Low-Res"));
                action->set_active(work_area->get_low_resolution_flag());
-               action_group->add(action, sigc::mem_fun(*work_area, &studio::WorkArea::toggle_low_resolution_flag));
+               action_group->add(action, sigc::mem_fun(*this, &studio::CanvasView::toggle_low_res_pixel_flag));
 
                action = Gtk::ToggleAction::create("toggle-onion-skin", _("Show Onion Skin"));
                action->set_active(work_area->get_onion_skin());
@@ -3066,9 +3087,11 @@ CanvasView::rebuild_ducks()
 void
 CanvasView::decrease_low_res_pixel_size()
 {
+       if(changing_resolution_)
+               return;
+       changing_resolution_=true;
        list<int> sizes = CanvasView::get_pixel_sizes();
        int pixel_size = work_area->get_low_res_pixel_size();
-
        for (list<int>::iterator iter = sizes.begin(); iter != sizes.end(); iter++)
                if (*iter == pixel_size)
                {
@@ -3084,17 +3107,32 @@ CanvasView::decrease_low_res_pixel_size()
                        }
                        break;
                }
+       // Update the "toggle-low-res" action
+       Glib::RefPtr<Gtk::ToggleAction> action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("toggle-low-res"));
+       action->set_active(work_area->get_low_resolution_flag());
+       // Update toggle low res button
+       resolutiondial->update_lowres(work_area->get_low_resolution_flag());
+       changing_resolution_=false;
 }
 
 void
 CanvasView::increase_low_res_pixel_size()
 {
+       if(changing_resolution_)
+               return;
+       changing_resolution_=true;
        list<int> sizes = CanvasView::get_pixel_sizes();
        int pixel_size = work_area->get_low_res_pixel_size();
-
        if (!work_area->get_low_resolution_flag())
        {
+               // We were using "hi res" so change it to low res.
                work_area->set_low_resolution_flag(true);
+               // Update the "toggle-low-res" action
+               Glib::RefPtr<Gtk::ToggleAction> action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("toggle-low-res"));
+               action->set_active(true);
+               // Update the toggle low res button
+               resolutiondial->update_lowres(true);
+               changing_resolution_=false;
                return;
        }
 
@@ -3110,6 +3148,27 @@ CanvasView::increase_low_res_pixel_size()
                        }
                        break;
                }
+       // Update the "toggle-low-res" action
+       Glib::RefPtr<Gtk::ToggleAction> action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("toggle-low-res"));
+       action->set_active(work_area->get_low_resolution_flag());
+       // Update toggle low res button
+       resolutiondial->update_lowres(work_area->get_low_resolution_flag());
+       changing_resolution_=false;
+}
+
+void
+CanvasView::toggle_low_res_pixel_flag()
+{
+       if(changing_resolution_)
+               return;
+       changing_resolution_=true;
+       work_area->toggle_low_resolution_flag();
+       // Update the toggle low res button
+       resolutiondial->update_lowres(work_area->get_low_resolution_flag());
+       // Update the "toggle-low-res" action
+       Glib::RefPtr<Gtk::ToggleAction> action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("toggle-low-res"));
+       action->set_active(work_area->get_low_resolution_flag());
+       changing_resolution_=false;
 }
 
 void
@@ -3684,6 +3743,21 @@ CanvasView::toggle_duck_mask(Duckmatic::Type type)
        work_area->queue_draw();
        try
        {
+               // Update the toggle ducks actions
+               Glib::RefPtr<Gtk::ToggleAction> action;
+               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-position-ducks"));
+               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_POSITION));
+               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-tangent-ducks"));
+               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_TANGENT));
+               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-vertex-ducks"));
+               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_VERTEX));
+               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-radius-ducks"));
+               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_RADIUS));
+               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-width-ducks"));
+               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_WIDTH));
+               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-angle-ducks"));
+               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_ANGLE));
+               // Update toggle ducks buttons
                toggleducksdial->update_toggles(work_area->get_type_mask());
        }
        catch(...)