X-Git-Url: https://main.carlh.net/gitweb/?p=ardour.git;a=blobdiff_plain;f=gtk2_ardour%2Fmixer_ui.cc;h=b56ed4d601a1b8affb8a7d595886cd0e343ad3d0;hp=49862c36a505564c1c308db8a582a419ed6c86ff;hb=b94c9ef8e09d41c28e44baae36e67bdf06e3758e;hpb=94a57e64f655c238aebd2780ea6c8b6727c48177 diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index 49862c36a5..b56ed4d601 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" @@ -101,22 +103,21 @@ Mixer_UI::Mixer_UI () , no_track_list_redisplay (false) , in_group_row_change (false) , track_menu (0) - , _monitor_section (0) , _plugin_selector (0) , _strip_width (UIConfiguration::instance().get_default_narrow_ms() ? Narrow : Wide) + , _spill_scroll_position (0) , ignore_reorder (false) - , _in_group_rebuild_or_clear (false) - , _route_deletion_in_progress (false) - , _following_editor_selection (false) + , _in_group_rebuild_or_clear (false) + , _route_deletion_in_progress (false) , _maximised (false) - , _show_mixer_list (true) - , myactions (X_("mixer")) + , _strip_selection_change_without_scroll (false) + , _selection (*this, *this) { - register_actions (); load_bindings (); + register_actions (); _content.set_data ("ardour-bindings", bindings); - PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::sync_treeview_from_presentation_info, this), gui_context()); + PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::presentation_info_changed, this, _1), gui_context()); scroller.set_can_default (true); // set_default (scroller); @@ -132,8 +133,31 @@ Mixer_UI::Mixer_UI () scroller_base.drag_dest_set (target_table); scroller_base.signal_drag_data_received().connect (sigc::mem_fun(*this, &Mixer_UI::scroller_drag_data_received)); - // add as last item of strip packer + /* create a button to add VCA strips ... will get packed in redisplay_track_list() */ + Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON)); + w->show (); + add_vca_button.add (*w); + add_vca_button.set_can_focus(false); + add_vca_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus)); + + /* create a button to add mixer strips */ + w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON)); + w->show (); + add_button.add (*w); + add_button.set_can_focus(false); + add_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus)); + + /* add as last item of strip packer */ strip_packer.pack_end (scroller_base, true, true); + strip_packer.pack_end (add_button, false, false); + +#ifdef MIXBUS + /* create a drop-shadow at the end of the mixer strips */ + mb_shadow.set_size_request( 4, -1 ); + mb_shadow.set_name("EditorWindow"); + mb_shadow.show(); + strip_packer.pack_end (mb_shadow, false, false); +#endif _group_tabs = new MixerGroupTabs (this); VBox* b = manage (new VBox); @@ -142,6 +166,7 @@ Mixer_UI::Mixer_UI () b->pack_start (*_group_tabs, PACK_SHRINK); b->pack_start (strip_packer); b->show_all (); + b->signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false); scroller.add (*b); scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC); @@ -184,37 +209,13 @@ Mixer_UI::Mixer_UI () group_display_scroller.add (group_display); group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); - HBox* route_group_display_button_box = manage (new HBox()); - - Button* route_group_add_button = manage (new Button ()); - Button* route_group_remove_button = manage (new Button ()); - - Widget* w; - - w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON)); - w->show(); - route_group_add_button->add (*w); - - w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON)); - w->show(); - route_group_remove_button->add (*w); - - route_group_display_button_box->set_homogeneous (true); - - route_group_add_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_route_group)); - route_group_remove_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::remove_selected_route_group)); - - route_group_display_button_box->add (*route_group_add_button); - route_group_display_button_box->add (*route_group_remove_button); group_display_vbox.pack_start (group_display_scroller, true, true); - group_display_vbox.pack_start (*route_group_display_button_box, false, false); group_display_frame.set_name ("BaseFrame"); group_display_frame.set_shadow_type (Gtk::SHADOW_IN); group_display_frame.add (group_display_vbox); - list target_list; target_list.push_back (TargetEntry ("PluginPresetPtr")); @@ -227,7 +228,6 @@ Mixer_UI::Mixer_UI () favorite_plugins_display.set_headers_visible (true); favorite_plugins_display.set_rules_hint (true); favorite_plugins_display.set_can_focus (false); - favorite_plugins_display.set_tooltip_column (0); favorite_plugins_display.add_object_drag (favorite_plugins_columns.plugin.index(), "PluginFavoritePtr"); favorite_plugins_display.set_drag_column (favorite_plugins_columns.name.index()); favorite_plugins_display.add_drop_targets (target_list); @@ -236,6 +236,9 @@ Mixer_UI::Mixer_UI () favorite_plugins_display.signal_drop.connect (sigc::mem_fun (*this, &Mixer_UI::plugin_drop)); favorite_plugins_display.signal_row_expanded().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state)); favorite_plugins_display.signal_row_collapsed().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state)); + if (UIConfiguration::instance().get_use_tooltips()) { + favorite_plugins_display.set_tooltip_column (0); + } favorite_plugins_model->signal_row_has_child_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::sync_treeview_favorite_ui_state)); favorite_plugins_scroller.add (favorite_plugins_display); @@ -243,7 +246,11 @@ Mixer_UI::Mixer_UI () favorite_plugins_frame.set_name ("BaseFrame"); favorite_plugins_frame.set_shadow_type (Gtk::SHADOW_IN); - favorite_plugins_frame.add (favorite_plugins_scroller); + favorite_plugins_frame.add (favorite_plugins_vbox); + + favorite_plugins_vbox.pack_start (favorite_plugins_scroller, true, true); + favorite_plugins_vbox.pack_start (favorite_plugins_tag_combo, false, false); + favorite_plugins_tag_combo.signal_changed().connect (sigc::mem_fun (*this, &Mixer_UI::tag_combo_changed)); rhs_pane1.add (favorite_plugins_frame); rhs_pane1.add (track_display_frame); @@ -259,7 +266,6 @@ Mixer_UI::Mixer_UI () vca_scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK); vca_scroller_base.set_name (X_("MixerWindow")); vca_scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::masters_scroller_button_release), false); - vca_hpacker.pack_end (vca_scroller_base, true, true); vca_scroller.add (vca_hpacker); vca_scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC); @@ -276,37 +282,30 @@ Mixer_UI::Mixer_UI () list_hpane.set_check_divider_position (true); list_hpane.add (list_vpacker); list_hpane.add (global_hpacker); - list_hpane.set_child_minsize (list_vpacker, 1); - + list_hpane.set_child_minsize (list_vpacker, 30); XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings(); - XMLProperty const * prop; 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 || ((prop = settings->property ("mixer-rhs-pane1-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) { - rhs_pane1.set_divider (0, 0.6f); - } else { - rhs_pane1.set_divider (0, fract); - } - if (!settings || ((prop = settings->property ("mixer-rhs-pane2-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) { - rhs_pane2.set_divider (0, 0.7f); - } else { - rhs_pane2.set_divider (0, fract); - } - if (!settings || ((prop = settings->property ("mixer-list-hpane-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) { - list_hpane.set_divider (0, 0.2f); - } else { - list_hpane.set_divider (0, fract); - } - if (!settings || ((prop = settings->property ("mixer-inner-pane-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) { - inner_pane.set_divider (0, 0.8f); - } else { - inner_pane.set_divider (0, atof (prop->value())); - } + 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-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); @@ -317,10 +316,6 @@ Mixer_UI::Mixer_UI () update_title (); - route_group_display_button_box->show(); - route_group_add_button->show(); - route_group_remove_button->show(); - _content.show (); _content.set_name ("MixerWindow"); @@ -331,7 +326,6 @@ Mixer_UI::Mixer_UI () mixer_scroller_vpacker.show(); list_vpacker.show(); group_display_button_label.show(); - group_display_button.show(); group_display_scroller.show(); favorite_plugins_scroller.show(); group_display_vbox.show(); @@ -351,8 +345,15 @@ Mixer_UI::Mixer_UI () list_hpane.show(); group_display.show(); favorite_plugins_display.show(); + add_button.show (); + + XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section")); + if (mnode) { + _monitor_section.tearoff().set_state (*mnode); + } MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context()); + VCAMasterStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context()); /* handle escape */ @@ -363,20 +364,30 @@ Mixer_UI::Mixer_UI () #else #error implement deferred Plugin-Favorite list #endif - PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context()); - PluginManager::instance ().PluginStatusesChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context()); + + PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context()); + PluginManager::instance ().PluginStatusChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context()); ARDOUR::Plugin::PresetsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context()); } Mixer_UI::~Mixer_UI () { - if (_monitor_section) { - monitor_section_detached (); - delete _monitor_section; - } + monitor_section_detached (); + delete _plugin_selector; + delete track_menu; } +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); + } +}; + + void Mixer_UI::escape () { @@ -384,9 +395,9 @@ Mixer_UI::escape () } void -Mixer_UI::track_editor_selection () +Mixer_UI::tag_combo_changed () { - PublicEditor::instance().get_selection().TracksChanged.connect (sigc::mem_fun (*this, &Mixer_UI::follow_editor_selection)); + refill_favorite_plugins(); } Gtk::Window* @@ -396,14 +407,16 @@ Mixer_UI::use_own_window (bool and_fill_it) Gtk::Window* win = Tabbable::use_own_window (and_fill_it); - if (win && new_window) { win->set_name ("MixerWindow"); ARDOUR_UI::instance()->setup_toplevel_window (*win, _("Mixer"), this); - win->signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false); win->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), win)); win->set_data ("ardour-bindings", bindings); update_title (); + if (!win->get_focus()) { + /* set focus widget to something, anything */ + win->set_focus (scroller); + } } return win; @@ -450,7 +463,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; } @@ -501,7 +514,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]; @@ -512,6 +525,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; @@ -520,7 +534,6 @@ Mixer_UI::add_stripables (StripableList& slist) MixerStrip* strip; - try { PBD::Unwinder uw (no_track_list_redisplay, true); @@ -542,7 +555,7 @@ Mixer_UI::add_stripables (StripableList& slist) row[stripable_columns.strip] = vms; row[stripable_columns.stripable] = vca; - vms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context()); + vms->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::vca_button_release_event), vms)); } else if ((route = boost::dynamic_pointer_cast (*s))) { @@ -552,23 +565,18 @@ Mixer_UI::add_stripables (StripableList& slist) if (route->is_monitor()) { - if (!_monitor_section) { - _monitor_section = new MonitorSection (_session); - - XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section")); - if (mnode) { - _monitor_section->tearoff().set_state (*mnode); - } - } - - out_packer.pack_end (_monitor_section->tearoff(), false, false); - _monitor_section->set_session (_session); - _monitor_section->tearoff().show_all (); + out_packer.pack_end (_monitor_section.tearoff(), false, false); + _monitor_section.set_session (_session); + _monitor_section.tearoff().show_all (); - _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.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()); @@ -588,7 +596,12 @@ Mixer_UI::add_stripables (StripableList& slist) show_strip (strip); - if (!route->is_master()) { + if (route->is_master()) { + + out_packer.pack_start (*strip, false, false); + strip->set_packed (true); + + } else { TreeModel::Row row = *(track_model->insert (insert_iter)); @@ -596,15 +609,6 @@ Mixer_UI::add_stripables (StripableList& slist) row[stripable_columns.visible] = strip->marked_for_display(); row[stripable_columns.stripable] = route; row[stripable_columns.strip] = strip; - - if (nroutes != 0) { - _selection.add (strip); - } - - } else { - - out_packer.pack_start (*strip, false, false); - strip->set_packed (true); } strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed)); @@ -621,6 +625,9 @@ Mixer_UI::add_stripables (StripableList& slist) track_display.set_model (track_model); + /* catch up on selection state, which we left to the editor to set */ + sync_treeview_from_presentation_info (PropertyChange (Properties::selected)); + if (!from_scratch) { sync_presentation_info_from_treeview (); } @@ -637,20 +644,24 @@ Mixer_UI::deselect_all_strip_processors () } void -Mixer_UI::select_strip (MixerStrip& ms, bool add) +Mixer_UI::select_none () { - if (add) { - _selection.add (&ms); - } else { - _selection.set (&ms); - } + _selection.clear_routes(); + deselect_all_strip_processors(); } void -Mixer_UI::select_none () +Mixer_UI::select_next_strip () { - _selection.clear_routes(); deselect_all_strip_processors(); + _session->selection().select_next_stripable (true, false); +} + +void +Mixer_UI::select_prev_strip () +{ + deselect_all_strip_processors(); + _session->selection().select_prev_stripable (true, false); } void @@ -678,15 +689,34 @@ 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; } } } +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); + soh.add (Properties::hidden); + + if (what_changed.contains (soh)) { + sync_treeview_from_presentation_info (what_changed); + } +} + void Mixer_UI::sync_presentation_info_from_treeview () { @@ -704,74 +734,55 @@ 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 (); + PresentationInfo::order_t master_key = _session->master_order_key (); + PresentationInfo::order_t order = 0; - // 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::ChangeSuspender cs; for (ri = rows.begin(); ri != rows.end(); ++ri) { 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, false); + 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 (sr->old_display_order != n) { - change = true; - } - } - } + change |= _session->ensure_stripable_sort_order (); if (change) { DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n"); - _session->notify_presentation_info_change (); _session->set_dirty(); } } void -Mixer_UI::sync_treeview_from_presentation_info () +Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_changed) { if (!_session || _session->deletion_in_progress()) { return; @@ -793,22 +804,20 @@ Mixer_UI::sync_treeview_from_presentation_info () 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; @@ -822,35 +831,39 @@ Mixer_UI::sync_treeview_from_presentation_info () track_model->reorder (neworder); } - redisplay_track_list (); -} + if (what_changed.contains (Properties::selected)) { -void -Mixer_UI::follow_editor_selection () -{ - if (_following_editor_selection) { - return; - } - - _following_editor_selection = true; - _selection.block_routes_changed (true); + PresentationInfo::ChangeSuspender cs; - TrackSelection& s (PublicEditor::instance().get_selection().tracks); + for (list::const_iterator i = strips.begin(); i != strips.end(); ++i) { + boost::shared_ptr stripable = (*i)->stripable(); + if (stripable && stripable->is_selected()) { + _selection.add (*i); + } else { + _selection.remove (*i); + } + } - _selection.clear_routes (); + if (!_selection.axes.empty() && !PublicEditor::instance().track_selection_change_without_scroll () && !_strip_selection_change_without_scroll) { + move_stripable_into_view ((*_selection.axes.begin())->stripable()); + } - for (TrackViewList::iterator i = s.begin(); i != s.end(); ++i) { - TimeAxisView* tav = dynamic_cast (*i); - if (tav) { - AxisView* axis = axis_by_stripable (tav->stripable()); - if (axis) { - _selection.add (axis); + TreeModel::Children rows = track_model->children(); + for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) { + AxisView* av = (*i)[stripable_columns.strip]; + VCAMasterStrip* vms = dynamic_cast (av); + if (!vms) { + continue; + } + if (vms->vca() && vms->vca()->is_selected()) { + _selection.add (vms); + } else { + _selection.remove (vms); } } } - _following_editor_selection = false; - _selection.block_routes_changed (false); + redisplay_track_list (); } @@ -866,8 +879,20 @@ Mixer_UI::strip_by_route (boost::shared_ptr r) const return 0; } +MixerStrip* +Mixer_UI::strip_by_stripable (boost::shared_ptr s) const +{ + for (list::const_iterator i = strips.begin(); i != strips.end(); ++i) { + if ((*i)->stripable() == s) { + return (*i); + } + } + + return 0; +} + 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) { @@ -875,24 +900,61 @@ Mixer_UI::axis_by_stripable (boost::shared_ptr s) const } } + TreeModel::Children rows = track_model->children(); + for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) { + AxisView* av = (*i)[stripable_columns.strip]; + VCAMasterStrip* vms = dynamic_cast (av); + if (vms && vms->stripable () == s) { + return av; + } + } + + 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; } bool Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) { + /* Selecting a mixer-strip may also select grouped-tracks, and + * presentation_info_changed() being emitted and + * _selection.axes.begin() is being moved into view. This may + * effectively move the track that was clicked-on out of view. + * + * So here only the track that is actually clicked-on is moved into + * view (in case it's partially visible) + */ + PBD::Unwinder uw (_strip_selection_change_without_scroll, true); + move_stripable_into_view (strip->stripable()); + if (ev->button == 1) { 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 */ @@ -901,10 +963,13 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) bool accumulate = false; bool found_another = false; - tmp.push_back (strip); + strips.sort (MixerStripSorter()); for (list::iterator i = strips.begin(); i != strips.end(); ++i) { - if ((*i) == strip) { + MixerStrip* ms = *i; + assert (ms); + + if (ms == strip) { /* hit clicked strip, start accumulating till we hit the first selected strip */ @@ -914,7 +979,7 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) } else { accumulate = true; } - } else if (_selection.selected (*i)) { + } else if (_selection.selected (ms)) { /* hit selected strip. if currently accumulating others, we're done. if not accumulating others, start doing so. */ @@ -927,17 +992,21 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) } } else { if (accumulate) { - tmp.push_back (*i); + tmp.push_back (ms); } } } + tmp.push_back (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 + } else { _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet + } } else { _selection.set (strip); } @@ -947,10 +1016,18 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) return true; } +bool +Mixer_UI::vca_button_release_event (GdkEventButton *ev, VCAMasterStrip *strip) +{ + _selection.set (strip); + return true; +} + void Mixer_UI::set_session (Session* sess) { SessionHandlePtr::set_session (sess); + _monitor_section.set_session (sess); if (_plugin_selector) { _plugin_selector->set_session (_session); @@ -958,15 +1035,13 @@ Mixer_UI::set_session (Session* sess) _group_tabs->set_session (sess); - if (_monitor_section) { - _monitor_section->set_session (_session); - } - if (!_session) { + _selection.clear (); return; } refill_favorite_plugins(); + refill_tag_combo(); XMLNode* node = ARDOUR_UI::instance()->mixer_settings(); set_state (*node, 0); @@ -992,6 +1067,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 (); } @@ -1011,9 +1093,7 @@ Mixer_UI::session_going_away () delete (*i); } - if (_monitor_section) { - _monitor_section->tearoff().hide_visible (); - } + _monitor_section.tearoff().hide_visible (); monitor_section_detached (); @@ -1111,15 +1191,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 @@ -1281,9 +1361,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 @@ -1305,6 +1385,7 @@ Mixer_UI::spill_redisplay (boost::shared_ptr vca) AxisView* av = (*i)[stripable_columns.strip]; MixerStrip* strip = dynamic_cast (av); + bool const visible = (*i)[stripable_columns.visible]; if (!strip) { /* we're in the middle of changing a row, don't worry */ @@ -1328,7 +1409,7 @@ Mixer_UI::spill_redisplay (boost::shared_ptr vca) } } - if (slaved) { + if (slaved && visible) { if (strip->packed()) { strip_packer.reorder_child (*strip, -1); /* put at end */ @@ -1354,11 +1435,16 @@ Mixer_UI::redisplay_track_list () return; } - boost::shared_ptr sv = spilled_vca.lock (); - - if (sv) { - spill_redisplay (sv); - return; + boost::shared_ptr ss = spilled_strip.lock (); + if (ss) { + boost::shared_ptr sv = boost::dynamic_pointer_cast (ss); + if (sv) { + if (_spill_scroll_position <= 0 && scroller.get_hscrollbar()) { + _spill_scroll_position = scroller.get_hscrollbar()->get_adjustment()->get_value(); + } + spill_redisplay (sv); + return; + } } TreeModel::Children rows = track_model->children(); @@ -1366,7 +1452,12 @@ Mixer_UI::redisplay_track_list () uint32_t n_masters = 0; container_clear (vca_hpacker); + vca_hpacker.pack_end (vca_scroller_base, true, true); + vca_hpacker.pack_end (add_vca_button, false, false); + + add_vca_button.show (); + vca_scroller_base.show(); for (i = rows.begin(); i != rows.end(); ++i) { @@ -1421,14 +1512,35 @@ Mixer_UI::redisplay_track_list () /* update visibility of VCA assign buttons */ if (n_masters == 0) { + //show/hide the channelstrip VCA assign buttons on channelstrips: UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA"))); + + Glib::RefPtr act = ActionManager::get_action ("Mixer", "ToggleVCAPane"); + if (act) { + act->set_sensitive (false); + } + + //remove the VCA packer, but don't change our prior setting for show/hide: vca_vpacker.hide (); } else { + //show/hide the channelstrip VCA assign buttons on channelstrips: UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA"))); - vca_vpacker.show (); + + Glib::RefPtr act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane"); + act->set_sensitive (true); + + //if we were showing VCAs before, show them now: + showhide_vcas (act->get_active ()); } _group_tabs->set_dirty (); + + if (_spill_scroll_position > 0 && scroller.get_hscrollbar()) { + Adjustment* adj = scroller.get_hscrollbar()->get_adjustment(); + adj->set_value (max (adj->get_lower(), min (adj->get_upper(), _spill_scroll_position))); + } + _spill_scroll_position = 0; + } void @@ -1477,18 +1589,7 @@ void Mixer_UI::initial_track_display () { StripableList sl; - - boost::shared_ptr routes = _session->get_routes(); - - for (RouteList::iterator r = routes->begin(); r != routes->end(); ++r) { - sl.push_back (*r); - } - - VCAList vcas = _session->vca_manager().vcas(); - - for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) { - sl.push_back (boost::dynamic_pointer_cast (*v)); - } + _session->get_stripables (sl); sl.sort (PresentationInfoMixerSorter()); @@ -1503,25 +1604,17 @@ Mixer_UI::initial_track_display () add_stripables (sl); } - redisplay_track_list (); - sync_treeview_from_presentation_info (); -} - -void -Mixer_UI::show_track_list_menu () -{ - if (track_menu == 0) { - build_track_menu (); - } - - track_menu->popup (1, gtk_get_current_event_time()); + sync_treeview_from_presentation_info (Properties::order); } bool Mixer_UI::track_display_button_press (GdkEventButton* ev) { if (Keyboard::is_context_menu_event (ev)) { - show_track_list_menu (); + if (track_menu == 0) { + build_track_menu (); + } + track_menu->popup (ev->button, ev->time); return true; } if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) { @@ -1556,11 +1649,13 @@ Mixer_UI::move_stripable_into_view (boost::shared_ptr s) #endif bool found = false; int x0 = 0; + Gtk::Allocation alloc; for (list::const_iterator i = strips.begin(); i != strips.end(); ++i) { if ((*i)->route() == s) { int y; found = true; (*i)->translate_coordinates (strip_packer, 0, 0, x0, y); + alloc = (*i)->get_allocation (); break; } } @@ -1569,7 +1664,13 @@ Mixer_UI::move_stripable_into_view (boost::shared_ptr s) } Adjustment* adj = scroller.get_hscrollbar()->get_adjustment(); - scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), x0 - 1.0))); + + if (x0 < adj->get_value()) { + adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0))); + } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) { + int x1 = x0 + alloc.get_width() - adj->get_page_size(); + adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1))); + } } void @@ -1586,10 +1687,10 @@ Mixer_UI::build_track_menu () items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes))); items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks))); items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks))); - items.push_back (MenuElem (_("Show All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus))); - items.push_back (MenuElem (_("Hide All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus))); items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks))); items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks))); + items.push_back (MenuElem (_("Show All Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus))); + items.push_back (MenuElem (_("Hide All Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus))); } @@ -1627,6 +1728,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; } @@ -1639,13 +1744,17 @@ Mixer_UI::group_display_button_press (GdkEventButton* ev) int celly; if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) { - _group_tabs->get_menu(0)->popup (1, ev->time); + if (ev->button == 3) { + _group_tabs->get_menu(0)->popup (ev->button, ev->time); + } return true; } TreeIter iter = group_model->get_iter (path); if (!iter) { - _group_tabs->get_menu(0)->popup (1, ev->time); + if (ev->button == 3) { + _group_tabs->get_menu(0)->popup (ev->button, ev->time); + } return true; } @@ -1812,33 +1921,80 @@ Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& } void -Mixer_UI::show_mixer_list (bool yn) +Mixer_UI::toggle_mixer_list () +{ + Glib::RefPtr act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList"); + showhide_mixer_list (act->get_active()); +} + +void +Mixer_UI::showhide_mixer_list (bool yn) { if (yn) { list_vpacker.show (); } else { list_vpacker.hide (); } +} - _show_mixer_list = yn; +void +Mixer_UI::toggle_monitor_section () +{ + Glib::RefPtr act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection"); + showhide_monitor_section (act->get_active()); } + void -Mixer_UI::show_monitor_section (bool yn) +Mixer_UI::showhide_monitor_section (bool yn) { - if (!monitor_section()) { + if (monitor_section().tearoff().torn_off()) { return; } - if (monitor_section()->tearoff().torn_off()) { - return; + + if (yn) { + monitor_section().tearoff().show(); + } else { + monitor_section().tearoff().hide(); } +} + +void +Mixer_UI::toggle_vcas () +{ + Glib::RefPtr act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane"); + showhide_vcas (act->get_active()); +} +void +Mixer_UI::showhide_vcas (bool yn) +{ if (yn) { - monitor_section()->tearoff().show(); + vca_vpacker.show(); + } else { + vca_vpacker.hide(); + } +} + +#ifdef MIXBUS +void +Mixer_UI::toggle_mixbuses () +{ + Glib::RefPtr act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane"); + showhide_mixbuses (act->get_active()); +} + +void +Mixer_UI::showhide_mixbuses (bool on) +{ + if (on) { + mb_vpacker.show(); } else { - monitor_section()->tearoff().hide(); + mb_vpacker.hide(); } } +#endif + void Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text) @@ -1958,7 +2114,6 @@ Mixer_UI::strip_scroller_button_release (GdkEventButton* ev) void Mixer_UI::scroller_drag_data_received (const Glib::RefPtr& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time) { - printf ("Mixer_UI::scroller_drag_data_received\n"); if (data.get_target() != "PluginFavoritePtr") { context->drag_finish (false, false, time); return; @@ -1980,7 +2135,7 @@ Mixer_UI::scroller_drag_data_received (const Glib::RefPtr& con if (!pip->is_instrument ()) { continue; } - ARDOUR_UI::instance()->session_add_midi_track ((RouteGroup*) 0, 1, _("MIDI"), Config->get_strict_io (), pip, ppp->_preset.valid ? &ppp->_preset : 0, PresentationInfo::max_order); + ARDOUR_UI::instance()->session_add_midi_route (true, (RouteGroup*) 0, 1, _("MIDI"), Config->get_strict_io (), pip, ppp->_preset.valid ? &ppp->_preset : 0, PresentationInfo::max_order); ok = true; } @@ -2023,106 +2178,161 @@ private: int Mixer_UI::set_state (const XMLNode& node, int version) { - XMLProperty const * prop; - LocaleGuard lg; + bool yn; Tabbable::set_state (node, version); - if ((prop = node.property ("narrow-strips"))) { - if (string_is_affirmative (prop->value())) { + if (node.get_property ("narrow-strips", yn)) { + if (yn) { set_strip_width (Narrow); } else { set_strip_width (Wide); } } - if ((prop = node.property ("show-mixer"))) { - if (string_is_affirmative (prop->value())) { - _visible = true; - } - } + node.get_property ("show-mixer", _visible); - if ((prop = node.property ("maximised"))) { - bool yn = string_is_affirmative (prop->value()); - Glib::RefPtr act = ActionManager::get_action (X_("Common"), X_("ToggleMaximalMixer")); - assert (act); - Glib::RefPtr tact = Glib::RefPtr::cast_dynamic(act); - bool fs = tact && tact->get_active(); + if (node.get_property ("maximised", yn)) { + Glib::RefPtr act = ActionManager::get_toggle_action (X_("Common"), X_("ToggleMaximalMixer")); + bool fs = act && act->get_active(); if (yn ^ fs) { ActionManager::do_action ("Common", "ToggleMaximalMixer"); } } - if ((prop = node.property ("show-mixer-list"))) { - bool yn = string_is_affirmative (prop->value()); - Glib::RefPtr act = ActionManager::get_action (X_("Common"), X_("ToggleMixerList")); - assert (act); - Glib::RefPtr tact = Glib::RefPtr::cast_dynamic(act); + if (node.get_property ("show-mixer-list", yn)) { + Glib::RefPtr act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixerList")); /* do it twice to force the change */ - tact->set_active (!yn); - tact->set_active (yn); + act->set_active (!yn); + act->set_active (yn); } + if (node.get_property ("monitor-section-visible", yn)) { + Glib::RefPtr act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMonitorSection")); + /* do it twice to force the change */ + act->set_active (!yn); + act->set_active (yn); + } + + if (node.get_property ("show-vca-pane", yn)) { + Glib::RefPtr act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleVCAPane")); + /* do it twice to force the change */ + act->set_active (!yn); + act->set_active (yn); + } + +#ifdef MIXBUS + if (node.get_property ("show-mixbus-pane", yn)) { + Glib::RefPtr act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixbusPane")); + /* do it twice to force the change */ + act->set_active (!yn); + act->set_active (yn); + } - XMLNode* plugin_order; - if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) { +#endif + + //check for the user's plugin_order file + XMLNode plugin_order_new(X_("PO")); + if (PluginManager::instance().load_plugin_order_file(plugin_order_new)) { store_current_favorite_order (); std::list order; - const XMLNodeList& kids = plugin_order->children("PluginInfo"); + const XMLNodeList& kids = plugin_order_new.children("PluginInfo"); XMLNodeConstIterator i; for (i = kids.begin(); i != kids.end(); ++i) { - if ((prop = (*i)->property ("unique-id"))) { - std::string unique_id = prop->value(); + std::string unique_id; + if ((*i)->get_property ("unique-id", unique_id)) { order.push_back (unique_id); - if ((prop = (*i)->property ("expanded"))) { - favorite_ui_state[unique_id] = string_is_affirmative (prop->value()); + if ((*i)->get_property ("expanded", yn)) { + favorite_ui_state[unique_id] = yn; } } } PluginStateSorter cmp (order); favorite_order.sort (cmp); sync_treeview_from_favorite_order (); + + } else { + //if there is no user file, then use an existing one from instant.xml + //NOTE: if you are loading an old session, this might come from the session's instant.xml + //Todo: in the next major version, we should probably stop doing the instant.xml check, and just use the new file + XMLNode* plugin_order; + if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) { + store_current_favorite_order (); + std::list order; + const XMLNodeList& kids = plugin_order->children("PluginInfo"); + XMLNodeConstIterator i; + for (i = kids.begin(); i != kids.end(); ++i) { + std::string unique_id; + if ((*i)->get_property ("unique-id", unique_id)) { + order.push_back (unique_id); + if ((*i)->get_property ("expanded", yn)) { + favorite_ui_state[unique_id] = yn; + } + } + } + + PluginStateSorter cmp (order); + favorite_order.sort (cmp); + sync_treeview_from_favorite_order (); + } } + return 0; } -XMLNode& -Mixer_UI::get_state () +void +Mixer_UI::save_plugin_order_file () { - XMLNode* node = new XMLNode (X_("Mixer")); - char buf[128]; - LocaleGuard lg; + //this writes the plugin order to the user's preference file ( plugin_metadata/plugin_order ) - node->add_child_nocopy (Tabbable::get_state()); - - snprintf(buf,sizeof(buf), "%f", rhs_pane1.get_divider()); - node->add_property(X_("mixer-rhs-pane1-pos"), string(buf)); - snprintf(buf,sizeof(buf), "%f", rhs_pane2.get_divider()); - node->add_property(X_("mixer-rhs_pane2-pos"), string(buf)); - snprintf(buf,sizeof(buf), "%f", list_hpane.get_divider()); - node->add_property(X_("mixer-list-hpane-pos"), string(buf)); - snprintf(buf,sizeof(buf), "%f", inner_pane.get_divider()); - node->add_property(X_("mixer-inner-pane-pos"), string(buf)); - - node->add_property ("narrow-strips", _strip_width == Narrow ? "yes" : "no"); - node->add_property ("show-mixer", _visible ? "yes" : "no"); - node->add_property ("show-mixer-list", _show_mixer_list ? "yes" : "no"); - node->add_property ("maximised", _maximised ? "yes" : "no"); + //NOTE: this replaces the old code that stores info in instant.xml + //why? because instant.xml prefers the per-session settings, and we want this to be a global pref store_current_favorite_order (); - XMLNode* plugin_order = new XMLNode ("PluginOrder"); - int cnt = 0; + XMLNode plugin_order ("PluginOrder"); + uint32_t cnt = 0; for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) { XMLNode* p = new XMLNode ("PluginInfo"); - p->add_property ("sort", cnt); - p->add_property ("unique-id", (*i)->unique_id); + p->set_property ("sort", cnt); + p->set_property ("unique-id", (*i)->unique_id); if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) { - p->add_property ("expanded", favorite_ui_state[(*i)->unique_id]); + p->set_property ("expanded", favorite_ui_state[(*i)->unique_id]); } - plugin_order->add_child_nocopy (*p); + plugin_order.add_child_nocopy (*p); } - node->add_child_nocopy (*plugin_order); + PluginManager::instance().save_plugin_order_file( plugin_order ); +} + +XMLNode& +Mixer_UI::get_state () +{ + XMLNode* node = new XMLNode (X_("Mixer")); + + node->add_child_nocopy (Tabbable::get_state()); + + node->set_property (X_("mixer-rhs-pane1-pos"), rhs_pane1.get_divider()); + node->set_property (X_("mixer-rhs_pane2-pos"), rhs_pane2.get_divider()); + node->set_property (X_("mixer-list-hpane-pos"), list_hpane.get_divider()); + node->set_property (X_("mixer-inner-pane-pos"), inner_pane.get_divider()); + + node->set_property ("narrow-strips", (_strip_width == Narrow)); + node->set_property ("show-mixer", _visible); + node->set_property ("maximised", _maximised); + + Glib::RefPtr act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList"); + node->set_property ("show-mixer-list", act->get_active ()); + + act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection"); + node->set_property ("monitor-section-visible", act->get_active ()); + + act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane"); + node->set_property ("show-vca-pane", act->get_active ()); + +#ifdef MIXBUS + act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane"); + node->set_property ("show-mixbus-pane", act->get_active ()); +#endif return *node; } @@ -2142,6 +2352,14 @@ Mixer_UI::scroll_left () using namespace Gtk::Box_Helpers; const BoxList& strips = strip_packer.children(); for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) { + if (i->get_widget() == & add_button) { + continue; + } +#ifdef MIXBUS + if (i->get_widget() == &mb_shadow) { + continue; + } +#endif lm += i->get_widget()->get_width (); if (lm >= lp) { lm -= i->get_widget()->get_width (); @@ -2166,6 +2384,14 @@ Mixer_UI::scroll_right () using namespace Gtk::Box_Helpers; const BoxList& strips = strip_packer.children(); for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) { + if (i->get_widget() == & add_button) { + continue; + } +#ifdef MIXBUS + if (i->get_widget() == &mb_shadow) { + continue; + } +#endif lm += i->get_widget()->get_width (); if (lm > lp + 1) { break; @@ -2219,10 +2445,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 (); - } } } @@ -2278,16 +2500,6 @@ Mixer_UI::setup_track_display () v->show (); v->pack_start (track_display_scroller, true, true); - Button* b = manage (new Button); - b->show (); - Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON)); - w->show (); - b->add (*w); - - b->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus)); - - v->pack_start (*b, false, false); - track_display_frame.set_name("BaseFrame"); track_display_frame.set_shadow_type (Gtk::SHADOW_IN); track_display_frame.add (*v); @@ -2370,13 +2582,27 @@ Mixer_UI::set_axis_targets_for_operation () void Mixer_UI::monitor_section_going_away () { - if (_monitor_section) { - monitor_section_detached (); - out_packer.remove (_monitor_section->tearoff()); - _monitor_section->set_session (0); - delete _monitor_section; - _monitor_section = 0; + 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()); } void @@ -2432,16 +2658,15 @@ Mixer_UI::restore_mixer_space () void Mixer_UI::monitor_section_attached () { - Glib::RefPtr act = ActionManager::get_action ("Common", "ToggleMonitorSection"); - Glib::RefPtr tact = Glib::RefPtr::cast_dynamic(act); + Glib::RefPtr act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection"); act->set_sensitive (true); - tact->set_active (); + showhide_monitor_section (act->get_active ()); } void Mixer_UI::monitor_section_detached () { - Glib::RefPtr act = ActionManager::get_action ("Common", "ToggleMonitorSection"); + Glib::RefPtr act = ActionManager::get_action ("Mixer", "ToggleMonitorSection"); act->set_sensitive (false); } @@ -2475,9 +2700,24 @@ Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs) { PluginManager& manager (PluginManager::instance()); for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) { + + /* not a Favorite? skip it */ if (manager.get_status (*i) != PluginManager::Favorite) { continue; } + + /* Check the tag combo selection, and skip this plugin if it doesn't match the selected tag(s) */ + string test = favorite_plugins_tag_combo.get_active_text(); + if (test != _("Show All")) { + vector tags = manager.get_tags(*i); + + //does the selected tag match any of the tags in the plugin? + vector::iterator tt = find (tags.begin(), tags.end(), test); + if (tt == tags.end()) { + continue; + } + } + result.push_back (*i); } } @@ -2540,6 +2780,30 @@ Mixer_UI::refill_favorite_plugins () sync_treeview_from_favorite_order (); } +void +Mixer_UI::plugin_list_changed () +{ + refill_favorite_plugins(); + refill_tag_combo(); +} + +void +Mixer_UI::refill_tag_combo () +{ + PluginManager& mgr (PluginManager::instance()); + + std::vector tags = mgr.get_all_tags (PluginManager::OnlyFavorites); + + favorite_plugins_tag_combo.clear(); + favorite_plugins_tag_combo.append_text (_("Show All")); + + for (vector::iterator t = tags.begin (); t != tags.end (); ++t) { + favorite_plugins_tag_combo.append_text (*t); + } + + favorite_plugins_tag_combo.set_active_text (_("Show All")); +} + void Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&) { @@ -2626,7 +2890,7 @@ Mixer_UI::popup_note_context_menu (GdkEventButton *ev) bool Mixer_UI::plugin_row_button_press (GdkEventButton *ev) { - if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3) ) { + if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3)) { TreeModel::Path path; TreeViewColumn* column; int cellx, celly; @@ -2830,13 +3094,13 @@ Mixer_UI::do_vca_unassign (boost::shared_ptr vca) } void -Mixer_UI::show_vca_slaves (boost::shared_ptr vca) +Mixer_UI::show_spill (boost::shared_ptr s) { - boost::shared_ptr v = spilled_vca.lock(); - if (v != vca) { - spilled_vca = vca; - show_vca_change (vca); /* EMIT SIGNAL */ - if (vca) { + boost::shared_ptr ss = spilled_strip.lock(); + if (ss != s) { + spilled_strip = s; + show_spill_change (s); /* EMIT SIGNAL */ + if (s) { _group_tabs->hide (); } else { _group_tabs->show (); @@ -2846,44 +3110,57 @@ Mixer_UI::show_vca_slaves (boost::shared_ptr vca) } bool -Mixer_UI::showing_vca_slaves_for (boost::shared_ptr vca) const +Mixer_UI::showing_spill_for (boost::shared_ptr s) const { - return vca == spilled_vca.lock(); + return s == spilled_strip.lock(); } void Mixer_UI::register_actions () { - Glib::RefPtr group = myactions.create_action_group (X_("Mixer")); + Glib::RefPtr group = ActionManager::create_action_group (bindings, X_("Mixer")); + + ActionManager::register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action)); + ActionManager::register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action)); + ActionManager::register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action)); + ActionManager::register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action)); + ActionManager::register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action)); + ActionManager::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, "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)); + ActionManager::register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors)); + ActionManager::register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors)); + ActionManager::register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors)); + ActionManager::register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors)); + ActionManager::register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors)); + ActionManager::register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors)); + ActionManager::register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins)); + ActionManager::register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none)); - 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)); + ActionManager::register_action (group, "select-next-stripable", _("Select Next Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_next_strip)); + ActionManager::register_action (group, "select-prev-stripable", _("Scroll Previous Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_prev_strip)); - 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)); + ActionManager::register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left)); + ActionManager::register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), 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"), + ActionManager::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)); + + ActionManager::register_toggle_action (group, X_("ToggleMixerList"), _("Mixer: Show Mixer List"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixer_list)); + + ActionManager::register_toggle_action (group, X_("ToggleVCAPane"), _("Mixer: Show VCAs"), sigc::mem_fun (*this, &Mixer_UI::toggle_vcas)); + +#ifdef MIXBUS + ActionManager::register_toggle_action (group, X_("ToggleMixbusPane"), _("Mixer: Show Mixbuses"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixbuses)); +#endif + + ActionManager::register_toggle_action (group, X_("ToggleMonitorSection"), _("Mixer: Show Monitor Section"), sigc::mem_fun (*this, &Mixer_UI::toggle_monitor_section)); } void Mixer_UI::load_bindings () { - bindings = Bindings::get_bindings (X_("Mixer"), myactions); + bindings = Bindings::get_bindings (X_("Mixer")); } template void @@ -2931,29 +3208,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); } } @@ -3050,26 +3342,22 @@ void Mixer_UI::vca_assign (boost::shared_ptr vca) { set_axis_targets_for_operation (); -#if 0 BOOST_FOREACH(AxisView* r, _axis_targets) { MixerStrip* ms = dynamic_cast (r); if (ms) { ms->vca_assign (vca); } } -#endif } void Mixer_UI::vca_unassign (boost::shared_ptr vca) { set_axis_targets_for_operation (); -#if 0 BOOST_FOREACH(AxisView* r, _axis_targets) { MixerStrip* ms = dynamic_cast (r); if (ms) { ms->vca_unassign (vca); } } -#endif }