From cb8f069e7717db78394d68fddc9a19d7e8cd1eb6 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 7 Jan 2011 21:38:22 +0000 Subject: [PATCH] more cleanups of PannerUI, add start/end gesture support to mono panner git-svn-id: svn://localhost/ardour2/branches/3.0@8478 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/mono_panner.cc | 7 +++++-- gtk2_ardour/mono_panner.h | 3 +++ gtk2_ardour/panner_ui.cc | 35 +++++++++-------------------------- 3 files changed, 17 insertions(+), 28 deletions(-) diff --git a/gtk2_ardour/mono_panner.cc b/gtk2_ardour/mono_panner.cc index 63f00d43c5..93f635d970 100644 --- a/gtk2_ardour/mono_panner.cc +++ b/gtk2_ardour/mono_panner.cc @@ -301,9 +301,10 @@ MonoPanner::on_button_press_event (GdkEventButton* ev) if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) { /* handled by button release */ return true; - } + } dragging = true; + StartGesture (); } return true; @@ -319,7 +320,7 @@ MonoPanner::on_button_release_event (GdkEventButton* ev) dragging = false; accumulated_delta = 0; detented = false; - + if (drag_data_window) { drag_data_window->hide (); } @@ -327,6 +328,8 @@ MonoPanner::on_button_release_event (GdkEventButton* ev) if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) { /* reset to default */ position_control->set_value (0.5); + } else { + StopGesture (); } return true; diff --git a/gtk2_ardour/mono_panner.h b/gtk2_ardour/mono_panner.h index 5a44474a48..411fadc688 100644 --- a/gtk2_ardour/mono_panner.h +++ b/gtk2_ardour/mono_panner.h @@ -39,6 +39,9 @@ class MonoPanner : public Gtk::DrawingArea boost::shared_ptr get_controllable() const { return position_control; } + sigc::signal StartGesture; + sigc::signal StopGesture; + protected: bool on_expose_event (GdkEventExpose*); bool on_button_press_event (GdkEventButton*); diff --git a/gtk2_ardour/panner_ui.cc b/gtk2_ardour/panner_ui.cc index 390e47d096..61247d26cc 100644 --- a/gtk2_ardour/panner_ui.cc +++ b/gtk2_ardour/panner_ui.cc @@ -220,6 +220,7 @@ PannerUI::build_astyle_menu () boost::shared_ptr PannerUI::get_controllable() { + assert (!pan_bars.empty()); return pan_bars[0]->get_controllable(); } @@ -374,6 +375,8 @@ PannerUI::setup_pan () uint32_t const nouts = _panner->nouts(); uint32_t const npans = _panner->npanners(); + cerr << "Pan setup, outs == " << nouts << " pans = " << npans << endl; + if (int32_t (nouts) == _current_nouts && int32_t (npans) == _current_npans) { return; } @@ -424,35 +427,16 @@ PannerUI::setup_pan () while ((p = pan_bars.size()) < npans) { - float x, rx; MonoPanner* mp; + boost::shared_ptr ac = _panner->pan_control (p); - /* initialize adjustment with 0.0 (L) or 1.0 (R) for the first and second panners, - which serves as a default, otherwise use current value - */ - - rx = _panner->pan_control (p)->get_value(); - - if (npans == 1) { - x = 0.5; - } else if (p == 0) { - x = 0.0; - } else if (p == 1) { - x = 1.0; - } else { - x = rx; - } - mp = new MonoPanner (_panner->pan_control (p)); -#if 0 - if (asz) { - bc->StartGesture.connect (sigc::bind (sigc::mem_fun (*this, &PannerUI::start_touch), - boost::weak_ptr (ac))); - bc->StopGesture.connect (sigc::bind (sigc::mem_fun (*this, &PannerUI::stop_touch), - boost::weak_ptr(ac))); - } -#endif + mp->StartGesture.connect (sigc::bind (sigc::mem_fun (*this, &PannerUI::start_touch), + boost::weak_ptr (ac))); + mp->StopGesture.connect (sigc::bind (sigc::mem_fun (*this, &PannerUI::stop_touch), + boost::weak_ptr(ac))); + mp->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &PannerUI::pan_button_event), (uint32_t) p)); @@ -467,7 +451,6 @@ PannerUI::setup_pan () automation state. */ - update_pan_sensitive (); panning_viewport.add (pan_bar_packer); }