From: dooglus Date: Thu, 31 Jan 2008 14:13:17 +0000 (+0000) Subject: Create the pixel-size menus dynamically. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=0487f6874f8d68440e26836dba776063d29e1be2;p=synfig.git Create the pixel-size menus dynamically. git-svn-id: http://svn.voria.com/code@1535 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-studio/trunk/src/gtkmm/app.cpp b/synfig-studio/trunk/src/gtkmm/app.cpp index 6c185a4..6380a9c 100644 --- a/synfig-studio/trunk/src/gtkmm/app.cpp +++ b/synfig-studio/trunk/src/gtkmm/app.cpp @@ -639,21 +639,8 @@ init_ui_manager() DEFINE_ACTION("quality-08", _("Use Quality Level 8")); DEFINE_ACTION("quality-09", _("Use Quality Level 9")); DEFINE_ACTION("quality-10", _("Use Quality Level 10")); - DEFINE_ACTION("lowres-pixel-2", _("Set Low-Res pixel size to 2")); - DEFINE_ACTION("lowres-pixel-3", _("Set Low-Res pixel size to 3")); - DEFINE_ACTION("lowres-pixel-4", _("Set Low-Res pixel size to 4")); - DEFINE_ACTION("lowres-pixel-5", _("Set Low-Res pixel size to 5")); - DEFINE_ACTION("lowres-pixel-6", _("Set Low-Res pixel size to 6")); - DEFINE_ACTION("lowres-pixel-8", _("Set Low-Res pixel size to 8")); - DEFINE_ACTION("lowres-pixel-10", _("Set Low-Res pixel size to 10")); - DEFINE_ACTION("lowres-pixel-12", _("Set Low-Res pixel size to 12")); - DEFINE_ACTION("lowres-pixel-15", _("Set Low-Res pixel size to 15")); - DEFINE_ACTION("lowres-pixel-20", _("Set Low-Res pixel size to 20")); - DEFINE_ACTION("lowres-pixel-24", _("Set Low-Res pixel size to 24")); - DEFINE_ACTION("lowres-pixel-30", _("Set Low-Res pixel size to 30")); - DEFINE_ACTION("lowres-pixel-40", _("Set Low-Res pixel size to 40")); - DEFINE_ACTION("lowres-pixel-60", _("Set Low-Res pixel size to 60")); - DEFINE_ACTION("lowres-pixel-120", _("Set Low-Res pixel size to 120")); + for(list::iterator iter = CanvasView::get_pixel_sizes().begin(); iter != CanvasView::get_pixel_sizes().end(); iter++) + DEFINE_ACTION(strprintf("lowres-pixel-%d", *iter), strprintf(_("Set Low-Res pixel size to %d"), *iter)); DEFINE_ACTION("play", _("Play")); // DEFINE_ACTION("pause", _("Pause")); DEFINE_ACTION("stop", _("Stop")); @@ -785,22 +772,12 @@ init_ui_manager() " " " " " " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " +" "; + + for(list::iterator iter = CanvasView::get_pixel_sizes().begin(); iter != CanvasView::get_pixel_sizes().end(); iter++) + ui_info += strprintf(" ", *iter); + + ui_info += " " " " " " diff --git a/synfig-studio/trunk/src/gtkmm/canvasview.cpp b/synfig-studio/trunk/src/gtkmm/canvasview.cpp index eb9795b..416ae62 100644 --- a/synfig-studio/trunk/src/gtkmm/canvasview.cpp +++ b/synfig-studio/trunk/src/gtkmm/canvasview.cpp @@ -917,6 +917,16 @@ CanvasView::~CanvasView() +std::list& +CanvasView::get_pixel_sizes() +{ + // prime factors of 120 are 2, 2, 2, 3, 5 - see TILE_SIZE in synfig-core/trunk/src/synfig/target_tile.h + static int pixel_size_array[] = {2,3,4,5,6,8,10,12,15,20,24,30,40,60,120}; + static list pixel_sizes = list(pixel_size_array, pixel_size_array + sizeof(pixel_size_array) / sizeof(int)); + + return pixel_sizes; +} + Gtk::Widget * CanvasView::create_time_bar() { @@ -1290,14 +1300,10 @@ CanvasView::init_menus() } } - // prime factors of 120 are 2, 2, 2, 3, 5 - int pixel_size_array[] = {2,3,4,5,6,8,10,12,15,20,24,30,40,60,120}; - list pixel_sizes(pixel_size_array, pixel_size_array + sizeof(pixel_size_array) / sizeof(int)); - // Low-Res Quality Menu { int i; - for(list::iterator iter = pixel_sizes.begin(); iter != pixel_sizes.end(); iter++) + for(list::iterator iter = CanvasView::get_pixel_sizes().begin(); iter != CanvasView::get_pixel_sizes().end(); iter++) { i = *iter; Glib::RefPtr action(Gtk::RadioAction::create(low_res_pixel_size_group,strprintf("lowres-pixel-%d",i), diff --git a/synfig-studio/trunk/src/gtkmm/canvasview.h b/synfig-studio/trunk/src/gtkmm/canvasview.h index 57799b1..be2be34 100644 --- a/synfig-studio/trunk/src/gtkmm/canvasview.h +++ b/synfig-studio/trunk/src/gtkmm/canvasview.h @@ -696,6 +696,8 @@ protected: public: static etl::handle create(etl::loose_handle instance,etl::handle canvas); + static std::list& get_pixel_sizes(); + }; // END of class CanvasView }; // END of namespace studio