merge MixerActor API (back) into Mixer_UI; make solo/mute/recenable actions there do the right thing

This commit is contained in:
Paul Davis 2016-07-06 15:20:42 -04:00
parent db3223478c
commit 6e469ffb5e
5 changed files with 263 additions and 383 deletions

View File

@ -1,283 +0,0 @@
/*
Copyright (C) 2000-2004 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.
*/
#ifdef WAF_BUILD
#include "gtk2ardour-config.h"
#endif
#include <boost/foreach.hpp>
#include "pbd/file_utils.h"
#include "pbd/error.h"
#include "ardour/filesystem_paths.h"
#include "gtkmm2ext/bindings.h"
#include "actions.h"
#include "mixer_actor.h"
#include "mixer_strip.h"
#include "route_ui.h"
#include "i18n.h"
using namespace ARDOUR;
using namespace Gtk;
using namespace PBD;
using Gtkmm2ext::Bindings;
MixerActor::MixerActor ()
: myactions (X_("mixer"))
{
register_actions ();
load_bindings ();
}
MixerActor::~MixerActor ()
{
}
void
MixerActor::register_actions ()
{
Glib::RefPtr<ActionGroup> group = myactions.create_action_group (X_("Mixer"));
myactions.register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::solo_action));
myactions.register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::mute_action));
myactions.register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::rec_enable_action));
myactions.register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::step_gain_up_action));
myactions.register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::step_gain_down_action));
myactions.register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::unity_gain_action));
myactions.register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &MixerActor::copy_processors));
myactions.register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &MixerActor::cut_processors));
myactions.register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &MixerActor::paste_processors));
myactions.register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &MixerActor::delete_processors));
myactions.register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &MixerActor::select_all_processors));
myactions.register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &MixerActor::toggle_processors));
myactions.register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &MixerActor::ab_plugins));
myactions.register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &MixerActor::select_none));
myactions.register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &MixerActor::scroll_left));
myactions.register_action (group, "scroll-right", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &MixerActor::scroll_right));
myactions.register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
sigc::bind (sigc::mem_fun (*this, &MixerActor::toggle_midi_input_active), false));
}
void
MixerActor::load_bindings ()
{
bindings = Bindings::get_bindings (X_("Mixer"), myactions);
}
void
MixerActor::solo_action ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
boost::shared_ptr<Stripable> s = r->stripable();
if (s) {
boost::shared_ptr<AutomationControl> ac = s->solo_control();
if (ac) {
ac->set_value (!ac->get_value(), Controllable::UseGroup);
}
}
}
}
void
MixerActor::mute_action ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
boost::shared_ptr<Stripable> s = r->stripable();
if (s) {
boost::shared_ptr<AutomationControl> ac = s->mute_control();
if (ac) {
ac->set_value (!ac->get_value(), Controllable::UseGroup);
}
}
}
}
void
MixerActor::rec_enable_action ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
boost::shared_ptr<Stripable> s = r->stripable();
if (s) {
boost::shared_ptr<AutomationControl> ac = s->rec_enable_control();
if (ac) {
ac->set_value (!ac->get_value(), Controllable::UseGroup);
}
}
}
}
void
MixerActor::step_gain_up_action ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->step_gain_up ();
}
}
}
void
MixerActor::step_gain_down_action ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->step_gain_down ();
}
}
}
void
MixerActor::unity_gain_action ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
boost::shared_ptr<Stripable> s = r->stripable();
if (s) {
boost::shared_ptr<AutomationControl> ac = s->gain_control();
if (ac) {
ac->set_value (1.0, Controllable::UseGroup);
}
}
}
}
void
MixerActor::copy_processors ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->copy_processors ();
}
}
}
void
MixerActor::cut_processors ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->cut_processors ();
}
}
}
void
MixerActor::paste_processors ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->paste_processors ();
}
}
}
void
MixerActor::select_all_processors ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->select_all_processors ();
}
}
}
void
MixerActor::toggle_processors ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->toggle_processors ();
}
}
}
void
MixerActor::ab_plugins ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->ab_plugins ();
}
}
}
void
MixerActor::vca_assign (boost::shared_ptr<VCA> vca)
{
set_axis_targets_for_operation ();
#if 0
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->vca_assign (vca);
}
}
#endif
}
void
MixerActor::vca_unassign (boost::shared_ptr<VCA> vca)
{
set_axis_targets_for_operation ();
#if 0
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->vca_unassign (vca);
}
}
#endif
}

View File

@ -1,91 +0,0 @@
/*
Copyright (C) 2000 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.
*/
#ifndef __gtk2_ardour_mixer_actor_h__
#define __gtk2_ardour_mixer_actor_h__
#include <glibmm/refptr.h>
#include <gtkmm2ext/bindings.h>
#include "route_processor_selection.h"
namespace Gtk {
class ActionGroup;
}
namespace ARDOUR {
class VCA;
}
class MixerActor : virtual public sigc::trackable
{
public:
MixerActor ();
virtual ~MixerActor ();
RouteProcessorSelection& selection() { return _selection; }
void register_actions ();
void load_bindings ();
Gtkmm2ext::Bindings* bindings;
protected:
Gtkmm2ext::ActionMap myactions;
RouteProcessorSelection _selection;
AxisViewSelection _axis_targets;
virtual void set_axis_targets_for_operation () = 0;
void vca_assign (boost::shared_ptr<ARDOUR::VCA>);
void vca_unassign (boost::shared_ptr<ARDOUR::VCA>);
void solo_action ();
void mute_action ();
void rec_enable_action ();
void step_gain_up_action ();
void step_gain_down_action ();
void unity_gain_action ();
void copy_processors ();
void cut_processors ();
void paste_processors ();
void select_all_processors ();
void toggle_processors ();
void ab_plugins ();
//this op is different because it checks _all_ mixer strips, and deletes selected plugins on any of them (ignores track selections)
//BUT... note that we have used mixerstrip's "Enter" to enforce the rule that only one strip will have an active selection
virtual void delete_processors () = 0;
virtual void select_none () = 0;
/* these actions need access to a Session, do defer to
a derived class
*/
virtual void toggle_midi_input_active (bool flip_others) = 0;
/* these actions don't apply to the selection, so defer to
a derived class.
*/
virtual void scroll_left () {}
virtual void scroll_right () {}
};
#endif /* __gtk2_ardour_mixer_actor_h__ */

View File

@ -25,6 +25,8 @@
#include <map>
#include <sigc++/bind.h>
#include <boost/foreach.hpp>
#include <gtkmm/accelmap.h>
#include "pbd/convert.h"
@ -108,13 +110,14 @@ Mixer_UI::Mixer_UI ()
, _following_editor_selection (false)
, _maximised (false)
, _show_mixer_list (true)
, myactions (X_("mixer"))
{
PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::sync_treeview_from_presentation_info, this), gui_context());
/* bindings was already set in MixerActor constructor */
register_actions ();
load_bindings ();
_content.set_data ("ardour-bindings", bindings);
PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::sync_treeview_from_presentation_info, this), gui_context());
scroller.set_can_default (true);
// set_default (scroller);
@ -2725,3 +2728,226 @@ Mixer_UI::showing_vca_slaves_for (boost::shared_ptr<VCA> vca) const
{
return vca == spilled_vca.lock();
}
void
Mixer_UI::register_actions ()
{
Glib::RefPtr<ActionGroup> group = myactions.create_action_group (X_("Mixer"));
myactions.register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action));
myactions.register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action));
myactions.register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action));
myactions.register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action));
myactions.register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action));
myactions.register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action));
myactions.register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors));
myactions.register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors));
myactions.register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors));
myactions.register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors));
myactions.register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors));
myactions.register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
myactions.register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
myactions.register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
myactions.register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
myactions.register_action (group, "scroll-right", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
myactions.register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false));
}
void
Mixer_UI::load_bindings ()
{
bindings = Bindings::get_bindings (X_("Mixer"), myactions);
}
template<class T> void
Mixer_UI::control_action (boost::shared_ptr<T> (Stripable::*get_control)() const)
{
boost::shared_ptr<ControlList> cl (new ControlList);
boost::shared_ptr<AutomationControl> ac;
bool val = false;
bool have_val = false;
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
boost::shared_ptr<Stripable> s = r->stripable();
if (s) {
ac = (s.get()->*get_control)();
if (ac) {
cl->push_back (ac);
if (!have_val) {
val = !ac->get_value();
have_val = true;
}
}
}
}
_session->set_controls (cl, val, Controllable::UseGroup);
}
void
Mixer_UI::solo_action ()
{
control_action (&Stripable::solo_control);
}
void
Mixer_UI::mute_action ()
{
control_action (&Stripable::mute_control);
}
void
Mixer_UI::rec_enable_action ()
{
control_action (&Stripable::rec_enable_control);
}
void
Mixer_UI::step_gain_up_action ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->step_gain_up ();
}
}
}
void
Mixer_UI::step_gain_down_action ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->step_gain_down ();
}
}
}
void
Mixer_UI::unity_gain_action ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
boost::shared_ptr<Stripable> s = r->stripable();
if (s) {
boost::shared_ptr<AutomationControl> ac = s->gain_control();
if (ac) {
ac->set_value (1.0, Controllable::UseGroup);
}
}
}
}
void
Mixer_UI::copy_processors ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->copy_processors ();
}
}
}
void
Mixer_UI::cut_processors ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->cut_processors ();
}
}
}
void
Mixer_UI::paste_processors ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->paste_processors ();
}
}
}
void
Mixer_UI::select_all_processors ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->select_all_processors ();
}
}
}
void
Mixer_UI::toggle_processors ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->toggle_processors ();
}
}
}
void
Mixer_UI::ab_plugins ()
{
set_axis_targets_for_operation ();
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->ab_plugins ();
}
}
}
void
Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
{
set_axis_targets_for_operation ();
#if 0
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->vca_assign (vca);
}
}
#endif
}
void
Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
{
set_axis_targets_for_operation ();
#if 0
BOOST_FOREACH(AxisView* r, _axis_targets) {
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
ms->vca_unassign (vca);
}
}
#endif
}

View File

@ -41,18 +41,19 @@
#include "ardour/plugin.h"
#include "ardour/plugin_manager.h"
#include <gtkmm2ext/bindings.h>
#include "gtkmm2ext/dndtreeview.h"
#include <gtkmm2ext/pane.h>
#include "gtkmm2ext/tabbable.h"
#include "gtkmm2ext/treeutils.h"
#include "gtkmm2ext/tabbable.h"
#include "enums.h"
#include "mixer_actor.h"
#include "route_processor_selection.h"
namespace ARDOUR {
class Route;
class RouteGroup;
class VCA;
};
class AxisView;
@ -75,7 +76,7 @@ protected:
virtual bool row_drop_possible_vfunc (const Gtk::TreeModel::Path&, const Gtk::SelectionData&) const;
};
class Mixer_UI : public Gtkmm2ext::Tabbable, public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr, public MixerActor
class Mixer_UI : public Gtkmm2ext::Tabbable, public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr
{
public:
static Mixer_UI* instance();
@ -120,6 +121,12 @@ class Mixer_UI : public Gtkmm2ext::Tabbable, public PBD::ScopedConnectionList, p
sigc::signal1<void,boost::shared_ptr<ARDOUR::VCA> > show_vca_change;
RouteProcessorSelection& selection() { return _selection; }
void register_actions ();
void load_bindings ();
Gtkmm2ext::Bindings* bindings;
protected:
void set_axis_targets_for_operation ();
@ -376,6 +383,28 @@ class Mixer_UI : public Gtkmm2ext::Tabbable, public PBD::ScopedConnectionList, p
mutable boost::weak_ptr<ARDOUR::VCA> spilled_vca;
void escape ();
Gtkmm2ext::ActionMap myactions;
RouteProcessorSelection _selection;
AxisViewSelection _axis_targets;
void vca_assign (boost::shared_ptr<ARDOUR::VCA>);
void vca_unassign (boost::shared_ptr<ARDOUR::VCA>);
template<class T> void control_action (boost::shared_ptr<T> (ARDOUR::Stripable::*get_control)() const);
void solo_action ();
void mute_action ();
void rec_enable_action ();
void step_gain_up_action ();
void step_gain_down_action ();
void unity_gain_action ();
void copy_processors ();
void cut_processors ();
void paste_processors ();
void select_all_processors ();
void toggle_processors ();
void ab_plugins ();
};
#endif /* __ardour_mixer_ui_h__ */

View File

@ -154,7 +154,6 @@ gtk2_ardour_sources = [
'midi_velocity_dialog.cc',
'missing_file_dialog.cc',
'missing_plugin_dialog.cc',
'mixer_actor.cc',
'mixer_group_tabs.cc',
'mixer_strip.cc',
'mixer_ui.cc',