From fc860c23ed833d1da82174bd636d51d1b54a4af2 Mon Sep 17 00:00:00 2001 From: dooglus Date: Thu, 31 Jan 2008 14:13:28 +0000 Subject: [PATCH] Add menu entries and shortcuts to increase and decrease the pixel size : control-'(' and control-')'. git-svn-id: http://svn.voria.com/code@1536 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-studio/trunk/src/gtkmm/app.cpp | 11 +++++- synfig-studio/trunk/src/gtkmm/canvasview.cpp | 58 ++++++++++++++++++++++++++++ synfig-studio/trunk/src/gtkmm/canvasview.h | 3 ++ 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/synfig-studio/trunk/src/gtkmm/app.cpp b/synfig-studio/trunk/src/gtkmm/app.cpp index 6380a9c..5fabbbb 100644 --- a/synfig-studio/trunk/src/gtkmm/app.cpp +++ b/synfig-studio/trunk/src/gtkmm/app.cpp @@ -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() " " " " " " -" "; +" " +" " +" " +" " +; for(list::iterator iter = CanvasView::get_pixel_sizes().begin(); iter != CanvasView::get_pixel_sizes().end(); iter++) ui_info += strprintf(" ", *iter); @@ -922,6 +928,9 @@ init_ui_manager() ACCEL("//time-zoom-in","+"); ACCEL("//time-zoom-out","_"); */ + ACCEL2(Gtk::AccelKey('(',Gdk::CONTROL_MASK,"//decrease-low-res-pixel-size")); + ACCEL2(Gtk::AccelKey(')',Gdk::CONTROL_MASK,"//increase-low-res-pixel-size")); + ACCEL2(Gtk::AccelKey('(',Gdk::MOD1_MASK|Gdk::CONTROL_MASK,"//amount-dec")); ACCEL2(Gtk::AccelKey(')',Gdk::MOD1_MASK|Gdk::CONTROL_MASK,"//amount-inc")); diff --git a/synfig-studio/trunk/src/gtkmm/canvasview.cpp b/synfig-studio/trunk/src/gtkmm/canvasview.cpp index 416ae62..39d58f3 100644 --- a/synfig-studio/trunk/src/gtkmm/canvasview.cpp +++ b/synfig-studio/trunk/src/gtkmm/canvasview.cpp @@ -1320,6 +1320,15 @@ CanvasView::init_menus() ) ); } + + Glib::RefPtr 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 sizes = CanvasView::get_pixel_sizes(); + int pixel_size = work_area->get_low_res_pixel_size(); + + for (list::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 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 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::iterator iter = sizes.begin(); iter != sizes.end(); iter++) + if (*iter == pixel_size) + { + iter++; + if (iter != sizes.end()) + { + Glib::RefPtr 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_) diff --git a/synfig-studio/trunk/src/gtkmm/canvasview.h b/synfig-studio/trunk/src/gtkmm/canvasview.h index be2be34..c99dbd5 100644 --- a/synfig-studio/trunk/src/gtkmm/canvasview.h +++ b/synfig-studio/trunk/src/gtkmm/canvasview.h @@ -429,6 +429,9 @@ private: void rebuild_ducks_layer_(synfig::TransformStack& transform_stack, synfig::Canvas::Handle canvas, std::set& 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 ----------------------------------------- */ -- 2.7.4