diff options
author | David Robillard <d@drobilla.net> | 2006-07-05 08:32:58 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-07-05 08:32:58 +0000 |
commit | 94ac1eb5bd854244e9d90dc636a33d9cc5b82b01 (patch) | |
tree | 716543d29210d8182a5b0319643f01b406de3beb /src | |
parent | c449044cd4c8178afca187bab823f580d517b813 (diff) | |
download | ingen-94ac1eb5bd854244e9d90dc636a33d9cc5b82b01.tar.gz ingen-94ac1eb5bd854244e9d90dc636a33d9cc5b82b01.tar.bz2 ingen-94ac1eb5bd854244e9d90dc636a33d9cc5b82b01.zip |
Control slider (etc) cleanups
git-svn-id: http://svn.drobilla.net/lad/ingen@85 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/engine/Plugin.h | 19 | ||||
-rw-r--r-- | src/progs/ingenuity/ControlGroups.cpp | 83 | ||||
-rw-r--r-- | src/progs/ingenuity/ControlGroups.h | 68 | ||||
-rw-r--r-- | src/progs/ingenuity/ControlPanel.cpp | 5 | ||||
-rw-r--r-- | src/progs/ingenuity/ControlPanel.h | 2 |
5 files changed, 84 insertions, 93 deletions
diff --git a/src/libs/engine/Plugin.h b/src/libs/engine/Plugin.h index a5b70b22..da274eae 100644 --- a/src/libs/engine/Plugin.h +++ b/src/libs/engine/Plugin.h @@ -85,25 +85,8 @@ public: void name(const string& s) { m_name = s; } unsigned long id() const { return m_id; } void id(unsigned long i) { m_id = i; } + const string uri() const { return m_uri; } void uri(const string& s) { m_uri = s; } - const string uri() const - { - /* char id_str[11]; - snprintf(id_str, 11, "%lu", m_id); - - if (m_uri.length() > 0) { - return m_uri; - } else if (m_type == Internal) { - return string("om:") + m_plug_label; - } else if (m_type == LADSPA) { - return string("ladspa:").append(id_str); - } else if (m_type == DSSI) { - return string("dssi:") + lib_name() +":"+ m_plug_label; - } else { - return ""; - }*/ - return m_uri; - } PluginLibrary* library() const { return m_library; } void library(PluginLibrary* const library) { m_library = library; } diff --git a/src/progs/ingenuity/ControlGroups.cpp b/src/progs/ingenuity/ControlGroups.cpp index ef94b75f..2c067d8d 100644 --- a/src/progs/ingenuity/ControlGroups.cpp +++ b/src/progs/ingenuity/ControlGroups.cpp @@ -26,8 +26,41 @@ using namespace LibOmClient; namespace OmGtk { -//////////////////// SliderControlGroup //////////////////////// +// ////////////////////// ControlGroup ///////////////////////////////// // + +ControlGroup::ControlGroup(ControlPanel* panel, CountedPtr<PortModel> pm, bool separator) +: Gtk::VBox(false, 0), + m_control_panel(panel), + m_port_model(pm), + m_has_separator(separator) +{ + assert(m_port_model); + assert(panel); + + if (separator) { + m_separator = new Gtk::HSeparator(); + pack_start(*m_separator, false, false, 4); + } else { + m_separator = NULL; + } + + pm->metadata_update_sig.connect(sigc::mem_fun(this, &ControlGroup::metadata_update)); + pm->control_change_sig.connect(sigc::mem_fun(this, &ControlGroup::set_value)); +} + + +void +ControlGroup::metadata_update(const string& key, const string& value) +{ + if (key == "user-min") + set_min(atof(value.c_str())); + else if (key == "user-max") + set_max(atof(value.c_str())); +} + + +// ////////////////// SliderControlGroup ////////////////////// // SliderControlGroup::SliderControlGroup(ControlPanel* panel, CountedPtr<PortModel> pm, bool separator) : ControlGroup(panel, pm, separator), @@ -97,7 +130,7 @@ SliderControlGroup::SliderControlGroup(ControlPanel* panel, CountedPtr<PortModel pack_start(m_header_box, false, false, 0); pack_start(m_slider_box, false, false, 0); - update_range(); + m_slider.set_range(m_port_model->user_min(), m_port_model->user_max()); m_enable_signal = true; @@ -167,7 +200,13 @@ SliderControlGroup::min_changed() m_min_spinner.set_value(min); } - update_range(); + m_slider.set_range(min, max); + + if (m_enable_signal) { + char temp_buf[16]; + snprintf(temp_buf, 16, "%f", min); + Controller::instance().set_metadata(m_port_model->path(), "user-min", temp_buf); + } } @@ -182,27 +221,11 @@ SliderControlGroup::max_changed() m_max_spinner.set_value(max); } - update_range(); -} - - -void -SliderControlGroup::update_range() -{ - const double min = m_min_spinner.get_value(); - const double max = m_max_spinner.get_value(); - - assert(min < max); m_slider.set_range(min, max); - - m_port_model->user_min(min); - m_port_model->user_max(max); - + if (m_enable_signal) { char temp_buf[16]; - snprintf(temp_buf, 16, "%f", m_port_model->user_min()); - Controller::instance().set_metadata(m_port_model->path(), "user-min", temp_buf); - snprintf(temp_buf, 16, "%f", m_port_model->user_max()); + snprintf(temp_buf, 16, "%f", max); Controller::instance().set_metadata(m_port_model->path(), "user-max", temp_buf); } } @@ -229,15 +252,17 @@ SliderControlGroup::update_value_from_spinner() if (m_enable_signal) { m_enable_signal = false; const float value = m_value_spinner.get_value(); - if (value < m_min_spinner.get_value()) + + if (value < m_min_spinner.get_value()) { m_min_spinner.set_value(value); - if (value > m_max_spinner.get_value()) + m_slider.set_range(m_min_spinner.get_value(), m_max_spinner.get_value()); + } + if (value > m_max_spinner.get_value()) { m_max_spinner.set_value(value); + m_slider.set_range(m_min_spinner.get_value(), m_max_spinner.get_value()); + } - m_enable_signal = false; - update_range(); m_slider.set_value(m_value_spinner.get_value()); - m_enable_signal = true; m_control_panel->value_changed(m_port_model->path(), value); @@ -268,7 +293,7 @@ SliderControlGroup::slider_pressed(GdkEvent* ev) } -/////////////// IntegerControlGroup //////////////// +// ///////////// IntegerControlGroup ////////////// // IntegerControlGroup::IntegerControlGroup(ControlPanel* panel, CountedPtr<PortModel> pm, bool separator) @@ -311,7 +336,6 @@ IntegerControlGroup::set_value(float val) //cerr << "[IntegerControlGroup] Setting value to " << val << endl; m_enable_signal = false; m_spinner.set_value(val); - m_port_model->value(val); m_enable_signal = true; } @@ -343,7 +367,7 @@ IntegerControlGroup::update_value() } -/////////////// ToggleControlGroup //////////////// +// ///////////// ToggleControlGroup ////////////// // ToggleControlGroup::ToggleControlGroup(ControlPanel* panel, CountedPtr<PortModel> pm, bool separator) @@ -383,7 +407,6 @@ ToggleControlGroup::set_value(float val) //cerr << "[ToggleControlGroup] Setting value to " << val << endl; m_enable_signal = false; m_checkbutton.set_active( (val > 0.0f) ); - m_port_model->value(val); m_enable_signal = true; } diff --git a/src/progs/ingenuity/ControlGroups.h b/src/progs/ingenuity/ControlGroups.h index 6bd32c50..0e9d5810 100644 --- a/src/progs/ingenuity/ControlGroups.h +++ b/src/progs/ingenuity/ControlGroups.h @@ -33,52 +33,38 @@ namespace OmGtk { class ControlPanel; -/** A group of controls in a NodeControlWindow. +/** A group of controls (for a single Port) in a NodeControlWindow. * * \ingroup OmGtk */ class ControlGroup : public Gtk::VBox { public: - ControlGroup(ControlPanel* panel, CountedPtr<PortModel> pm, bool separator) - : Gtk::VBox(false, 0), - m_control_panel(panel), - m_port_model(pm), - m_has_separator(separator) - { - assert(m_port_model); - assert(panel); - - if (separator) { - m_separator = new Gtk::HSeparator(); - pack_start(*m_separator, false, false, 4); - } else { - m_separator = NULL; - } - } + ControlGroup(ControlPanel* panel, CountedPtr<PortModel> pm, bool separator); ~ControlGroup() { delete m_separator; } - virtual void set_name(const string& name) {} - - virtual void set_value(float val) = 0; - inline const CountedPtr<PortModel> port_model() const { return m_port_model; } - virtual void set_min(float val) {} - virtual void set_max(float val) {} - - void remove_separator() { assert(m_has_separator); - remove(*m_separator); delete m_separator; } + void remove_separator() { + assert(m_has_separator); remove(*m_separator); delete m_separator; + } virtual void enable() {} virtual void disable() {} protected: - ControlPanel* m_control_panel; - CountedPtr<PortModel> m_port_model; - bool m_has_separator; - Gtk::HSeparator* m_separator; + virtual void set_name(const string& name) {} + virtual void set_value(float val) = 0; + virtual void set_min(float val) {} + virtual void set_max(float val) {} + + virtual void metadata_update(const string& key, const string& value); + + ControlPanel* m_control_panel; + CountedPtr<PortModel> m_port_model; + bool m_has_separator; + Gtk::HSeparator* m_separator; }; @@ -90,17 +76,17 @@ class SliderControlGroup : public ControlGroup { public: SliderControlGroup(ControlPanel* panel, CountedPtr<PortModel> pm, bool separator); - + + void enable(); + void disable(); + +private: void set_name(const string& name); inline void set_value(const float val); void set_min(float val); void set_max(float val); - void enable(); - void disable(); - -private: void min_changed(); void max_changed(); void update_range(); @@ -150,13 +136,13 @@ class IntegerControlGroup : public ControlGroup public: IntegerControlGroup(ControlPanel* panel, CountedPtr<PortModel> pm, bool separator); - void set_name(const string& name); - void set_value(float val); - void enable(); void disable(); private: + void set_name(const string& name); + void set_value(float val); + void update_value(); bool m_enable_signal; @@ -175,13 +161,13 @@ class ToggleControlGroup : public ControlGroup public: ToggleControlGroup(ControlPanel* panel, CountedPtr<PortModel> pm, bool separator); - void set_name(const string& name); - void set_value(float val); - void enable(); void disable(); private: + void set_name(const string& name); + void set_value(float val); + void update_value(); bool m_enable_signal; diff --git a/src/progs/ingenuity/ControlPanel.cpp b/src/progs/ingenuity/ControlPanel.cpp index ee511e36..bb3e74d4 100644 --- a/src/progs/ingenuity/ControlPanel.cpp +++ b/src/progs/ingenuity/ControlPanel.cpp @@ -117,8 +117,6 @@ ControlPanel::add_port(PortController* port) else cg = new SliderControlGroup(this, pm, separator); - // FIXME: ControlGroup constructor should do this - pm->control_change_sig.connect(sigc::mem_fun(cg, &ControlGroup::set_value)); m_controls.push_back(cg); m_control_box->pack_start(*cg, false, false, 0); @@ -168,6 +166,7 @@ ControlPanel::remove_port(const Path& path) /** Rename the control for the given port. */ +/* void ControlPanel::rename_port(const Path& old_path, const Path& new_path) { @@ -178,7 +177,7 @@ ControlPanel::rename_port(const Path& old_path, const Path& new_path) } } } - +*/ /** Enable the control for the given port. * diff --git a/src/progs/ingenuity/ControlPanel.h b/src/progs/ingenuity/ControlPanel.h index 77628156..ea6cede5 100644 --- a/src/progs/ingenuity/ControlPanel.h +++ b/src/progs/ingenuity/ControlPanel.h @@ -63,7 +63,7 @@ public: void add_port(PortController* port); void remove_port(const Path& path); - void rename_port(const Path& old_path, const Path& new_path); + //void rename_port(const Path& old_path, const Path& new_path); void enable_port(const Path& path); void disable_port(const Path& path); |