From cfec427867f42d7aa7bea6dfbb0736b5ce99e9e2 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 12 Nov 2009 07:02:33 +0000 Subject: Factor out common Control code. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2256 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/Controls.cpp | 36 +++++++++--------------------------- src/gui/Controls.hpp | 10 ++-------- 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/src/gui/Controls.cpp b/src/gui/Controls.cpp index 39c18a88..6ab9081a 100644 --- a/src/gui/Controls.cpp +++ b/src/gui/Controls.cpp @@ -42,6 +42,7 @@ Control::Control(BaseObjectType* cobject, const Glib::RefPtr& : Gtk::VBox(cobject) , _control_panel(NULL) , _enable_signal(false) + , _name_label(NULL) { Glib::RefPtr menu_xml = GladeFactory::new_glade_reference("port_control_menu"); menu_xml->get_widget("port_control_menu", _menu); @@ -73,6 +74,14 @@ Control::init(ControlPanel* panel, SharedPtr pm) } +void +Control::set_name(const string& name) +{ + const string name_markup = string("") + name + ""; + _name_label->set_markup(name_markup); +} + + void Control::menu_properties() { @@ -212,15 +221,6 @@ SliderControl::set_range(float min, float max) } -void -SliderControl::set_name(const string& name) -{ - string name_label = ""; - name_label += name + ""; - _name_label->set_markup(name_label); -} - - void SliderControl::enable() { @@ -409,15 +409,6 @@ ToggleControl::init(ControlPanel* panel, SharedPtr pm) } -void -ToggleControl::set_name(const string& name) -{ - string name_label = ""; - name_label += name + ""; - _name_label->set_markup(name_label); -} - - void ToggleControl::set_value(const Atom& val) { @@ -499,15 +490,6 @@ StringControl::init(ControlPanel* panel, SharedPtr pm) } -void -StringControl::set_name(const string& name) -{ - string name_label = ""; - name_label += name + ""; - _name_label->set_markup(name_label); -} - - void StringControl::set_value(const Atom& val) { diff --git a/src/gui/Controls.hpp b/src/gui/Controls.hpp index 0f0dbd79..844e6738 100644 --- a/src/gui/Controls.hpp +++ b/src/gui/Controls.hpp @@ -54,6 +54,7 @@ protected: virtual void set_value(const Raul::Atom& value) = 0; virtual void set_range(float min, float max) {} + void set_name(const std::string& name); void menu_properties(); ControlPanel* _control_panel; @@ -63,6 +64,7 @@ protected: Gtk::Menu* _menu; Gtk::MenuItem* _menu_properties; + Gtk::Label* _name_label; }; @@ -83,7 +85,6 @@ public: void set_max(float val); private: - void set_name(const std::string& name); void set_value(const Raul::Atom& value); void set_range(float min, float max); @@ -98,7 +99,6 @@ private: bool _enabled; - Gtk::Label* _name_label; Gtk::SpinButton* _value_spinner; Gtk::HScale* _slider; }; @@ -119,14 +119,12 @@ public: void disable(); private: - void set_name(const string& name); void set_value(float val); void update_value(); bool _enable_signal; Gtk::Alignment _alignment; - Gtk::Label _name_label; Gtk::SpinButton _spinner; }; #endif @@ -147,12 +145,10 @@ public: void disable(); private: - void set_name(const std::string& name); void set_value(const Raul::Atom& value); void toggled(); - Gtk::Label* _name_label; Gtk::CheckButton* _checkbutton; }; @@ -172,12 +168,10 @@ public: void disable(); private: - void set_name(const std::string& name); void set_value(const Raul::Atom& value); void activated(); - Gtk::Label* _name_label; Gtk::Entry* _entry; }; -- cgit v1.2.1