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
This commit is contained in:
@@ -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); }
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
string name = get_widget_name ();
|
||||
name = name.substr (0, name.find_last_of ('-'));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user