X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fpanner_ui.cc;h=433b5b0c0258685b48393301eedc36a82335d174;hb=3e59452fa0182ace7785c62acef83cb0d213cc86;hp=730b382d6b3ac08e8fa5153f8ac906ffcbd59dae;hpb=669247a4c4d835e80a14d1f9307ba290da03648d;p=ardour.git diff --git a/gtk2_ardour/panner_ui.cc b/gtk2_ardour/panner_ui.cc index 730b382d6b..433b5b0c02 100644 --- a/gtk2_ardour/panner_ui.cc +++ b/gtk2_ardour/panner_ui.cc @@ -18,13 +18,17 @@ #include -#include "ardour/io.h" -#include "ardour/dB.h" #include #include + #include "midi++/manager.h" #include "pbd/fastlog.h" +#include "ardour/pannable.h" +#include "ardour/panner.h" +#include "ardour/panner_shell.h" +#include "ardour/session.h" + #include "ardour_ui.h" #include "panner_ui.h" #include "panner2d.h" @@ -33,11 +37,6 @@ #include "stereo_panner.h" #include "mono_panner.h" -#include "ardour/delivery.h" -#include "ardour/session.h" -#include "ardour/panner.h" -#include "ardour/route.h" - #include "i18n.h" using namespace std; @@ -46,17 +45,11 @@ using namespace PBD; using namespace Gtkmm2ext; using namespace Gtk; -const int PannerUI::pan_bar_height = 40; +const int PannerUI::pan_bar_height = 35; 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")) + , _current_nins (-1) , pan_automation_style_button ("") , pan_automation_state_button ("") { @@ -68,6 +61,7 @@ PannerUI::PannerUI (Session* s) pan_astyle_menu = 0; in_pan_update = false; _stereo_panner = 0; + _mono_panner = 0; _ignore_width_change = false; _ignore_position_change = false; @@ -80,52 +74,13 @@ PannerUI::PannerUI (Session* s) //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); - panning_viewport.set_name (X_("BaseFrame")); - - ARDOUR_UI::instance()->set_tip (panning_link_button, - _("panning link control")); - 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 (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")); - - panning_link_box.pack_start (panning_link_button, true, true); - panning_link_box.pack_start (panning_link_direction_button, true, true); - panning_link_box.pack_start (pan_automation_state_button, true, true); - - /* the pixmap will be reset at some point, but the key thing is that - we need a pixmap in the button just to get started. - */ - panning_link_direction_button.add (*(manage (new Image (get_xpm("forwardblarrow.xpm"))))); - - panning_link_direction_button.signal_clicked().connect - (sigc::mem_fun(*this, &PannerUI::panning_link_direction_clicked)); - - panning_link_button.signal_button_press_event().connect - (sigc::mem_fun(*this, &PannerUI::panning_link_button_press), false); - panning_link_button.signal_button_release_event().connect - (sigc::mem_fun(*this, &PannerUI::panning_link_button_release), false); - - panning_up.set_border_width (3); - panning_down.set_border_width (3); - panning_up.add (panning_up_arrow); - panning_down.add (panning_down_arrow); - panning_up.set_name (X_("PanScrollerBase")); - panning_down.set_name (X_("PanScrollerBase")); - panning_up_arrow.set_name (X_("PanScrollerArrow")); - panning_down_arrow.set_name (X_("PanScrollerArrow")); - pan_vbox.set_spacing (2); - pan_vbox.pack_start (panning_viewport, Gtk::PACK_SHRINK); - pan_vbox.pack_start (panning_link_box, Gtk::PACK_SHRINK); - pack_start (pan_vbox, true, true); twod_panner = 0; @@ -135,8 +90,11 @@ PannerUI::PannerUI (Session* s) } void -PannerUI::set_panner (boost::shared_ptr p) +PannerUI::set_panner (boost::shared_ptr ps, boost::shared_ptr p) { + /* note that the panshell might not change here (i.e. ps == _panshell) + */ + connections.drop_connections (); delete pan_astyle_menu; @@ -145,6 +103,7 @@ PannerUI::set_panner (boost::shared_ptr p) delete pan_astate_menu; pan_astate_menu = 0; + _panshell = ps; _panner = p; delete twod_panner; @@ -157,21 +116,17 @@ PannerUI::set_panner (boost::shared_ptr p) return; } - _panner->Changed.connect (connections, invalidator (*this), boost::bind (&PannerUI::panner_changed, this, 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()); + _panshell->Changed.connect (connections, invalidator (*this), boost::bind (&PannerUI::panshell_changed, this), gui_context()); /* new panner object, force complete reset of panner GUI */ _current_nouts = 0; - _current_npans = 0; + _current_nins = 0; - panner_changed (0); + setup_pan (); update_pan_sensitive (); - update_pan_linkage (); pan_automation_state_changed (); - } void @@ -186,9 +141,12 @@ PannerUI::build_astate_menu () pan_astate_menu->items().clear (); } - pan_astate_menu->items().push_back (MenuElem (_("Manual"), sigc::bind ( + /** TRANSLATORS: this is `Manual' in the sense of automation not being played, + so that changes to pan must be done by hand. + */ + pan_astate_menu->items().push_back (MenuElem (S_("Automation|Manual"), sigc::bind ( sigc::mem_fun (_panner.get(), &Panner::set_automation_state), - (AutoState) Off))); + (AutoState) ARDOUR::Off))); pan_astate_menu->items().push_back (MenuElem (_("Play"), sigc::bind ( sigc::mem_fun (_panner.get(), &Panner::set_automation_state), (AutoState) Play))); @@ -217,67 +175,6 @@ PannerUI::build_astyle_menu () pan_astyle_menu->items().push_back (MenuElem (_("Abs"))); } -boost::shared_ptr -PannerUI::get_controllable() -{ - return pan_bars[0]->get_controllable(); -} - -bool -PannerUI::panning_link_button_press (GdkEventButton*) -{ - return true; -} - -bool -PannerUI::panning_link_button_release (GdkEventButton*) -{ - if (!ignore_toggle) { - _panner->set_linked (!_panner->linked()); - } - return true; -} - -void -PannerUI::panning_link_direction_clicked() -{ - switch (_panner->link_direction()) { - case Panner::SameDirection: - _panner->set_link_direction (Panner::OppositeDirection); - break; - default: - _panner->set_link_direction (Panner::SameDirection); - break; - } -} - -void -PannerUI::update_pan_linkage () -{ - 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; - } - - panning_link_direction_button.set_sensitive (x); - - switch (_panner->link_direction()) { - case Panner::SameDirection: - panning_link_direction_button.set_image (*(manage (new Image (get_xpm ("forwardblarrow.xpm"))))); - break; - default: - panning_link_direction_button.set_image (*(manage (new Image (get_xpm("revdblarrow.xpm"))))); - break; - } -} - void PannerUI::on_size_allocate (Allocation& a) { @@ -287,216 +184,140 @@ PannerUI::on_size_allocate (Allocation& a) void PannerUI::set_width (Width w) { - switch (w) { - case Wide: - panning_link_button.set_label (_("link")); - break; - case Narrow: - panning_link_button.set_label (_("L")); - break; - } - _width = w; } - PannerUI::~PannerUI () { - for (vector::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) { - delete (*i); - } - delete twod_panner; delete big_window; delete pan_menu; delete pan_astyle_menu; delete pan_astate_menu; delete _stereo_panner; + delete _mono_panner; } - void -PannerUI::panner_changed (void* src) +PannerUI::panshell_changed () { - ENSURE_GUI_THREAD (*this, &PannerUI::panner_changed) - + set_panner (_panshell, _panshell->panner()); setup_pan (); - - if (src == this) { - return; - } - - switch (_panner->npanners()) { - case 0: - panning_link_direction_button.set_sensitive (false); - panning_link_button.set_sensitive (false); - return; - case 1: - panning_link_direction_button.set_sensitive (false); - panning_link_button.set_sensitive (false); - break; - default: - panning_link_direction_button.set_sensitive (_panner->linked ()); - panning_link_button.set_sensitive (true); - } - - uint32_t const nouts = _panner->nouts(); - - switch (nouts) { - case 0: - case 1: - /* relax */ - break; - - case 2: - break; - - default: - // panner->move_puck (pan_value (pans[0], pans[1]), 0.5); - break; - } -} - -void -PannerUI::update_pan_state () -{ - /* currently nothing to do */ - // ENSURE_GUI_THREAD (*this, &PannerUI::update_panner_state) } void PannerUI::setup_pan () { - if (!_panner) { - return; - } - - uint32_t const nouts = _panner->nouts(); - uint32_t const npans = _panner->npanners(); + int const nouts = _panner ? _panner->out().n_audio() : -1; + int const nins = _panner ? _panner->in().n_audio() : -1; - if (int32_t (nouts) == _current_nouts && int32_t (npans) == _current_npans) { + if (nouts == _current_nouts && nins == _current_nins) { return; } - _current_nouts = nouts; - _current_npans = npans; + _current_nins = nins; + _current_nouts = nouts; - panning_viewport.remove (); + container_clear (pan_vbox); delete twod_panner; twod_panner = 0; delete _stereo_panner; _stereo_panner = 0; + delete _mono_panner; + _mono_panner = 0; - if (nouts == 0 || nouts == 1) { + if (!_panner) { + return; + } - while (!pan_bars.empty()) { - delete pan_bars.back(); - pan_bars.pop_back (); - } + if (nouts == 0 || nouts == 1) { /* stick something into the panning viewport so that it redraws */ EventBox* eb = manage (new EventBox()); - panning_viewport.add (*eb); + pan_vbox.pack_start (*eb, false, false); - } else if (nouts == 2) { - - vector::size_type p; + delete big_window; + big_window = 0; - while (!pan_bars.empty()) { - delete pan_bars.back(); - pan_bars.pop_back (); - } + } else if (nouts == 2) { - if (npans == 2) { + if (nins == 2) { /* add integrated 2in/2out panner GUI */ - _stereo_panner = new StereoPanner (_panner->direction_control(), - _panner->width_control()); + boost::shared_ptr pannable = _panner->pannable(); + + _stereo_panner = new StereoPanner (_panner); _stereo_panner->set_size_request (-1, pan_bar_height); - panning_viewport.add (*_stereo_panner); + pan_vbox.pack_start (*_stereo_panner, false, false); - } else { - - /* N-in/2out - just use a set of single-channel panners */ - - while ((p = pan_bars.size()) < npans) { - - float x, rx; - MonoPanner* mp; - - /* 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->signal_button_release_event().connect - (sigc::bind (sigc::mem_fun(*this, &PannerUI::pan_button_event), (uint32_t) p)); - - mp->set_size_request (-1, pan_bar_height); - - pan_bars.push_back (mp); - pan_bar_packer.pack_start (*mp, false, false); - } - - /* now that we actually have the pan bars, - set their sensitivity based on current - automation state. - */ - + boost::shared_ptr ac; + + ac = pannable->pan_azimuth_control; + _stereo_panner->StartPositionGesture.connect (sigc::bind (sigc::mem_fun (*this, &PannerUI::start_touch), + boost::weak_ptr (ac))); + _stereo_panner->StopPositionGesture.connect (sigc::bind (sigc::mem_fun (*this, &PannerUI::stop_touch), + boost::weak_ptr(ac))); + + ac = pannable->pan_width_control; + _stereo_panner->StartWidthGesture.connect (sigc::bind (sigc::mem_fun (*this, &PannerUI::start_touch), + boost::weak_ptr (ac))); + _stereo_panner->StopWidthGesture.connect (sigc::bind (sigc::mem_fun (*this, &PannerUI::stop_touch), + boost::weak_ptr(ac))); + _stereo_panner->signal_button_release_event().connect (sigc::mem_fun(*this, &PannerUI::pan_button_event)); + + } else if (nins == 1) { + /* 1-in/2out */ + + boost::shared_ptr pannable = _panner->pannable(); + boost::shared_ptr ac = pannable->pan_azimuth_control; + + _mono_panner = new MonoPanner (_panner); + + _mono_panner->StartGesture.connect (sigc::bind (sigc::mem_fun (*this, &PannerUI::start_touch), + boost::weak_ptr (ac))); + _mono_panner->StopGesture.connect (sigc::bind (sigc::mem_fun (*this, &PannerUI::stop_touch), + boost::weak_ptr(ac))); + + _mono_panner->signal_button_release_event().connect (sigc::mem_fun(*this, &PannerUI::pan_button_event)); + + _mono_panner->set_size_request (-1, pan_bar_height); update_pan_sensitive (); - panning_viewport.add (pan_bar_packer); + pan_vbox.pack_start (*_mono_panner, false, false); + + } else { + warning << string_compose (_("No panner user interface is currently available for %1-in/2out tracks/busses"), + nins) << endmsg; } + delete big_window; + big_window = 0; } else { if (!twod_panner) { - twod_panner = new Panner2d (_panner, 61); + twod_panner = new Panner2d (_panshell, 61); twod_panner->set_name ("MixerPanZone"); twod_panner->show (); - - twod_panner->signal_button_press_event().connect - (sigc::bind (sigc::mem_fun(*this, &PannerUI::pan_button_event), (uint32_t) 0), false); + twod_panner->signal_button_press_event().connect (sigc::mem_fun(*this, &PannerUI::pan_button_event), false); } update_pan_sensitive (); - twod_panner->reset (npans); + twod_panner->reset (nins); if (big_window) { - big_window->reset (npans); + big_window->reset (nins); } twod_panner->set_size_request (-1, 61); /* and finally, add it to the panner frame */ - panning_viewport.add (*twod_panner); + pan_vbox.pack_start (*twod_panner, false, false); } - panning_viewport.show_all (); + pan_vbox.show_all (); } void @@ -520,13 +341,13 @@ PannerUI::stop_touch (boost::weak_ptr wac) } bool -PannerUI::pan_button_event (GdkEventButton* ev, uint32_t which) +PannerUI::pan_button_event (GdkEventButton* ev) { switch (ev->button) { case 1: if (twod_panner && ev->type == GDK_2BUTTON_PRESS) { if (!big_window) { - big_window = new Panner2dWindow (_panner, 400, _panner->npanners()); + big_window = new Panner2dWindow (_panshell, 400, _panner->in().n_audio()); } big_window->show (); return true; @@ -538,7 +359,7 @@ PannerUI::pan_button_event (GdkEventButton* ev, uint32_t which) pan_menu = manage (new Menu); pan_menu->set_name ("ArdourContextMenu"); } - build_pan_menu (which); + build_pan_menu (); pan_menu->popup (1, ev->time); return true; break; @@ -550,141 +371,69 @@ PannerUI::pan_button_event (GdkEventButton* ev, uint32_t which) } void -PannerUI::build_pan_menu (uint32_t which) +PannerUI::build_pan_menu () { using namespace Menu_Helpers; MenuList& items (pan_menu->items()); items.clear (); - items.push_back (CheckMenuElem (_("Mute"))); - - /* set state first, connect second */ - - (dynamic_cast (&items.back()))->set_active (_panner->streampanner(which).muted()); - (dynamic_cast (&items.back()))->signal_toggled().connect - (sigc::bind (sigc::mem_fun(*this, &PannerUI::pan_mute), which)); - 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 (_panner->bypassed()); + bypass_menu_item->set_active (_panshell->bypassed()); bypass_menu_item->signal_toggled().connect (sigc::mem_fun(*this, &PannerUI::pan_bypass_toggle)); - 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"), sigc::mem_fun (*this, &PannerUI::pan_reset_all))); -} - -void -PannerUI::pan_mute (uint32_t which) -{ - StreamPanner& sp = _panner->streampanner(which); - sp.set_muted (!sp.muted()); + items.push_back (MenuElem (_("Reset"), sigc::mem_fun (*this, &PannerUI::pan_reset))); + items.push_back (MenuElem (_("Edit..."), sigc::mem_fun (*this, &PannerUI::pan_edit))); } void PannerUI::pan_bypass_toggle () { - if (bypass_menu_item && (_panner->bypassed() != bypass_menu_item->get_active())) { - _panner->set_bypassed (!_panner->bypassed()); + if (bypass_menu_item && (_panshell->bypassed() != bypass_menu_item->get_active())) { + _panshell->set_bypassed (!_panshell->bypassed()); } } void -PannerUI::pan_reset (uint32_t which) +PannerUI::pan_edit () { - _panner->reset_streampanner (which); + if (_mono_panner) { + _mono_panner->edit (); + } else if (_stereo_panner) { + _stereo_panner->edit (); + } } void -PannerUI::pan_reset_all () +PannerUI::pan_reset () { - _panner->reset_to_default (); + _panner->reset (); } void PannerUI::effective_pan_display () { - if (_panner->empty()) { - return; - } - - switch (_panner->nouts()) { - case 0: - case 1: - /* relax: no panning */ - break; - - case 2: - update_pan_bars (true); - break; - - default: - //panner->move_puck (pan_value (v, right), 0.5); - break; - } -} - -void -PannerUI::update_pan_bars (bool only_if_aplay) -{ - uint32_t n; - - in_pan_update = true; - -#if 0 - /* this runs during automation playback, and moves the bar controllers - and/or pucks around. - */ - - for (i = pan_bars.begin(), n = 0; i != pan_bars.end(); ++i, ++n) { - - if (only_if_aplay) { - boost::shared_ptr alist (_panner->streampanner(n).pan_control()->alist()); - if (!alist->automation_playback()) { - continue; - } - } - - AngularVector model = _panner->streampanner(n).get_effective_position(); - double fract = (*i)->get_value(); - AngularVector view (BaseStereoPanner::lr_fract_to_azimuth (fract), 0.0); - - if (!Panner::equivalent (model, view)) { - (*i)->set_value (BaseStereoPanner::azimuth_to_lr_fract (model.azi)); - } - } -#endif - - in_pan_update = false; + if (_stereo_panner) { + _stereo_panner->queue_draw (); + } else if (twod_panner) { + twod_panner->queue_draw (); + } } void PannerUI::update_pan_sensitive () { - bool const sensitive = !(_panner->mono()) && !(_panner->automation_state() & Play); + bool const sensitive = !(_panner->pannable()->automation_state() & Play); - switch (_panner->nouts()) { - case 0: - case 1: - break; - case 2: - for (vector::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) { - (*i)->set_sensitive (sensitive); - } - break; - default: - if (twod_panner) { - twod_panner->set_sensitive (sensitive); - } - if (big_window) { - big_window->set_sensitive (sensitive); - } - break; - } + pan_vbox.set_sensitive (sensitive); + + if (big_window) { + big_window->set_sensitive (sensitive); + } } gint @@ -748,32 +497,21 @@ PannerUI::pan_automation_style_changed () void PannerUI::pan_automation_state_changed () { - ENSURE_GUI_THREAD (*this, &PannerUI::pan_automation_state_changed) - - bool x; + boost::shared_ptr pannable (_panner->pannable()); switch (_width) { case Wide: - pan_automation_state_button.set_label (astate_string(_panner->automation_state())); + pan_automation_state_button.set_label (astate_string(pannable->automation_state())); break; case Narrow: - pan_automation_state_button.set_label (short_astate_string(_panner->automation_state())); + pan_automation_state_button.set_label (short_astate_string(pannable->automation_state())); break; } - /* when creating a new session, we get to create busses (and - sometimes tracks) with no outputs by the time they get - here. - */ - - if (_panner->empty()) { - return; - } - - x = (_panner->streampanner(0).pan_control()->alist()->automation_state() != Off); + bool x = (pannable->automation_state() != ARDOUR::Off); if (pan_automation_state_button.get_active() != x) { - ignore_toggle = true; + ignore_toggle = true; pan_automation_state_button.set_active (x); ignore_toggle = false; } @@ -807,7 +545,7 @@ PannerUI::_astate_string (AutoState state, bool shrt) string sstr; switch (state) { - case Off: + case ARDOUR::Off: sstr = (shrt ? "M" : _("M")); break; case Play: @@ -848,13 +586,6 @@ PannerUI::_astyle_string (AutoStyle style, bool shrt) } } -void -PannerUI::set_mono (bool yn) -{ - _panner->set_mono (yn); - update_pan_sensitive (); -} - void PannerUI::show_width () {