X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmixer_ui.cc;h=d982e5a30142f72e57a88b08c14afbcfbcced823;hb=2bec17ca1ac04dd716363906991ec35859a1b9dc;hp=4c5d60d6c753c27479b2a7efe9df713f6c8ae532;hpb=d41d6122769cabdb51922297f37bfc8e667dc9fd;p=ardour.git diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index 4c5d60d6c7..d982e5a301 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -27,31 +27,34 @@ #include +#include + #include +#include #include "pbd/convert.h" #include "pbd/stacktrace.h" #include "pbd/unwind.h" -#include - -#include -#include -#include -#include -#include -#include - #include "ardour/amp.h" #include "ardour/debug.h" #include "ardour/audio_track.h" #include "ardour/midi_track.h" #include "ardour/plugin_manager.h" #include "ardour/route_group.h" +#include "ardour/selection.h" #include "ardour/session.h" #include "ardour/vca.h" #include "ardour/vca_manager.h" +#include "gtkmm2ext/gtk_ui.h" +#include "gtkmm2ext/keyboard.h" +#include "gtkmm2ext/utils.h" +#include "gtkmm2ext/window_title.h" +#include "gtkmm2ext/doi.h" + +#include "widgets/tearoff.h" + #include "keyboard.h" #include "mixer_ui.h" #include "mixer_strip.h" @@ -60,7 +63,6 @@ #include "public_editor.h" #include "mouse_cursors.h" #include "ardour_ui.h" -#include "prompter.h" #include "utils.h" #include "route_sorter.h" #include "actions.h" @@ -105,11 +107,12 @@ Mixer_UI::Mixer_UI () , _plugin_selector (0) , _strip_width (UIConfiguration::instance().get_default_narrow_ms() ? Narrow : Wide) , ignore_reorder (false) - , _in_group_rebuild_or_clear (false) - , _route_deletion_in_progress (false) + , _in_group_rebuild_or_clear (false) + , _route_deletion_in_progress (false) , _maximised (false) , _show_mixer_list (true) , myactions (X_("mixer")) + , _selection (*this, *this) { register_actions (); load_bindings (); @@ -278,33 +281,28 @@ Mixer_UI::Mixer_UI () list_hpane.add (global_hpacker); list_hpane.set_child_minsize (list_vpacker, 1); - XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings(); float fract; - { - LocaleGuard lg; - - if (!settings || !settings->get_property ("mixer-rhs-pane1-pos", fract) || fract > 1.0) { - fract = 0.6f; - } - rhs_pane1.set_divider (0, fract); + if (!settings || !settings->get_property ("mixer-rhs-pane1-pos", fract) || fract > 1.0) { + fract = 0.6f; + } + rhs_pane1.set_divider (0, fract); - if (!settings || !settings->get_property ("mixer-rhs-pane2-pos", fract) || fract > 1.0) { - fract = 0.7f; - } - rhs_pane2.set_divider (0, fract); + if (!settings || !settings->get_property ("mixer-rhs-pane2-pos", fract) || fract > 1.0) { + fract = 0.7f; + } + rhs_pane2.set_divider (0, fract); - if (!settings || !settings->get_property ("mixer-list-hpane-pos", fract) || fract > 1.0) { - fract = 0.2f; - } - list_hpane.set_divider (0, fract); + if (!settings || !settings->get_property ("mixer-list-hpane-pos", fract) || fract > 1.0) { + fract = 0.2f; + } + list_hpane.set_divider (0, fract); - if (!settings || !settings->get_property ("mixer-inner-pane-pos", fract) || fract > 1.0) { - fract = 0.8f; - } - inner_pane.set_divider (0, fract); + if (!settings || !settings->get_property ("mixer-inner-pane-pos", fract) || fract > 1.0) { + fract = 0.8f; } + inner_pane.set_divider (0, fract); rhs_pane1.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down); rhs_pane2.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down); @@ -445,7 +443,7 @@ Mixer_UI::remove_master (VCAMasterStrip* vms) for (ri = rows.begin(); ri != rows.end(); ++ri) { if ((*ri)[stripable_columns.strip] == vms) { - PBD::Unwinder uw (_route_deletion_in_progress, true); + PBD::Unwinder uw (_route_deletion_in_progress, true); track_model->erase (ri); break; } @@ -496,7 +494,7 @@ Mixer_UI::add_stripables (StripableList& slist) bool from_scratch = (track_model->children().size() == 0); uint32_t nroutes = 0; - slist.sort (StripablePresentationInfoSorter()); + slist.sort (Stripable::Sorter()); for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) { boost::shared_ptr s = (*it)[stripable_columns.stripable]; @@ -507,6 +505,7 @@ Mixer_UI::add_stripables (StripableList& slist) nroutes++; + // XXX what does this special case do? if (s->presentation_info().order() == (slist.front()->presentation_info().order() + slist.size())) { insert_iter = it; break; @@ -562,7 +561,11 @@ Mixer_UI::add_stripables (StripableList& slist) _monitor_section->tearoff().Detach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_detached)); _monitor_section->tearoff().Attach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_attached)); - monitor_section_attached (); + if (_monitor_section->tearoff().torn_off()) { + monitor_section_detached (); + } else { + monitor_section_attached (); + } route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context()); @@ -630,13 +633,9 @@ Mixer_UI::deselect_all_strip_processors () } void -Mixer_UI::select_strip (MixerStrip& ms, bool add) +Mixer_UI::select_all_tracks () { - if (add) { - _selection.add (&ms); - } else { - _selection.set (&ms); - } + PublicEditor::instance().select_all_tracks (); } void @@ -671,9 +670,11 @@ Mixer_UI::remove_strip (MixerStrip* strip) strips.erase (i); } + PBD::Unwinder uwi (ignore_reorder, true); + for (ri = rows.begin(); ri != rows.end(); ++ri) { if ((*ri)[stripable_columns.strip] == strip) { - PBD::Unwinder uw (_route_deletion_in_progress, true); + PBD::Unwinder uw (_route_deletion_in_progress, true); track_model->erase (ri); break; } @@ -683,6 +684,10 @@ Mixer_UI::remove_strip (MixerStrip* strip) void Mixer_UI::presentation_info_changed (PropertyChange const & what_changed) { + if (what_changed.contains (Properties::selected)) { + _selection.presentation_info_changed (what_changed); + } + PropertyChange soh; soh.add (Properties::selected); soh.add (Properties::order); @@ -710,15 +715,9 @@ Mixer_UI::sync_presentation_info_from_treeview () TreeModel::Children::iterator ri; bool change = false; - uint32_t order = 0; - - OrderingKeys sorted; - const size_t cmp_max = rows.size (); - // special case master if it's got PI order 0 lets keep it there - if (_session->master_out() && (_session->master_out()->presentation_info().order() == 0)) { - order++; - } + PresentationInfo::order_t master_key = _session->master_order_key (); + PresentationInfo::order_t order = 0; PresentationInfo::ChangeSuspender cs; @@ -726,65 +725,36 @@ Mixer_UI::sync_presentation_info_from_treeview () bool visible = (*ri)[stripable_columns.visible]; boost::shared_ptr stripable = (*ri)[stripable_columns.stripable]; +#ifndef NDEBUG // these should not exist in the mixer's treeview if (!stripable) { + assert (0); continue; } - - /* Monitor and Auditioner do not get their presentation - * info reset here. - */ - if (stripable->is_monitor() || stripable->is_auditioner()) { + assert (0); continue; } - - /* Master also doesn't get set here but since the editor allows - * it to be reordered, we need to preserve its ordering. - */ + if (stripable->is_master()) { + assert (0); + continue; + } +#endif stripable->presentation_info().set_hidden (!visible); - // master may not get set here, but if it is zero keep it there - if (stripable->is_master() && (stripable->presentation_info().order() == 0)) { - continue; + // leave master where it is. + if (order == master_key) { + ++order; } if (order != stripable->presentation_info().order()) { stripable->set_presentation_order (order); change = true; } - - sorted.push_back (OrderKeys (order, stripable, cmp_max)); - ++order; } - if (!change) { - // VCA (and Mixbus) special cases according to SortByNewDisplayOrder - uint32_t n = 0; - SortByNewDisplayOrder cmp; - sort (sorted.begin(), sorted.end(), cmp); - for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) { - if (_session->master_out() && (_session->master_out()->presentation_info().order() == n)) { - ++n; - } - if (sr->old_display_order != n) { - change = true; - break; - } - } - if (change) { - n = 0; - for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) { - if (_session->master_out() && (_session->master_out()->presentation_info().order() == n)) { - ++n; - } - if (sr->stripable->presentation_info().order() != n) { - sr->stripable->set_presentation_order (n); - } - } - } - } + change |= _session->ensure_stripable_sort_order (); if (change) { DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n"); @@ -815,22 +785,20 @@ Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_chan return; } - OrderingKeys sorted; - const size_t cmp_max = rows.size (); - + TreeOrderKeys sorted; for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) { boost::shared_ptr stripable = (*ri)[stripable_columns.stripable]; - sorted.push_back (OrderKeys (old_order, stripable, cmp_max)); + sorted.push_back (TreeOrderKey (old_order, stripable)); } - SortByNewDisplayOrder cmp; + TreeOrderKeySorter cmp; sort (sorted.begin(), sorted.end(), cmp); neworder.assign (sorted.size(), 0); uint32_t n = 0; - for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) { + for (TreeOrderKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) { neworder[n] = sr->old_display_order; @@ -850,7 +818,7 @@ Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_chan for (list::const_iterator i = strips.begin(); i != strips.end(); ++i) { boost::shared_ptr stripable = (*i)->stripable(); - if (stripable && stripable->presentation_info().selected()) { + if (stripable && stripable->is_selected()) { _selection.add (*i); } else { _selection.remove (*i); @@ -891,7 +859,7 @@ Mixer_UI::strip_by_stripable (boost::shared_ptr s) const } AxisView* -Mixer_UI::axis_by_stripable (boost::shared_ptr s) const +Mixer_UI::axis_view_by_stripable (boost::shared_ptr s) const { for (list::const_iterator i = strips.begin(); i != strips.end(); ++i) { if ((*i)->stripable() == s) { @@ -902,6 +870,27 @@ Mixer_UI::axis_by_stripable (boost::shared_ptr s) const return 0; } +AxisView* +Mixer_UI::axis_view_by_control (boost::shared_ptr c) const +{ + for (list::const_iterator i = strips.begin(); i != strips.end(); ++i) { + if ((*i)->control() == c) { + return (*i); + } + } + + return 0; +} + +struct MixerStripSorter { + bool operator() (const MixerStrip* ms_a, const MixerStrip* ms_b) + { + boost::shared_ptr const& a = ms_a->stripable (); + boost::shared_ptr const& b = ms_b->stripable (); + return ARDOUR::Stripable::Sorter(true)(a, b); + } +}; + bool Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) { @@ -909,14 +898,19 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) if (_selection.selected (strip)) { /* primary-click: toggle selection state of strip */ if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { - _selection.remove (strip); + _selection.remove (strip, true); } else if (_selection.axes.size() > 1) { /* de-select others */ _selection.set (strip); } + PublicEditor& pe = PublicEditor::instance(); + TimeAxisView* tav = pe.time_axis_view_from_stripable (strip->stripable()); + if (tav) { + pe.set_selected_mixer_strip (*tav); + } } else { if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { - _selection.add (strip); + _selection.add (strip, true); } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) { /* extend selection */ @@ -925,16 +919,10 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) bool accumulate = false; bool found_another = false; - OrderingKeys sorted; - const size_t cmp_max = strips.size (); - for (list::iterator i = strips.begin(); i != strips.end(); ++i) { - sorted.push_back (OrderKeys (-1, (*i)->stripable(), cmp_max)); - } - SortByNewDisplayOrder cmp; - sort (sorted.begin(), sorted.end(), cmp); + strips.sort (MixerStripSorter()); - for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr) { - MixerStrip* ms = strip_by_stripable (sr->stripable); + for (list::iterator i = strips.begin(); i != strips.end(); ++i) { + MixerStrip* ms = *i; assert (ms); if (ms == strip) { @@ -970,7 +958,7 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) if (found_another) { PresentationInfo::ChangeSuspender cs; for (vector::iterator i = tmp.begin(); i != tmp.end(); ++i) { - _selection.add (*i); + _selection.add (*i, true); } } else { _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet @@ -1000,6 +988,7 @@ Mixer_UI::set_session (Session* sess) } if (!_session) { + _selection.clear (); return; } @@ -1029,6 +1018,13 @@ Mixer_UI::set_session (Session* sess) if (_visible) { show_window(); } + + /* catch up on selection state, etc. */ + + PropertyChange sc; + sc.add (Properties::selected); + _selection.presentation_info_changed (sc); + start_updating (); } @@ -1148,15 +1144,15 @@ Mixer_UI::hide_strip (MixerStrip* ms) gint Mixer_UI::start_updating () { - fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips)); - return 0; + fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips)); + return 0; } gint Mixer_UI::stop_updating () { - fast_screen_update_connection.disconnect(); - return 0; + fast_screen_update_connection.disconnect(); + return 0; } void @@ -1318,9 +1314,9 @@ Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&) DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n"); sync_presentation_info_from_treeview (); - if (_route_deletion_in_progress) { - redisplay_track_list (); - } + if (_route_deletion_in_progress) { + redisplay_track_list (); + } } void @@ -1667,6 +1663,10 @@ Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost: } } + if (s->is_master ()) { + return; + } + error << _("track display list item for renamed strip not found!") << endmsg; } @@ -2067,7 +2067,6 @@ private: int Mixer_UI::set_state (const XMLNode& node, int version) { - LocaleGuard lg; bool yn; Tabbable::set_state (node, version); @@ -2102,6 +2101,14 @@ Mixer_UI::set_state (const XMLNode& node, int version) tact->set_active (yn); } + if (node.get_property ("monitor-section-visible", yn)) { + Glib::RefPtr act = ActionManager::get_action ("Common", "ToggleMonitorSection"); + Glib::RefPtr tact = Glib::RefPtr::cast_dynamic(act); + /* do it twice to force the change */ + tact->set_active (yn); + show_monitor_section (yn); + } + XMLNode* plugin_order; if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) { @@ -2129,7 +2136,6 @@ XMLNode& Mixer_UI::get_state () { XMLNode* node = new XMLNode (X_("Mixer")); - LocaleGuard lg; node->add_child_nocopy (Tabbable::get_state()); @@ -2143,6 +2149,11 @@ Mixer_UI::get_state () node->set_property ("show-mixer-list", _show_mixer_list); node->set_property ("maximised", _maximised); + Glib::RefPtr act = ActionManager::get_action ("Common", "ToggleMonitorSection"); + Glib::RefPtr tact = Glib::RefPtr::cast_dynamic(act); + assert (tact); + node->set_property ("monitor-section-visible", tact->get_active ()); + store_current_favorite_order (); XMLNode* plugin_order = new XMLNode ("PluginOrder"); uint32_t cnt = 0; @@ -2252,10 +2263,6 @@ Mixer_UI::parameter_changed (string const & p) for (list::iterator i = strips.begin(); i != strips.end(); ++i) { (*i)->set_width_enum (s ? Narrow : Wide, this); } - } else if (p == "use-monitor-bus") { - if (_session && !_session->monitor_out()) { - monitor_section_detached (); - } } } @@ -2404,6 +2411,22 @@ void Mixer_UI::monitor_section_going_away () { if (_monitor_section) { + XMLNode* ui_node = Config->extra_xml(X_("UI")); + /* immediate state save. + * + * Tearoff settings are otherwise only stored during + * save_ardour_state(). The mon-section may or may not + * exist at that point. + * */ + if (ui_node) { + XMLNode* tearoff_node = ui_node->child (X_("Tearoffs")); + if (tearoff_node) { + tearoff_node->remove_nodes_and_delete (X_("monitor-section")); + XMLNode* t = new XMLNode (X_("monitor-section")); + _monitor_section->tearoff().add_state (*t); + tearoff_node->add_child_nocopy (*t); + } + } monitor_section_detached (); out_packer.remove (_monitor_section->tearoff()); _monitor_section->set_session (0); @@ -2468,7 +2491,7 @@ Mixer_UI::monitor_section_attached () Glib::RefPtr act = ActionManager::get_action ("Common", "ToggleMonitorSection"); Glib::RefPtr tact = Glib::RefPtr::cast_dynamic(act); act->set_sensitive (true); - tact->set_active (); + show_monitor_section (tact->get_active ()); } void @@ -2913,6 +2936,7 @@ Mixer_UI::register_actions () 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, "select-all-tracks", _("Select All Tracks"), sigc::mem_fun (*this, &Mixer_UI::select_all_tracks)); 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 right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right)); @@ -2972,29 +2996,44 @@ Mixer_UI::rec_enable_action () control_action (&Stripable::rec_enable_control); } -void -Mixer_UI::step_gain_up_action () +AutomationControlSet +Mixer_UI::selected_gaincontrols () { set_axis_targets_for_operation (); - + AutomationControlSet rv; BOOST_FOREACH(AxisView* r, _axis_targets) { MixerStrip* ms = dynamic_cast (r); if (ms) { - ms->step_gain_up (); + boost::shared_ptr ac (ms->route()->gain_control()); + ControlList cl (ac->grouped_controls()); + for (ControlList::const_iterator c = cl.begin(); c != cl.end (); ++c) { + rv.insert (*c); + } + rv.insert (ac); } } + return rv; } void -Mixer_UI::step_gain_down_action () +Mixer_UI::step_gain_up_action () { - set_axis_targets_for_operation (); + AutomationControlSet acs = selected_gaincontrols (); + for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) { + boost::shared_ptr ac = boost::dynamic_pointer_cast (*i); + assert (ac); + ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) + 0.1), Controllable::NoGroup); + } +} - BOOST_FOREACH(AxisView* r, _axis_targets) { - MixerStrip* ms = dynamic_cast (r); - if (ms) { - ms->step_gain_down (); - } +void +Mixer_UI::step_gain_down_action () +{ + AutomationControlSet acs = selected_gaincontrols (); + for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) { + boost::shared_ptr ac = boost::dynamic_pointer_cast (*i); + assert (ac); + ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) - 0.1), Controllable::NoGroup); } }