add editor to Theme Manager for modifiers
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 15 Dec 2014 17:07:05 +0000 (12:07 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 15 Dec 2014 17:07:05 +0000 (12:07 -0500)
gtk2_ardour/theme_manager.cc
gtk2_ardour/theme_manager.h
gtk2_ardour/ui_config.cc
gtk2_ardour/ui_config.h

index b21b713706220d7bb80a7aa40a5fc995a80810e7..958d952d070d103e13e455fffa52743e4a1c7d44 100644 (file)
@@ -157,9 +157,12 @@ ThemeManager::ThemeManager()
        palette_viewport.signal_size_allocate().connect (sigc::bind (sigc::mem_fun (*this, &ThemeManager::palette_canvas_allocated), palette_group, palette_viewport.canvas(),
                                                                     sigc::mem_fun (*this, &ThemeManager::palette_event)));
        palette_scroller.add (palette_viewport);
+
+       modifier_scroller.add (modifier_vbox);
        
        notebook.append_page (alias_scroller, _("Items"));
        notebook.append_page (palette_scroller, _("Palette"));
+       notebook.append_page (modifier_scroller, _("Modifiers"));
        
        vbox->pack_start (notebook);
 
@@ -200,7 +203,8 @@ ThemeManager::ThemeManager()
        set_size_request (-1, 400);
        /* no need to call setup_palette() here, it will be done when its size is allocated */
        setup_aliases ();
-
+       setup_modifiers ();
+       
        /* Trigger setting up the color scheme and loading the GTK RC file */
 
        ARDOUR_UI::config()->load_rc_file (false);
@@ -212,11 +216,54 @@ ThemeManager::~ThemeManager()
 {
 }
 
+void
+ThemeManager::setup_modifiers ()
+{
+       UIConfiguration* uic (ARDOUR_UI::config());
+       UIConfiguration::Modifiers& modifiers (uic->modifiers);
+       Gtk::HBox* mod_hbox;
+       Gtk::Label* mod_label;
+       Gtk::HScale* mod_scale;
+       
+       Gtkmm2ext::container_clear (modifier_vbox);
+
+       for (UIConfiguration::Modifiers::const_iterator m = modifiers.begin(); m != modifiers.end(); ++m) {
+               mod_hbox = manage (new HBox);
+
+               mod_scale = manage (new HScale (0.0, 1.0, 0.01));
+               mod_scale->set_draw_value (false);
+               mod_scale->set_value (m->second.a());
+               mod_scale->set_update_policy (Gtk::UPDATE_DISCONTINUOUS);
+               mod_scale->signal_value_changed().connect (sigc::bind (sigc::mem_fun (*this, &ThemeManager::modifier_edited), mod_scale, m->first));
+
+               mod_label = manage (new Label (m->first));
+               
+               mod_hbox->pack_start (*mod_label, false, true, 6);
+               mod_hbox->pack_start (*mod_scale, true, true);
+
+               modifier_vbox.pack_start (*mod_hbox, false, false);
+       }
+
+       modifier_vbox.show_all ();
+
+}
+
+void
+ThemeManager::modifier_edited (Gtk::Range* range, string name)
+{
+       using namespace ArdourCanvas;
+       
+       double alpha = range->get_value();
+       SVAModifier svam (SVAModifier::Assign, -1.0, -1.0, alpha);
+       ARDOUR_UI::config()->set_modifier (name, svam);
+}
+
 void
 ThemeManager::colors_changed ()
 {
        setup_palette ();
        setup_aliases ();       
+       setup_modifiers ();     
 }
 
 int
index f023076c97512c1078ce0929b7381ee441eddff6..e9a12b185e0e2b136ed5fe80fdc3870554603048 100644 (file)
@@ -161,6 +161,12 @@ class ThemeManager : public ArdourWindow
        void setup_aliases ();
        void setup_palette ();
 
+       Gtk::ScrolledWindow modifier_scroller;
+       Gtk::VBox modifier_vbox;
+       
+       void setup_modifiers ();
+       void modifier_edited (Gtk::Range*, std::string);
+       
        void colors_changed ();
 };
 
index 629b20dcdde9fcae92a252bdc00e2b71eb85a205..70e77e3345e6a01f4cc067aaf68365816ced1f4a 100644 (file)
@@ -68,6 +68,7 @@ UIConfiguration::UIConfiguration ()
        _dirty (false),
        aliases_modified (false),
        colors_modified (false),
+       modifiers_modified (false),
        block_save (0)
 {
        _instance = this;
@@ -354,7 +355,7 @@ UIConfiguration::save_state()
                _dirty = false;
        }
 
-       if (aliases_modified || colors_modified) {
+       if (aliases_modified || colors_modified || modifiers_modified) {
 
                if (store_color_theme ()) {
                        error << string_compose (_("Color file %1 not saved"), color_file.get()) << endmsg;
@@ -363,6 +364,7 @@ UIConfiguration::save_state()
 
                aliases_modified = false;
                colors_modified = false;
+               modifiers_modified = false;
        }
        
 
@@ -628,6 +630,21 @@ UIConfiguration::set_alias (string const & name, string const & alias)
        ARDOUR_UI_UTILS::ColorsChanged (); /* EMIT SIGNAL */
 }
 
+void
+UIConfiguration::set_modifier (string const & name, SVAModifier svam)
+{
+       Modifiers::iterator m = modifiers.find (name);
+
+       if (m == modifiers.end()) {
+               return;
+       }
+
+       m->second = svam;
+       modifiers_modified = true;
+
+       ARDOUR_UI_UTILS::ColorsChanged (); /* EMIT SIGNAL */
+}
+
 void
 UIConfiguration::load_rc_file (bool themechange, bool allow_own)
 {
index b30c76fa1199a0ae574c72396379cc811d95ee40..c8dcbacf126af35a4d25d758f2f55a165e779544 100644 (file)
@@ -64,6 +64,7 @@ class UIConfiguration : public PBD::Stateful
 
        void set_alias (std::string const & name, std::string const & alias);
        void set_color (const std::string& name, ArdourCanvas::Color);
+       void set_modifier (std::string const &, ArdourCanvas::SVAModifier svam);
        
        std::string color_as_alias (ArdourCanvas::Color c);
        ArdourCanvas::Color quantized (ArdourCanvas::Color) const;
@@ -106,6 +107,7 @@ class UIConfiguration : public PBD::Stateful
        bool _dirty;
        bool aliases_modified;
        bool colors_modified;
+       bool modifiers_modified;
        
        static UIConfiguration* _instance;