Add menu entries and shortcuts to increase and decrease the pixel size : control...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Thu, 31 Jan 2008 14:13:28 +0000 (14:13 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Thu, 31 Jan 2008 14:13:28 +0000 (14:13 +0000)
git-svn-id: http://svn.voria.com/code@1536 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-studio/trunk/src/gtkmm/app.cpp
synfig-studio/trunk/src/gtkmm/canvasview.cpp
synfig-studio/trunk/src/gtkmm/canvasview.h

index 6380a9c..5fabbbb 100644 (file)
@@ -648,6 +648,8 @@ init_ui_manager()
        DEFINE_ACTION("toggle-grid-snap", _("Toggle Grid Snap"));
        DEFINE_ACTION("toggle-guide-show", _("Toggle Guide Show"));
        DEFINE_ACTION("toggle-low-res", _("Toggle Low-Res"));
+       DEFINE_ACTION("decrease-low-res-pixel-size", _("Decrease Low-Res Pixel Size"));
+       DEFINE_ACTION("increase-low-res-pixel-size", _("Increase Low-Res Pixel Size"));
        DEFINE_ACTION("toggle-onion-skin", _("Toggle Onion Skin"));
        DEFINE_ACTION("canvas-zoom-in", Gtk::StockID("gtk-zoom-in"));
        DEFINE_ACTION("canvas-zoom-out", Gtk::StockID("gtk-zoom-out"));
@@ -772,7 +774,11 @@ init_ui_manager()
 "                      <menuitem action='quality-09' />"
 "                      <menuitem action='quality-10' />"
 "              </menu>"
-"              <menu action='menu-lowres-pixel'>";
+"              <menu action='menu-lowres-pixel'>"
+"              <menuitem action='decrease-low-res-pixel-size'/>"
+"              <menuitem action='increase-low-res-pixel-size'/>"
+"              <separator name='pixel-size-separator'/>"
+;
 
        for(list<int>::iterator iter = CanvasView::get_pixel_sizes().begin(); iter != CanvasView::get_pixel_sizes().end(); iter++)
                ui_info += strprintf("                  <menuitem action='lowres-pixel-%d' />", *iter);
@@ -922,6 +928,9 @@ init_ui_manager()
        ACCEL("<Actions>//time-zoom-in","+");
        ACCEL("<Actions>//time-zoom-out","_");
 */
+       ACCEL2(Gtk::AccelKey('(',Gdk::CONTROL_MASK,"<Actions>//decrease-low-res-pixel-size"));
+       ACCEL2(Gtk::AccelKey(')',Gdk::CONTROL_MASK,"<Actions>//increase-low-res-pixel-size"));
+
        ACCEL2(Gtk::AccelKey('(',Gdk::MOD1_MASK|Gdk::CONTROL_MASK,"<Actions>//amount-dec"));
        ACCEL2(Gtk::AccelKey(')',Gdk::MOD1_MASK|Gdk::CONTROL_MASK,"<Actions>//amount-inc"));
 
index 416ae62..39d58f3 100644 (file)
@@ -1320,6 +1320,15 @@ CanvasView::init_menus()
                                )
                        );
                }
+
+               Glib::RefPtr<Gtk::Action> action;
+
+               action=Gtk::Action::create("decrease-low-res-pixel-size", _("Decrease Low-Res Pixel Size"));
+               action_group->add( action,sigc::mem_fun(this, &studio::CanvasView::decrease_low_res_pixel_size));
+
+               action=Gtk::Action::create("increase-low-res-pixel-size",  _("Increase Low-Res Pixel Size"));
+               action_group->add( action, sigc::mem_fun(this, &studio::CanvasView::increase_low_res_pixel_size));
+
        }
 
        action_group->add( Gtk::Action::create("play", Gtk::Stock::MEDIA_PLAY),
@@ -2858,6 +2867,55 @@ CanvasView::rebuild_ducks()
 }
 
 void
+CanvasView::decrease_low_res_pixel_size()
+{
+       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)
+               {
+                       if (iter == sizes.begin())
+                               // we already have the smallest low-res pixels possible - turn off low-res instead
+                               work_area->set_low_resolution_flag(false);
+                       else
+                       {
+                               iter--;
+                               Glib::RefPtr<Gtk::Action> action = action_group->get_action(strprintf("lowres-pixel-%d", *iter));
+                               action->activate(); // to make sure the radiobutton in the menu is updated too
+                               work_area->set_low_resolution_flag(true);
+                       }
+                       break;
+               }
+}
+
+void
+CanvasView::increase_low_res_pixel_size()
+{
+       list<int> sizes = CanvasView::get_pixel_sizes();
+       int pixel_size = work_area->get_low_res_pixel_size();
+
+       if (!work_area->get_low_resolution_flag())
+       {
+               work_area->set_low_resolution_flag(true);
+               return;
+       }
+
+       for (list<int>::iterator iter = sizes.begin(); iter != sizes.end(); iter++)
+               if (*iter == pixel_size)
+               {
+                       iter++;
+                       if (iter != sizes.end())
+                       {
+                               Glib::RefPtr<Gtk::Action> action = action_group->get_action(strprintf("lowres-pixel-%d", *iter));
+                               action->activate(); // to make sure the radiobutton in the menu is updated too
+                               work_area->set_low_resolution_flag(true);
+                       }
+                       break;
+               }
+}
+
+void
 CanvasView::on_dirty_preview()
 {
        if(!is_playing_)
index be2be34..c99dbd5 100644 (file)
@@ -429,6 +429,9 @@ private:
 
        void rebuild_ducks_layer_(synfig::TransformStack& transform_stack, synfig::Canvas::Handle canvas, std::set<synfig::Layer::Handle>& selected_list);
 
+       void decrease_low_res_pixel_size();
+       void increase_low_res_pixel_size();
+
        /*
  -- ** -- P U B L I C   M E T H O D S -----------------------------------------
        */