using namespace ARDOUR;
using namespace PBD;
+uint32_t RouteUI::_max_invert_buttons = 3;
+
RouteUI::RouteUI (ARDOUR::Session* sess)
: AxisView(sess)
{
delete mute_menu;
delete sends_menu;
delete record_menu;
+ delete _invert_menu;
}
void
solo_menu = 0;
sends_menu = 0;
record_menu = 0;
+ _invert_menu = 0;
pre_fader_mute_check = 0;
post_fader_mute_check = 0;
listen_mute_check = 0;
solo_isolated_check = 0;
solo_isolated_led = 0;
solo_safe_led = 0;
- ignore_toggle = false;
_solo_release = 0;
_mute_release = 0;
- route_active_menu_item = 0;
denormal_menu_item = 0;
step_edit_item = 0;
multiple_mute_change = false;
multiple_solo_change = false;
+ _i_am_the_modifier = 0;
- invert_button = manage (new BindableToggleButton ());
- // mute_button->set_self_managed (true);
- invert_button->set_name ("InvertButton");
- invert_button->add (invert_button_label);
- invert_button_label.show ();
- UI::instance()->set_tip (invert_button, _("Invert (Phase reverse) this track"), "");
+ setup_invert_buttons ();
mute_button = manage (new BindableToggleButton ());
// mute_button->set_self_managed (true);
solo_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::solo_release), false);
mute_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::mute_press), false);
mute_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::mute_release), false);
- invert_button->signal_toggled().connect (sigc::mem_fun(*this, &RouteUI::invert_toggled), false);
-
}
void
xml_node = 0;
}
- route_active_menu_item = 0;
denormal_menu_item = 0;
}
_route->phase_invert_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::polarity_changed, this), gui_context());
_route->PropertyChanged.connect (route_connections, invalidator (*this), ui_bind (&RouteUI::property_changed, this, _1), gui_context());
+ _route->io_changed.connect (route_connections, invalidator (*this), ui_bind (&RouteUI::setup_invert_buttons, this), gui_context ());
+
if (_session->writable() && is_track()) {
boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(_route);
solo_button->unset_flags (Gtk::CAN_FOCUS);
mute_button->show();
- invert_button->show ();
if (_route->is_monitor()) {
solo_button->hide ();
}
map_frozen ();
-}
-void
-RouteUI::invert_toggled ()
-{
- _route->set_phase_invert (invert_button->get_active());
+ setup_invert_buttons ();
+ set_invert_button_state ();
}
void
if (!_route) {
return;
}
-
- if (_route->phase_invert()) {
- invert_button->set_active (true);
- } else {
- invert_button->set_active (false);
- }
+
+ set_invert_button_state ();
}
bool
multiple_mute_change = false;
- if (!ignore_toggle) {
+ if (!_i_am_the_modifier) {
if (Keyboard::is_context_menu_event (ev)) {
bool
RouteUI::mute_release (GdkEventButton*)
{
- if (!ignore_toggle) {
+ if (!_i_am_the_modifier) {
if (_mute_release){
_session->set_mute (_mute_release->routes, _mute_release->active, Session::rt_cleanup, true);
delete _mute_release;
multiple_solo_change = false;
- if (!ignore_toggle) {
+ if (!_i_am_the_modifier) {
if (Keyboard::is_context_menu_event (ev)) {
}
if (Config->get_solo_control_is_listen_control()) {
- _session->set_listen (_session->get_routes(), !_route->listening(), Session::rt_cleanup, true);
+ _session->set_listen (_session->get_routes(), !_route->listening_via_monitor(), Session::rt_cleanup, true);
} else {
_session->set_solo (_session->get_routes(), !_route->self_soloed(), Session::rt_cleanup, true);
}
}
if (Config->get_solo_control_is_listen_control()) {
- _session->set_listen (_route->route_group()->route_list(), !_route->listening(), Session::rt_cleanup, true);
+ _session->set_listen (_route->route_group()->route_list(), !_route->listening_via_monitor(), Session::rt_cleanup, true);
} else {
_session->set_solo (_route->route_group()->route_list(), !_route->self_soloed(), Session::rt_cleanup, true);
}
}
if (Config->get_solo_control_is_listen_control()) {
- _session->set_listen (rl, !_route->listening());
+ _session->set_listen (rl, !_route->listening_via_monitor());
} else {
_session->set_solo (rl, !_route->self_soloed());
}
bool
RouteUI::solo_release (GdkEventButton*)
{
- if (!ignore_toggle) {
+ if (!_i_am_the_modifier) {
if (_solo_release) {
}
}
- if (!ignore_toggle && is_track() && rec_enable_button) {
+ if (!_i_am_the_modifier && is_track() && rec_enable_button) {
if (Keyboard::is_button2_event (ev)) {
using namespace Menu_Helpers;
MenuList& items = record_menu->items();
- items.push_back (CheckMenuElem (_("Step Edit"), sigc::mem_fun (*this, &RouteUI::toggle_step_edit)));
+ items.push_back (CheckMenuElem (_("Step Entry"), sigc::mem_fun (*this, &RouteUI::toggle_step_edit)));
step_edit_item = dynamic_cast<CheckMenuItem*> (&items.back());
if (_route->record_enabled()) {
sends_menu->set_name ("ArdourContextMenu");
MenuList& items = sends_menu->items();
- items.push_back (MenuElem(_("Assign all tracks (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PreFader)));
- items.push_back (MenuElem(_("Assign all tracks (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PostFader)));
- items.push_back (MenuElem(_("Assign selected tracks (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PreFader)));
- items.push_back (MenuElem(_("Assign selected tracks (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PostFader)));
- items.push_back (MenuElem(_("Copy track gains to sends"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_from_track)));
+ items.push_back (
+ MenuElem(_("Assign all tracks (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PreFader, false))
+ );
+
+ items.push_back (
+ MenuElem(_("Assign all tracks and buses (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PreFader, true))
+ );
+
+ items.push_back (
+ MenuElem(_("Assign all tracks (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PostFader, false))
+ );
+
+ items.push_back (
+ MenuElem(_("Assign all tracks and buses (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PostFader, true))
+ );
+
+ items.push_back (
+ MenuElem(_("Assign selected tracks (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PreFader, false))
+ );
+
+ items.push_back (
+ MenuElem(_("Assign selected tracks and buses (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PreFader, true)));
+
+ items.push_back (
+ MenuElem(_("Assign selected tracks (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PostFader, false))
+ );
+
+ items.push_back (
+ MenuElem(_("Assign selected tracks and buses (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PostFader, true))
+ );
+
+ items.push_back (MenuElem(_("Copy track/bus gains to sends"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_from_track)));
items.push_back (MenuElem(_("Set sends gain to -inf"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_to_zero)));
items.push_back (MenuElem(_("Set sends gain to 0dB"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_to_unity)));
}
void
-RouteUI::create_sends (Placement p)
+RouteUI::create_sends (Placement p, bool include_buses)
{
- _session->globally_add_internal_sends (_route, p);
+ _session->globally_add_internal_sends (_route, p, include_buses);
}
void
-RouteUI::create_selected_sends (Placement p)
+RouteUI::create_selected_sends (Placement p, bool include_buses)
{
boost::shared_ptr<RouteList> rlist (new RouteList);
TrackSelection& selected_tracks (ARDOUR_UI::instance()->the_editor().get_selection().tracks);
RouteUI* rui;
if ((rtv = dynamic_cast<RouteTimeAxisView*>(*i)) != 0) {
if ((rui = dynamic_cast<RouteUI*>(rtv)) != 0) {
- if (boost::dynamic_pointer_cast<AudioTrack>(rui->route())) {
+ if (include_buses || boost::dynamic_pointer_cast<AudioTrack>(rui->route())) {
rlist->push_back (rui->route());
}
}
return true;
}
- if (!ignore_toggle && !is_track() && show_sends_button) {
+ if (!_i_am_the_modifier && !is_track() && show_sends_button) {
if (Keyboard::is_button2_event (ev) && Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
if (Config->get_solo_control_is_listen_control()) {
- if (r->listening()) {
+ if (r->listening_via_monitor()) {
return 1;
} else {
return 0;
if (Config->get_solo_control_is_listen_control()) {
- if (r->listening()) {
+ if (r->listening_via_monitor()) {
return 1;
} else {
return 0;
if (Config->get_solo_control_is_listen_control()) {
- if (solo_button->get_active() != (x = _route->listening())) {
- ignore_toggle = true;
+ if (solo_button->get_active() != (x = _route->listening_via_monitor())) {
+ ++_i_am_the_modifier;
solo_button->set_active(x);
- ignore_toggle = false;
+ --_i_am_the_modifier;
}
} else {
if (solo_button->get_active() != (x = _route->soloed())) {
- ignore_toggle = true;
+ ++_i_am_the_modifier;
solo_button->set_active (x);
- ignore_toggle = false;
+ --_i_am_the_modifier;
}
}
return 0;
}
- if (Config->get_show_solo_mutes()) {
+
+ if (Config->get_show_solo_mutes() && !Config->get_solo_control_is_listen_control ()) {
if (r->muted ()) {
/* full mute */
*/
if (model != view) {
- ignore_toggle = true;
+ ++_i_am_the_modifier;
mute_button->set_active (model);
- ignore_toggle = false;
+ --_i_am_the_modifier;
}
- mute_button->set_visual_state (mute_visual_state (_session, _route));
+ mute_button->set_visual_state (mute_visual_state (_session, _route));
}
void
*/
if (model != view) {
- ignore_toggle = true;
+ ++_i_am_the_modifier;
rec_enable_button->set_active (model);
- ignore_toggle = false;
+ --_i_am_the_modifier;
}
/* now make sure its color state is correct */
}
bool
-RouteUI::solo_safe_button_release (GdkEventButton* ev)
+RouteUI::solo_safe_button_release (GdkEventButton*)
{
_route->set_solo_safe (!(solo_safe_led->visual_state() > 0), this);
return true;
_route->set_solo_safe (check->get_active(), this);
}
-bool
-RouteUI::choose_color()
+/** Ask the user to choose a colour, and then set all selected tracks
+ * to that colour.
+ */
+void
+RouteUI::choose_color ()
{
bool picked;
- Gdk::Color color;
-
- color = Gtkmm2ext::UI::instance()->get_color (_("Color Selection"), picked, &_color);
+ Gdk::Color const color = Gtkmm2ext::UI::instance()->get_color (_("Color Selection"), picked, &_color);
if (picked) {
- set_color (color);
+ ARDOUR_UI::instance()->the_editor().get_selection().tracks.foreach_route_ui (
+ boost::bind (&RouteUI::set_color, _1, color)
+ );
}
-
- return picked;
}
void
if ((xml_node = _route->extra_xml ("GUI")) == 0) {
xml_node = new XMLNode ("GUI");
_route->add_extra_xml (*xml_node);
+ } else {
+ /* the Route has one; it may have been loaded */
+ if (Stateful::loading_state_version != 0 && Stateful::loading_state_version < 3000) {
+ /* the GUI extra XML is in 2.X format; we must convert it to the new
+ format to avoid problems later
+ */
+
+ XMLNode* new_xml_node = new XMLNode (X_("GUI"));
+ XMLPropertyList old_gui_props = xml_node->properties ();
+ for (XMLPropertyIterator i = old_gui_props.begin(); i != old_gui_props.end(); ++i) {
+ new_xml_node->add_property ((*i)->name().c_str (), (*i)->value().c_str ());
+ }
+
+ XMLNodeList old_children = xml_node->children ();
+ for (XMLNodeConstIterator i = old_children.begin(); i != old_children.end(); ++i) {
+ XMLNode* new_child = new XMLNode (AutomationTimeAxisView::state_node_name);
+ new_child->add_property (X_("automation-id"), (*i)->name());
+
+ XMLPropertyList old_props = (*i)->properties ();
+ for (XMLPropertyIterator j = old_props.begin(); j != old_props.end(); ++j) {
+ new_child->add_property ((*j)->name().c_str (), (*j)->value().c_str ());
+ }
+
+ new_xml_node->add_child_nocopy (*new_child);
+ }
+
+ _route->add_extra_xml (*new_xml_node);
+ xml_node = new_xml_node;
+ }
}
}
}
const string sym = ARDOUR::EventTypeMap::instance().to_symbol(param);
for (iter = kids.begin(); iter != kids.end(); ++iter) {
+
if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
XMLProperty* type = (*iter)->property("automation-id");
- if (type && type->value() == sym)
+ if (type && type->value() == sym) {
return *iter;
+ }
}
}
}
void
-RouteUI::remove_this_route ()
+RouteUI::remove_this_route (bool apply_to_selection)
{
- if ((route()->is_master() || route()->is_monitor()) &&
- !Config->get_allow_special_bus_removal()) {
- MessageDialog msg (_("That would be bad news ...."),
- false,
- Gtk::MESSAGE_INFO,
+ if (apply_to_selection) {
+ ARDOUR_UI::instance()->the_editor().get_selection().tracks.foreach_route_ui (boost::bind (&RouteUI::remove_this_route, _1, false));
+ } else {
+ if ((route()->is_master() || route()->is_monitor()) &&
+ !Config->get_allow_special_bus_removal()) {
+ MessageDialog msg (_("That would be bad news ...."),
+ false,
+ Gtk::MESSAGE_INFO,
Gtk::BUTTONS_OK);
- msg.set_secondary_text (string_compose (_(
+ msg.set_secondary_text (string_compose (_(
"Removing the master or monitor bus is such a bad idea\n\
that %1 is not going to allow it.\n\
\n\
edit your ardour.rc file to set the\n\
\"allow-special-bus-removal\" option to be \"yes\""), PROGRAM_NAME));
- msg.present ();
- msg.run ();
- return;
- }
-
- vector<string> choices;
- string prompt;
-
- if (is_track()) {
- prompt = string_compose (_("Do you really want to remove track \"%1\" ?\n\nYou may also lose the playlist used by this track.\n(this cannot be undone)"), _route->name());
- } else {
- prompt = string_compose (_("Do you really want to remove bus \"%1\" ?\n(this cannot be undone)"), _route->name());
- }
-
- choices.push_back (_("No, do nothing."));
- choices.push_back (_("Yes, remove it."));
-
- string title;
- if (is_track()) {
- title = _("Remove track");
- } else {
- title = _("Remove bus");
- }
-
- Choice prompter (title, prompt, choices);
-
- if (prompter.run () == 1) {
- Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (&RouteUI::idle_remove_this_route), this));
+ msg.present ();
+ msg.run ();
+ return;
+ }
+
+ vector<string> choices;
+ string prompt;
+
+ if (is_track()) {
+ prompt = string_compose (_("Do you really want to remove track \"%1\" ?\n\nYou may also lose the playlist used by this track.\n\n(This action cannot be undone, and the session file will be overwritten)"), _route->name());
+ } else {
+ prompt = string_compose (_("Do you really want to remove bus \"%1\" ?\n\nYou may also lose the playlist used by this track.\n\n(This action cannot be undone, and the session file will be overwritten)"), _route->name());
+ }
+
+ choices.push_back (_("No, do nothing."));
+ choices.push_back (_("Yes, remove it."));
+
+ string title;
+ if (is_track()) {
+ title = _("Remove track");
+ } else {
+ title = _("Remove bus");
+ }
+
+ Choice prompter (title, prompt, choices);
+
+ if (prompter.run () == 1) {
+ Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (&RouteUI::idle_remove_this_route), this));
+ }
}
}
name_prompter.show_all ();
switch (name_prompter.run ()) {
-
case Gtk::RESPONSE_ACCEPT:
- name_prompter.get_result (result);
- if (result.length()) {
+ name_prompter.get_result (result);
+ if (result.length()) {
_route->set_name (result);
}
break;
}
void
-RouteUI::toggle_route_active ()
+RouteUI::set_route_active (bool a, bool apply_to_selection)
{
- bool yn;
-
- if (route_active_menu_item) {
- if (route_active_menu_item->get_active() != (yn = _route->active())) {
- _route->set_active (!yn);
- }
- }
-}
-
-void
-RouteUI::route_active_changed ()
-{
- if (route_active_menu_item) {
- Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&CheckMenuItem::set_active, route_active_menu_item, _route->active()));
+ if (apply_to_selection) {
+ ARDOUR_UI::instance()->the_editor().get_selection().tracks.foreach_route_ui (boost::bind (&RouteTimeAxisView::set_route_active, _1, a, false));
+ } else {
+ _route->set_active (a, this);
}
}
-
void
RouteUI::toggle_denormal_protection ()
{
return boost::dynamic_pointer_cast<MidiTrack>(_route);
}
+bool
+RouteUI::has_audio_outputs () const
+{
+ return (_route->n_outputs().n_audio() > 0);
+}
+
string
RouteUI::name() const
{
RouteUI::save_as_template ()
{
sys::path path;
- Glib::ustring safe_name;
+ std::string safe_name;
string name;
path = ARDOUR::user_route_template_directory ();
p.set_title (_("Save As Template"));
p.set_prompt (_("Template name:"));
+ p.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
switch (p.run()) {
case RESPONSE_ACCEPT:
break;
{
if (p == "disable-disarm-during-roll") {
check_rec_enable_sensitivity ();
- } else if (p == "solo-control-is-listen-control") {
- set_button_names ();
- } else if (p == "listen-position") {
+ } else if (p == "use-monitor-bus" || p == "solo-control-is-listen-control" || p == "listen-position") {
set_button_names ();
}
}
_route->set_remote_control_id (spin->get_value_as_int ());
}
}
+
+void
+RouteUI::setup_invert_buttons ()
+{
+ /* remove old invert buttons */
+ for (list<BindableToggleButton*>::iterator i = _invert_buttons.begin(); i != _invert_buttons.end(); ++i) {
+ _invert_button_box.remove (**i);
+ }
+
+ _invert_buttons.clear ();
+
+ if (!_route || !_route->input()) {
+ return;
+ }
+
+ uint32_t const N = _route->input()->n_ports().n_audio ();
+
+ uint32_t const to_add = (N <= _max_invert_buttons) ? N : 1;
+
+ for (uint32_t i = 0; i < to_add; ++i) {
+ BindableToggleButton* b = manage (new BindableToggleButton);
+ b->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::invert_toggled), i, b));
+ b->signal_button_press_event().connect (sigc::mem_fun (*this, &RouteUI::invert_press));
+
+ b->set_name (X_("MixerInvertButton"));
+ if (to_add == 1) {
+ b->add (*manage (new Label (X_("Ø"))));
+ } else {
+ b->add (*manage (new Label (string_compose (X_("Ø%1"), i + 1))));
+ }
+
+ if (N <= 4) {
+ UI::instance()->set_tip (*b, string_compose (_("Left-click to invert (phase reverse) channel %1 of this track. Right-click to show menu."), i + 1));
+ } else {
+ UI::instance()->set_tip (*b, string_compose (_("Left-click to invert (phase reverse) all channels of this track. Right-click to show menu."), i + 1));
+ }
+
+ _invert_buttons.push_back (b);
+ _invert_button_box.pack_start (*b);
+ }
+
+ _invert_button_box.show_all ();
+}
+
+void
+RouteUI::set_invert_button_state ()
+{
+ ++_i_am_the_modifier;
+
+ uint32_t const N = _route->input()->n_ports().n_audio();
+ if (N > _max_invert_buttons) {
+ _invert_buttons.front()->set_active (_route->phase_invert().any());
+ --_i_am_the_modifier;
+ return;
+ }
+
+ int j = 0;
+ for (list<BindableToggleButton*>::iterator i = _invert_buttons.begin(); i != _invert_buttons.end(); ++i, ++j) {
+ (*i)->set_active (_route->phase_invert (j));
+ }
+
+ --_i_am_the_modifier;
+}
+
+void
+RouteUI::invert_toggled (uint32_t i, BindableToggleButton* b)
+{
+ if (_i_am_the_modifier) {
+ return;
+ }
+
+ uint32_t const N = _route->input()->n_ports().n_audio();
+ if (N <= _max_invert_buttons) {
+ _route->set_phase_invert (i, b->get_active ());
+ } else {
+ boost::dynamic_bitset<> p (N);
+ if (b->get_active ()) {
+ p.set ();
+ }
+ _route->set_phase_invert (p);
+ }
+}
+
+bool
+RouteUI::invert_press (GdkEventButton* ev)
+{
+ using namespace Menu_Helpers;
+
+ if (ev->button != 3) {
+ return true;
+ }
+
+ delete _invert_menu;
+ _invert_menu = new Menu;
+ _invert_menu->set_name ("ArdourContextMenu");
+ MenuList& items = _invert_menu->items ();
+
+ uint32_t const N = _route->input()->n_ports().n_audio();
+ for (uint32_t i = 0; i < N; ++i) {
+ items.push_back (CheckMenuElem (string_compose (X_("Ø%1"), i + 1), sigc::bind (sigc::mem_fun (*this, &RouteUI::invert_menu_toggled), i)));
+ CheckMenuItem* e = dynamic_cast<CheckMenuItem*> (&items.back ());
+ ++_i_am_the_modifier;
+ e->set_active (_route->phase_invert (i));
+ --_i_am_the_modifier;
+ }
+
+ _invert_menu->popup (0, ev->time);
+
+ return false;
+}
+
+void
+RouteUI::invert_menu_toggled (uint32_t c)
+{
+ if (_i_am_the_modifier) {
+ return;
+ }
+
+ _route->set_phase_invert (c, !_route->phase_invert (c));
+}
+
+void
+RouteUI::set_invert_sensitive (bool yn)
+{
+ for (list<BindableToggleButton*>::iterator b = _invert_buttons.begin(); b != _invert_buttons.end(); ++b) {
+ (*b)->set_sensitive (yn);
+ }
+}