2 Copyright (C) 1998-99 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.
23 #include <midi++/controllable.h>
25 #include <gtkmm2ext/gtk_ui.h>
26 #include <gtkmm2ext/slider_controller.h>
27 #include <gtkmm2ext/pix.h>
31 using namespace Gtkmm2ext;
33 SliderController::SliderController (Pix *pixset,
35 MIDI::Controllable *mc,
38 : PixScroller (*adj, *pixset),
40 prompter (Gtk::WIN_POS_MOUSE, 30000, false),
43 bind_statemask (Gdk::CONTROL_MASK)
46 signal_button_press_event().connect (mem_fun (this, &SliderController::button_press));
47 spin.set_name ("SliderControllerValue");
48 spin.set_size_request (70,-1); // should be based on font size somehow
49 spin.set_numeric (true);
50 spin.set_snap_to_ticks (false);
52 prompter.signal_unmap_event().connect (mem_fun (*this, &SliderController::prompter_hiding));
58 mc->learning_started.connect (mem_fun (*this, &SliderController::midicontrol_prompt));
59 mc->learning_stopped.connect (mem_fun (*this, &SliderController::midicontrol_unprompt));
64 SliderController::set_value (float v)
70 SliderController::set_bind_button_state (guint button, guint statemask)
73 bind_statemask = statemask;
77 SliderController::get_bind_button_state (guint &button, guint &statemask)
80 statemask = bind_statemask;
84 SliderController::midi_learn()
88 midi_control->learn_about_external_control ();
93 SliderController::button_press (GdkEventButton *ev)
95 if ((ev->state & bind_statemask) && ev->button == bind_button) {
104 SliderController::midicontrol_set_tip ()
108 // Gtkmm2ext::UI::instance()->set_tip (this, midi_control->control_description());
113 SliderController::prompter_hiding (GdkEventAny *ev)
117 midi_control->stop_learning();
126 SliderController::midicontrol_prompt ()
131 string prompt = _("operate MIDI controller now");
132 prompter.set_text (prompt);
133 Gtkmm2ext::UI::instance()->touch_display (&prompter);
141 SliderController::midicontrol_unprompt ()
145 Gtkmm2ext::UI::instance()->touch_display (&prompter);
151 VSliderController::VSliderController (Pix *pixset,
152 Gtk::Adjustment *adj,
153 MIDI::Controllable *mcontrol,
156 : SliderController (pixset, adj, mcontrol, with_numeric)
159 spin_frame.add (spin);
160 spin_frame.set_shadow_type (Gtk::SHADOW_IN);
161 spin_frame.set_name ("BaseFrame");
162 spin_hbox.pack_start (spin_frame, false, true);
163 // pack_start (spin_hbox, false, false);
167 HSliderController::HSliderController (Pix *pixset,
168 Gtk::Adjustment *adj,
169 MIDI::Controllable *mcontrol,
172 : SliderController (pixset, adj, mcontrol, with_numeric)
175 spin_frame.add (spin);
176 //spin_frame.set_shadow_type (Gtk::SHADOW_IN);
177 spin_frame.set_name ("BaseFrame");
178 spin_hbox.pack_start (spin_frame, false, true);
179 // pack_start (spin_hbox, false, false);