diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2007-02-13 14:25:17 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2007-02-13 14:25:17 +0000 |
commit | d405df54ec37ef039d1044b727044e109b110ffa (patch) | |
tree | e5f2ceaf405716feb9f4c3af00554095a27de042 /libs | |
parent | 8e79cd5610789b377d0975640a555cc45d9300cb (diff) |
the buttons will submit to my rule! prelight-when-active, be gonecd /usr/local/music/src/ardour
git-svn-id: svn://localhost/ardour2/trunk@1451 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/stateful_button.h | 18 | ||||
-rw-r--r-- | libs/gtkmm2ext/stateful_button.cc | 60 |
2 files changed, 26 insertions, 52 deletions
diff --git a/libs/gtkmm2ext/gtkmm2ext/stateful_button.h b/libs/gtkmm2ext/gtkmm2ext/stateful_button.h index 00ae766645..83ef622e73 100644 --- a/libs/gtkmm2ext/gtkmm2ext/stateful_button.h +++ b/libs/gtkmm2ext/gtkmm2ext/stateful_button.h @@ -33,19 +33,17 @@ class StateButton StateButton(); virtual ~StateButton() {} - void set_colors (const std::vector<Gdk::Color>& colors); void set_visual_state (int); int get_visual_state () { return visual_state; } void set_self_managed (bool yn) { _self_managed = yn; } protected: - std::vector<Gdk::Color> colors; int visual_state; - Gdk::Color saved_bg; - bool have_saved_bg; bool _self_managed; + bool _is_realized; - virtual void bg_modify (Gtk::StateType, Gdk::Color) = 0; + virtual std::string get_widget_name() const = 0; + virtual void set_widget_name (std::string) = 0; }; @@ -60,9 +58,8 @@ class StatefulToggleButton : public StateButton, public Gtk::ToggleButton void on_realize (); void on_toggled (); - void bg_modify (Gtk::StateType state, Gdk::Color col) { - modify_bg (state, col); - } + std::string get_widget_name() const { return get_name(); } + void set_widget_name (std::string name) { set_name (name); get_child()->set_name (name); } }; class StatefulButton : public StateButton, public Gtk::Button @@ -75,9 +72,8 @@ class StatefulButton : public StateButton, public Gtk::Button protected: void on_realize (); - void bg_modify (Gtk::StateType state, Gdk::Color col) { - modify_bg (state, col); - } + std::string get_widget_name() const { return get_name(); } + void set_widget_name (std::string name) { set_name (name); get_child()->set_name (name); } }; }; diff --git a/libs/gtkmm2ext/stateful_button.cc b/libs/gtkmm2ext/stateful_button.cc index 000b7b8ea1..b40105c0d2 100644 --- a/libs/gtkmm2ext/stateful_button.cc +++ b/libs/gtkmm2ext/stateful_button.cc @@ -12,22 +12,14 @@ using namespace std; StateButton::StateButton () { + _is_realized = false; visual_state = 0; - have_saved_bg = false; -} - -void -StateButton::set_colors (const vector<Gdk::Color>& c) -{ - colors = c; - visual_state++; // to force transition - set_visual_state (visual_state - 1); } void StateButton::set_visual_state (int n) { - if (!have_saved_bg) { + if (!_is_realized) { /* not yet realized */ visual_state = n; return; @@ -36,29 +28,23 @@ StateButton::set_visual_state (int n) if (n == visual_state) { return; } + + string name = get_widget_name (); + name = name.substr (0, name.find_last_of ('-')); - if (n == 0) { - - /* back to the default color */ - - if (have_saved_bg) { - bg_modify (STATE_NORMAL, saved_bg); - bg_modify (STATE_ACTIVE, saved_bg); - bg_modify (STATE_SELECTED, saved_bg); - bg_modify (STATE_PRELIGHT, saved_bg); - } - - - } else { - - int index = (n-1) % colors.size (); - - bg_modify (STATE_NORMAL, colors[index]); - bg_modify (STATE_ACTIVE, colors[index]); - bg_modify (STATE_SELECTED, colors[index]); - bg_modify (STATE_PRELIGHT, colors[index]); + switch (n) { + case 0: + name += "-normal"; + break; + case 1: + name += "-active"; + break; + case 2: + name += "-alternate"; + break; } - + + set_widget_name (name); visual_state = n; } @@ -69,11 +55,7 @@ StatefulToggleButton::on_realize () { ToggleButton::on_realize (); - if (!have_saved_bg) { - saved_bg = get_style()->get_bg (STATE_NORMAL); - have_saved_bg = true; - } - + _is_realized = true; visual_state++; // to force transition set_visual_state (visual_state - 1); } @@ -83,11 +65,7 @@ StatefulButton::on_realize () { Button::on_realize (); - if (!have_saved_bg) { - saved_bg = get_style()->get_bg (STATE_NORMAL); - have_saved_bg = true; - } - + _is_realized = true; visual_state++; // to force transition set_visual_state (visual_state - 1); } |