button hacks and more

git-svn-id: svn://localhost/trunk/ardour2@200 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2005-12-21 21:37:18 +00:00
parent bf5180d17a
commit 541ff63201
21 changed files with 389 additions and 391 deletions

View file

@ -231,7 +231,7 @@ env.Alias('install', env.Install(os.path.join(install_prefix, 'share/ardour/glad
env.Alias ('tarball', env.Distribute (env['DISTTREE'],
[ 'SConscript',
'i18n.h', 'gettext.h',
'editor_xpms', 'misc_xpms', 'transport_xpms',
'editor_xpms', 'misc_xpms',
'ardour2_ui.rc', 'splash.ppm'
] +
gtkardour_files + vst_files + glade_files +

View file

@ -46,6 +46,7 @@ vector<RefPtr<Gtk::Action> > ActionManager::plugin_selection_sensitive_actions;
vector<RefPtr<Gtk::Action> > ActionManager::range_sensitive_actions;
vector<RefPtr<Gtk::Action> > ActionManager::jack_sensitive_actions;
vector<RefPtr<Gtk::Action> > ActionManager::jack_opposite_sensitive_actions;
vector<RefPtr<Gtk::Action> > ActionManager::transport_sensitive_actions;
RefPtr<UIManager> ActionManager::ui_manager;
string ActionManager::unbound_string = "--";

View file

@ -26,6 +26,7 @@ class ActionManager
static std::vector<Glib::RefPtr<Gtk::Action> > track_selection_sensitive_actions;
static std::vector<Glib::RefPtr<Gtk::Action> > plugin_selection_sensitive_actions;
static std::vector<Glib::RefPtr<Gtk::Action> > range_sensitive_actions;
static std::vector<Glib::RefPtr<Gtk::Action> > transport_sensitive_actions;
static std::vector<Glib::RefPtr<Gtk::Action> > jack_sensitive_actions;
static std::vector<Glib::RefPtr<Gtk::Action> > jack_opposite_sensitive_actions;

View file

@ -25,14 +25,19 @@
<separator/>
<menuitem action='Quit'/>
</menu>
<menu name='Transport' action='JACK'>
<menuitem action='toggle-playback'/>
<menuitem action='TransportRoll'/>
<menuitem action='TransportStop'/>
<menuitem action='TransportForward'/>
<menuitem action='TransportRewind'/>
<menuitem action='TransportGotoStart'/>
<menuitem action='TransportGotoEnd'/>
<menu name='Transport' action='Transport'>
<menuitem action='ToggleRoll'/>
<menuitem action='ToggleRollForgetCapture'/>
<menuitem action='Loop'/>
<menuitem action='PlaySelection'/>
<menuitem action='Forward'/>
<menuitem action='Rewind'/>
<menuitem action='GotoStart'/>
<menuitem action='GotoEnd'/>
<separator/>
<menuitem action='TogglePunchIn'/>
<menuitem action='TogglePunchOut'/>
<menuitem action='set-playhead'/>
</menu>
<menu name='JACK' action='JACK'>
<menuitem action='JACKDisconnect'/>
@ -90,10 +95,4 @@
<menuitem action='SetShuttleUnitsSemitones'/>
</popup>
<popup name='ShuttleStylePopup'>
<menuitem action='SetShuttleActionSprung'/>
<menuitem action='SetShuttleActionWheel'/>
</popup>
</ui>

View file

@ -1,15 +1,19 @@
; this file is an automated accelerator map dump
(gtk_accel_path "<Actions>/Editor/set-playhead" "p")
(gtk_accel_path "<Actions>/Common/Quit" "<Control>q")
(gtk_accel_path "<Actions>/Common/Save" "<Control>s")
(gtk_accel_path "<Actions>/Common/TransportForward" "Right")
(gtk_accel_path "<Actions>/Common/TransportRewind" "Left")
(gtk_accel_path "<Actions>/Common/TransportRecord" "R")
(gtk_accel_path "<Actions>/Common/TransportGotoStart" "<Control>a")
(gtk_accel_path "<Actions>/Common/TransportGotoEnd" "<Control>e")
(gtk_accel_path "<Actions>/Editor/toggle-playback" "space")
(gtk_accel_path "<Actions>/Editor/set-playhead" "p")
(gtk_accel_path "<Actions>/Transport/ToggleRoll" "space")
(gtk_accel_path "<Actions>/Transport/ToggleRollForgetCapture" "<Control>space")
(gtk_accel_path "<Actions>/Transport/Forward" "Right")
(gtk_accel_path "<Actions>/Transport/Rewind" "Left")
(gtk_accel_path "<Actions>/Transport/Record" "R")
(gtk_accel_path "<Actions>/Transport/loop" "l")
(gtk_accel_path "<Actions>/Transport/GotoStart" "<Control>a")
(gtk_accel_path "<Actions>/Transport/GotoEnd" "<Control>e")
(gtk_accel_path "<Actions>/Editor/set-edit-cursor" "e")
(gtk_accel_path "<Actions>/Editor/undo" "<Control>z")
(gtk_accel_path "<Actions>/Editor/redo" "<Control>r")

View file

@ -804,7 +804,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
/* transport */
shuttle_units_button (_("% ")),
shuttle_style_button (_("spring")),
punch_in_button (_("punch\nin")),
punch_out_button (_("punch\nout")),
@ -2568,19 +2567,18 @@ ARDOUR_UI::transport_rec_enable_blink (bool onoff)
switch (session->record_status()) {
case Session::Enabled:
if (onoff) {
rec_button.set_state (STATE_ACTIVE);
rec_button.set_state (1);
} else {
rec_button.set_state (STATE_NORMAL);
rec_button.set_state (0);
}
break;
case Session::Recording:
rec_button.set_state (STATE_ACTIVE);
rec_button.set_state (2);
break;
default:
rec_button.set_active (false);
rec_button.set_state (STATE_NORMAL);
rec_button.set_state (0);
break;
}
}

View file

@ -53,8 +53,8 @@
#include <gtkmm/menubar.h>
#include <gtkmm/adjustment.h>
#include <gtkmm2ext/gtk_ui.h>
#include <gtkmm2ext/pix.h>
#include <gtkmm2ext/click_box.h>
#include <gtkmm2ext/stateful_button.h>
#include <ardour/ardour.h>
#include <ardour/session.h>
@ -339,7 +339,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI
void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
Gtkmm2ext::TearOff* transport_tearoff;
Gtkmm2ext::TearOff* transport_tearoff;
Gtk::Frame transport_frame;
Gtk::HBox transport_tearoff_hbox;
Gtk::HBox transport_hbox;
@ -355,11 +355,16 @@ class ARDOUR_UI : public Gtkmm2ext::UI
Gtk::HBox primary_clock_hbox;
Gtk::HBox secondary_clock_hbox;
Gtk::Button goto_start_button;
Gtk::Button goto_end_button;
Gtk::Button rewind_button;
Gtk::Button forward_button;
Gtk::Button stop_button;
Gtkmm2ext::StatefulButton roll_button;
Gtkmm2ext::StatefulButton stop_button;
Gtkmm2ext::StatefulButton rewind_button;
Gtkmm2ext::StatefulButton forward_button;
Gtkmm2ext::StatefulButton goto_start_button;
Gtkmm2ext::StatefulButton goto_end_button;
Gtkmm2ext::StatefulButton auto_loop_button;
Gtkmm2ext::StatefulButton play_selection_button;
Gtkmm2ext::StatefulButton rec_button;
enum ShuttleBehaviour {
Sprung,
@ -371,17 +376,17 @@ class ARDOUR_UI : public Gtkmm2ext::UI
Semitones
};
Gtk::DrawingArea shuttle_box;
Gtk::EventBox speed_display_box;
Gtk::Label speed_display_label;
Gtk::Button shuttle_units_button;
Gtk::Button shuttle_style_button;
Gtk::Menu* shuttle_unit_menu;
Gtk::Menu* shuttle_style_menu;
ShuttleBehaviour shuttle_behaviour;
ShuttleUnits shuttle_units;
Gtk::DrawingArea shuttle_box;
Gtk::EventBox speed_display_box;
Gtk::Label speed_display_label;
Gtk::Button shuttle_units_button;
Gtk::ComboBoxText shuttle_style_button;
Gtk::Menu* shuttle_unit_menu;
Gtk::Menu* shuttle_style_menu;
ShuttleBehaviour shuttle_behaviour;
ShuttleUnits shuttle_units;
void shuttle_style_clicked ();
void shuttle_style_changed();
void shuttle_unit_clicked ();
void set_shuttle_behaviour (ShuttleBehaviour);
void set_shuttle_units (ShuttleUnits);
@ -397,11 +402,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI
bool shuttle_grabbed;
double shuttle_fract;
Gtk::ToggleButton auto_loop_button;
Gtk::ToggleButton play_selection_button;
Gtk::ToggleButton roll_button;
Gtk::ToggleButton rec_button;
Gtk::ToggleButton punch_in_button;
Gtk::ToggleButton punch_out_button;
Gtk::ToggleButton auto_return_button;
@ -474,7 +474,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI
/* menu bar and associated stuff */
Gtk::MenuBar* menu_bar;
Gtk::Fixed menu_bar_base;
Gtk::EventBox menu_bar_base;
Gtk::HBox menu_hbox;
void build_menu_bar ();
@ -669,6 +669,8 @@ class ARDOUR_UI : public Gtkmm2ext::UI
bool filter_ardour_session_dirs (const Gtk::FileFilter::Info&);
Glib::RefPtr<Gtk::ActionGroup> common_actions;
void editor_realized ();
};

View file

@ -85,10 +85,8 @@ ARDOUR_UI::setup_windows ()
return 0;
}
void
ARDOUR_UI::setup_adjustables ()
{
adjuster_table.set_homogeneous (true);
@ -119,11 +117,35 @@ ARDOUR_UI::setup_adjustables ()
adjuster_table.attach (*mmc_id_button, 2, 3, 1, 2, FILL, FILL, 5, 5);
}
#include "transport_xpms"
static const gchar * loop_xpm[] = {
"19 19 3 1",
" c None",
". c #000000",
"+ c #FFFFFF",
" ... ",
" .+.. ",
" .++.. ",
" ...+++.... ",
" ...++++++++... ",
" ..+++.+++..+++.. ",
" ..++...++.....++..",
" .++.. .+.. ..++.",
" .+.. ... ..+.",
" .+. .+.",
" .+.. ... ..+.",
" .++.. ..+. ..++.",
" ..++.....++...++..",
" ..+++..+++.+++.. ",
" ...++++++++... ",
" ....+++... ",
" ..++. ",
" ..+. ",
" ... "};
void
ARDOUR_UI::transport_stopped ()
{
stop_button.set_active (true);
roll_button.set_active (false);
play_selection_button.set_active (false);
auto_loop_button.set_active (false);
@ -139,6 +161,8 @@ static const double SHUTTLE_FRACT_SPEED1=0.48412291827; /* derived from A1,A2 */
void
ARDOUR_UI::transport_rolling ()
{
stop_button.set_active (false);
if (session->get_play_range()) {
play_selection_button.set_active (true);
@ -167,6 +191,7 @@ ARDOUR_UI::transport_rolling ()
void
ARDOUR_UI::transport_rewinding ()
{
stop_button.set_active (false);
roll_button.set_active (true);
play_selection_button.set_active (false);
auto_loop_button.set_active (false);
@ -175,6 +200,7 @@ ARDOUR_UI::transport_rewinding ()
void
ARDOUR_UI::transport_forwarding ()
{
stop_button.set_active (false);
roll_button.set_active (true);
play_selection_button.set_active (false);
auto_loop_button.set_active (false);
@ -191,49 +217,44 @@ ARDOUR_UI::setup_transport ()
transport_base.set_name ("TransportBase");
transport_base.add (transport_hbox);
transport_frame.set_shadow_type (Gtk::SHADOW_OUT);
transport_frame.set_shadow_type (SHADOW_OUT);
transport_frame.set_name ("BaseFrame");
transport_frame.add (transport_base);
transport_tearoff->Detach.connect (bind (mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast<Gtk::Box*>(&top_packer),
static_cast<Gtk::Widget*>(&transport_frame)));
transport_tearoff->Attach.connect (bind (mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Gtk::Box*> (&top_packer),
static_cast<Gtk::Widget*> (&transport_frame), 1));
transport_tearoff->Detach.connect (bind (mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast<Box*>(&top_packer),
static_cast<Widget*>(&transport_frame)));
transport_tearoff->Attach.connect (bind (mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Box*> (&top_packer),
static_cast<Widget*> (&transport_frame), 1));
vector<Gdk::Color> colors;
Gdk::Color c;
/* record button has 3 color states, so we set 2 extra here */
c.set_rgb_p (0.91, 0.68, 0.68);
colors.push_back (c);
c.set_rgb_p (1, 0, 0);
colors.push_back (c);
rec_button.set_colors (colors);
colors.clear ();
/* other buttons get 2 color states, so add one here */
c.set_rgb_p (0.66, 0.97, 0.18);
colors.push_back (c);
stop_button.set_colors (colors);
roll_button.set_colors (colors);
auto_loop_button.set_colors (colors);
play_selection_button.set_colors (colors);
goto_start_button.set_colors (colors);
goto_end_button.set_colors (colors);
Widget* w;
#ifdef THE_OLD
w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(start_xpm)));
w->show();
goto_start_button.add (*w);
w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(end_xpm)));
w->show();
goto_end_button.add (*w);
w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(arrow_xpm)));
w->show();
roll_button.add (*w);
w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(stop_xpm)));
w->show();
stop_button.add (*w);
w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(play_selection_xpm)));
w->show();
play_selection_button.add (*w);
w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(rec_xpm)));
w->show();
rec_button.add (*w);
w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(loop_xpm)));
w->show();
auto_loop_button.add (*w);
stop_button.set_active (true);
stop_button.set_use_stock (false);
roll_button.set_use_stock (false);
rec_button.set_use_stock (false);
goto_start_button.set_use_stock (false);
goto_end_button.set_use_stock (false);
auto_loop_button.set_use_stock (false);
#else
w = manage (new Image (Stock::MEDIA_PREVIOUS, ICON_SIZE_BUTTON));
w->show();
goto_start_button.add (*w);
@ -256,28 +277,22 @@ ARDOUR_UI::setup_transport ()
w->show();
auto_loop_button.add (*w);
stop_button.set_use_stock (true);
roll_button.set_use_stock (true);
rec_button.set_use_stock (true);
goto_start_button.set_use_stock (true);
goto_end_button.set_use_stock (true);
auto_loop_button.set_use_stock (true);
#endif
RefPtr<Action> act;
act = ActionManager::get_action (X_("<Actions>/Common/TransportStop"));
act = ActionManager::get_action (X_("<Actions>/Transport/Stop"));
act->connect_proxy (stop_button);
act = ActionManager::get_action (X_("<Actions>/Common/TransportRoll"));
act = ActionManager::get_action (X_("<Actions>/Transport/Roll"));
act->connect_proxy (roll_button);
act = ActionManager::get_action (X_("<Actions>/Common/TransportRecord"));
act = ActionManager::get_action (X_("<Actions>/Transport/Record"));
act->connect_proxy (rec_button);
act = ActionManager::get_action (X_("<Actions>/Common/TransportGotoStart"));
act = ActionManager::get_action (X_("<Actions>/Transport/GotoStart"));
act->connect_proxy (goto_start_button);
act = ActionManager::get_action (X_("<Actions>/Common/TransportGotoEnd"));
act = ActionManager::get_action (X_("<Actions>/Transport/GotoEnd"));
act->connect_proxy (goto_end_button);
act = ActionManager::get_action (X_("<Actions>/Common/TransportLoop"));
act = ActionManager::get_action (X_("<Actions>/Transport/Loop"));
act->connect_proxy (auto_loop_button);
act = ActionManager::get_action (X_("<Actions>/Transport/PlaySelection"));
act->connect_proxy (play_selection_button);
ARDOUR_UI::instance()->tooltips().set_tip (roll_button, _("Play from playhead"));
ARDOUR_UI::instance()->tooltips().set_tip (stop_button, _("Stop playback"));
@ -294,7 +309,6 @@ ARDOUR_UI::setup_transport ()
ARDOUR_UI::instance()->tooltips().set_tip (follow_button, _("Enable/Disable follow playhead"));
ARDOUR_UI::instance()->tooltips().set_tip (shuttle_box, _("Shuttle speed control"));
ARDOUR_UI::instance()->tooltips().set_tip (shuttle_units_button, _("Select semitones or %%-age for speed display"));
ARDOUR_UI::instance()->tooltips().set_tip (shuttle_style_button, _("Select sprung or wheel behaviour"));
ARDOUR_UI::instance()->tooltips().set_tip (speed_display_box, _("Current transport speed"));
shuttle_box.set_flags (CAN_FOCUS);
@ -317,20 +331,20 @@ ARDOUR_UI::setup_transport ()
click_button.set_name ("TransportButton");
follow_button.set_name ("TransportButton");
goto_start_button.unset_flags (Gtk::CAN_FOCUS);
goto_end_button.unset_flags (Gtk::CAN_FOCUS);
roll_button.unset_flags (Gtk::CAN_FOCUS);
stop_button.unset_flags (Gtk::CAN_FOCUS);
play_selection_button.unset_flags (Gtk::CAN_FOCUS);
rec_button.unset_flags (Gtk::CAN_FOCUS);
auto_loop_button.unset_flags (Gtk::CAN_FOCUS);
auto_return_button.unset_flags (Gtk::CAN_FOCUS);
auto_play_button.unset_flags (Gtk::CAN_FOCUS);
auto_input_button.unset_flags (Gtk::CAN_FOCUS);
punch_out_button.unset_flags (Gtk::CAN_FOCUS);
punch_in_button.unset_flags (Gtk::CAN_FOCUS);
click_button.unset_flags (Gtk::CAN_FOCUS);
follow_button.unset_flags (Gtk::CAN_FOCUS);
goto_start_button.unset_flags (CAN_FOCUS);
goto_end_button.unset_flags (CAN_FOCUS);
roll_button.unset_flags (CAN_FOCUS);
stop_button.unset_flags (CAN_FOCUS);
play_selection_button.unset_flags (CAN_FOCUS);
rec_button.unset_flags (CAN_FOCUS);
auto_loop_button.unset_flags (CAN_FOCUS);
auto_return_button.unset_flags (CAN_FOCUS);
auto_play_button.unset_flags (CAN_FOCUS);
auto_input_button.unset_flags (CAN_FOCUS);
punch_out_button.unset_flags (CAN_FOCUS);
punch_in_button.unset_flags (CAN_FOCUS);
click_button.unset_flags (CAN_FOCUS);
follow_button.unset_flags (CAN_FOCUS);
goto_start_button.set_events (goto_start_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
goto_end_button.set_events (goto_end_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
@ -376,11 +390,11 @@ ARDOUR_UI::setup_transport ()
punch_in_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_punch_in));
punch_out_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_punch_out));
preroll_button.unset_flags (Gtk::CAN_FOCUS);
preroll_button.unset_flags (CAN_FOCUS);
preroll_button.set_events (preroll_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
preroll_button.set_name ("TransportButton");
postroll_button.unset_flags (Gtk::CAN_FOCUS);
postroll_button.unset_flags (CAN_FOCUS);
postroll_button.set_events (postroll_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
postroll_button.set_name ("TransportButton");
@ -406,28 +420,32 @@ ARDOUR_UI::setup_transport ()
transport_tearoff_hbox.pack_start (goto_start_button, false, false);
transport_tearoff_hbox.pack_start (goto_end_button, false, false);
Gtk::Frame* sframe = manage (new Frame);
Gtk::VBox* svbox = manage (new VBox);
Gtk::HBox* shbox = manage (new HBox);
Frame* sframe = manage (new Frame);
VBox* svbox = manage (new VBox);
HBox* shbox = manage (new HBox);
sframe->set_shadow_type (Gtk::SHADOW_IN);
sframe->set_shadow_type (SHADOW_IN);
sframe->add (shuttle_box);
shuttle_box.set_name (X_("ShuttleControl"));
speed_display_box.add (speed_display_label);
set_size_request_to_display_given_text (speed_display_box, _("stopped"), 2, 2);
speed_display_box.set_name (X_("ShuttleDisplay"));
shuttle_units_button.set_name (X_("ShuttleButton"));
shuttle_units_button.signal_clicked().connect (mem_fun(*this, &ARDOUR_UI::shuttle_unit_clicked));
shuttle_style_button.set_name (X_("ShuttleButton"));
shuttle_style_button.signal_clicked().connect (mem_fun(*this, &ARDOUR_UI::shuttle_style_clicked));
Gtk::Frame* sdframe = manage (new Frame);
vector<string> shuttle_strings;
shuttle_strings.push_back (_("sprung"));
shuttle_strings.push_back (_("wheel"));
set_popdown_strings (shuttle_style_button, shuttle_strings);
shuttle_style_button.signal_changed().connect (mem_fun (*this, &ARDOUR_UI::shuttle_style_changed));
sdframe->set_shadow_type (Gtk::SHADOW_IN);
Frame* sdframe = manage (new Frame);
sdframe->set_shadow_type (SHADOW_IN);
sdframe->add (speed_display_box);
shbox->pack_start (*sdframe, false, false);
@ -478,7 +496,7 @@ ARDOUR_UI::setup_clock ()
{
ARDOUR_UI::Clock.connect (bind (mem_fun (big_clock, &AudioClock::set), false));
big_clock_window = new Gtk::Window (WINDOW_TOPLEVEL);
big_clock_window = new Window (WINDOW_TOPLEVEL);
big_clock_window->set_border_width (0);
big_clock_window->add (big_clock);
@ -499,14 +517,14 @@ ARDOUR_UI::manage_window (Window& win)
}
void
ARDOUR_UI::detach_tearoff (Gtk::Box* b, Gtk::Widget* w)
ARDOUR_UI::detach_tearoff (Box* b, Widget* w)
{
editor->ensure_float (*transport_tearoff->tearoff_window());
b->remove (*w);
}
void
ARDOUR_UI::reattach_tearoff (Gtk::Box* b, Gtk::Widget* w, int32_t n)
ARDOUR_UI::reattach_tearoff (Box* b, Widget* w, int32_t n)
{
b->pack_start (*w);
b->reorder_child (*w, n);
@ -560,13 +578,13 @@ ARDOUR_UI::solo_blink (bool onoff)
if (session->soloing()) {
if (onoff) {
solo_alert_button.set_state (Gtk::STATE_ACTIVE);
solo_alert_button.set_state (STATE_ACTIVE);
} else {
solo_alert_button.set_state (Gtk::STATE_NORMAL);
solo_alert_button.set_state (STATE_NORMAL);
}
} else {
solo_alert_button.set_active (false);
solo_alert_button.set_state (Gtk::STATE_NORMAL);
solo_alert_button.set_state (STATE_NORMAL);
}
}
@ -579,13 +597,13 @@ ARDOUR_UI::audition_blink (bool onoff)
if (session->is_auditioning()) {
if (onoff) {
auditioning_alert_button.set_state (Gtk::STATE_ACTIVE);
auditioning_alert_button.set_state (STATE_ACTIVE);
} else {
auditioning_alert_button.set_state (Gtk::STATE_NORMAL);
auditioning_alert_button.set_state (STATE_NORMAL);
}
} else {
auditioning_alert_button.set_active (false);
auditioning_alert_button.set_state (Gtk::STATE_NORMAL);
auditioning_alert_button.set_state (STATE_NORMAL);
}
}
@ -747,15 +765,6 @@ ARDOUR_UI::shuttle_box_expose (GdkEventExpose* event)
return TRUE;
}
void
ARDOUR_UI::shuttle_style_clicked ()
{
if (shuttle_style_menu == 0) {
shuttle_style_menu = dynamic_cast<Menu*> (ActionManager::get_widget ("/ShuttleStylePopup"));
}
shuttle_style_menu->popup (1, 0);
}
void
ARDOUR_UI::shuttle_unit_clicked ()
{
@ -770,20 +779,33 @@ ARDOUR_UI::set_shuttle_units (ShuttleUnits u)
{
switch ((shuttle_units = u)) {
case Percentage:
static_cast<Gtk::Label*>(shuttle_units_button.get_child())->set_text ("% ");
static_cast<Label*>(shuttle_units_button.get_child())->set_text ("% ");
break;
case Semitones:
static_cast<Gtk::Label*>(shuttle_units_button.get_child())->set_text (_("st"));
static_cast<Label*>(shuttle_units_button.get_child())->set_text (_("st"));
break;
}
}
void
ARDOUR_UI::shuttle_style_changed ()
{
ustring str = shuttle_style_button.get_active_text ();
if (str == _("sprung")) {
set_shuttle_behaviour (Sprung);
} else if (str == _("wheel")) {
set_shuttle_behaviour (Wheel);
}
}
void
ARDOUR_UI::set_shuttle_behaviour (ShuttleBehaviour b)
{
switch ((shuttle_behaviour = b)) {
case Sprung:
static_cast<Gtk::Label*>(shuttle_style_button.get_child())->set_text (_("sprung"));
shuttle_style_button.set_active_text (_("sprung"));
shuttle_fract = 0.0;
shuttle_box.queue_draw ();
if (session) {
@ -794,7 +816,7 @@ ARDOUR_UI::set_shuttle_behaviour (ShuttleBehaviour b)
}
break;
case Wheel:
static_cast<Gtk::Label*>(shuttle_style_button.get_child())->set_text (_("wheel"));
shuttle_style_button.set_active_text (_("wheel"));
break;
}
}
@ -829,12 +851,16 @@ ARDOUR_UI::update_speed_display ()
void
ARDOUR_UI::set_transport_sensitivity (bool yn)
{
goto_start_button.set_sensitive (yn);
goto_end_button.set_sensitive (yn);
roll_button.set_sensitive (yn);
stop_button.set_sensitive (yn);
play_selection_button.set_sensitive (yn);
rec_button.set_sensitive (yn);
auto_loop_button.set_sensitive (yn);
ActionManager::set_sensitive (ActionManager::transport_sensitive_actions, yn);
shuttle_box.set_sensitive (yn);
}
void
ARDOUR_UI::editor_realized ()
{
set_size_request_to_display_given_text (speed_display_box, _("stopped"), 2, 2);
/* XXX: this should really be saved in instant.xml or something similar and restored from there */
shuttle_style_button.set_active_text (_("sprung"));
const guint32 FUDGE = 20; // Combo's are stupid - they steal space from the entry for the button
set_size_request_to_display_given_text (shuttle_style_button, _("sprung"), 2+FUDGE, 10);
}

View file

@ -53,6 +53,7 @@ ARDOUR_UI::create_editor ()
}
editor->DisplayControlChanged.connect (mem_fun(*this, &ARDOUR_UI::editor_display_control_changed));
editor->Realized.connect (mem_fun (*this, &ARDOUR_UI::editor_realized));
return 0;
}
@ -170,12 +171,6 @@ ARDOUR_UI::install_actions ()
ActionManager::session_sensitive_actions.push_back (act);
ActionManager::register_action (common_actions, X_("About"), _("About"), mem_fun(*this, &ARDOUR_UI::show_splash));
act = ActionManager::register_action (common_actions, X_("ToggleAutoLoop"), _("toggle auto loop"), mem_fun(*this, &ARDOUR_UI::toggle_session_auto_loop));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("TogglePunchIn"), _("toggle punch in"), mem_fun(*this, &ARDOUR_UI::toggle_session_punch_in));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("NewSession"), _("new session"), bind (mem_fun(*this, &ARDOUR_UI::new_session), false, string()));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("AddAudioTrack"), _("add audio track"), bind (mem_fun(*this, &ARDOUR_UI::session_add_audio_track), 1, 1));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("AddAudioBus"), _("add audio bus"), bind (mem_fun(*this, &ARDOUR_UI::session_add_audio_bus), 1, 1));
@ -184,32 +179,72 @@ ARDOUR_UI::install_actions ()
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("RemoveLastCapture"), _("remove last capture"), mem_fun(*this, &ARDOUR_UI::remove_last_capture));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("TransportStop"), _("stop"), mem_fun(*this, &ARDOUR_UI::transport_stop));
Glib::RefPtr<ActionGroup> transport_actions = ActionGroup::create (X_("Transport"));
/* do-nothing action for the "transport" menu bar item */
ActionManager::register_action (transport_actions, X_("Transport"), _("Transport"));
/* these two are not used by key bindings, instead use ToggleRoll for that. these two do show up in
menus and via button proxies.
*/
act = ActionManager::register_action (transport_actions, X_("Stop"), _("stop"), mem_fun(*this, &ARDOUR_UI::transport_stop));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("TransportStopAndForgetCapture"), _("stop and forget capture"), mem_fun(*this, &ARDOUR_UI::transport_stop_and_forget_capture));
ActionManager::transport_sensitive_actions.push_back (act);
act = ActionManager::register_action (transport_actions, X_("Roll"), _("roll"), mem_fun(*this, &ARDOUR_UI::transport_roll));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("TransportRoll"), _("roll"), mem_fun(*this, &ARDOUR_UI::transport_roll));
ActionManager::transport_sensitive_actions.push_back (act);
ActionManager::register_action (transport_actions, X_("ToggleRoll"), _("start/stop"), bind (mem_fun (*editor, &PublicEditor::toggle_playback), false));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("TransportLoop"), _("loop"), mem_fun(*this, &ARDOUR_UI::transport_loop));
ActionManager::transport_sensitive_actions.push_back (act);
ActionManager::register_action (transport_actions, X_("ToggleRollForgetCapture"), _("stop + forget capture"), bind (mem_fun(*editor, &PublicEditor::toggle_playback), true));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("TransportRecord"), _("enable record"), mem_fun(*this, &ARDOUR_UI::transport_record));
ActionManager::transport_sensitive_actions.push_back (act);
act = ActionManager::register_action (transport_actions, X_("Loop"), _("play loop range"), mem_fun(*this, &ARDOUR_UI::toggle_session_auto_loop));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("TransportRewind"), _("rewind"), bind (mem_fun(*this, &ARDOUR_UI::transport_rewind), 0));
ActionManager::transport_sensitive_actions.push_back (act);
act = ActionManager::register_action (transport_actions, X_("PlaySelection"), _("play selection"), mem_fun(*this, &ARDOUR_UI::transport_play_selection));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("TransportRewindSlow"), _("rewind (slow)"), bind (mem_fun(*this, &ARDOUR_UI::transport_rewind), -1));
ActionManager::transport_sensitive_actions.push_back (act);
act = ActionManager::register_action (transport_actions, X_("Record"), _("enable record"), mem_fun(*this, &ARDOUR_UI::transport_record));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("TransportRewindFast"), _("rewind (fast)"), bind (mem_fun(*this, &ARDOUR_UI::transport_rewind), 1));
ActionManager::transport_sensitive_actions.push_back (act);
act = ActionManager::register_action (transport_actions, X_("Rewind"), _("rewind"), bind (mem_fun(*this, &ARDOUR_UI::transport_rewind), 0));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("TransportForward"), _("forward"), bind (mem_fun(*this, &ARDOUR_UI::transport_forward), 0));
ActionManager::transport_sensitive_actions.push_back (act);
act = ActionManager::register_action (transport_actions, X_("RewindSlow"), _("rewind (slow)"), bind (mem_fun(*this, &ARDOUR_UI::transport_rewind), -1));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("TransportForwardSlow"), _("forward (slow)"), bind (mem_fun(*this, &ARDOUR_UI::transport_forward), -1));
ActionManager::transport_sensitive_actions.push_back (act);
act = ActionManager::register_action (transport_actions, X_("RewindFast"), _("rewind (fast)"), bind (mem_fun(*this, &ARDOUR_UI::transport_rewind), 1));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("TransportForwardFast"), _("forward (fast)"), bind (mem_fun(*this, &ARDOUR_UI::transport_forward), 1));
ActionManager::transport_sensitive_actions.push_back (act);
act = ActionManager::register_action (transport_actions, X_("Forward"), _("forward"), bind (mem_fun(*this, &ARDOUR_UI::transport_forward), 0));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("TransportGotoStart"), _("goto start"), mem_fun(*this, &ARDOUR_UI::transport_goto_start));
ActionManager::transport_sensitive_actions.push_back (act);
act = ActionManager::register_action (transport_actions, X_("ForwardSlow"), _("forward (slow)"), bind (mem_fun(*this, &ARDOUR_UI::transport_forward), -1));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("TransportGotoEnd"), _("goto end"), mem_fun(*this, &ARDOUR_UI::transport_goto_end));
ActionManager::transport_sensitive_actions.push_back (act);
act = ActionManager::register_action (transport_actions, X_("ForwardFast"), _("forward (fast)"), bind (mem_fun(*this, &ARDOUR_UI::transport_forward), 1));
ActionManager::session_sensitive_actions.push_back (act);
ActionManager::transport_sensitive_actions.push_back (act);
act = ActionManager::register_action (transport_actions, X_("GotoStart"), _("goto start"), mem_fun(*this, &ARDOUR_UI::transport_goto_start));
ActionManager::session_sensitive_actions.push_back (act);
ActionManager::transport_sensitive_actions.push_back (act);
act = ActionManager::register_action (transport_actions, X_("GotoEnd"), _("goto end"), mem_fun(*this, &ARDOUR_UI::transport_goto_end));
ActionManager::session_sensitive_actions.push_back (act);
ActionManager::transport_sensitive_actions.push_back (act);
act = ActionManager::register_toggle_action (transport_actions, X_("TogglePunchIn"), _("punch in"), mem_fun(*this, &ARDOUR_UI::toggle_punch_in));
ActionManager::session_sensitive_actions.push_back (act);
ActionManager::transport_sensitive_actions.push_back (act);
act = ActionManager::register_toggle_action (transport_actions, X_("TogglePunchOut"), _("punch out"), mem_fun(*this, &ARDOUR_UI::toggle_punch_out));
ActionManager::session_sensitive_actions.push_back (act);
ActionManager::transport_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("SendAllMidiFeedback"), _("send all midi feedback"), mem_fun(*this, &ARDOUR_UI::send_all_midi_feedback));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("ToggleRecordEnableTrack1"), _("toggle record enable track1"), bind (mem_fun(*this, &ARDOUR_UI::toggle_record_enable), 0U));
@ -281,11 +316,10 @@ ARDOUR_UI::install_actions ()
shuttle_actions->add (Action::create (X_("SetShuttleUnitsPercentage"), _("Percentage")), bind (mem_fun(*this, &ARDOUR_UI::set_shuttle_units), Percentage));
shuttle_actions->add (Action::create (X_("SetShuttleUnitsSemitones"), _("Semitones")), bind (mem_fun(*this, &ARDOUR_UI::set_shuttle_units), Semitones));
shuttle_actions->add (Action::create (X_("SetShuttleActionSprung"), _("Sprung")), bind (mem_fun(*this, &ARDOUR_UI::set_shuttle_behaviour), Sprung));
shuttle_actions->add (Action::create (X_("SetShuttleActionWheel"), _("Wheel")), bind (mem_fun(*this, &ARDOUR_UI::set_shuttle_behaviour), Wheel));
ActionManager::add_action_group (shuttle_actions);
ActionManager::add_action_group (jack_actions);
ActionManager::add_action_group (transport_actions);
ActionManager::add_action_group (main_actions);
ActionManager::add_action_group (common_actions);
}

View file

@ -110,8 +110,8 @@ AudioClock::AudioClock (const string& name, bool allow_edit, bool duration, bool
meter_label->set_name ("BBTMeterLabel");
tempo_label->set_name ("BBTTempoLabel");
tempo_meter_box.pack_start (*meter_label, false, false);
tempo_meter_box.pack_start (*tempo_label, false, false);
tempo_meter_box.pack_start (*meter_label, true, true);
tempo_meter_box.pack_start (*tempo_label, true, true);
bbt_packer.pack_start (tempo_meter_box, false, false, 5);
} else {

View file

@ -198,6 +198,7 @@ Editor::on_key_press_event (GdkEventKey* ev)
return gtk_window_activate_key (win, ev);
}
return true;
}
@ -679,7 +680,9 @@ Editor::Editor (AudioEngine& eng)
global_hpacker.pack_start (global_vpacker, true, true);
set_name ("EditorWindow");
cerr << "Adding accel group " << ActionManager::ui_manager->get_accel_group()->gobj() << endl;
add_accel_group (ActionManager::ui_manager->get_accel_group());
cerr << "... done\n";
vpacker.pack_end (global_hpacker, true, true);
@ -984,16 +987,9 @@ void
Editor::on_realize ()
{
Window::on_realize ();
/* Even though we're not using acceleration, we want the
labels to show up.
*/
track_context_menu.accelerate (*this->get_toplevel());
track_region_context_menu.accelerate (*this->get_toplevel());
Realized ();
}
void
Editor::queue_session_control_changed (Session::ControlType t)
{

View file

@ -55,11 +55,6 @@ Editor::register_actions ()
ActionManager::register_action (editor_actions, "nudge-backward", _("nudge backward"), bind (mem_fun(*this, &Editor::nudge_backward), false));
ActionManager::register_action (editor_actions, "nudge-next-backward", _("nudge next backward"), bind (mem_fun(*this, &Editor::nudge_backward), true));
ActionManager::register_action (editor_actions, "toggle-playback", _("toggle playback"), bind (mem_fun(*this, &Editor::toggle_playback), false));
ActionManager::register_action (editor_actions, "toggle-playback-forget-capture", _("toggle playback forget capture"), bind (mem_fun(*this, &Editor::toggle_playback), true));
ActionManager::register_action (editor_actions, "toggle-loop-playback", _("toggle loop playback"), mem_fun(*this, &Editor::toggle_loop_playback));
ActionManager::register_action (editor_actions, "temporal-zoom-out", _("temporal zoom out"), bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
ActionManager::register_action (editor_actions, "temporal-zoom-in", _("temporal zoom in"), bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
ActionManager::register_action (editor_actions, "zoom-to-session", _("zoom to session"), mem_fun(*this, &Editor::temporal_zoom_session));

View file

@ -34,14 +34,9 @@ Editor::kbd_driver (sigc::slot<void,GdkEvent*> theslot, bool use_track_canvas, b
Glib::RefPtr<Gdk::Window> evw = track_canvas.get_window()->get_pointer (x, y, mask);
bool doit = false;
cerr << "editor keyboard driver\n";
if (use_track_canvas && track_canvas_event_box.get_window()->get_pointer(x, y, mask) != 0) {
cerr << "in track canvas\n";
doit = true;
} else if (use_time_canvas && time_canvas_event_box.get_window()->get_pointer(x, y, mask)!= 0) {
cerr << "in time canvas\n";
doit = true;
}

View file

@ -1615,14 +1615,6 @@ Editor::play_selected_region ()
}
}
void
Editor::toggle_loop_playback ()
{
if (session) {
session->request_auto_loop (true);
}
}
void
Editor::loop_selected_region ()
{

View file

@ -128,6 +128,7 @@ class PublicEditor : public Gtk::Window, public Stateful {
sigc::signal<void> ZoomChanged;
sigc::signal<void> XOriginChanged;
sigc::signal<void> Resized;
sigc::signal<void> Realized;
// FIXED FOR GTK2

View file

@ -1,181 +0,0 @@
/* XPM */
static const gchar * loop_xpm[] = {
"19 19 3 1",
" c None",
". c #000000",
"+ c #FFFFFF",
" ... ",
" .+.. ",
" .++.. ",
" ...+++.... ",
" ...++++++++... ",
" ..+++.+++..+++.. ",
" ..++...++.....++..",
" .++.. .+.. ..++.",
" .+.. ... ..+.",
" .+. .+.",
" .+.. ... ..+.",
" .++.. ..+. ..++.",
" ..++.....++...++..",
" ..+++..+++.+++.. ",
" ...++++++++... ",
" ....+++... ",
" ..++. ",
" ..+. ",
" ... "};
/* XPM */
static const gchar * arrow_xpm[] = {
"19 19 3 1",
" c None",
". c #000000",
"+ c #FFFFFF",
" ",
" ... ",
" .+.. ",
" .++.. ",
" .+++.. ",
" .++++.. ",
" .+++++.. ",
" .++++++.. ",
" .+++++++.. ",
" .++++++++. ",
" .+++++++.. ",
" .++++++.. ",
" .+++++.. ",
" .++++.. ",
" .+++.. ",
" .++.. ",
" .+.. ",
" ... ",
" "};
/* XPM */
static const gchar * play_selection_xpm[] = {
"19 19 3 1",
" c None",
". c #000000",
"+ c #FFFFFF",
" ",
".... ... ....",
".++. .+.. .++.",
".++. .++.. .++.",
".++. .+++.. .++.",
".++. .++++.. .++.",
".++. .+++++.. .++.",
".++. .++++++.. .++.",
".++...+++++++...++.",
".+++++++++++++++++.",
".++...+++++++...++.",
".++. .++++++.. .++.",
".++. .+++++.. .++.",
".++. .++++.. .++.",
".++. .+++.. .++.",
".++. .++.. .++.",
".++. .+.. .++.",
".... ... ....",
" "};
/* XPM */
static const gchar * end_xpm[] = {
"19 19 3 1",
" c None",
". c #000000",
"+ c #FFFFFF",
" ",
" ... ... ",
" .+.. .+.. ",
" .++.. .++. ",
" .+++.. .++. ",
" .++++.. .++. ",
" .+++++.. .++. ",
" .++++++...++. ",
" .+++++++..++. ",
" .+++++++..++. ",
" .+++++++..++. ",
" .++++++...++. ",
" .+++++.. .++. ",
" .++++.. .++. ",
" .+++.. .++. ",
" .++.. .++. ",
" .+.. .+.. ",
" ... ... ",
" "};
/* XPM */
static const gchar * rec_xpm[] = {
"19 19 5 1",
" c None",
". c #FFFFFF",
"+ c #FDBEB6",
"@ c #F92104",
"# c #FB7A69",
" ",
" ",
" ..... ",
" .+@@@@@+. ",
" .@@@@@@@@#. ",
" .@@@@@@@@@@#. ",
" +@@@@@@@@@@@+ ",
" .@@@@@@@@@@@@@. ",
" .@@@@@@@@@@@@@. ",
" .@@@@@@@@@@@@@. ",
" .@@@@@@@@@@@@@. ",
" .@@@@@@@@@@@@@. ",
" +@@@@@@@@@@@+ ",
" .@@@@@@@@@@#. ",
" .@@@@@@@@#. ",
" .+@@@@@+. ",
" ..... ",
" ",
" "};
/* XPM */
static const gchar * start_xpm[] = {
"19 19 3 1",
" c None",
". c #000000",
"+ c #FFFFFF",
" ",
" ... ... ",
" ..+. ..+. ",
" .++. ..++. ",
" .++. ..+++. ",
" .++. ..++++. ",
" .++. ..+++++. ",
" .++...++++++. ",
" .++..+++++++. ",
" .++..+++++++. ",
" .++..+++++++. ",
" .++...++++++. ",
" .++. ..+++++. ",
" .++. ..++++. ",
" .++. ..+++. ",
" .++. ..++. ",
" ..+. ..+. ",
" ... ... ",
" "};
/* XPM */
static const gchar * stop_xpm[] = {
"19 19 3 1",
" c None",
". c #000000",
"+ c #FFFFFF",
" ",
" ",
" ",
" ",
" ........... ",
" .+++++++++. ",
" .+++++++++. ",
" .+++++++++. ",
" .+++++++++. ",
" .+++++++++. ",
" .+++++++++. ",
" .+++++++++. ",
" .+++++++++. ",
" .+++++++++. ",
" ........... ",
" ",
" ",
" ",
" "};

View file

@ -49,6 +49,7 @@ popup.cc
prompter.cc
selector.cc
slider_controller.cc
stateful_button.cc
tearoff.cc
textviewer.cc
utils.cc

View file

@ -32,8 +32,7 @@ using namespace Gtkmm2ext;
using namespace std;
BindableToggleButton::BindableToggleButton (MIDI::Controllable *mc)
: ToggleButton (),
prompter (Gtk::WIN_POS_MOUSE, 30000, false),
: prompter (Gtk::WIN_POS_MOUSE, 30000, false),
midi_control (mc),
bind_button (2),
bind_statemask (Gdk::CONTROL_MASK)

View file

@ -21,7 +21,7 @@
#ifndef __pbd_gtkmm_bindable_button_h__
#define __pbd_gtkmm_bindable_button_h__
#include <gtkmm.h>
#include <gtkmm2ext/stateful_button.h>
#include <gtkmm2ext/popup.h>

View file

@ -0,0 +1,55 @@
/*
Copyright (C) 2005 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id$
*/
#ifndef __pbd_gtkmm_abutton_h__
#define __pbd_gtkmm_abutton_h__
#include <vector>
#include <gtkmm/togglebutton.h>
namespace Gtkmm2ext {
class StatefulButton : public Gtk::Button
{
public:
StatefulButton();
explicit StatefulButton(const std::string &label);
virtual ~StatefulButton() {}
void set_colors (const std::vector<Gdk::Color>& colors);
void set_state (int);
int get_state () { return current_state; }
void set_active (bool yn) {
set_state (yn ? 1 : 0);
}
protected:
std::vector<Gdk::Color> colors;
int current_state;
Gdk::Color saved_bg;
bool have_saved_bg;
void on_realize ();
};
};
#endif

View file

@ -0,0 +1,80 @@
#include <string>
#include <iostream>
#include "gtkmm2ext/stateful_button.h"
using namespace Gtk;
using namespace Glib;
using namespace Gtkmm2ext;
using namespace std;
StatefulButton::StatefulButton ()
{
current_state = 0;
have_saved_bg = false;
}
StatefulButton::StatefulButton (const string& label)
: Button (label)
{
current_state = 0;
have_saved_bg = false;
}
void
StatefulButton::set_colors (const vector<Gdk::Color>& c)
{
colors = c;
current_state++; // to force transition
set_state (current_state - 1);
}
void
StatefulButton::on_realize ()
{
Button::on_realize ();
if (!have_saved_bg) {
saved_bg = get_style()->get_bg (STATE_NORMAL);
have_saved_bg = true;
}
current_state++; // to force transition
set_state (current_state - 1);
}
void
StatefulButton::set_state (int n)
{
if (is_realized()) {
if (n == current_state) {
return;
}
if (n == 0) {
/* back to the default color */
if (have_saved_bg) {
modify_bg (STATE_NORMAL, saved_bg);
modify_bg (STATE_ACTIVE, saved_bg);
modify_bg (STATE_SELECTED, saved_bg);
modify_bg (STATE_PRELIGHT, saved_bg);
}
} else {
int index = (n-1) % colors.size ();
modify_bg (STATE_NORMAL, colors[index]);
modify_bg (STATE_ACTIVE, colors[index]);
modify_bg (STATE_SELECTED, colors[index]);
modify_bg (STATE_PRELIGHT, colors[index]);
}
/* leave insensitive alone */
}
current_state = n;
}