Create the pixel-size menus dynamically.
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Thu, 31 Jan 2008 14:13:17 +0000 (14:13 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Thu, 31 Jan 2008 14:13:17 +0000 (14:13 +0000)
git-svn-id: http://svn.voria.com/code@1535 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 6c185a4..6380a9c 100644 (file)
@@ -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<int>::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()
 "                      <menuitem action='quality-09' />"
 "                      <menuitem action='quality-10' />"
 "              </menu>"
-"              <menu action='menu-lowres-pixel'>"
-"                      <menuitem action='lowres-pixel-2' />"
-"                      <menuitem action='lowres-pixel-3' />"
-"                      <menuitem action='lowres-pixel-4' />"
-"                      <menuitem action='lowres-pixel-5' />"
-"                      <menuitem action='lowres-pixel-6' />"
-"                      <menuitem action='lowres-pixel-8' />"
-"                      <menuitem action='lowres-pixel-10' />"
-"                      <menuitem action='lowres-pixel-12' />"
-"                      <menuitem action='lowres-pixel-15' />"
-"                      <menuitem action='lowres-pixel-20' />"
-"                      <menuitem action='lowres-pixel-24' />"
-"                      <menuitem action='lowres-pixel-30' />"
-"                      <menuitem action='lowres-pixel-40' />"
-"                      <menuitem action='lowres-pixel-60' />"
-"                      <menuitem action='lowres-pixel-120' />"
+"              <menu action='menu-lowres-pixel'>";
+
+       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);
+
+       ui_info +=
 "              </menu>"
 "              <separator name='bleh08'/>"
 "              <menuitem action='play'/>"
index eb9795b..416ae62 100644 (file)
@@ -917,6 +917,16 @@ CanvasView::~CanvasView()
 
 
 
+std::list<int>&
+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<int> pixel_sizes = list<int>(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<int> pixel_sizes(pixel_size_array, pixel_size_array + sizeof(pixel_size_array) / sizeof(int));
-
        // Low-Res Quality Menu
        {
                int i;
-               for(list<int>::iterator iter = pixel_sizes.begin(); iter != pixel_sizes.end(); iter++)
+               for(list<int>::iterator iter = CanvasView::get_pixel_sizes().begin(); iter != CanvasView::get_pixel_sizes().end(); iter++)
                {
                        i = *iter;
                        Glib::RefPtr<Gtk::RadioAction> action(Gtk::RadioAction::create(low_res_pixel_size_group,strprintf("lowres-pixel-%d",i),
index 57799b1..be2be34 100644 (file)
@@ -696,6 +696,8 @@ protected:
 public:
 
        static etl::handle<studio::CanvasView> create(etl::loose_handle<Instance> instance,etl::handle<synfig::Canvas> canvas);
+       static std::list<int>& get_pixel_sizes();
+
 }; // END of class CanvasView
 
 }; // END of namespace studio