diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2006-07-07 23:51:30 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2006-07-07 23:51:30 +0000 |
commit | 8b46567e0677eb25c965ed46b80da8808fa33b2b (patch) | |
tree | f34e3d1cbdab142e7f155d981fee5fb56a82c431 /libs/gtkmm2ext | |
parent | 6f2e8de6a05d9d52069fa1f95c3264b5f151df5f (diff) |
id_t becomes a fully-fledged object, UUID's used for IDs, generic MIDI now owns bindings, MIDI binding concept removed from libardour itself in favor of generic Controllables
git-svn-id: svn://localhost/ardour2/trunk@669 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/gtkmm2ext')
-rw-r--r-- | libs/gtkmm2ext/SConscript | 5 | ||||
-rw-r--r-- | libs/gtkmm2ext/barcontroller.cc | 103 | ||||
-rw-r--r-- | libs/gtkmm2ext/controller.cc | 92 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/barcontroller.h | 23 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/bindable_button.h | 50 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/controller.h | 59 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/slider_controller.h | 44 | ||||
-rw-r--r-- | libs/gtkmm2ext/slider_controller.cc | 117 |
8 files changed, 51 insertions, 442 deletions
diff --git a/libs/gtkmm2ext/SConscript b/libs/gtkmm2ext/SConscript index 5d8489f103..bb28945641 100644 --- a/libs/gtkmm2ext/SConscript +++ b/libs/gtkmm2ext/SConscript @@ -10,7 +10,6 @@ gtkmm2ext = env.Copy() gtkmm2ext.Merge ([ libraries['sigc2'], libraries['pbd'], - libraries['midi++2'], libraries['gtk2'], libraries['glibmm2'], libraries['pangomm'], @@ -28,16 +27,16 @@ domain = 'libgtkmm2ext' gtkmm2ext.Append(DOMAIN=domain,MAJOR=0,MINOR=8,MICRO=2) gtkmm2ext.Append(CXXFLAGS="-DPACKAGE=\\\"" + domain + "\\\"") gtkmm2ext.Append(CXXFLAGS="-DLIBSIGC_DISABLE_DEPRECATED") +gtkmm2ext.Append(CPPPATH='#libs/surfaces/control_protocol') gtkmm2ext.Append(PACKAGE=domain) gtkmm2ext.Append(POTFILE=domain + '.pot') gtkmm2ext_files = Split(""" auto_spin.cc barcontroller.cc -bindable_button.cc +binding_proxy.cc choice.cc click_box.cc -controller.cc dndtreeview.cc fastmeter.cc gtk_ui.cc diff --git a/libs/gtkmm2ext/barcontroller.cc b/libs/gtkmm2ext/barcontroller.cc index c977f3e5f7..eefe6ca843 100644 --- a/libs/gtkmm2ext/barcontroller.cc +++ b/libs/gtkmm2ext/barcontroller.cc @@ -23,7 +23,7 @@ #include <cmath> #include <algorithm> -#include <midi++/controllable.h> +#include <pbd/controllable.h> #include <gtkmm2ext/gtk_ui.h> #include <gtkmm2ext/utils.h> @@ -36,16 +36,13 @@ using namespace Gtk; using namespace Gtkmm2ext; BarController::BarController (Gtk::Adjustment& adj, - MIDI::Controllable *mc, + PBD::Controllable& mc, sigc::slot<void,char*,unsigned int> lc) : adjustment (adj), - prompter (Gtk::WIN_POS_MOUSE, 30000, false), - midi_control (mc), + binding_proxy (mc), label_callback (lc), - spinner (adjustment), - bind_button (2), - bind_statemask (Gdk::CONTROL_MASK) + spinner (adjustment) { _style = LeftToRight; @@ -77,16 +74,6 @@ BarController::BarController (Gtk::Adjustment& adj, darea.signal_button_release_event().connect (mem_fun (*this, &BarController::button_release)); darea.signal_scroll_event().connect (mem_fun (*this, &BarController::scroll)); - prompter.signal_unmap_event().connect (mem_fun (*this, &BarController::prompter_hiding)); - - prompting = false; - unprompting = false; - - if (mc) { - mc->learning_started.connect (mem_fun (*this, &BarController::midicontrol_prompt)); - mc->learning_stopped.connect (mem_fun (*this, &BarController::midicontrol_unprompt)); - } - spinner.signal_activate().connect (mem_fun (*this, &BarController::entry_activated)); spinner.signal_focus_out_event().connect (mem_fun (*this, &BarController::entry_focus_out)); spinner.set_digits (3); @@ -95,24 +82,13 @@ BarController::BarController (Gtk::Adjustment& adj, show_all (); } -void -BarController::set_bind_button_state (guint button, guint statemask) -{ - bind_button = button; - bind_statemask = statemask; -} - -void -BarController::get_bind_button_state (guint &button, guint &statemask) -{ - button = bind_button; - statemask = bind_statemask; -} - - bool BarController::button_press (GdkEventButton* ev) { + if (binding_proxy.button_press_handler (ev)) { + return true; + } + switch (ev->button) { case 1: if (ev->type == GDK_2BUTTON_PRESS) { @@ -174,8 +150,8 @@ BarController::button_release (GdkEventButton* ev) break; case 2: - if ((ev->state & bind_statemask) && bind_button == 2) { - midi_learn (); + if (true) { // XXX FIX ME + /* relax */ } else { double fract; fract = ev->x / (darea.get_width() - 2.0); @@ -185,10 +161,6 @@ BarController::button_release (GdkEventButton* ev) return true; case 3: - if ((ev->state & bind_statemask) && bind_button == 3) { - midi_learn (); - return TRUE; - } return false; default: @@ -408,61 +380,6 @@ BarController::set_with_text (bool yn) } void -BarController::midicontrol_set_tip () -{ - if (midi_control) { - // Gtkmm2ext::UI::instance()->set_tip (&darea, midi_control->control_description()); - } -} - -void -BarController::midi_learn() -{ - if (midi_control) { - prompting = true; - midi_control->learn_about_external_control (); - } -} - - -void -BarController::midicontrol_prompt () -{ - if (prompting) { - string prompt = _("operate MIDI controller now"); - prompter.set_text (prompt); - Gtkmm2ext::UI::instance()->touch_display (&prompter); - - unprompting = true; - prompting = false; - } -} - -void -BarController::midicontrol_unprompt () -{ - if (unprompting) { - Gtkmm2ext::UI::instance()->touch_display (&prompter); - - unprompting = false; - } -} - -gint -BarController::prompter_hiding (GdkEventAny *ev) -{ - if (unprompting) { - if (midi_control) { - midi_control->stop_learning(); - } - unprompting = false; - } - - return FALSE; -} - - -void BarController::set_style (Style s) { _style = s; diff --git a/libs/gtkmm2ext/controller.cc b/libs/gtkmm2ext/controller.cc deleted file mode 100644 index 98d5566c69..0000000000 --- a/libs/gtkmm2ext/controller.cc +++ /dev/null @@ -1,92 +0,0 @@ -/* - Copyright (C) 1998-99 Paul Davis - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id$ -*/ - -#include <string> -#include <climits> - -#include <midi++/channel.h> -#include <gtkmm2ext/gtk_ui.h> -#include <gtkmm2ext/controller.h> - -#include "i18n.h" - -using namespace Gtkmm2ext; - -Controller::Controller (Gtk::Adjustment *adj, MIDI::Port *p) - : MIDI::Controllable (p), - adjustment (adj), - prompter (Gtk::WIN_POS_MOUSE, 30000, false) -{ - new_value_pending = false; - - /* hear about MIDI control learning */ - - learning_started.connect - (mem_fun (*this, &Controller::midicontrol_prompt)); - learning_stopped.connect - (mem_fun (*this, &Controller::midicontrol_unprompt)); -} - -void -Controller::midicontrol_prompt () - -{ - string prompt = _("operate MIDI controller now"); - - prompter.set_text (prompt); - Gtkmm2ext::UI::instance()->touch_display (&prompter); -} - -void -Controller::midicontrol_unprompt () - -{ - Gtkmm2ext::UI::instance()->touch_display (&prompter); -} - -int -Controller::update_controller_value (void *arg) - -{ - Controller *c = (Controller *) arg; - - c->adjustment->set_value (c->new_value); - c->new_value_pending = false; - - return FALSE; -} - -void -Controller::set_value (float v) - -{ - /* This is called from a MIDI callback. It could happen - a thousand times a second, or more. Therefore, instead - of going straight to the X server, which may not work for - thread-related reasons, simply request an update whenever - the GTK main loop is idle. - */ - - new_value = v; - - if (!new_value_pending) { - new_value_pending = true; - Gtkmm2ext::UI::instance()->idle_add (update_controller_value, this); - } -} diff --git a/libs/gtkmm2ext/gtkmm2ext/barcontroller.h b/libs/gtkmm2ext/gtkmm2ext/barcontroller.h index 67c8221a55..ebce4e2de9 100644 --- a/libs/gtkmm2ext/gtkmm2ext/barcontroller.h +++ b/libs/gtkmm2ext/gtkmm2ext/barcontroller.h @@ -21,9 +21,9 @@ #define __gtkmm2ext_bar_controller_h__ #include <gtkmm.h> -#include <gtkmm2ext/popup.h> +#include <gtkmm2ext/binding_proxy.h> -namespace MIDI { +namespace ARDOUR { class Controllable; } @@ -32,14 +32,9 @@ namespace Gtkmm2ext { class BarController : public Gtk::Frame { public: - BarController (Gtk::Adjustment& adj, MIDI::Controllable*, sigc::slot<void,char*,unsigned int>); + BarController (Gtk::Adjustment& adj, PBD::Controllable&, sigc::slot<void,char*,unsigned int>); virtual ~BarController () {} - 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 (); - void set_sensitive (bool yn) { darea.set_sensitive (yn); } @@ -69,9 +64,8 @@ class BarController : public Gtk::Frame protected: Gtk::Adjustment& adjustment; + BindingProxy binding_proxy; Gtk::DrawingArea darea; - Gtkmm2ext::PopUp prompter; - MIDI::Controllable* midi_control; sigc::slot<void,char*,unsigned int> label_callback; Glib::RefPtr<Pango::Layout> layout; Style _style; @@ -85,10 +79,6 @@ class BarController : public Gtk::Frame Gtk::SpinButton spinner; bool use_parent; - guint bind_button; - guint bind_statemask; - bool prompting, unprompting; - bool button_press (GdkEventButton *); bool button_release (GdkEventButton *); bool motion (GdkEventMotion *); @@ -98,11 +88,6 @@ class BarController : public Gtk::Frame gint mouse_control (double x, GdkWindow* w, double scaling); - gint prompter_hiding (GdkEventAny *); - void midicontrol_prompt (); - void midicontrol_unprompt (); - void update_midi_control (); - gint switch_to_bar (); gint switch_to_spinner (); diff --git a/libs/gtkmm2ext/gtkmm2ext/bindable_button.h b/libs/gtkmm2ext/gtkmm2ext/bindable_button.h index 7400cf15d0..1936125405 100644 --- a/libs/gtkmm2ext/gtkmm2ext/bindable_button.h +++ b/libs/gtkmm2ext/gtkmm2ext/bindable_button.h @@ -18,59 +18,31 @@ $Id$ */ -#ifndef __pbd_gtkmm_bindable_button_h__ -#define __pbd_gtkmm_bindable_button_h__ +#ifndef __bindable_button_h__ +#define __bindable_button_h__ #include <string> #include <gtkmm2ext/stateful_button.h> -#include <gtkmm2ext/popup.h> +#include "binding_proxy.h" -namespace MIDI { +namespace PBD { class Controllable; } -namespace Gtkmm2ext { - class BindableToggleButton : public Gtk::ToggleButton { 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 std::string &label); - + BindableToggleButton (PBD::Controllable& c) : binding_proxy (c) {} + explicit BindableToggleButton (PBD::Controllable& c, const std::string &label) : Gtk::ToggleButton (label), binding_proxy (c) {} 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 *); -}; + bool on_button_press_event (GdkEventButton *ev) { + return binding_proxy.button_press_handler (ev); + } + private: + BindingProxy binding_proxy; }; #endif diff --git a/libs/gtkmm2ext/gtkmm2ext/controller.h b/libs/gtkmm2ext/gtkmm2ext/controller.h deleted file mode 100644 index b72f6c7ed7..0000000000 --- a/libs/gtkmm2ext/gtkmm2ext/controller.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright (C) 1998-99 Paul Davis - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id$ -*/ - -#ifndef __gtkmm2ext_controller_h__ -#define __gtkmm2ext_controller_h__ - -#include <gtkmm.h> -#include <gtkmm2ext/popup.h> -#include <midi++/controllable.h> - -namespace Gtkmm2ext { - -class Controller : public MIDI::Controllable - -{ - public: - Controller (Gtk::Adjustment *, MIDI::Port *); - virtual ~Controller () {} - - void set_value (float); - float lower () { return adjustment->get_lower(); } - float upper () { return adjustment->get_upper(); } - float range () { return upper() - lower() /* XXX +1 ??? */ ; } - - void midicontrol_prompt (); - void midicontrol_unprompt (); - - protected: - Gtk::Adjustment *adjustment; - - private: - Gtkmm2ext::PopUp prompter; - gfloat new_value; - bool new_value_pending; - - static gint update_controller_value (void *); -}; - -}; /* namespace */ - -#endif // __gtkmm2ext_controller_h__ - - diff --git a/libs/gtkmm2ext/gtkmm2ext/slider_controller.h b/libs/gtkmm2ext/gtkmm2ext/slider_controller.h index 7abaf285d1..8054fdd1b7 100644 --- a/libs/gtkmm2ext/gtkmm2ext/slider_controller.h +++ b/libs/gtkmm2ext/gtkmm2ext/slider_controller.h @@ -1,5 +1,5 @@ /* - Copyright (C) 1998-99 Paul Davis + Copyright (C) 1998-2006 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -17,18 +17,19 @@ $Id$ */ -#ifndef __gtkmm2ext_motion_controller_h__ -#define __gtkmm2ext_motion_controller_h__ +#ifndef __gtkmm2ext_slider_controller_h__ +#define __gtkmm2ext_slider_controller_h__ #include <gtkmm.h> #include <gtkmm2ext/popup.h> #include <gtkmm2ext/pixscroller.h> +#include <gtkmm2ext/binding_proxy.h> namespace Gtkmm2ext { class Pix; } -namespace MIDI { +namespace PBD { class Controllable; } @@ -40,41 +41,26 @@ class SliderController : public Gtkmm2ext::PixScroller SliderController (Glib::RefPtr<Gdk::Pixbuf> slider, Glib::RefPtr<Gdk::Pixbuf> rail, Gtk::Adjustment* adj, - MIDI::Controllable*, + PBD::Controllable&, bool with_numeric = true); virtual ~SliderController () {} - 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 (); - void set_value (float); - // void set_sensitive (bool yn) { - // spin.set_sensitive (yn); - // } - Gtk::SpinButton & get_spin_button () { return spin; } + Gtk::SpinButton& get_spin_button () { return spin; } + bool on_button_press_event (GdkEventButton *ev) { + return binding_proxy.button_press_handler (ev); + } + protected: + BindingProxy binding_proxy; Glib::RefPtr<Gdk::Pixbuf> slider; Glib::RefPtr<Gdk::Pixbuf> rail; Gtk::SpinButton spin; Gtk::Frame spin_frame; Gtk::HBox spin_hbox; - Gtkmm2ext::PopUp prompter; - MIDI::Controllable* midi_control; - - guint bind_button; - guint bind_statemask; - bool prompting, unprompting; - - bool button_press (GdkEventButton *); - bool prompter_hiding (GdkEventAny *); - void midicontrol_prompt (); - void midicontrol_unprompt (); - void update_midi_control (); }; class VSliderController : public SliderController @@ -83,7 +69,7 @@ class VSliderController : public SliderController VSliderController (Glib::RefPtr<Gdk::Pixbuf> slider, Glib::RefPtr<Gdk::Pixbuf> rail, Gtk::Adjustment *adj, - MIDI::Controllable *, + PBD::Controllable&, bool with_numeric = true); }; @@ -93,11 +79,11 @@ class HSliderController : public SliderController HSliderController (Glib::RefPtr<Gdk::Pixbuf> slider, Glib::RefPtr<Gdk::Pixbuf> rail, Gtk::Adjustment *adj, - MIDI::Controllable *, + PBD::Controllable&, bool with_numeric = true); }; }; /* namespace */ -#endif // __gtkmm2ext_motion_controller_h__ +#endif // __gtkmm2ext_slider_controller_h__ diff --git a/libs/gtkmm2ext/slider_controller.cc b/libs/gtkmm2ext/slider_controller.cc index 734d5eb62f..aba58724eb 100644 --- a/libs/gtkmm2ext/slider_controller.cc +++ b/libs/gtkmm2ext/slider_controller.cc @@ -18,47 +18,30 @@ */ #include <string> -#include <climits> - -#include <midi++/controllable.h> #include <gtkmm2ext/gtk_ui.h> -#include <gtkmm2ext/slider_controller.h> #include <gtkmm2ext/pixscroller.h> +#include <gtkmm2ext/slider_controller.h> #include "i18n.h" using namespace Gtkmm2ext; +using namespace PBD; SliderController::SliderController (Glib::RefPtr<Gdk::Pixbuf> slide, Glib::RefPtr<Gdk::Pixbuf> rail, Gtk::Adjustment *adj, - MIDI::Controllable *mc, + Controllable& c, bool with_numeric) : PixScroller (*adj, slide, rail), - spin (*adj, 0, 2), - prompter (Gtk::WIN_POS_MOUSE, 30000, false), - midi_control (mc), - bind_button (2), - bind_statemask (Gdk::CONTROL_MASK) - + binding_proxy (c), + spin (*adj, 0, 2) { - signal_button_press_event().connect (mem_fun (this, &SliderController::button_press)); spin.set_name ("SliderControllerValue"); spin.set_size_request (70,-1); // should be based on font size somehow spin.set_numeric (true); spin.set_snap_to_ticks (false); - - prompter.signal_unmap_event().connect (mem_fun (*this, &SliderController::prompter_hiding)); - - prompting = false; - unprompting = false; - - if (mc) { - mc->learning_started.connect (mem_fun (*this, &SliderController::midicontrol_prompt)); - mc->learning_stopped.connect (mem_fun (*this, &SliderController::midicontrol_unprompt)); - } } void @@ -67,95 +50,13 @@ SliderController::set_value (float v) adj.set_value (v); } -void -SliderController::set_bind_button_state (guint button, guint statemask) -{ - bind_button = button; - bind_statemask = statemask; -} - -void -SliderController::get_bind_button_state (guint &button, guint &statemask) -{ - button = bind_button; - statemask = bind_statemask; -} - -void -SliderController::midi_learn() -{ - if (midi_control) { - prompting = true; - midi_control->learn_about_external_control (); - } -} - -bool -SliderController::button_press (GdkEventButton *ev) -{ - if ((ev->state & bind_statemask) && ev->button == bind_button) { - midi_learn (); - return true; - } - - return false; -} - -void -SliderController::midicontrol_set_tip () - -{ - if (midi_control) { - // Gtkmm2ext::UI::instance()->set_tip (this, midi_control->control_description()); - } -} - -bool -SliderController::prompter_hiding (GdkEventAny *ev) -{ - if (unprompting) { - if (midi_control) { - midi_control->stop_learning(); - } - unprompting = false; - } - - return false; -} - -void -SliderController::midicontrol_prompt () - -{ - if (prompting) { - - string prompt = _("operate MIDI controller now"); - prompter.set_text (prompt); - Gtkmm2ext::UI::instance()->touch_display (&prompter); - - unprompting = true; - prompting = false; - } -} - -void -SliderController::midicontrol_unprompt () - -{ - if (unprompting) { - Gtkmm2ext::UI::instance()->touch_display (&prompter); - unprompting = false; - } -} - - VSliderController::VSliderController (Glib::RefPtr<Gdk::Pixbuf> slide, Glib::RefPtr<Gdk::Pixbuf> rail, Gtk::Adjustment *adj, - MIDI::Controllable *mcontrol, + Controllable& control, bool with_numeric) - : SliderController (slide, rail, adj, mcontrol, with_numeric) + : SliderController (slide, rail, adj, control, with_numeric) { if (with_numeric) { spin_frame.add (spin); @@ -169,10 +70,10 @@ VSliderController::VSliderController (Glib::RefPtr<Gdk::Pixbuf> slide, HSliderController::HSliderController (Glib::RefPtr<Gdk::Pixbuf> slide, Glib::RefPtr<Gdk::Pixbuf> rail, Gtk::Adjustment *adj, - MIDI::Controllable *mcontrol, + Controllable& control, bool with_numeric) - : SliderController (slide, rail, adj, mcontrol, with_numeric) + : SliderController (slide, rail, adj, control, with_numeric) { if (with_numeric) { spin_frame.add (spin); |