2 Copyright (C) 2004 Paul Davis
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <midi++/controllable.h>
26 #include <gtkmm2ext/gtk_ui.h>
27 #include <gtkmm2ext/bindable_button.h>
31 using namespace Gtkmm2ext;
34 BindableToggleButton::BindableToggleButton (MIDI::Controllable *mc)
35 : prompter (Gtk::WIN_POS_MOUSE, 30000, false),
38 bind_statemask (Gdk::CONTROL_MASK)
44 BindableToggleButton::BindableToggleButton(MIDI::Controllable *mc, const string &label)
45 : ToggleButton (label),
46 prompter (Gtk::WIN_POS_MOUSE, 30000, false),
49 bind_statemask (Gdk::CONTROL_MASK)
56 BindableToggleButton::init_events ()
58 prompter.signal_unmap_event().connect (mem_fun (*this, &BindableToggleButton::prompter_hiding));
64 midi_control->learning_started.connect (mem_fun (*this, &BindableToggleButton::midicontrol_prompt));
65 midi_control->learning_stopped.connect (mem_fun (*this, &BindableToggleButton::midicontrol_unprompt));
70 BindableToggleButton::set_bind_button_state (guint button, guint statemask)
73 bind_statemask = statemask;
77 BindableToggleButton::get_bind_button_state (guint &button, guint &statemask)
80 statemask = bind_statemask;
84 BindableToggleButton::midi_learn()
88 midi_control->learn_about_external_control ();
93 BindableToggleButton::on_button_press_event (GdkEventButton *ev)
95 if ((ev->state & bind_statemask) && ev->button == bind_button) {
104 BindableToggleButton::prompter_hiding (GdkEventAny *ev)
108 midi_control->stop_learning();
118 BindableToggleButton::midicontrol_set_tip ()
122 // Gtkmm2ext::UI::instance()->set_tip (evbox, midi_control->control_description());
127 BindableToggleButton::midicontrol_prompt ()
131 string prompt = _("operate MIDI controller now");
132 prompter.set_text (prompt);
133 Gtkmm2ext::UI::instance()->touch_display (&prompter);
141 BindableToggleButton::midicontrol_unprompt ()
145 Gtkmm2ext::UI::instance()->touch_display (&prompter);