X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmixer_ui.cc;h=5b27ee7623f0e8b0236bc5d1dbef53dbcfe8e76e;hb=551eea452b1aad05a27fc64e07b0a031912d0866;hp=807de6baa4a8741fc8a7b39cc7e2f5278cb974d2;hpb=10747bc98070668e5666033f835423f557ac8bd0;p=ardour.git diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index 807de6baa4..edae72fe6c 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -25,24 +25,32 @@ #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/route_sorters.h" #include "ardour/session.h" +#include "ardour/vca.h" +#include "ardour/vca_manager.h" #include "keyboard.h" #include "mixer_ui.h" @@ -50,6 +58,7 @@ #include "monitor_section.h" #include "plugin_selector.h" #include "public_editor.h" +#include "mouse_cursors.h" #include "ardour_ui.h" #include "prompter.h" #include "utils.h" @@ -57,8 +66,12 @@ #include "actions.h" #include "gui_thread.h" #include "mixer_group_tabs.h" +#include "route_sorter.h" +#include "timers.h" +#include "ui_config.h" +#include "vca_master_strip.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace ARDOUR; using namespace ARDOUR_UI_UTILS; @@ -74,42 +87,51 @@ using PBD::Unwinder; Mixer_UI* Mixer_UI::_instance = 0; Mixer_UI* -Mixer_UI::instance () +Mixer_UI::instance () { if (!_instance) { _instance = new Mixer_UI; - } + } return _instance; } Mixer_UI::Mixer_UI () - : Window (Gtk::WINDOW_TOPLEVEL) - , VisibilityTracker (*((Gtk::Window*) this)) - , _visible (false) + : Tabbable (_content, _("Mixer")) , no_track_list_redisplay (false) , in_group_row_change (false) , track_menu (0) , _monitor_section (0) - , _strip_width (Config->get_default_narrow_ms() ? Narrow : Wide) + , _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) , _following_editor_selection (false) , _maximised (false) + , _show_mixer_list (true) + , myactions (X_("mixer")) { - /* allow this window to become the key focus window */ - set_flags (CAN_FOCUS); + register_actions (); + load_bindings (); + _content.set_data ("ardour-bindings", bindings); - Route::SyncOrderKeys.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::sync_treeview_from_order_keys, this), gui_context()); + PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::sync_treeview_from_presentation_info, this), gui_context()); scroller.set_can_default (true); - set_default (scroller); + // set_default (scroller); scroller_base.set_flags (Gtk::CAN_FOCUS); scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK); scroller_base.set_name ("MixerWindow"); scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release)); + + /* set up drag-n-drop */ + vector target_table; + target_table.push_back (TargetEntry ("PluginFavoritePtr")); + 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 strip_packer.pack_end (scroller_base, true, true); @@ -120,33 +142,35 @@ Mixer_UI::Mixer_UI () b->show_all (); scroller.add (*b); - scroller.set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC); setup_track_display (); group_model = ListStore::create (group_columns); group_display.set_model (group_model); - group_display.append_column (_("Group"), group_columns.text); group_display.append_column (_("Show"), group_columns.visible); + group_display.append_column (_("Group"), group_columns.text); group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0)); group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1)); - group_display.get_column (0)->set_expand(true); - group_display.get_column (1)->set_expand(false); + group_display.get_column (0)->set_expand(false); + group_display.get_column (1)->set_expand(true); + group_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED); group_display.set_name ("EditGroupList"); group_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE); group_display.set_reorderable (true); group_display.set_headers_visible (true); group_display.set_rules_hint (true); + group_display.set_can_focus(false); /* name is directly editable */ - CellRendererText* name_cell = dynamic_cast(group_display.get_column_cell_renderer (0)); + CellRendererText* name_cell = dynamic_cast(group_display.get_column_cell_renderer (1)); name_cell->property_editable() = true; name_cell->signal_edited().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_name_edit)); /* use checkbox for the active column */ - CellRendererToggle* active_cell = dynamic_cast(group_display.get_column_cell_renderer (1)); + CellRendererToggle* active_cell = dynamic_cast(group_display.get_column_cell_renderer (0)); active_cell->property_activatable() = true; active_cell->property_radio() = false; @@ -188,46 +212,126 @@ Mixer_UI::Mixer_UI () group_display_frame.set_shadow_type (Gtk::SHADOW_IN); group_display_frame.add (group_display_vbox); - rhs_pane1.pack1 (track_display_frame); - rhs_pane1.pack2 (group_display_frame); - list_vpacker.pack_start (rhs_pane1, true, true); + list target_list; + target_list.push_back (TargetEntry ("PluginPresetPtr")); - global_hpacker.pack_start (scroller, true, true); -#ifdef GTKOSX - /* current gtk-quartz has dirty updates on borders like this one */ - global_hpacker.pack_start (out_packer, false, false, 0); -#else - global_hpacker.pack_start (out_packer, false, false, 12); -#endif - list_hpane.pack1(list_vpacker, true, true); - list_hpane.pack2(global_hpacker, true, false); + favorite_plugins_model = PluginTreeStore::create (favorite_plugins_columns); + favorite_plugins_display.set_model (favorite_plugins_model); + favorite_plugins_display.append_column (_("Favorite Plugins"), favorite_plugins_columns.name); + favorite_plugins_display.set_name ("EditGroupList"); + favorite_plugins_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE); + favorite_plugins_display.set_reorderable (false); + 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); + favorite_plugins_display.signal_row_activated().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_activated)); + favorite_plugins_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_button_press), false); + 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)); + favorite_plugins_model->signal_row_has_child_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::sync_treeview_favorite_ui_state)); - rhs_pane1.signal_size_allocate().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::pane_allocation_handler), - static_cast (&rhs_pane1))); - list_hpane.signal_size_allocate().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::pane_allocation_handler), - static_cast (&list_hpane))); + favorite_plugins_scroller.add (favorite_plugins_display); + favorite_plugins_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); - global_vpacker.pack_start (list_hpane, true, true); + favorite_plugins_frame.set_name ("BaseFrame"); + favorite_plugins_frame.set_shadow_type (Gtk::SHADOW_IN); + favorite_plugins_frame.add (favorite_plugins_scroller); - add (global_vpacker); - set_name ("MixerWindow"); + rhs_pane1.add (favorite_plugins_frame); + rhs_pane1.add (track_display_frame); - update_title (); + rhs_pane2.add (rhs_pane1); + rhs_pane2.add (group_display_frame); + + list_vpacker.pack_start (rhs_pane2, true, true); + + string vca_text = _("Control Masters"); + Gtk::HBox* vca_top_padding = manage (new Gtk::HBox); + vca_top_padding->set_size_request (-1, 2); + vca_vpacker.pack_start (*vca_top_padding, false, false); + + vca_label.set_text (vca_text); + vca_label_bar.set_size_request (-1, 16); /* must match height in GroupTabs::set_size_request() */ + + vca_label_bar.set_name (X_("VCALabelBar")); + vca_label_bar.add (vca_label); + + vca_vpacker.pack_start (vca_label_bar, false, false); + + 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); + vca_scroller.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release)); + + vca_vpacker.pack_start (vca_scroller, true, true); + + inner_pane.add (scroller); + inner_pane.add (vca_vpacker); + + global_hpacker.pack_start (inner_pane, true, true); + global_hpacker.pack_start (out_packer, false, false); + + list_hpane.set_check_divider_position (true); + list_hpane.add (list_vpacker); + list_hpane.add (global_hpacker); + + + XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings(); + XMLProperty const * prop; + float fract; + + { + LocaleGuard lg; + + 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())); + } + } - set_wmclass (X_("ardour_mixer"), PROGRAM_NAME); + rhs_pane1.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down); + rhs_pane2.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down); + list_hpane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right); + inner_pane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right); - signal_delete_event().connect (sigc::mem_fun (*this, &Mixer_UI::hide_window)); - add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK); + _content.pack_start (list_hpane, true, true); - signal_configure_event().connect (sigc::mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler)); + update_title (); route_group_display_button_box->show(); route_group_add_button->show(); route_group_remove_button->show(); + _content.show (); + _content.set_name ("MixerWindow"); + global_hpacker.show(); - global_vpacker.show(); scroller.show(); scroller_base.show(); scroller_hpacker.show(); @@ -236,28 +340,55 @@ Mixer_UI::Mixer_UI () group_display_button_label.show(); group_display_button.show(); group_display_scroller.show(); + favorite_plugins_scroller.show(); group_display_vbox.show(); group_display_frame.show(); + favorite_plugins_frame.show(); rhs_pane1.show(); + rhs_pane2.show(); strip_packer.show(); + inner_pane.show(); + vca_top_padding->show (); + vca_scroller.show(); + vca_vpacker.show(); + vca_hpacker.show(); + vca_label_bar.show(); + vca_label.show(); + vca_scroller_base.show(); out_packer.show(); list_hpane.show(); group_display.show(); + favorite_plugins_display.show(); MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context()); - MonitorSection::setup_knob_images (); + /* handle escape */ + + ARDOUR_UI::instance()->Escape.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::escape, this), gui_context()); #ifndef DEFER_PLUGIN_SELECTOR_LOAD _plugin_selector = new PluginSelector (PluginManager::instance ()); +#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()); + 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; } + delete _plugin_selector; +} + +void +Mixer_UI::escape () +{ + select_none (); } void @@ -266,141 +397,242 @@ Mixer_UI::track_editor_selection () PublicEditor::instance().get_selection().TracksChanged.connect (sigc::mem_fun (*this, &Mixer_UI::follow_editor_selection)); } - -void -Mixer_UI::ensure_float (Window& win) +Gtk::Window* +Mixer_UI::use_own_window (bool and_fill_it) { - win.set_transient_for (*this); + bool new_window = !own_window(); + + 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 (); + } + + return win; } void Mixer_UI::show_window () { - present (); - if (!_visible) { - set_window_pos_and_size (); + Tabbable::show_window (); - /* show/hide group tabs as required */ - parameter_changed ("show-group-tabs"); + /* show/hide group tabs as required */ + parameter_changed ("show-group-tabs"); - /* now reset each strips width so the right widgets are shown */ - MixerStrip* ms; + /* now reset each strips width so the right widgets are shown */ - TreeModel::Children rows = track_model->children(); - TreeModel::Children::iterator ri; + TreeModel::Children rows = track_model->children(); + TreeModel::Children::iterator ri; - for (ri = rows.begin(); ri != rows.end(); ++ri) { - ms = (*ri)[track_columns.strip]; - ms->set_width_enum (ms->get_width_enum (), ms->width_owner()); - /* Fix visibility of mixer strip stuff */ - ms->parameter_changed (X_("mixer-strip-visibility")); + for (ri = rows.begin(); ri != rows.end(); ++ri) { + AxisView* av = (*ri)[stripable_columns.strip]; + MixerStrip* ms = dynamic_cast (av); + if (!ms) { + continue; } + ms->set_width_enum (ms->get_width_enum (), ms->width_owner()); + /* Fix visibility of mixer strip stuff */ + ms->parameter_changed (X_("mixer-element-visibility")); } - + /* force focus into main area */ scroller_base.grab_focus (); +} + +void +Mixer_UI::remove_master (VCAMasterStrip* vms) +{ + if (_session && _session->deletion_in_progress()) { + /* its all being taken care of */ + return; + } + + TreeModel::Children rows = track_model->children(); + TreeModel::Children::iterator ri; - _visible = true; + for (ri = rows.begin(); ri != rows.end(); ++ri) { + if ((*ri)[stripable_columns.strip] == vms) { + PBD::Unwinder uw (_route_deletion_in_progress, true); + track_model->erase (ri); + break; + } + } } bool -Mixer_UI::hide_window (GdkEventAny *ev) +Mixer_UI::masters_scroller_button_release (GdkEventButton* ev) +{ + using namespace Menu_Helpers; + + if (Keyboard::is_context_menu_event (ev)) { + ARDOUR_UI::instance()->add_route (); + return true; + } + + return false; +} + +void +Mixer_UI::add_masters (VCAList& vlist) { - get_window_pos_and_size (); + StripableList sl; + + for (VCAList::iterator v = vlist.begin(); v != vlist.end(); ++v) { + sl.push_back (boost::dynamic_pointer_cast (*v)); + } - _visible = false; - return just_hide_it(ev, static_cast(this)); + add_stripables (sl); } +void +Mixer_UI::add_routes (RouteList& rlist) +{ + StripableList sl; + + for (RouteList::iterator r = rlist.begin(); r != rlist.end(); ++r) { + sl.push_back (*r); + } + + add_stripables (sl); +} void -Mixer_UI::add_strips (RouteList& routes) +Mixer_UI::add_stripables (StripableList& slist) { - bool from_scratch = track_model->children().size() == 0; Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end(); + bool from_scratch = (track_model->children().size() == 0); + uint32_t nroutes = 0; + + slist.sort (StripablePresentationInfoSorter()); for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) { - boost::shared_ptr r = (*it)[track_columns.route]; + boost::shared_ptr s = (*it)[stripable_columns.stripable]; + + if (!s) { + continue; + } + + nroutes++; - if (r->order_key() == (routes.front()->order_key() + routes.size())) { + if (s->presentation_info().order() == (slist.front()->presentation_info().order() + slist.size())) { insert_iter = it; break; } } - if(!from_scratch) { - _selection.clear_routes (); - } - MixerStrip* strip; + try { - no_track_list_redisplay = true; + PBD::Unwinder uw (no_track_list_redisplay, true); + track_display.set_model (Glib::RefPtr()); - for (RouteList::iterator x = routes.begin(); x != routes.end(); ++x) { - boost::shared_ptr route = (*x); - - if (route->is_auditioner()) { - continue; - } - - 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); + for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) { + + boost::shared_ptr route; + boost::shared_ptr vca; + + if ((vca = boost::dynamic_pointer_cast (*s))) { + + VCAMasterStrip* vms = new VCAMasterStrip (_session, vca); + + TreeModel::Row row = *(track_model->append()); + + row[stripable_columns.text] = vca->name(); + row[stripable_columns.visible] = vms->marked_for_display (); + 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()); + + } else if ((route = boost::dynamic_pointer_cast (*s))) { + + if (route->is_auditioner()) { + continue; + } + + 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 (); - - route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context()); - - /* no regular strip shown for control out */ - - continue; - } - - strip = new MixerStrip (*this, _session, route); - strips.push_back (strip); - - Config->get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide; - - if (strip->width_owner() != strip) { - strip->set_width_enum (_strip_width, this); - } - - show_strip (strip); - - TreeModel::Row row = *(track_model->insert(insert_iter)); - row[track_columns.text] = route->name(); - row[track_columns.visible] = strip->route()->is_master() ? true : strip->marked_for_display(); - row[track_columns.route] = route; - row[track_columns.strip] = strip; - - if (!from_scratch) { - _selection.add (strip); + + 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_attached (); + + route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context()); + + /* no regular strip shown for control out */ + + continue; + } + + strip = new MixerStrip (*this, _session, route); + strips.push_back (strip); + + UIConfiguration::instance().get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide; + + if (strip->width_owner() != strip) { + strip->set_width_enum (_strip_width, this); + } + + show_strip (strip); + + if (!route->is_master()) { + + TreeModel::Row row = *(track_model->insert (insert_iter)); + + row[stripable_columns.text] = route->name(); + 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)); + strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip)); } - - route->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::strip_property_changed, this, _1, strip), gui_context()); - - strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed)); - strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip)); - } - } catch (...) { + (*s)->presentation_info().PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr(*s)), gui_context()); + (*s)->PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr(*s)), gui_context()); + } + + } catch (const std::exception& e) { + error << string_compose (_("Error adding GUI elements for new tracks/busses %1"), e.what()) << endmsg; } - no_track_list_redisplay = false; track_display.set_model (track_model); - - sync_order_keys_from_treeview (); + + if (!from_scratch) { + sync_presentation_info_from_treeview (); + } + redisplay_track_list (); } @@ -413,12 +645,19 @@ Mixer_UI::deselect_all_strip_processors () } void -Mixer_UI::select_none () +Mixer_UI::select_strip (MixerStrip& ms, bool add) { - for (list::iterator i = strips.begin(); i != strips.end(); ++i) { - (*i)->set_selected(false); + if (add) { + _selection.add (&ms); + } else { + _selection.set (&ms); } - +} + +void +Mixer_UI::select_none () +{ + _selection.clear_routes(); deselect_all_strip_processors(); } @@ -442,13 +681,13 @@ Mixer_UI::remove_strip (MixerStrip* strip) TreeModel::Children rows = track_model->children(); TreeModel::Children::iterator ri; list::iterator i; - + if ((i = find (strips.begin(), strips.end(), strip)) != strips.end()) { strips.erase (i); } - + for (ri = rows.begin(); ri != rows.end(); ++ri) { - if ((*ri)[track_columns.strip] == strip) { + if ((*ri)[stripable_columns.strip] == strip) { PBD::Unwinder uw (_route_deletion_in_progress, true); track_model->erase (ri); break; @@ -457,120 +696,68 @@ Mixer_UI::remove_strip (MixerStrip* strip) } void -Mixer_UI::reset_remote_control_ids () -{ - if (Config->get_remote_model() == UserOrdered || !_session || _session->deletion_in_progress()) { - return; - } - - TreeModel::Children rows = track_model->children(); - - if (rows.empty()) { - return; - } - - DEBUG_TRACE (DEBUG::OrderKeys, "mixer resets remote control ids after remote model change\n"); - - TreeModel::Children::iterator ri; - bool rid_change = false; - uint32_t rid = 1; - uint32_t invisible_key = UINT32_MAX; - - for (ri = rows.begin(); ri != rows.end(); ++ri) { - boost::shared_ptr route = (*ri)[track_columns.route]; - bool visible = (*ri)[track_columns.visible]; - - if (!route->is_master() && !route->is_monitor()) { - - uint32_t new_rid = (visible ? rid : invisible_key--); - - if (new_rid != route->remote_control_id()) { - route->set_remote_control_id_explicit (new_rid); - rid_change = true; - } - - if (visible) { - rid++; - } - } - } - - if (rid_change) { - /* tell the world that we changed the remote control IDs */ - _session->notify_remote_id_change (); - } -} - -void -Mixer_UI::sync_order_keys_from_treeview () +Mixer_UI::sync_presentation_info_from_treeview () { if (ignore_reorder || !_session || _session->deletion_in_progress()) { return; } TreeModel::Children rows = track_model->children(); - + if (rows.empty()) { return; } - DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync order keys from model\n"); + DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync presentation info from treeview\n"); TreeModel::Children::iterator ri; - bool changed = false; - bool rid_change = false; + bool change = false; uint32_t order = 0; - uint32_t rid = 1; - uint32_t invisible_key = UINT32_MAX; for (ri = rows.begin(); ri != rows.end(); ++ri) { - boost::shared_ptr route = (*ri)[track_columns.route]; - bool visible = (*ri)[track_columns.visible]; - - uint32_t old_key = route->order_key (); + bool visible = (*ri)[stripable_columns.visible]; + boost::shared_ptr stripable = (*ri)[stripable_columns.stripable]; - if (order != old_key) { - route->set_order_key (order); - changed = true; + if (!stripable) { + continue; } - if ((Config->get_remote_model() == MixerOrdered) && !route->is_master() && !route->is_monitor()) { + /* Monitor and Auditioner do not get their presentation + * info reset here. + */ - uint32_t new_rid = (visible ? rid : invisible_key--); + if (stripable->is_monitor() || stripable->is_auditioner()) { + continue; + } - if (new_rid != route->remote_control_id()) { - route->set_remote_control_id_explicit (new_rid); - rid_change = true; - } - - if (visible) { - rid++; - } + /* Master also doesn't get set here but since the editor allows + * it to be reordered, we need to preserve its ordering. + */ + + stripable->presentation_info().set_hidden (!visible); + if (order != stripable->presentation_info().order()) { + stripable->set_presentation_order (order, false); + change = true; } ++order; } - if (changed) { - /* tell everyone that we changed the mixer sort keys */ - _session->sync_order_keys (); - } - - if (rid_change) { - /* tell the world that we changed the remote control IDs */ - _session->notify_remote_id_change (); + if (change) { + DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n"); + _session->notify_presentation_info_change (); } } void -Mixer_UI::sync_treeview_from_order_keys () +Mixer_UI::sync_treeview_from_presentation_info () { if (!_session || _session->deletion_in_progress()) { return; } - DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from order keys.\n"); + DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from presentation info.\n"); /* we could get here after either a change in the Mixer or Editor sort * order, but either way, the mixer order keys reflect the intended @@ -586,30 +773,27 @@ Mixer_UI::sync_treeview_from_order_keys () return; } - OrderKeySortedRoutes sorted_routes; + OrderingKeys sorted; for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) { - boost::shared_ptr route = (*ri)[track_columns.route]; - sorted_routes.push_back (RoutePlusOrderKey (route, old_order, route->order_key ())); + boost::shared_ptr stripable = (*ri)[stripable_columns.stripable]; + sorted.push_back (OrderKeys (old_order, stripable->presentation_info().order())); } SortByNewDisplayOrder cmp; - sort (sorted_routes.begin(), sorted_routes.end(), cmp); - neworder.assign (sorted_routes.size(), 0); + sort (sorted.begin(), sorted.end(), cmp); + neworder.assign (sorted.size(), 0); uint32_t n = 0; - - for (OrderKeySortedRoutes::iterator sr = sorted_routes.begin(); sr != sorted_routes.end(); ++sr, ++n) { + + for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) { neworder[n] = sr->old_display_order; if (sr->old_display_order != n) { changed = true; } - - DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("MIXER change order for %1 from %2 to %3\n", - sr->route->name(), sr->old_display_order, n)); } if (changed) { @@ -623,23 +807,23 @@ Mixer_UI::sync_treeview_from_order_keys () void Mixer_UI::follow_editor_selection () { - if (!Config->get_link_editor_and_mixer_selection() || _following_editor_selection) { + if (_following_editor_selection) { return; } _following_editor_selection = true; _selection.block_routes_changed (true); - + TrackSelection& s (PublicEditor::instance().get_selection().tracks); _selection.clear_routes (); for (TrackViewList::iterator i = s.begin(); i != s.end(); ++i) { - RouteTimeAxisView* rtav = dynamic_cast (*i); - if (rtav) { - MixerStrip* ms = strip_by_route (rtav->route()); - if (ms) { - _selection.add (ms); + TimeAxisView* tav = dynamic_cast (*i); + if (tav) { + AxisView* axis = axis_by_stripable (tav->stripable()); + if (axis) { + _selection.add (axis); } } } @@ -650,9 +834,9 @@ Mixer_UI::follow_editor_selection () MixerStrip* -Mixer_UI::strip_by_route (boost::shared_ptr r) +Mixer_UI::strip_by_route (boost::shared_ptr r) const { - for (list::iterator i = strips.begin(); i != strips.end(); ++i) { + for (list::const_iterator i = strips.begin(); i != strips.end(); ++i) { if ((*i)->route() == r) { return (*i); } @@ -661,6 +845,18 @@ Mixer_UI::strip_by_route (boost::shared_ptr r) return 0; } +AxisView* +Mixer_UI::axis_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; +} + bool Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) { @@ -669,54 +865,58 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) /* primary-click: toggle selection state of strip */ if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { _selection.remove (strip); - } + } else if (_selection.axes.size() > 1) { + /* de-select others */ + _selection.set (strip); + } } else { if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { _selection.add (strip); } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) { - if (!_selection.selected(strip)) { - - /* extend selection */ - - vector tmp; - bool accumulate = false; - - tmp.push_back (strip); - - for (list::iterator i = strips.begin(); i != strips.end(); ++i) { - if ((*i) == strip) { - /* hit clicked strip, start accumulating till we hit the first - selected strip - */ - if (accumulate) { - /* done */ - break; - } else { - accumulate = true; - } - } else if (_selection.selected (*i)) { - /* hit selected strip. if currently accumulating others, - we're done. if not accumulating others, start doing so. - */ - if (accumulate) { - /* done */ - break; - } else { - accumulate = true; - } + /* extend selection */ + + vector tmp; + bool accumulate = false; + bool found_another = false; + + tmp.push_back (strip); + + for (list::iterator i = strips.begin(); i != strips.end(); ++i) { + if ((*i) == strip) { + /* hit clicked strip, start accumulating till we hit the first + selected strip + */ + if (accumulate) { + /* done */ + break; + } else { + accumulate = true; + } + } else if (_selection.selected (*i)) { + /* hit selected strip. if currently accumulating others, + we're done. if not accumulating others, start doing so. + */ + found_another = true; + if (accumulate) { + /* done */ + break; } else { - if (accumulate) { - tmp.push_back (*i); - } + accumulate = true; + } + } else { + if (accumulate) { + tmp.push_back (*i); } } + } + if (found_another) { for (vector::iterator i = tmp.begin(); i != tmp.end(); ++i) { _selection.add (*i); } - } - + } else + _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet } else { _selection.set (strip); } @@ -741,14 +941,16 @@ Mixer_UI::set_session (Session* sess) return; } + refill_favorite_plugins(); + XMLNode* node = ARDOUR_UI::instance()->mixer_settings(); - set_state (*node); + set_state (*node, 0); update_title (); initial_track_display (); - _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_strips, this, _1), gui_context()); + _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_routes, this, _1), gui_context()); _session->route_group_added.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_route_group, this, _1), gui_context()); _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context()); _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context()); @@ -756,20 +958,15 @@ Mixer_UI::set_session (Session* sess) _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context()); _session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context()); + _session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_masters, this, _1), gui_context()); + Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ()); route_groups_changed (); if (_visible) { show_window(); - - /* Bit of a hack; if we're here, we're opening the mixer because of our - instant XML state having a show-mixer property. Fix up the corresponding - action state. - */ - ActionManager::check_toggleaction ("/Common/toggle-mixer"); } - start_updating (); } @@ -789,9 +986,11 @@ Mixer_UI::session_going_away () delete (*i); } - if (_monitor_section) { - _monitor_section->tearoff().hide_visible (); - } + if (_monitor_section) { + _monitor_section->tearoff().hide_visible (); + } + + monitor_section_detached (); strips.clear (); @@ -813,13 +1012,12 @@ Mixer_UI::track_visibility_changed (std::string const & path) TreeIter iter; if ((iter = track_model->get_iter (path))) { - MixerStrip* strip = (*iter)[track_columns.strip]; - if (strip) { - bool visible = (*iter)[track_columns.visible]; - if (strip->set_marked_for_display (!visible)) { - update_track_visibility (); - } + AxisView* av = (*iter)[stripable_columns.strip]; + bool visible = (*iter)[stripable_columns.visible]; + + if (av->set_marked_for_display (!visible)) { + update_track_visibility (); } } } @@ -832,16 +1030,16 @@ Mixer_UI::update_track_visibility () { Unwinder uw (no_track_list_redisplay, true); - + for (i = rows.begin(); i != rows.end(); ++i) { - MixerStrip *strip = (*i)[track_columns.strip]; - (*i)[track_columns.visible] = strip->marked_for_display (); + AxisView* av = (*i)[stripable_columns.strip]; + (*i)[stripable_columns.visible] = av->marked_for_display (); } - - /* force route order keys catch up with visibility changes + + /* force presentation catch up with visibility changes */ - - sync_order_keys_from_treeview (); + + sync_presentation_info_from_treeview (); } redisplay_track_list (); @@ -855,10 +1053,12 @@ Mixer_UI::show_strip (MixerStrip* ms) for (i = rows.begin(); i != rows.end(); ++i) { - MixerStrip* strip = (*i)[track_columns.strip]; + AxisView* av = (*i)[stripable_columns.strip]; + MixerStrip* strip = dynamic_cast (av); if (strip == ms) { - (*i)[track_columns.visible] = true; - redisplay_track_list (); + (*i)[stripable_columns.visible] = true; + av->set_marked_for_display (true); + update_track_visibility (); break; } } @@ -872,10 +1072,12 @@ Mixer_UI::hide_strip (MixerStrip* ms) for (i = rows.begin(); i != rows.end(); ++i) { - MixerStrip* strip = (*i)[track_columns.strip]; + AxisView* av = (*i)[stripable_columns.strip]; + MixerStrip* strip = dynamic_cast (av); if (strip == ms) { - (*i)[track_columns.visible] = false; - redisplay_track_list (); + (*i)[stripable_columns.visible] = false; + av->set_marked_for_display (false); + update_track_visibility (); break; } } @@ -884,7 +1086,7 @@ Mixer_UI::hide_strip (MixerStrip* ms) gint Mixer_UI::start_updating () { - fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips)); + fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips)); return 0; } @@ -898,7 +1100,7 @@ Mixer_UI::stop_updating () void Mixer_UI::fast_update_strips () { - if (is_mapped () && _session) { + if (_content.is_mapped () && _session) { for (list::iterator i = strips.begin(); i != strips.end(); ++i) { (*i)->fast_update (); } @@ -913,21 +1115,21 @@ Mixer_UI::set_all_strips_visibility (bool yn) { Unwinder uw (no_track_list_redisplay, true); - + for (i = rows.begin(); i != rows.end(); ++i) { - - TreeModel::Row row = (*i); - MixerStrip* strip = row[track_columns.strip]; - - if (strip == 0) { + + AxisView* av = (*i)[stripable_columns.strip]; + MixerStrip* strip = dynamic_cast (av); + + if (!strip) { continue; } - + if (strip->route()->is_master() || strip->route()->is_monitor()) { continue; } - - (*i)[track_columns.visible] = yn; + + (*i)[stripable_columns.visible] = yn; } } @@ -936,42 +1138,50 @@ Mixer_UI::set_all_strips_visibility (bool yn) void -Mixer_UI::set_all_audio_visibility (int tracks, bool yn) +Mixer_UI::set_all_audio_midi_visibility (int tracks, bool yn) { TreeModel::Children rows = track_model->children(); TreeModel::Children::iterator i; { Unwinder uw (no_track_list_redisplay, true); - + for (i = rows.begin(); i != rows.end(); ++i) { - TreeModel::Row row = (*i); - MixerStrip* strip = row[track_columns.strip]; - - if (strip == 0) { + + AxisView* av = (*i)[stripable_columns.strip]; + MixerStrip* strip = dynamic_cast (av); + + if (!strip) { continue; } - + if (strip->route()->is_master() || strip->route()->is_monitor()) { continue; } - + boost::shared_ptr at = strip->audio_track(); - + boost::shared_ptr mt = strip->midi_track(); + switch (tracks) { case 0: - (*i)[track_columns.visible] = yn; + (*i)[stripable_columns.visible] = yn; break; - + case 1: if (at) { /* track */ - (*i)[track_columns.visible] = yn; + (*i)[stripable_columns.visible] = yn; } break; - + case 2: - if (!at) { /* bus */ - (*i)[track_columns.visible] = yn; + if (!at && !mt) { /* bus */ + (*i)[stripable_columns.visible] = yn; + } + break; + + case 3: + if (mt) { /* midi-track */ + (*i)[stripable_columns.visible] = yn; } break; } @@ -996,30 +1206,41 @@ Mixer_UI::show_all_routes () void Mixer_UI::show_all_audiobus () { - set_all_audio_visibility (2, true); + set_all_audio_midi_visibility (2, true); } void Mixer_UI::hide_all_audiobus () { - set_all_audio_visibility (2, false); + set_all_audio_midi_visibility (2, false); } void Mixer_UI::show_all_audiotracks() { - set_all_audio_visibility (1, true); + set_all_audio_midi_visibility (1, true); } void Mixer_UI::hide_all_audiotracks () { - set_all_audio_visibility (1, false); + set_all_audio_midi_visibility (1, false); +} + +void +Mixer_UI::show_all_miditracks() +{ + set_all_audio_midi_visibility (3, true); +} +void +Mixer_UI::hide_all_miditracks () +{ + set_all_audio_midi_visibility (3, false); } void Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/) { DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n"); - sync_order_keys_from_treeview (); + sync_presentation_info_from_treeview (); } void @@ -1027,13 +1248,13 @@ Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&) { /* this happens as the second step of a DnD within the treeview as well as when a row/route is actually deleted. - + if it was a deletion then we have to force a redisplay because order keys may not have changed. */ DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n"); - sync_order_keys_from_treeview (); + sync_presentation_info_from_treeview (); if (_route_deletion_in_progress) { redisplay_track_list (); @@ -1041,53 +1262,109 @@ Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&) } void -Mixer_UI::redisplay_track_list () +Mixer_UI::spill_redisplay (boost::shared_ptr vca) { TreeModel::Children rows = track_model->children(); - TreeModel::Children::iterator i; - + + for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) { + + AxisView* av = (*i)[stripable_columns.strip]; + MixerStrip* strip = dynamic_cast (av); + + if (!strip) { + /* we're in the middle of changing a row, don't worry */ + continue; + } + + if (!strip->route()) { + /* non-route element */ + continue; + } + + if (strip->route()->is_master() || strip->route()->is_monitor()) { + continue; + } + + if (strip->route()->slaved_to (vca)) { + + if (strip->packed()) { + strip_packer.reorder_child (*strip, -1); /* put at end */ + } else { + strip_packer.pack_start (*strip, false, false); + strip->set_packed (true); + } + + } else { + + if (strip->packed()) { + strip_packer.remove (*strip); + strip->set_packed (false); + } + } + } +} + +void +Mixer_UI::redisplay_track_list () +{ if (no_track_list_redisplay) { return; } + boost::shared_ptr sv = spilled_vca.lock (); + + if (sv) { + spill_redisplay (sv); + return; + } + + TreeModel::Children rows = track_model->children(); + TreeModel::Children::iterator i; + uint32_t n_masters = 0; + + container_clear (vca_hpacker); + vca_hpacker.pack_end (vca_scroller_base, true, true); + for (i = rows.begin(); i != rows.end(); ++i) { - MixerStrip* strip = (*i)[track_columns.strip]; + AxisView* s = (*i)[stripable_columns.strip]; + bool const visible = (*i)[stripable_columns.visible]; + boost::shared_ptr stripable = (*i)[stripable_columns.stripable]; - if (strip == 0) { + if (!s) { /* we're in the middle of changing a row, don't worry */ continue; } - bool const visible = (*i)[track_columns.visible]; + VCAMasterStrip* vms; - if (visible) { - strip->set_gui_property ("visible", true); + if ((vms = dynamic_cast (s))) { + if (visible) { + vca_hpacker.pack_start (*vms, false, false); + vms->show (); + n_masters++; + } + continue; + } - if (strip->packed()) { + MixerStrip* strip = dynamic_cast (s); - if (strip->route()->is_master() || strip->route()->is_monitor()) { - out_packer.reorder_child (*strip, -1); + if (!strip) { + continue; + } - } else { - strip_packer.reorder_child (*strip, -1); /* put at end */ - } + if (visible) { + if (strip->packed()) { + strip_packer.reorder_child (*strip, -1); /* put at end */ } else { - - if (strip->route()->is_master() || strip->route()->is_monitor()) { - out_packer.pack_start (*strip, false, false); - } else { - strip_packer.pack_start (*strip, false, false); - } + strip_packer.pack_start (*strip, false, false); strip->set_packed (true); } } else { - strip->set_gui_property ("visible", false); - - if (strip->route()->is_master() || strip->route()->is_monitor()) { + if (stripable->is_master() || stripable->is_monitor()) { /* do nothing, these cannot be hidden */ } else { if (strip->packed()) { @@ -1098,6 +1375,16 @@ Mixer_UI::redisplay_track_list () } } + /* update visibility of VCA assign buttons */ + + if (n_masters == 0) { + UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA"))); + vca_vpacker.hide (); + } else { + UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA"))); + vca_vpacker.show (); + } + _group_tabs->set_dirty (); } @@ -1106,19 +1393,20 @@ Mixer_UI::strip_width_changed () { _group_tabs->set_dirty (); -#ifdef GTKOSX +#ifdef __APPLE__ TreeModel::Children rows = track_model->children(); TreeModel::Children::iterator i; long order; for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) { - MixerStrip* strip = (*i)[track_columns.strip]; + AxisView* av = (*i)[stripable_columns.strip]; + MixerStrip* strip = dynamic_cast (av); if (strip == 0) { continue; } - bool visible = (*i)[track_columns.visible]; + bool visible = (*i)[stripable_columns.visible]; if (visible) { strip->queue_draw(); @@ -1128,24 +1416,49 @@ Mixer_UI::strip_width_changed () } +struct PresentationInfoMixerSorter +{ + bool operator() (boost::shared_ptr a, boost::shared_ptr b) { + if (a->is_master()) { + /* master after everything else */ + return false; + } else if (b->is_master()) { + /* everything else before master */ + return true; + } + return a->presentation_info().order () < b->presentation_info().order (); + } +}; + void Mixer_UI::initial_track_display () { + StripableList sl; + boost::shared_ptr routes = _session->get_routes(); - RouteList copy (*routes); - ARDOUR::SignalOrderRouteSorter sorter; - copy.sort (sorter); + 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)); + } + + sl.sort (PresentationInfoMixerSorter()); { + /* These are also used inside ::add_stripables() but we need + * them here because we're going to clear the track_model also. + */ Unwinder uw1 (no_track_list_redisplay, true); Unwinder uw2 (ignore_reorder, true); track_model->clear (); - add_strips (copy); + add_stripables (sl); } - - _session->sync_order_keys (); redisplay_track_list (); } @@ -1167,10 +1480,46 @@ Mixer_UI::track_display_button_press (GdkEventButton* ev) show_track_list_menu (); return true; } + if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) { + TreeModel::Path path; + TreeViewColumn* column; + int cellx, celly; + if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) { + TreeIter iter = track_model->get_iter (path); + if ((*iter)[stripable_columns.visible]) { + boost::shared_ptr s = (*iter)[stripable_columns.stripable]; + move_stripable_into_view (s); + } + } + } return false; } +void +Mixer_UI::move_stripable_into_view (boost::shared_ptr s) +{ + if (!scroller.get_hscrollbar()) { + return; + } + bool found = false; + int x0 = 0; + 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); + break; + } + } + if (!found) { + return; + } + + Adjustment* adj = scroller.get_hscrollbar()->get_adjustment(); + scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), x0 - 1.0))); +} + void Mixer_UI::build_track_menu () { @@ -1187,24 +1536,41 @@ Mixer_UI::build_track_menu () 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))); } void -Mixer_UI::strip_property_changed (const PropertyChange& what_changed, MixerStrip* mx) +Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost::weak_ptr ws) { - if (!what_changed.contains (ARDOUR::Properties::name)) { + if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) { return; } - ENSURE_GUI_THREAD (*this, &Mixer_UI::strip_name_changed, what_changed, mx) + boost::shared_ptr s = ws.lock (); + + if (!s) { + return; + } TreeModel::Children rows = track_model->children(); TreeModel::Children::iterator i; for (i = rows.begin(); i != rows.end(); ++i) { - if ((*i)[track_columns.strip] == mx) { - (*i)[track_columns.text] = mx->route()->name(); + boost::shared_ptr ss = (*i)[stripable_columns.stripable]; + + if (s == ss) { + + if (what_changed.contains (ARDOUR::Properties::name)) { + (*i)[stripable_columns.text] = s->name(); + } + + if (what_changed.contains (ARDOUR::Properties::hidden)) { + (*i)[stripable_columns.visible] = !s->presentation_info().hidden(); + redisplay_track_list (); + } + return; } } @@ -1221,12 +1587,14 @@ 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)) { - return false; + _group_tabs->get_menu(0)->popup (1, ev->time); + return true; } TreeIter iter = group_model->get_iter (path); if (!iter) { - return false; + _group_tabs->get_menu(0)->popup (1, ev->time); + return true; } RouteGroup* group = (*iter)[group_columns.group]; @@ -1237,11 +1605,11 @@ Mixer_UI::group_display_button_press (GdkEventButton* ev) } switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) { - case 0: + case 1: if (Keyboard::is_edit_event (ev)) { if (group) { // edit_route_group (group); -#ifdef GTKOSX +#ifdef __APPLE__ group_display.queue_draw(); #endif return true; @@ -1249,11 +1617,11 @@ Mixer_UI::group_display_button_press (GdkEventButton* ev) } break; - case 1: + case 0: { bool visible = (*iter)[group_columns.visible]; (*iter)[group_columns.visible] = !visible; -#ifdef GTKOSX +#ifdef __APPLE__ group_display.queue_draw(); #endif return true; @@ -1289,6 +1657,14 @@ Mixer_UI::route_groups_changed () group_model->clear (); +#if 0 + /* this is currently not used, + * Mixer_UI::group_display_button_press() has a case for it, + * and a commented edit_route_group() but that's n/a since 2011. + * + * This code is left as reminder that + * row[group_columns.group] = 0 has special meaning. + */ { TreeModel::Row row; row = *(group_model->append()); @@ -1296,6 +1672,7 @@ Mixer_UI::route_groups_changed () row[group_columns.text] = (_("-all-")); row[group_columns.group] = 0; } +#endif _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group)); @@ -1306,9 +1683,7 @@ Mixer_UI::route_groups_changed () void Mixer_UI::new_route_group () { - RouteList rl; - - _group_tabs->run_new_group_dialog (rl); + _group_tabs->run_new_group_dialog (0, false); } void @@ -1384,6 +1759,35 @@ Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& } } +void +Mixer_UI::show_mixer_list (bool yn) +{ + if (yn) { + list_vpacker.show (); + } else { + list_vpacker.hide (); + } + + _show_mixer_list = yn; +} + +void +Mixer_UI::show_monitor_section (bool yn) +{ + if (!monitor_section()) { + return; + } + if (monitor_section()->tearoff().torn_off()) { + return; + } + + if (yn) { + monitor_section()->tearoff().show(); + } else { + monitor_section()->tearoff().hide(); + } +} + void Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text) { @@ -1477,7 +1881,7 @@ Mixer_UI::add_route_group (RouteGroup* group) if (focus) { TreeViewColumn* col = group_display.get_column (0); - CellRendererText* name_cell = dynamic_cast(group_display.get_column_cell_renderer (0)); + CellRendererText* name_cell = dynamic_cast(group_display.get_column_cell_renderer (1)); group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true); } @@ -1492,7 +1896,7 @@ Mixer_UI::strip_scroller_button_release (GdkEventButton* ev) using namespace Menu_Helpers; if (Keyboard::is_context_menu_event (ev)) { - ARDOUR_UI::instance()->add_route (this); + ARDOUR_UI::instance()->add_route (); return true; } @@ -1500,73 +1904,77 @@ Mixer_UI::strip_scroller_button_release (GdkEventButton* ev) } void -Mixer_UI::set_strip_width (Width w, bool save) +Mixer_UI::scroller_drag_data_received (const Glib::RefPtr& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time) { - _strip_width = w; + printf ("Mixer_UI::scroller_drag_data_received\n"); + if (data.get_target() != "PluginFavoritePtr") { + context->drag_finish (false, false, time); + return; + } - for (list::iterator i = strips.begin(); i != strips.end(); ++i) { - (*i)->set_width_enum (w, save ? (*i)->width_owner() : this); + const void * d = data.get_data(); + const Gtkmm2ext::DnDTreeView* tv = reinterpret_cast*>(d); + + PluginPresetList nfos; + TreeView* source; + tv->get_object_drag_data (nfos, &source); + + Route::ProcessorList pl; + bool ok = false; + + for (list::const_iterator i = nfos.begin(); i != nfos.end(); ++i) { + PluginPresetPtr ppp = (*i); + PluginInfoPtr pip = ppp->_pip; + 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); + ok = true; } + + context->drag_finish (ok, false, time); } void -Mixer_UI::set_window_pos_and_size () +Mixer_UI::set_strip_width (Width w, bool save) { - resize (m_width, m_height); - move (m_root_x, m_root_y); -} + _strip_width = w; - void -Mixer_UI::get_window_pos_and_size () -{ - get_position(m_root_x, m_root_y); - get_size(m_width, m_height); + for (list::iterator i = strips.begin(); i != strips.end(); ++i) { + (*i)->set_width_enum (w, save ? (*i)->width_owner() : this); + } } -int -Mixer_UI::set_state (const XMLNode& node) -{ - const XMLProperty* prop; - XMLNode* geometry; - - m_width = default_width; - m_height = default_height; - m_root_x = 1; - m_root_y = 1; - if ((geometry = find_named_node (node, "geometry")) != 0) { - - XMLProperty* prop; - - if ((prop = geometry->property("x_size")) == 0) { - prop = geometry->property ("x-size"); +struct PluginStateSorter { +public: + bool operator() (PluginInfoPtr a, PluginInfoPtr b) const { + std::list::const_iterator aiter = std::find(_user.begin(), _user.end(), (*a).unique_id); + std::list::const_iterator biter = std::find(_user.begin(), _user.end(), (*b).unique_id); + if (aiter != _user.end() && biter != _user.end()) { + return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter); } - if (prop) { - m_width = atoi(prop->value()); - } - if ((prop = geometry->property("y_size")) == 0) { - prop = geometry->property ("y-size"); + if (aiter != _user.end()) { + return true; } - if (prop) { - m_height = atoi(prop->value()); + if (biter != _user.end()) { + return false; } + return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1; + } - if ((prop = geometry->property ("x_pos")) == 0) { - prop = geometry->property ("x-pos"); - } - if (prop) { - m_root_x = atoi (prop->value()); + PluginStateSorter(std::list user) : _user (user) {} +private: + std::list _user; +}; - } - if ((prop = geometry->property ("y_pos")) == 0) { - prop = geometry->property ("y-pos"); - } - if (prop) { - m_root_y = atoi (prop->value()); - } - } +int +Mixer_UI::set_state (const XMLNode& node, int version) +{ + XMLProperty const * prop; + LocaleGuard lg; - set_window_pos_and_size (); + Tabbable::set_state (node, version); if ((prop = node.property ("narrow-strips"))) { if (string_is_affirmative (prop->value())) { @@ -1589,125 +1997,106 @@ Mixer_UI::set_state (const XMLNode& node) Glib::RefPtr tact = Glib::RefPtr::cast_dynamic(act); bool fs = tact && tact->get_active(); if (yn ^ fs) { - ActionManager::do_action ("Common", - "ToggleMaximalMixer"); + 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); + + /* do it twice to force the change */ + tact->set_active (!yn); + tact->set_active (yn); + } + + 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) { + if ((prop = (*i)->property ("unique-id"))) { + std::string unique_id = prop->value(); + order.push_back (unique_id); + if ((prop = (*i)->property ("expanded"))) { + favorite_ui_state[unique_id] = string_is_affirmative (prop->value()); + } + } + } + PluginStateSorter cmp (order); + favorite_order.sort (cmp); + sync_treeview_from_favorite_order (); + } return 0; } XMLNode& -Mixer_UI::get_state (void) +Mixer_UI::get_state () { - XMLNode* node = new XMLNode ("Mixer"); - - if (is_realized()) { - Glib::RefPtr win = get_window(); - - get_window_pos_and_size (); + XMLNode* node = new XMLNode (X_("Mixer")); + char buf[128]; + LocaleGuard lg; - XMLNode* geometry = new XMLNode ("geometry"); - char buf[32]; - snprintf(buf, sizeof(buf), "%d", m_width); - geometry->add_property(X_("x_size"), string(buf)); - snprintf(buf, sizeof(buf), "%d", m_height); - geometry->add_property(X_("y_size"), string(buf)); - snprintf(buf, sizeof(buf), "%d", m_root_x); - geometry->add_property(X_("x_pos"), string(buf)); - snprintf(buf, sizeof(buf), "%d", m_root_y); - geometry->add_property(X_("y_pos"), string(buf)); + node->add_child_nocopy (Tabbable::get_state()); - // written only for compatibility, they are not used. - snprintf(buf, sizeof(buf), "%d", 0); - geometry->add_property(X_("x_off"), string(buf)); - snprintf(buf, sizeof(buf), "%d", 0); - geometry->add_property(X_("y_off"), string(buf)); - - snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast(&rhs_pane1)->gobj())); - geometry->add_property(X_("mixer_rhs_pane1_pos"), string(buf)); - snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast(&list_hpane)->gobj())); - geometry->add_property(X_("mixer_list_hpane_pos"), string(buf)); - - node->add_child_nocopy (*geometry); - } + 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"); - return *node; -} - - -void -Mixer_UI::pane_allocation_handler (Allocation&, Gtk::Paned* which) -{ - int pos; - XMLProperty* prop = 0; - char buf[32]; - XMLNode* node = ARDOUR_UI::instance()->mixer_settings(); - XMLNode* geometry; - int height; - static int32_t done[3] = { 0, 0, 0 }; - - height = default_height; - - if ((geometry = find_named_node (*node, "geometry")) != 0) { - - if ((prop = geometry->property ("y_size")) == 0) { - prop = geometry->property ("y-size"); - } - if (prop) { - height = atoi (prop->value()); + store_current_favorite_order (); + XMLNode* plugin_order = new XMLNode ("PluginOrder"); + int 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); + if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) { + p->add_property ("expanded", favorite_ui_state[(*i)->unique_id]); } + plugin_order->add_child_nocopy (*p); } + node->add_child_nocopy (*plugin_order); - if (which == static_cast (&rhs_pane1)) { - - if (done[0]) { - return; - } - - if (!geometry || (prop = geometry->property("mixer-rhs-pane1-pos")) == 0) { - pos = height / 3; - snprintf (buf, sizeof(buf), "%d", pos); - } else { - pos = atoi (prop->value()); - } - - if ((done[0] = GTK_WIDGET(rhs_pane1.gobj())->allocation.height > pos)) { - rhs_pane1.set_position (pos); - } - - } else if (which == static_cast (&list_hpane)) { - - if (done[2]) { - return; - } - - if (!geometry || (prop = geometry->property("mixer-list-hpane-pos")) == 0) { - pos = 75; - snprintf (buf, sizeof(buf), "%d", pos); - } else { - pos = atoi (prop->value()); - } - - if ((done[2] = GTK_WIDGET(list_hpane.gobj())->allocation.width > pos)) { - list_hpane.set_position (pos); - } - } + return *node; } + void Mixer_UI::scroll_left () { if (!scroller.get_hscrollbar()) return; Adjustment* adj = scroller.get_hscrollbar()->get_adjustment(); - /* stupid GTK: can't rely on clamping across versions */ - scroller.get_hscrollbar()->set_value (max (adj->get_lower(), adj->get_value() - adj->get_step_increment())); + int sc_w = scroller.get_width(); + int sp_w = strip_packer.get_width(); + if (sp_w <= sc_w) { + return; + } + int lp = adj->get_value(); + int lm = 0; + using namespace Gtk::Box_Helpers; + const BoxList& strips = strip_packer.children(); + for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) { + lm += i->get_widget()->get_width (); + if (lm >= lp) { + lm -= i->get_widget()->get_width (); + break; + } + } + scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0))); } void @@ -1715,46 +2104,22 @@ Mixer_UI::scroll_right () { if (!scroller.get_hscrollbar()) return; Adjustment* adj = scroller.get_hscrollbar()->get_adjustment(); - /* stupid GTK: can't rely on clamping across versions */ - scroller.get_hscrollbar()->set_value (min (adj->get_upper(), adj->get_value() + adj->get_step_increment())); -} - -bool -Mixer_UI::on_key_press_event (GdkEventKey* ev) -{ - /* focus widget gets first shot, then bindings, otherwise - forward to main window - */ - - if (gtk_window_propagate_key_event (GTK_WINDOW(gobj()), ev)) { - return true; - } - - KeyboardKey k (ev->state, ev->keyval); - - if (bindings.activate (k, Bindings::Press)) { - return true; - } - - return forward_key_press (ev); -} - -bool -Mixer_UI::on_key_release_event (GdkEventKey* ev) -{ - if (gtk_window_propagate_key_event (GTK_WINDOW(gobj()), ev)) { - return true; + int sc_w = scroller.get_width(); + int sp_w = strip_packer.get_width(); + if (sp_w <= sc_w) { + return; } - - KeyboardKey k (ev->state, ev->keyval); - - if (bindings.activate (k, Bindings::Release)) { - return true; + int lp = adj->get_value(); + int lm = 0; + using namespace Gtk::Box_Helpers; + const BoxList& strips = strip_packer.children(); + for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) { + lm += i->get_widget()->get_width (); + if (lm > lp + 1) { + break; + } } - - /* don't forward releases */ - - return true; + scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0))); } bool @@ -1798,12 +2163,14 @@ Mixer_UI::parameter_changed (string const & p) _group_tabs->hide (); } } else if (p == "default-narrow_ms") { - bool const s = Config->get_default_narrow_ms (); + bool const s = UIConfiguration::instance().get_default_narrow_ms (); for (list::iterator i = strips.begin(); i != strips.end(); ++i) { (*i)->set_width_enum (s ? Narrow : Wide, this); } - } else if (p == "remote-model") { - reset_remote_control_ids (); + } else if (p == "use-monitor-bus") { + if (_session && !_session->monitor_out()) { + monitor_section_detached (); + } } } @@ -1827,23 +2194,25 @@ Mixer_UI::plugin_selector() void Mixer_UI::setup_track_display () { - track_model = ListStore::create (track_columns); + track_model = ListStore::create (stripable_columns); track_display.set_model (track_model); - track_display.append_column (_("Strips"), track_columns.text); - track_display.append_column (_("Show"), track_columns.visible); + track_display.append_column (_("Show"), stripable_columns.visible); + track_display.append_column (_("Strips"), stripable_columns.text); track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0)); track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1)); - track_display.get_column (0)->set_expand(true); - track_display.get_column (1)->set_expand(false); + track_display.get_column (0)->set_expand(false); + track_display.get_column (1)->set_expand(true); + track_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED); track_display.set_name (X_("EditGroupList")); track_display.get_selection()->set_mode (Gtk::SELECTION_NONE); track_display.set_reorderable (true); track_display.set_headers_visible (true); + track_display.set_can_focus(false); track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete)); track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder)); - CellRendererToggle* track_list_visible_cell = dynamic_cast(track_display.get_column_cell_renderer (1)); + CellRendererToggle* track_list_visible_cell = dynamic_cast(track_display.get_column_cell_renderer (0)); track_list_visible_cell->property_activatable() = true; track_list_visible_cell->property_radio() = false; track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed)); @@ -1879,16 +2248,19 @@ Mixer_UI::setup_track_display () void Mixer_UI::new_track_or_bus () { - ARDOUR_UI::instance()->add_route (this); + ARDOUR_UI::instance()->add_route (); } - void Mixer_UI::update_title () { + if (!own_window()) { + return; + } + if (_session) { string n; - + if (_session->snap_name() != _session->name()) { n = _session->snap_name (); } else { @@ -1898,17 +2270,17 @@ Mixer_UI::update_title () if (_session->dirty ()) { n = "*" + n; } - + WindowTitle title (n); title += S_("Window|Mixer"); title += Glib::get_application_name (); - set_title (title.get_string()); + own_window()->set_title (title.get_string()); } else { - + WindowTitle title (S_("Window|Mixer")); title += Glib::get_application_name (); - set_title (title.get_string()); + own_window()->set_title (title.get_string()); } } @@ -1918,7 +2290,7 @@ Mixer_UI::strip_by_x (int x) for (list::iterator i = strips.begin(); i != strips.end(); ++i) { int x1, x2, y; - (*i)->translate_coordinates (*this, 0, 0, x1, y); + (*i)->translate_coordinates (_content, 0, 0, x1, y); x2 = x1 + (*i)->get_width(); if (x >= x1 && x <= x2) { @@ -1930,12 +2302,12 @@ Mixer_UI::strip_by_x (int x) } void -Mixer_UI::set_route_targets_for_operation () +Mixer_UI::set_axis_targets_for_operation () { - _route_targets.clear (); + _axis_targets.clear (); if (!_selection.empty()) { - _route_targets = _selection.routes; + _axis_targets = _selection.axes; return; } @@ -1947,8 +2319,11 @@ 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; } } @@ -1958,40 +2333,688 @@ Mixer_UI::toggle_midi_input_active (bool flip_others) boost::shared_ptr rl (new RouteList); bool onoff = false; - set_route_targets_for_operation (); + set_axis_targets_for_operation (); - for (RouteUISelection::iterator r = _route_targets.begin(); r != _route_targets.end(); ++r) { - boost::shared_ptr mt = (*r)->midi_track(); + for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) { + boost::shared_ptr mt = boost::dynamic_pointer_cast ((*r)->stripable()); if (mt) { - rl->push_back ((*r)->route()); + rl->push_back (mt); onoff = !mt->input_active(); } } - + _session->set_exclusive_input_active (rl, onoff, flip_others); } void Mixer_UI::maximise_mixer_space () { - if (_maximised) { + if (!own_window()) { return; } - fullscreen (); + if (_maximised) { + return; + } + _window->fullscreen (); _maximised = true; } void Mixer_UI::restore_mixer_space () { - if (!_maximised) { + if (!own_window()) { return; } - unfullscreen(); + if (!_maximised) { + return; + } + own_window()->unfullscreen(); _maximised = false; } + +void +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 (); +} + +void +Mixer_UI::monitor_section_detached () +{ + Glib::RefPtr act = ActionManager::get_action ("Common", "ToggleMonitorSection"); + act->set_sensitive (false); +} + +void +Mixer_UI::store_current_favorite_order () +{ + typedef Gtk::TreeModel::Children type_children; + type_children children = favorite_plugins_model->children(); + favorite_order.clear(); + for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter) + { + Gtk::TreeModel::Row row = *iter; + ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin]; + favorite_order.push_back (ppp->_pip); + std::string name = row[favorite_plugins_columns.name]; + favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter)); + } +} + +void +Mixer_UI::save_favorite_ui_state (const TreeModel::iterator& iter, const TreeModel::Path& path) +{ + Gtk::TreeModel::Row row = *iter; + ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin]; + assert (ppp); + favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter)); +} + +void +Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs) +{ + PluginManager& manager (PluginManager::instance()); + for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) { + if (manager.get_status (*i) != PluginManager::Favorite) { + continue; + } + result.push_back (*i); + } +} + +struct PluginCustomSorter { +public: + bool operator() (PluginInfoPtr a, PluginInfoPtr b) const { + PluginInfoList::const_iterator aiter = _user.begin(); + PluginInfoList::const_iterator biter = _user.begin(); + while (aiter != _user.end()) { if ((*aiter)->unique_id == a->unique_id) { break; } ++aiter; } + while (biter != _user.end()) { if ((*biter)->unique_id == b->unique_id) { break; } ++biter; } + + if (aiter != _user.end() && biter != _user.end()) { + return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter); + } + if (aiter != _user.end()) { + return true; + } + if (biter != _user.end()) { + return false; + } + return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1; + } + PluginCustomSorter(PluginInfoList user) : _user (user) {} +private: + PluginInfoList _user; +}; + +void +Mixer_UI::refill_favorite_plugins () +{ + PluginInfoList plugs; + PluginManager& mgr (PluginManager::instance()); + +#ifdef LV2_SUPPORT + refiller (plugs, mgr.lv2_plugin_info ()); +#endif +#ifdef WINDOWS_VST_SUPPORT + refiller (plugs, mgr.windows_vst_plugin_info ()); +#endif +#ifdef LXVST_SUPPORT + refiller (plugs, mgr.lxvst_plugin_info ()); +#endif +#ifdef AUDIOUNIT_SUPPORT + refiller (plugs, mgr.au_plugin_info ()); +#endif + refiller (plugs, mgr.ladspa_plugin_info ()); + refiller (plugs, mgr.lua_plugin_info ()); + + store_current_favorite_order (); + + PluginCustomSorter cmp (favorite_order); + plugs.sort (cmp); + + favorite_order = plugs; + + sync_treeview_from_favorite_order (); +} + +void +Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&) +{ + TreeIter iter; + if (!(iter = favorite_plugins_model->get_iter (path))) { + return; + } + ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin]; + if (!ppp) { + return; + } + PluginInfoPtr pip = ppp->_pip; + if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) { + if (favorite_ui_state[pip->unique_id]) { + favorite_plugins_display.expand_row (path, true); + } + } +} + +void +Mixer_UI::sync_treeview_from_favorite_order () +{ + favorite_plugins_model->clear (); + for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i) { + PluginInfoPtr pip = (*i); + + TreeModel::Row newrow = *(favorite_plugins_model->append()); + newrow[favorite_plugins_columns.name] = (*i)->name; + newrow[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip)); + if (!_session) { + continue; + } + + vector presets = (*i)->get_presets (true); + for (vector::const_iterator j = presets.begin(); j != presets.end(); ++j) { + Gtk::TreeModel::Row child_row = *(favorite_plugins_model->append (newrow.children())); + child_row[favorite_plugins_columns.name] = (*j).label; + child_row[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip, &(*j))); + } + if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) { + if (favorite_ui_state[pip->unique_id]) { + favorite_plugins_display.expand_row (favorite_plugins_model->get_path(newrow), true); + } + } + } +} + +void +Mixer_UI::popup_note_context_menu (GdkEventButton *ev) +{ + using namespace Gtk::Menu_Helpers; + + Gtk::Menu* m = manage (new Menu); + MenuList& items = m->items (); + + if (_selection.axes.empty()) { + items.push_back (MenuElem (_("No Track/Bus is selected."))); + } else { + items.push_back (MenuElem (_("Add at the top"), + sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop))); + items.push_back (MenuElem (_("Add Pre-Fader"), + sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPreFader))); + items.push_back (MenuElem (_("Add Post-Fader"), + sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPostFader))); + items.push_back (MenuElem (_("Add at the end"), + sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom))); + } + + items.push_back (SeparatorElem()); + + items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites))); + + ARDOUR::PluginPresetPtr ppp = selected_plugin(); + if (ppp && ppp->_preset.valid && ppp->_preset.user) { + // we cannot currently delete AU presets + if (!ppp->_pip || ppp->_pip->type != AudioUnit) { + items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset))); + } + } + + m->popup (ev->button, ev->time); +} + +bool +Mixer_UI::plugin_row_button_press (GdkEventButton *ev) +{ + if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3) ) { + TreeModel::Path path; + TreeViewColumn* column; + int cellx, celly; + if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) { + Glib::RefPtr selection = favorite_plugins_display.get_selection(); + if (selection) { + selection->unselect_all(); + selection->select(path); + } + } + ARDOUR::PluginPresetPtr ppp = selected_plugin(); + if (ppp) { + popup_note_context_menu (ev); + } + } + return false; +} + + +PluginPresetPtr +Mixer_UI::selected_plugin () +{ + Glib::RefPtr selection = favorite_plugins_display.get_selection(); + if (!selection) { + return PluginPresetPtr(); + } + Gtk::TreeModel::iterator iter = selection->get_selected(); + if (!iter) { + return PluginPresetPtr(); + } + return (*iter)[favorite_plugins_columns.plugin]; +} + +void +Mixer_UI::add_selected_processor (ProcessorPosition pos) +{ + ARDOUR::PluginPresetPtr ppp = selected_plugin(); + if (ppp) { + add_favorite_processor (ppp, pos); + } +} + +void +Mixer_UI::delete_selected_preset () +{ + if (!_session) { + return; + } + ARDOUR::PluginPresetPtr ppp = selected_plugin(); + if (!ppp || !ppp->_preset.valid || !ppp->_preset.user) { + return; + } + PluginPtr plugin = ppp->_pip->load (*_session); + plugin->get_presets(); + plugin->remove_preset (ppp->_preset.label); +} + +void +Mixer_UI::remove_selected_from_favorites () +{ + ARDOUR::PluginPresetPtr ppp = selected_plugin(); + if (!ppp) { + return; + } + PluginManager::PluginStatusType status = PluginManager::Normal; + PluginManager& manager (PluginManager::instance()); + + manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status); + manager.save_statuses (); +} + +void +Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* column) +{ + TreeIter iter; + if (!(iter = favorite_plugins_model->get_iter (path))) { + return; + } + ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin]; + add_favorite_processor (ppp, AddPreFader); // TODO: preference?! +} + +void +Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos) +{ + if (!_session || _selection.axes.empty()) { + return; + } + + PluginInfoPtr pip = ppp->_pip; + for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) { + boost::shared_ptr rt = boost::dynamic_pointer_cast ((*i)->stripable()); + + if (!rt) { + continue; + } + + PluginPtr p = pip->load (*_session); + + if (!p) { + continue; + } + + if (ppp->_preset.valid) { + p->load_preset (ppp->_preset); + } + + Route::ProcessorStreams err; + boost::shared_ptr processor (new PluginInsert (*_session, p)); + + switch (pos) { + case AddTop: + rt->add_processor_by_index (processor, 0, &err, Config->get_new_plugins_active ()); + break; + case AddPreFader: + rt->add_processor (processor, PreFader, &err, Config->get_new_plugins_active ()); + break; + case AddPostFader: + { + int idx = 0; + int pos = 0; + for (;;++idx) { + boost::shared_ptr np = rt->nth_processor (idx); + if (!np) { + break; + } + if (!np->display_to_user()) { + continue; + } + if (boost::dynamic_pointer_cast (np) && // Fader, not Trim + boost::dynamic_pointer_cast (np)->gain_control()->parameter().type() == GainAutomation) { + break; + } + ++pos; + } + rt->add_processor_by_index (processor, ++pos, &err, Config->get_new_plugins_active ()); + } + break; + case AddBottom: + rt->add_processor_by_index (processor, -1, &err, Config->get_new_plugins_active ()); + break; + } + } +} + +bool +PluginTreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& data) const +{ + if (data.get_target() != "GTK_TREE_MODEL_ROW") { + return false; + } + + // only allow to re-order top-level items + TreePath src; + if (TreePath::get_from_selection_data (data, src)) { + if (src.up() && src.up()) { + return false; + } + } + + // don't allow to drop as child-rows. + Gtk::TreeModel::Path _dest = dest; // un const + const bool is_child = _dest.up (); // explicit bool for clang + if (!is_child || _dest.empty ()) { + return true; + } + return false; +} + +void +Mixer_UI::plugin_drop (const Glib::RefPtr&, const Gtk::SelectionData& data) +{ + if (data.get_target() != "PluginPresetPtr") { + return; + } + if (data.get_length() != sizeof (PluginPresetPtr)) { + return; + } + const void *d = data.get_data(); + const PluginPresetPtr ppp = *(static_cast (d)); + + PluginManager::PluginStatusType status = PluginManager::Favorite; + PluginManager& manager (PluginManager::instance()); + + manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status); + manager.save_statuses (); +} + +void +Mixer_UI::do_vca_assign (boost::shared_ptr vca) +{ + /* call protected MixerActor:: method */ + vca_assign (vca); +} + +void +Mixer_UI::do_vca_unassign (boost::shared_ptr vca) +{ + /* call protected MixerActor:: method */ + vca_unassign (vca); +} + +void +Mixer_UI::show_vca_slaves (boost::shared_ptr vca) +{ + boost::shared_ptr v = spilled_vca.lock(); + if (v != vca) { + spilled_vca = vca; + show_vca_change (vca); /* EMIT SIGNAL */ + if (vca) { + _group_tabs->hide (); + } else { + _group_tabs->show (); + } + redisplay_track_list (); + } +} + +bool +Mixer_UI::showing_vca_slaves_for (boost::shared_ptr vca) const +{ + return vca == spilled_vca.lock(); +} + +void +Mixer_UI::register_actions () +{ + Glib::RefPtr group = myactions.create_action_group (X_("Mixer")); + + myactions.register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action)); + myactions.register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action)); + myactions.register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action)); + myactions.register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action)); + myactions.register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action)); + myactions.register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action)); + + + myactions.register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors)); + myactions.register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors)); + myactions.register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors)); + myactions.register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors)); + myactions.register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors)); + myactions.register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors)); + myactions.register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins)); + myactions.register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none)); + + myactions.register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left)); + myactions.register_action (group, "scroll-right", _("Scroll Mixer Window to the 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"), + sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false)); +} + +void +Mixer_UI::load_bindings () +{ + bindings = Bindings::get_bindings (X_("Mixer"), myactions); +} + +template void +Mixer_UI::control_action (boost::shared_ptr (Stripable::*get_control)() const) +{ + boost::shared_ptr cl (new ControlList); + boost::shared_ptr ac; + bool val = false; + bool have_val = false; + + set_axis_targets_for_operation (); + + BOOST_FOREACH(AxisView* r, _axis_targets) { + boost::shared_ptr s = r->stripable(); + if (s) { + ac = (s.get()->*get_control)(); + if (ac) { + cl->push_back (ac); + if (!have_val) { + val = !ac->get_value(); + have_val = true; + } + } + } + } + + _session->set_controls (cl, val, Controllable::UseGroup); +} + +void +Mixer_UI::solo_action () +{ + control_action (&Stripable::solo_control); +} + +void +Mixer_UI::mute_action () +{ + control_action (&Stripable::mute_control); +} + +void +Mixer_UI::rec_enable_action () +{ + control_action (&Stripable::rec_enable_control); +} + +void +Mixer_UI::step_gain_up_action () +{ + set_axis_targets_for_operation (); + + BOOST_FOREACH(AxisView* r, _axis_targets) { + MixerStrip* ms = dynamic_cast (r); + if (ms) { + ms->step_gain_up (); + } + } +} + +void +Mixer_UI::step_gain_down_action () +{ + set_axis_targets_for_operation (); + + BOOST_FOREACH(AxisView* r, _axis_targets) { + MixerStrip* ms = dynamic_cast (r); + if (ms) { + ms->step_gain_down (); + } + } +} + +void +Mixer_UI::unity_gain_action () +{ + set_axis_targets_for_operation (); + + BOOST_FOREACH(AxisView* r, _axis_targets) { + boost::shared_ptr s = r->stripable(); + if (s) { + boost::shared_ptr ac = s->gain_control(); + if (ac) { + ac->set_value (1.0, Controllable::UseGroup); + } + } + } +} + +void +Mixer_UI::copy_processors () +{ + set_axis_targets_for_operation (); + + BOOST_FOREACH(AxisView* r, _axis_targets) { + MixerStrip* ms = dynamic_cast (r); + if (ms) { + ms->copy_processors (); + } + } +} +void +Mixer_UI::cut_processors () +{ + set_axis_targets_for_operation (); + + BOOST_FOREACH(AxisView* r, _axis_targets) { + MixerStrip* ms = dynamic_cast (r); + if (ms) { + ms->cut_processors (); + } + } +} +void +Mixer_UI::paste_processors () +{ + set_axis_targets_for_operation (); + + BOOST_FOREACH(AxisView* r, _axis_targets) { + MixerStrip* ms = dynamic_cast (r); + if (ms) { + ms->paste_processors (); + } + } +} +void +Mixer_UI::select_all_processors () +{ + set_axis_targets_for_operation (); + + BOOST_FOREACH(AxisView* r, _axis_targets) { + MixerStrip* ms = dynamic_cast (r); + if (ms) { + ms->select_all_processors (); + } + } +} +void +Mixer_UI::toggle_processors () +{ + set_axis_targets_for_operation (); + + BOOST_FOREACH(AxisView* r, _axis_targets) { + MixerStrip* ms = dynamic_cast (r); + if (ms) { + ms->toggle_processors (); + } + } +} +void +Mixer_UI::ab_plugins () +{ + set_axis_targets_for_operation (); + + BOOST_FOREACH(AxisView* r, _axis_targets) { + MixerStrip* ms = dynamic_cast (r); + if (ms) { + ms->ab_plugins (); + } + } +} + +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 +}