gui: Store pointers to play and pause buttons
We use these every half-second, so let's not waste time looking them up every call. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
a2987c2952
commit
bc5e53a423
|
@ -7,6 +7,8 @@
|
||||||
#include <gui/ocarina.h>
|
#include <gui/ocarina.h>
|
||||||
|
|
||||||
static Gtk::Label *o_position;
|
static Gtk::Label *o_position;
|
||||||
|
static Gtk::Button *o_play_button;
|
||||||
|
static Gtk::Button *o_pause_button;
|
||||||
static Glib::RefPtr<Gtk::Adjustment> o_pos_bar;
|
static Glib::RefPtr<Gtk::Adjustment> o_pos_bar;
|
||||||
|
|
||||||
static inline bool audio_playing()
|
static inline bool audio_playing()
|
||||||
|
@ -14,19 +16,15 @@ static inline bool audio_playing()
|
||||||
return driver :: get_driver()->is_playing();
|
return driver :: get_driver()->is_playing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void hide_show_buttons(const std::string &hide, const std::string &show)
|
|
||||||
{
|
|
||||||
lib :: get_widget<Gtk::Button>(hide)->hide();
|
|
||||||
lib :: get_widget<Gtk::Button>(show)->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void o_fix_buttons()
|
void o_fix_buttons()
|
||||||
{
|
{
|
||||||
if (audio_playing())
|
if (audio_playing()) {
|
||||||
hide_show_buttons("o_play", "o_pause");
|
o_play_button->hide();
|
||||||
else
|
o_pause_button->show();
|
||||||
hide_show_buttons("o_pause", "o_play");
|
} else {
|
||||||
|
o_play_button->show();
|
||||||
|
o_pause_button->hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -84,6 +82,9 @@ void controls_init()
|
||||||
o_position = lib :: get_widget<Gtk::Label>("o_cur_position");
|
o_position = lib :: get_widget<Gtk::Label>("o_cur_position");
|
||||||
o_pos_bar = lib :: get_object<Gtk::Adjustment>("o_progress");
|
o_pos_bar = lib :: get_object<Gtk::Adjustment>("o_progress");
|
||||||
|
|
||||||
|
o_play_button = lib :: get_widget<Gtk::Button>("o_play");
|
||||||
|
o_pause_button = lib :: get_widget<Gtk::Button>("o_pause");
|
||||||
|
|
||||||
pos_scale->signal_change_value().connect(sigc::ptr_fun(o_seek));
|
pos_scale->signal_change_value().connect(sigc::ptr_fun(o_seek));
|
||||||
connect_button("o_play", o_play);
|
connect_button("o_play", o_play);
|
||||||
connect_button("o_pause", o_pause);
|
connect_button("o_pause", o_pause);
|
||||||
|
|
Loading…
Reference in New Issue