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 <gtkmm2ext/stateful_button.h>
-#include <gtkmm2ext/popup.h>
+#include <string>
+#include "pbd/signals.h"
+#include "gtkmm2ext/stateful_button.h"
+#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);
+ 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;
+ }
+ }
- void midicontrol_set_tip ();
+ boost::shared_ptr<PBD::Controllable> get_controllable() { return binding_proxy.get_controllable(); }
+ void set_controllable (boost::shared_ptr<PBD::Controllable> c);
+ void watch ();
- void midi_learn ();
-
protected:
+ void controllable_changed ();
+ PBD::ScopedConnection watch_connection;
- 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 *);
+ private:
+ BindingProxy binding_proxy;
};
+class BindableButton : public Gtkmm2ext::StatefulButton
+{
+ public:
+ BindableButton (boost::shared_ptr<PBD::Controllable> 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<PBD::Controllable> get_controllable() { return binding_proxy.get_controllable(); }
+ void set_controllable (boost::shared_ptr<PBD::Controllable> c) { binding_proxy.set_controllable (c); }
+
+ private:
+ BindingProxy binding_proxy;
};
#endif