X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fpanner_ui.cc;h=263a8ec51836d3f9c3f59c85ebcfbffd4bf43ced;hb=da8eec7a8311295ee91308eca9fae2146385c512;hp=ed1e84f29bc58d967aabdc11de649b9a7f003c6a;hpb=66e91bafd2b72100f0ad2cdcc4d39818bd766ca3;p=ardour.git diff --git a/gtk2_ardour/panner_ui.cc b/gtk2_ardour/panner_ui.cc index ed1e84f29b..263a8ec518 100644 --- a/gtk2_ardour/panner_ui.cc +++ b/gtk2_ardour/panner_ui.cc @@ -18,13 +18,12 @@ #include -#include -#include +#include "ardour/io.h" +#include "ardour/dB.h" #include -#include #include -#include -#include +#include "midi++/manager.h" +#include "pbd/fastlog.h" #include "ardour_ui.h" #include "panner_ui.h" @@ -33,31 +32,35 @@ #include "panner.h" #include "gui_thread.h" -#include -#include -#include +#include "ardour/delivery.h" +#include "ardour/session.h" +#include "ardour/panner.h" +#include "ardour/route.h" #include "i18n.h" +using namespace std; using namespace ARDOUR; using namespace PBD; using namespace Gtkmm2ext; using namespace Gtk; -using namespace sigc; const int PannerUI::pan_bar_height = 30; -PannerUI::PannerUI (Session& s) - : _session (s), - hAdjustment(0.0, 0.0, 0.0), - vAdjustment(0.0, 0.0, 0.0), - panning_viewport(hAdjustment, vAdjustment), - panning_up_arrow (Gtk::ARROW_UP, Gtk::SHADOW_OUT), - panning_down_arrow (Gtk::ARROW_DOWN, Gtk::SHADOW_OUT), - panning_link_button (_("link")), - pan_automation_style_button (""), - pan_automation_state_button ("") +PannerUI::PannerUI (Session* s) + : _current_nouts (-1) + , _current_npans (-1) + , hAdjustment(0.0, 0.0, 0.0) + , vAdjustment(0.0, 0.0, 0.0) + , panning_viewport(hAdjustment, vAdjustment) + , panning_up_arrow (Gtk::ARROW_UP, Gtk::SHADOW_OUT) + , panning_down_arrow (Gtk::ARROW_DOWN, Gtk::SHADOW_OUT) + , panning_link_button (_("link")) + , pan_automation_style_button ("") + , pan_automation_state_button ("") { + set_session (s); + ignore_toggle = false; pan_menu = 0; pan_astate_menu = 0; @@ -67,26 +70,24 @@ PannerUI::PannerUI (Session& s) pan_automation_style_button.set_name ("MixerAutomationModeButton"); pan_automation_state_button.set_name ("MixerAutomationPlaybackButton"); - ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_state_button, _("Pan automation mode")); - ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_style_button, _("Pan automation type")); + ARDOUR_UI::instance()->set_tip (pan_automation_state_button, _("Pan automation mode")); + ARDOUR_UI::instance()->set_tip (pan_automation_style_button, _("Pan automation type")); //set_size_request_to_display_given_text (pan_automation_state_button, X_("O"), 2, 2); //set_size_request_to_display_given_text (pan_automation_style_button, X_("0"), 2, 2); - pan_bar_packer.set_size_request (-1, 61); - panning_viewport.set_size_request (-1, 61); panning_viewport.set_name (X_("BaseFrame")); - ARDOUR_UI::instance()->tooltips().set_tip (panning_link_button, + ARDOUR_UI::instance()->set_tip (panning_link_button, _("panning link control")); - ARDOUR_UI::instance()->tooltips().set_tip (panning_link_direction_button, + ARDOUR_UI::instance()->set_tip (panning_link_direction_button, _("panning link direction")); pan_automation_style_button.unset_flags (Gtk::CAN_FOCUS); pan_automation_state_button.unset_flags (Gtk::CAN_FOCUS); - pan_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &PannerUI::pan_automation_style_button_event), false); - pan_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &PannerUI::pan_automation_state_button_event), false); + pan_automation_style_button.signal_button_press_event().connect (sigc::mem_fun(*this, &PannerUI::pan_automation_style_button_event), false); + pan_automation_state_button.signal_button_press_event().connect (sigc::mem_fun(*this, &PannerUI::pan_automation_state_button_event), false); panning_link_button.set_name (X_("PanningLinkButton")); panning_link_direction_button.set_name (X_("PanningLinkDirectionButton")); @@ -101,12 +102,12 @@ PannerUI::PannerUI (Session& s) panning_link_direction_button.add (*(manage (new Image (get_xpm("forwardblarrow.xpm"))))); panning_link_direction_button.signal_clicked().connect - (mem_fun(*this, &PannerUI::panning_link_direction_clicked)); + (sigc::mem_fun(*this, &PannerUI::panning_link_direction_clicked)); panning_link_button.signal_button_press_event().connect - (mem_fun(*this, &PannerUI::panning_link_button_press), false); + (sigc::mem_fun(*this, &PannerUI::panning_link_button_press), false); panning_link_button.signal_button_release_event().connect - (mem_fun(*this, &PannerUI::panning_link_button_release), false); + (sigc::mem_fun(*this, &PannerUI::panning_link_button_release), false); panning_up.set_border_width (3); panning_down.set_border_width (3); @@ -123,60 +124,42 @@ PannerUI::PannerUI (Session& s) pack_start (pan_vbox, true, true); - panner = 0; + twod_panner = 0; big_window = 0; set_width(Narrow); } - + void -PannerUI::set_io (boost::shared_ptr io) -{ - connections.clear (); - - if (pan_astyle_menu) { - delete pan_astyle_menu; - pan_astyle_menu = 0; - } - - if (pan_astate_menu) { - delete pan_astate_menu; - pan_astate_menu = 0; - } - - _io = io; - - connections.push_back (_io->panner().Changed.connect (mem_fun(*this, &PannerUI::panner_changed))); - connections.push_back (_io->panner().LinkStateChanged.connect (mem_fun(*this, &PannerUI::update_pan_linkage))); - connections.push_back (_io->panner().StateChanged.connect (mem_fun(*this, &PannerUI::update_pan_state))); - - if (panner) { - delete panner; - panner = 0; - } - +PannerUI::set_panner (boost::shared_ptr p) +{ + connections.drop_connections (); + + delete pan_astyle_menu; + pan_astyle_menu = 0; + + delete pan_astate_menu; + pan_astate_menu = 0; + + _panner = p; + + delete twod_panner; + twod_panner = 0; + + if (!_panner) { + return; + } + + _panner->Changed.connect (connections, invalidator (*this), boost::bind (&PannerUI::panner_changed, this), gui_context()); + _panner->LinkStateChanged.connect (connections, invalidator (*this), boost::bind (&PannerUI::update_pan_linkage, this), gui_context()); + _panner->StateChanged.connect (connections, invalidator (*this), boost::bind (&PannerUI::update_pan_state, this), gui_context()); + setup_pan (); pan_changed (0); update_pan_sensitive (); update_pan_linkage (); pan_automation_state_changed (); - -#if WHERE_DOES_THIS_LIVE - pan_bar_packer.show(); - panning_viewport.show(); - panning_up.show(); - panning_up_arrow.show(); - panning_down.show(); - panning_down_arrow.show(); - pan_vbox.show(); - panning_link_button.show(); - panning_link_direction_button.show(); - panning_link_box.show(); - pan_automation_style_button.show(); - pan_automation_state_button.show(); - show(); -#endif } void @@ -191,14 +174,18 @@ PannerUI::build_astate_menu () pan_astate_menu->items().clear (); } - pan_astate_menu->items().push_back (MenuElem (_("Manual"), - bind (mem_fun (_io->panner(), &Panner::set_automation_state), (AutoState) Off))); - pan_astate_menu->items().push_back (MenuElem (_("Play"), - bind (mem_fun (_io->panner(), &Panner::set_automation_state), (AutoState) Play))); - pan_astate_menu->items().push_back (MenuElem (_("Write"), - bind (mem_fun (_io->panner(), &Panner::set_automation_state), (AutoState) Write))); - pan_astate_menu->items().push_back (MenuElem (_("Touch"), - bind (mem_fun (_io->panner(), &Panner::set_automation_state), (AutoState) Touch))); + pan_astate_menu->items().push_back (MenuElem (_("Manual"), sigc::bind ( + sigc::mem_fun (_panner.get(), &Panner::set_automation_state), + (AutoState) Off))); + pan_astate_menu->items().push_back (MenuElem (_("Play"), sigc::bind ( + sigc::mem_fun (_panner.get(), &Panner::set_automation_state), + (AutoState) Play))); + pan_astate_menu->items().push_back (MenuElem (_("Write"), sigc::bind ( + sigc::mem_fun (_panner.get(), &Panner::set_automation_state), + (AutoState) Write))); + pan_astate_menu->items().push_back (MenuElem (_("Touch"), sigc::bind ( + sigc::mem_fun (_panner.get(), &Panner::set_automation_state), + (AutoState) Touch))); } @@ -219,22 +206,22 @@ PannerUI::build_astyle_menu () } boost::shared_ptr -PannerUI::get_controllable() -{ +PannerUI::get_controllable() +{ return pan_bars[0]->get_controllable(); } bool -PannerUI::panning_link_button_press (GdkEventButton* ev) +PannerUI::panning_link_button_press (GdkEventButton*) { return true; } bool -PannerUI::panning_link_button_release (GdkEventButton* ev) +PannerUI::panning_link_button_release (GdkEventButton*) { if (!ignore_toggle) { - _io->panner().set_linked (!_io->panner().linked()); + _panner->set_linked (!_panner->linked()); } return true; } @@ -242,12 +229,12 @@ PannerUI::panning_link_button_release (GdkEventButton* ev) void PannerUI::panning_link_direction_clicked() { - switch (_io->panner().link_direction()) { + switch (_panner->link_direction()) { case Panner::SameDirection: - _io->panner().set_link_direction (Panner::OppositeDirection); + _panner->set_link_direction (Panner::OppositeDirection); break; default: - _io->panner().set_link_direction (Panner::SameDirection); + _panner->set_link_direction (Panner::SameDirection); break; } } @@ -255,13 +242,13 @@ PannerUI::panning_link_direction_clicked() void PannerUI::update_pan_linkage () { - ENSURE_GUI_THREAD(mem_fun(*this, &PannerUI::update_pan_linkage)); - - bool x = _io->panner().linked(); - bool bx = panning_link_button.get_active(); + ENSURE_GUI_THREAD (*this, &PannerUI::update_pan_linkage) + + bool const x = _panner->linked(); + bool const bx = panning_link_button.get_active(); if (x != bx) { - + ignore_toggle = true; panning_link_button.set_active (x); ignore_toggle = false; @@ -269,7 +256,7 @@ PannerUI::update_pan_linkage () panning_link_direction_button.set_sensitive (x); - switch (_io->panner().link_direction()) { + switch (_panner->link_direction()) { case Panner::SameDirection: panning_link_direction_button.set_image (*(manage (new Image (get_xpm ("forwardblarrow.xpm"))))); break; @@ -300,37 +287,23 @@ PannerUI::~PannerUI () for (vector::iterator i = pan_adjustments.begin(); i != pan_adjustments.end(); ++i) { delete (*i); } - + for (vector::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) { delete (*i); } - if (panner) { - delete panner; - } - - if (big_window) { - delete big_window; - } - - if (pan_menu) { - delete pan_menu; - } - - if (pan_astyle_menu) { - delete pan_astyle_menu; - } - - if (pan_astate_menu) { - delete pan_astate_menu; - } + delete twod_panner; + delete big_window; + delete pan_menu; + delete pan_astyle_menu; + delete pan_astate_menu; } void PannerUI::panner_changed () { - ENSURE_GUI_THREAD (mem_fun(*this, &PannerUI::panner_changed)); + ENSURE_GUI_THREAD (*this, &PannerUI::panner_changed) setup_pan (); pan_changed (0); } @@ -339,13 +312,30 @@ void PannerUI::update_pan_state () { /* currently nothing to do */ - // ENSURE_GUI_THREAD (mem_fun(*this, &PannerUI::update_panner_state)); + // ENSURE_GUI_THREAD (*this, &PannerUI::update_panner_state) } void PannerUI::setup_pan () { - uint32_t nouts = _io->n_outputs ().n_audio(); + if (!_panner) { + return; + } + + uint32_t const nouts = _panner->nouts(); + uint32_t const npans = _panner->npanners(); + + if (int32_t (nouts) == _current_nouts && int32_t (npans) == _current_npans) { + return; + } + + _pan_control_connections.drop_connections (); + for (uint32_t i = 0; i < _panner->npanners(); ++i) { + connect_to_pan_control (i); + } + + _current_nouts = nouts; + _current_npans = npans; if (nouts == 0 || nouts == 1) { @@ -356,6 +346,9 @@ PannerUI::setup_pan () pan_adjustments.pop_back (); } + delete twod_panner; + twod_panner = 0; + /* stick something into the panning viewport so that it redraws */ EventBox* eb = manage (new EventBox()); @@ -366,7 +359,6 @@ PannerUI::setup_pan () } else if (nouts == 2) { vector::size_type asz; - uint32_t npans = _io->panner().npanners(); while (!pan_adjustments.empty()) { delete pan_bars.back(); @@ -375,6 +367,9 @@ PannerUI::setup_pan () pan_adjustments.pop_back (); } + delete twod_panner; + twod_panner = 0; + while ((asz = pan_adjustments.size()) < npans) { float x, rx; @@ -383,7 +378,7 @@ PannerUI::setup_pan () /* 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 = _io->panner().pan_control( asz)->get_value(); + rx = _panner->pan_control( asz)->get_value(); if (npans == 1) { x = 0.5; @@ -395,29 +390,33 @@ PannerUI::setup_pan () x = rx; } - pan_adjustments.push_back (new Adjustment (x, 0, 1.0, 0.05, 0.1)); + pan_adjustments.push_back (new Adjustment (x, 0, 1.0, 0.005, 0.05)); bc = new PannerBar (*pan_adjustments[asz], - boost::static_pointer_cast( _io->panner().pan_control( asz )) ); + boost::static_pointer_cast( _panner->pan_control( asz )) ); /* now set adjustment with current value of panner, then connect the signals */ pan_adjustments.back()->set_value(rx); - pan_adjustments.back()->signal_value_changed().connect (bind (mem_fun(*this, &PannerUI::pan_adjustment_changed), (uint32_t) asz)); - - _io->panner().pan_control( asz )->Changed.connect (bind (mem_fun(*this, &PannerUI::pan_value_changed), (uint32_t) asz)); + pan_adjustments.back()->signal_value_changed().connect (sigc::bind (sigc::mem_fun(*this, &PannerUI::pan_adjustment_changed), (uint32_t) asz)); + connect_to_pan_control (asz); - bc->set_name ("PanSlider"); bc->set_shadow_type (Gtk::SHADOW_NONE); - bc->StartGesture.connect (bind (mem_fun (*_io, &IO::start_pan_touch), (uint32_t) asz)); - bc->StopGesture.connect (bind (mem_fun (*_io, &IO::end_pan_touch), (uint32_t) asz)); + boost::shared_ptr ac = _panner->pan_control (asz); + + 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))); + } char buf[64]; snprintf (buf, sizeof (buf), _("panner for channel %zu"), asz + 1); - ARDOUR_UI::instance()->tooltips().set_tip (bc->event_widget(), buf); + ARDOUR_UI::instance()->set_tip (bc->event_widget(), buf); bc->event_widget().signal_button_release_event().connect - (bind (mem_fun(*this, &PannerUI::pan_button_event), (uint32_t) asz)); + (sigc::bind (sigc::mem_fun(*this, &PannerUI::pan_button_event), (uint32_t) asz)); bc->set_size_request (-1, pan_bar_height); @@ -438,39 +437,58 @@ PannerUI::setup_pan () } else { - if (panner == 0) { - panner = new Panner2d (_io->panner(), 61); - panner->set_name ("MixerPanZone"); - panner->show (); + if (!twod_panner) { + twod_panner = new Panner2d (_panner, 61); + twod_panner->set_name ("MixerPanZone"); + twod_panner->show (); - - panner->signal_button_press_event().connect - (bind (mem_fun(*this, &PannerUI::pan_button_event), (uint32_t) 0), false); + twod_panner->signal_button_press_event().connect + (sigc::bind (sigc::mem_fun(*this, &PannerUI::pan_button_event), (uint32_t) 0), false); } - + update_pan_sensitive (); - panner->reset (_io->n_inputs().n_audio()); + twod_panner->reset (npans); if (big_window) { - big_window->reset (_io->n_inputs().n_audio()); + big_window->reset (npans); } - panner->set_size_request (-1, 61); + twod_panner->set_size_request (-1, 61); /* and finally, add it to the panner frame */ panning_viewport.remove (); - panning_viewport.add (*panner); + panning_viewport.add (*twod_panner); panning_viewport.show_all (); } } +void +PannerUI::start_touch (boost::weak_ptr wac) +{ + boost::shared_ptr ac = wac.lock(); + if (!ac) { + return; + } + ac->start_touch (ac->session().transport_frame()); +} + +void +PannerUI::stop_touch (boost::weak_ptr wac) +{ + boost::shared_ptr ac = wac.lock(); + if (!ac) { + return; + } + ac->stop_touch (false, ac->session().transport_frame()); +} + bool PannerUI::pan_button_event (GdkEventButton* ev, uint32_t which) { switch (ev->button) { case 1: - if (panner && ev->type == GDK_2BUTTON_PRESS) { + if (twod_panner && ev->type == GDK_2BUTTON_PRESS) { if (!big_window) { - big_window = new Panner2dWindow (panner->get_panner(), 400, _io->n_inputs().n_audio()); + big_window = new Panner2dWindow (_panner, 400, _panner->npanners()); } big_window->show (); return true; @@ -502,55 +520,62 @@ PannerUI::build_pan_menu (uint32_t which) items.clear (); items.push_back (CheckMenuElem (_("Mute"))); - + /* set state first, connect second */ - (dynamic_cast (&items.back()))->set_active (_io->panner().streampanner(which).muted()); + (dynamic_cast (&items.back()))->set_active (_panner->streampanner(which).muted()); (dynamic_cast (&items.back()))->signal_toggled().connect - (bind (mem_fun(*this, &PannerUI::pan_mute), which)); + (sigc::bind (sigc::mem_fun(*this, &PannerUI::pan_mute), which)); - items.push_back (CheckMenuElem (_("Bypass"), mem_fun(*this, &PannerUI::pan_bypass_toggle))); + items.push_back (CheckMenuElem (_("Bypass"), sigc::mem_fun(*this, &PannerUI::pan_bypass_toggle))); bypass_menu_item = static_cast (&items.back()); /* set state first, connect second */ - bypass_menu_item->set_active (_io->panner().bypassed()); - bypass_menu_item->signal_toggled().connect (mem_fun(*this, &PannerUI::pan_bypass_toggle)); + bypass_menu_item->set_active (_panner->bypassed()); + bypass_menu_item->signal_toggled().connect (sigc::mem_fun(*this, &PannerUI::pan_bypass_toggle)); - items.push_back (MenuElem (_("Reset"), mem_fun(*this, &PannerUI::pan_reset))); + items.push_back (MenuElem (_("Reset"), sigc::bind (sigc::mem_fun (*this, &PannerUI::pan_reset), which))); items.push_back (SeparatorElem()); - items.push_back (MenuElem (_("Reset all"))); + items.push_back (MenuElem (_("Reset all"), sigc::mem_fun (*this, &PannerUI::pan_reset_all))); } void PannerUI::pan_mute (uint32_t which) { - StreamPanner& sp = _io->panner().streampanner(which); + StreamPanner& sp = _panner->streampanner(which); sp.set_muted (!sp.muted()); } void PannerUI::pan_bypass_toggle () { - if (bypass_menu_item && (_io->panner().bypassed() != bypass_menu_item->get_active())) { - _io->panner().set_bypassed (!_io->panner().bypassed()); + if (bypass_menu_item && (_panner->bypassed() != bypass_menu_item->get_active())) { + _panner->set_bypassed (!_panner->bypassed()); } } void -PannerUI::pan_reset () +PannerUI::pan_reset (uint32_t which) +{ + _panner->reset_streampanner (which); +} + +void +PannerUI::pan_reset_all () { + _panner->reset_to_default (); } void PannerUI::effective_pan_display () { - if (_io->panner().empty()) { + if (_panner->empty()) { return; } - switch (_io->n_outputs().n_audio()) { - case 0: + switch (_panner->nouts()) { + case 0: case 1: /* relax */ break; @@ -572,7 +597,7 @@ PannerUI::pan_changed (void *src) return; } - switch (_io->panner().npanners()) { + switch (_panner->npanners()) { case 0: panning_link_direction_button.set_sensitive (false); panning_link_button.set_sensitive (false); @@ -582,11 +607,11 @@ PannerUI::pan_changed (void *src) panning_link_button.set_sensitive (false); break; default: - panning_link_direction_button.set_sensitive (true); + panning_link_direction_button.set_sensitive (_panner->linked ()); panning_link_button.set_sensitive (true); } - uint32_t nouts = _io->n_outputs().n_audio(); + uint32_t const nouts = _panner->nouts(); switch (nouts) { case 0: @@ -608,16 +633,15 @@ PannerUI::pan_changed (void *src) void PannerUI::pan_adjustment_changed (uint32_t which) { - if (!in_pan_update && which < _io->panner().npanners()) { + if (!in_pan_update && which < _panner->npanners()) { - float xpos; float val = pan_adjustments[which]->get_value (); - xpos = _io->panner().pan_control( which )->get_value(); + float const xpos = _panner->pan_control(which)->get_value(); /* add a kinda-sorta detent for the middle */ - + if (val != 0.5 && Panner::equivalent (val, 0.5)) { - /* this is going to be reentrant, so just + /* this is going to be reentrant, so just return after it. */ @@ -626,15 +650,15 @@ PannerUI::pan_adjustment_changed (uint32_t which) in_pan_update = false; return; } - + if (!Panner::equivalent (val, xpos)) { - _io->panner().streampanner(which).set_position (val); - /* XXX + _panner->pan_control(which)->set_value (val); + /* XXX the panner objects have no access to the session, so do this here. ick. */ - _session.set_dirty(); + _session->set_dirty(); } } } @@ -642,13 +666,23 @@ PannerUI::pan_adjustment_changed (uint32_t which) void PannerUI::pan_value_changed (uint32_t which) { - ENSURE_GUI_THREAD (bind (mem_fun(*this, &PannerUI::pan_value_changed), which)); - - if (_io->n_outputs().n_audio() > 1 && which < _io->panner().npanners()) { + ENSURE_GUI_THREAD (*this, &PannerUI::pan_value_changed, which) + + if (twod_panner) { + + float x; + float y; + _panner->streampanner(which).get_position (x, y); + + in_pan_update = true; + twod_panner->move_puck (which, x, y); + in_pan_update = false; + + } else if (_panner->npanners() > 0 && which < _panner->npanners()) { float xpos; float val = pan_adjustments[which]->get_value (); - _io->panner().streampanner(which).get_position (xpos); + _panner->streampanner(which).get_position (xpos); if (!Panner::equivalent (val, xpos)) { in_pan_update = true; @@ -656,7 +690,7 @@ PannerUI::pan_value_changed (uint32_t which) in_pan_update = false; } } -} +} void PannerUI::update_pan_bars (bool only_if_aplay) @@ -674,16 +708,16 @@ PannerUI::update_pan_bars (bool only_if_aplay) float xpos, val; if (only_if_aplay) { - boost::shared_ptr alist (_io->panner().streampanner(n).pan_control()->alist()); - + boost::shared_ptr alist (_panner->streampanner(n).pan_control()->alist()); + if (!alist->automation_playback()) { continue; } } - _io->panner().streampanner(n).get_effective_position (xpos); + _panner->streampanner(n).get_effective_position (xpos); val = (*i)->get_value (); - + if (!Panner::equivalent (val, xpos)) { (*i)->set_value (xpos); } @@ -693,28 +727,11 @@ PannerUI::update_pan_bars (bool only_if_aplay) } void -PannerUI::pan_printer (char *buf, uint32_t len, Adjustment* adj) -{ - float val = adj->get_value(); - - if (val == 0.0f) { - snprintf (buf, len, X_("L")); - } else if (val == 1.0f) { - snprintf (buf, len, X_("R")); - } else if (Panner::equivalent (val, 0.5f)) { - snprintf (buf, len, X_("C")); - } else { - /* don't print anything */ - buf[0] = '\0'; - } -} - -void -PannerUI::update_pan_sensitive () +PannerUI::update_pan_sensitive () { - bool sensitive = !(_io->panner().automation_state() & Play); + bool const sensitive = !(_panner->mono()) && !(_panner->automation_state() & Play); - switch (_io->n_outputs().n_audio()) { + switch (_panner->nouts()) { case 0: case 1: break; @@ -724,8 +741,8 @@ PannerUI::update_pan_sensitive () } break; default: - if (panner) { - panner->set_sensitive (sensitive); + if (twod_panner) { + twod_panner->set_sensitive (sensitive); } if (big_window) { big_window->set_sensitive (sensitive); @@ -780,14 +797,14 @@ PannerUI::pan_automation_style_button_event (GdkEventButton *ev) void PannerUI::pan_automation_style_changed () { - ENSURE_GUI_THREAD(mem_fun(*this, &PannerUI::pan_automation_style_changed)); - + ENSURE_GUI_THREAD (*this, &PannerUI::pan_automation_style_changed) + switch (_width) { case Wide: - pan_automation_style_button.set_label (astyle_string(_io->panner().automation_style())); + pan_automation_style_button.set_label (astyle_string(_panner->automation_style())); break; case Narrow: - pan_automation_style_button.set_label (short_astyle_string(_io->panner().automation_style())); + pan_automation_style_button.set_label (short_astyle_string(_panner->automation_style())); break; } } @@ -795,16 +812,16 @@ PannerUI::pan_automation_style_changed () void PannerUI::pan_automation_state_changed () { - ENSURE_GUI_THREAD(mem_fun(*this, &PannerUI::pan_automation_state_changed)); - + ENSURE_GUI_THREAD (*this, &PannerUI::pan_automation_state_changed) + bool x; switch (_width) { case Wide: - pan_automation_state_button.set_label (astate_string(_io->panner().automation_state())); + pan_automation_state_button.set_label (astate_string(_panner->automation_state())); break; case Narrow: - pan_automation_state_button.set_label (short_astate_string(_io->panner().automation_state())); + pan_automation_state_button.set_label (short_astate_string(_panner->automation_state())); break; } @@ -813,11 +830,11 @@ PannerUI::pan_automation_state_changed () here. */ - if (_io->panner().empty()) { + if (_panner->empty()) { return; } - x = (_io->panner().streampanner(0).pan_control()->alist()->automation_state() != Off); + x = (_panner->streampanner(0).pan_control()->alist()->automation_state() != Off); if (pan_automation_state_button.get_active() != x) { ignore_toggle = true; @@ -832,7 +849,7 @@ PannerUI::pan_automation_state_changed () pan_watching.disconnect(); if (x) { - pan_watching = ARDOUR_UI::RapidScreenUpdate.connect (mem_fun (*this, &PannerUI::effective_pan_display)); + pan_watching = ARDOUR_UI::RapidScreenUpdate.connect (sigc::mem_fun (*this, &PannerUI::effective_pan_display)); } } @@ -894,3 +911,19 @@ PannerUI::_astyle_string (AutoStyle style, bool shrt) return (shrt ? _("Abs") : _("Abs")); } } + +void +PannerUI::set_mono (bool yn) +{ + _panner->set_mono (yn); + update_pan_sensitive (); +} + + +void +PannerUI::connect_to_pan_control (uint32_t i) +{ + _panner->pan_control(i)->Changed.connect ( + _pan_control_connections, invalidator (*this), boost::bind (&PannerUI::pan_value_changed, this, i), gui_context () + ); +}