From cf099732084c20dfe45ae78b2d64816f2bf03ab6 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 28 Jan 2010 06:02:14 +0000 Subject: Shrink code (generic Control::enable and Control::disable by iterating over box). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2389 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/Controls.cpp | 68 ++++++++++++++-------------------------------------- src/gui/Controls.hpp | 15 ++---------- 2 files changed, 20 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/gui/Controls.cpp b/src/gui/Controls.cpp index 6e2fd6be..8564fbed 100644 --- a/src/gui/Controls.cpp +++ b/src/gui/Controls.cpp @@ -75,6 +75,24 @@ Control::init(ControlPanel* panel, SharedPtr pm) } +void +Control::enable() +{ + for (Gtk::Box_Helpers::BoxList::const_iterator i = children().begin(); + i != children().end(); ++i) + i->get_widget()->set_sensitive(true); +} + + +void +Control::disable() +{ + for (Gtk::Box_Helpers::BoxList::const_iterator i = children().begin(); + i != children().end(); ++i) + i->get_widget()->set_sensitive(false); +} + + void Control::set_name(const string& name) { @@ -222,24 +240,6 @@ SliderControl::set_range(float min, float max) } -void -SliderControl::enable() -{ - _slider->property_sensitive() = true; - _value_spinner->property_sensitive() = true; - _name_label->property_sensitive() = true; -} - - -void -SliderControl::disable() -{ - _slider->property_sensitive() = false; - _value_spinner->property_sensitive() = false; - _name_label->property_sensitive() = false; -} - - void SliderControl::update_value_from_slider() { @@ -352,22 +352,6 @@ ToggleControl::set_value(const Atom& val) } -void -ToggleControl::enable() -{ - _checkbutton->property_sensitive() = true; - _name_label->property_sensitive() = true; -} - - -void -ToggleControl::disable() -{ - _checkbutton->property_sensitive() = false; - _name_label->property_sensitive() = false; -} - - void ToggleControl::toggled() { @@ -421,22 +405,6 @@ StringControl::set_value(const Atom& val) } -void -StringControl::enable() -{ - _entry->property_sensitive() = true; - _name_label->property_sensitive() = true; -} - - -void -StringControl::disable() -{ - _entry->property_sensitive() = false; - _name_label->property_sensitive() = false; -} - - void StringControl::activated() { diff --git a/src/gui/Controls.hpp b/src/gui/Controls.hpp index 91b737ed..1a5ee46d 100644 --- a/src/gui/Controls.hpp +++ b/src/gui/Controls.hpp @@ -45,8 +45,8 @@ public: virtual void init(ControlPanel* panel, SharedPtr pm); - virtual void enable() = 0; - virtual void disable() = 0; + void enable(); + void disable(); inline const SharedPtr port_model() const { return _port_model; } @@ -78,9 +78,6 @@ public: SliderControl(BaseObjectType* cobject, const Glib::RefPtr& glade_xml); void init(ControlPanel* panel, SharedPtr pm); - void enable(); - void disable(); - void set_min(float val); void set_max(float val); @@ -115,12 +112,8 @@ public: void init(ControlPanel* panel, SharedPtr pm); - void enable(); - void disable(); - private: void set_value(const Raul::Atom& value); - void toggled(); Gtk::CheckButton* _checkbutton; @@ -138,12 +131,8 @@ public: void init(ControlPanel* panel, SharedPtr pm); - void enable(); - void disable(); - private: void set_value(const Raul::Atom& value); - void activated(); Gtk::Entry* _entry; -- cgit v1.2.1