X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fgtkmm2ext%2Fgtkmm2ext%2Fbindable_button.h;h=18e3ceb339d268b3f9811e72f2a0eacb3988fba3;hb=c38e02285fda1fd7966c9e4ad85994445247e6a6;hp=11f5ab45e7c70d8250059db33968001e585a001a;hpb=dd455c894aed80a4aa73e4fa186d0b8419c105c8;p=ardour.git diff --git a/libs/gtkmm2ext/gtkmm2ext/bindable_button.h b/libs/gtkmm2ext/gtkmm2ext/bindable_button.h index 11f5ab45e7..18e3ceb339 100644 --- a/libs/gtkmm2ext/gtkmm2ext/bindable_button.h +++ b/libs/gtkmm2ext/gtkmm2ext/bindable_button.h @@ -15,62 +15,65 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ -#ifndef __pbd_gtkmm_bindable_button_h__ -#define __pbd_gtkmm_bindable_button_h__ +#ifndef __bindable_button_h__ +#define __bindable_button_h__ -#include -#include +#include +#include +#include "binding_proxy.h" -namespace MIDI { +namespace PBD { class Controllable; } - -namespace Gtkmm2ext { - -class BindableToggleButton : public Gtk::ToggleButton +class BindableToggleButton : public Gtkmm2ext::StatefulToggleButton { public: - BindableToggleButton(MIDI::Controllable *); - - //: Create a check button with a label. - //- You won't be able - //- to add a widget in this button since it already has a {\class Gtk_Label} - //- in it. - explicit BindableToggleButton(MIDI::Controllable *, const string &label); + BindableToggleButton (const std::string &label) + : Gtkmm2ext::StatefulToggleButton (label) {} + BindableToggleButton () {} virtual ~BindableToggleButton() {} - void set_bind_button_state (guint button, guint statemask); - void get_bind_button_state (guint &button, guint &statemask); - - void midicontrol_set_tip (); - - void midi_learn (); - - protected: - - Gtkmm2ext::PopUp prompter; - - MIDI::Controllable* midi_control; - - guint bind_button; - guint bind_statemask; - - bool prompting, unprompting; - - void init_events (); - bool prompter_hiding (GdkEventAny *); - void midicontrol_prompt (); - void midicontrol_unprompt (); + bool on_button_press_event (GdkEventButton *ev) { + if (!binding_proxy.button_press_handler (ev)) { + StatefulToggleButton::on_button_press_event (ev); + return false; + } else { + return true; + } + } - bool on_button_press_event (GdkEventButton *); + boost::shared_ptr get_controllable() { return binding_proxy.get_controllable(); } + void set_controllable (boost::shared_ptr c) { binding_proxy.set_controllable (c); } + + private: + BindingProxy binding_proxy; }; +class BindableButton : public Gtkmm2ext::StatefulButton +{ + public: + BindableButton (boost::shared_ptr c) : binding_proxy (c) {} + ~BindableButton() {} + + bool on_button_press_event (GdkEventButton *ev) { + if (!binding_proxy.button_press_handler (ev)) { + StatefulButton::on_button_press_event (ev); + return false; + } else { + return true; + } + } + + boost::shared_ptr get_controllable() { return binding_proxy.get_controllable(); } + void set_controllable (boost::shared_ptr c) { binding_proxy.set_controllable (c); } + + private: + BindingProxy binding_proxy; }; #endif