X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmixer_ui.cc;h=0e6d21b7fc4708c3411fa0573b5bfd08b5238d4b;hb=4b230069f8140547b4ef42989a51716d3c673dcb;hp=b750f8a470ed4e7cc0e6e5813b112e7cd243b092;hpb=b6f4cdaea27fbf49f924b2684d4c638089314067;p=ardour.git diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index b750f8a470..e28fb40edf 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -17,6 +17,10 @@ */ +#ifdef WAF_BUILD +#include "gtk2ardour-config.h" +#endif + #include #include #include @@ -24,35 +28,42 @@ #include #include "pbd/convert.h" -#include "pbd/stacktrace.h" -#include +#include "pbd/unwind.h" + +#include #include #include -#include +#include #include -#include "ardour/audio_diskstream.h" -#include "ardour/audio_track.h" +#include "ardour/debug.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/session_route.h" #include "keyboard.h" #include "mixer_ui.h" #include "mixer_strip.h" +#include "monitor_section.h" #include "plugin_selector.h" +#include "public_editor.h" #include "ardour_ui.h" #include "prompter.h" #include "utils.h" +#include "route_sorter.h" #include "actions.h" #include "gui_thread.h" #include "mixer_group_tabs.h" +#include "timers.h" +#include "ui_config.h" #include "i18n.h" using namespace ARDOUR; +using namespace ARDOUR_UI_UTILS; using namespace PBD; using namespace Gtk; using namespace Glib; @@ -60,22 +71,45 @@ using namespace Gtkmm2ext; using namespace std; using PBD::atoi; +using PBD::Unwinder; -Mixer_UI::Mixer_UI () - : Window (Gtk::WINDOW_TOPLEVEL) +Mixer_UI* Mixer_UI::_instance = 0; + +Mixer_UI* +Mixer_UI::instance () { - _strip_width = Config->get_default_narrow_ms() ? Narrow : Wide; - track_menu = 0; - route_group_context_menu = 0; - no_track_list_redisplay = false; - in_group_row_change = false; - _visible = false; - strip_redisplay_does_not_reset_order_keys = false; - strip_redisplay_does_not_sync_order_keys = false; - ignore_sync = false; + if (!_instance) { + _instance = new Mixer_UI; + } - Route::SyncOrderKeys.connect (*this, ui_bind (&Mixer_UI::sync_order_keys, this, _1), gui_context()); + return _instance; +} +Mixer_UI::Mixer_UI () + : Window (Gtk::WINDOW_TOPLEVEL) + , VisibilityTracker (*((Gtk::Window*) this)) + , _visible (false) + , 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) + , ignore_reorder (false) + , _in_group_rebuild_or_clear (false) + , _route_deletion_in_progress (false) + , _following_editor_selection (false) + , _maximised (false) +{ + /* allow this window to become the key focus window */ + set_flags (CAN_FOCUS); + + Route::SyncOrderKeys.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::sync_treeview_from_order_keys, this), gui_context()); + + scroller.set_can_default (true); + 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)); @@ -91,31 +125,7 @@ Mixer_UI::Mixer_UI () scroller.add (*b); scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC); - track_model = ListStore::create (track_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.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.set_name (X_("MixerTrackDisplayList")); - track_display.get_selection()->set_mode (Gtk::SELECTION_NONE); - track_display.set_reorderable (true); - track_display.set_headers_visible (true); - - track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete)); - track_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_change)); - 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)); - track_list_visible_cell->property_activatable() = true; - track_list_visible_cell->property_radio() = false; - - track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false); - - track_display_scroller.add (track_display); - track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); + setup_track_display (); group_model = ListStore::create (group_columns); group_display.set_model (group_model); @@ -125,11 +135,12 @@ Mixer_UI::Mixer_UI () 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.set_name ("MixerGroupList"); + 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 */ @@ -144,7 +155,8 @@ Mixer_UI::Mixer_UI () active_cell->property_radio() = false; group_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change)); - + /* We use this to notice drag-and-drop reorders of the group list */ + group_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_deleted)); group_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press), false); group_display_scroller.add (group_display); @@ -170,16 +182,12 @@ Mixer_UI::Mixer_UI () 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_remove_button); 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); - track_display_frame.set_name("BaseFrame"); - track_display_frame.set_shadow_type (Gtk::SHADOW_IN); - track_display_frame.add(track_display_scroller); - group_display_frame.set_name ("BaseFrame"); group_display_frame.set_shadow_type (Gtk::SHADOW_IN); group_display_frame.add (group_display_vbox); @@ -196,8 +204,8 @@ Mixer_UI::Mixer_UI () #else global_hpacker.pack_start (out_packer, false, false, 12); #endif - list_hpane.add1(list_vpacker); - list_hpane.add2(global_hpacker); + list_hpane.pack1(list_vpacker, false, true); + list_hpane.pack2(global_hpacker, true, false); rhs_pane1.signal_size_allocate().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::pane_allocation_handler), static_cast (&rhs_pane1))); @@ -209,21 +217,15 @@ Mixer_UI::Mixer_UI () add (global_vpacker); set_name ("MixerWindow"); - WindowTitle title(Glib::get_application_name()); - title += _("Mixer"); - set_title (title.get_string()); + update_title (); - set_wmclass (X_("ardour_mixer"), "Ardour"); - - add_accel_group (ActionManager::ui_manager->get_accel_group()); + set_wmclass (X_("ardour_mixer"), PROGRAM_NAME); signal_delete_event().connect (sigc::mem_fun (*this, &Mixer_UI::hide_window)); add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK); signal_configure_event().connect (sigc::mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler)); - _selection.RoutesChanged.connect (sigc::mem_fun(*this, &Mixer_UI::follow_strip_selection)); - route_group_display_button_box->show(); route_group_add_button->show(); route_group_remove_button->show(); @@ -237,29 +239,37 @@ Mixer_UI::Mixer_UI () list_vpacker.show(); group_display_button_label.show(); group_display_button.show(); - track_display_scroller.show(); group_display_scroller.show(); group_display_vbox.show(); - track_display_frame.show(); group_display_frame.show(); rhs_pane1.show(); strip_packer.show(); out_packer.show(); list_hpane.show(); - track_display.show(); group_display.show(); - auto_rebinding = FALSE; - - MixerStrip::CatchDeletion.connect (*this, ui_bind (&Mixer_UI::remove_strip, this, _1), gui_context()); + MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context()); - _plugin_selector = new PluginSelector (PluginManager::the_manager ()); +#ifndef DEFER_PLUGIN_SELECTOR_LOAD + _plugin_selector = new PluginSelector (PluginManager::instance ()); +#endif } Mixer_UI::~Mixer_UI () { + if (_monitor_section) { + delete _monitor_section; + } + delete _plugin_selector; } +void +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) { @@ -273,6 +283,9 @@ Mixer_UI::show_window () if (!_visible) { set_window_pos_and_size (); + /* show/hide group tabs as required */ + parameter_changed ("show-group-tabs"); + /* now reset each strips width so the right widgets are shown */ MixerStrip* ms; @@ -282,8 +295,14 @@ Mixer_UI::show_window () 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-element-visibility")); } } + + /* force focus into main area */ + scroller_base.grab_focus (); + _visible = true; } @@ -298,56 +317,120 @@ Mixer_UI::hide_window (GdkEventAny *ev) void -Mixer_UI::add_strip (RouteList& routes) +Mixer_UI::add_strips (RouteList& routes) { - ENSURE_GUI_THREAD (*this, &Mixer_UI::add_strip, routes) + bool from_scratch = track_model->children().size() == 0; + Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end(); + + for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) { + boost::shared_ptr r = (*it)[track_columns.route]; + + if (r->order_key() == (routes.front()->order_key() + routes.size())) { + insert_iter = it; + break; + } + } + + if(!from_scratch) { + _selection.clear_routes (); + } MixerStrip* strip; - no_track_list_redisplay = true; - strip_redisplay_does_not_sync_order_keys = true; + try { + 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); + for (RouteList::iterator x = routes.begin(); x != routes.end(); ++x) { + boost::shared_ptr route = (*x); - if (route->is_hidden()) { - return; - } + if (route->is_auditioner()) { + continue; + } - strip = new MixerStrip (*this, _session, route); - strips.push_back (strip); + if (route->is_monitor()) { - Config->get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide; + if (!_monitor_section) { + _monitor_section = new MonitorSection (_session); - if (strip->width_owner() != strip) { - strip->set_width_enum (_strip_width, this); - } + XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section")); + if (mnode) { + _monitor_section->tearoff().set_state (*mnode); + } + } - show_strip (strip); + out_packer.pack_end (_monitor_section->tearoff(), false, false); + _monitor_section->set_session (_session); + _monitor_section->tearoff().show_all (); - TreeModel::Row row = *(track_model->append()); - row[track_columns.text] = route->name(); - row[track_columns.visible] = strip->marked_for_display(); - row[track_columns.route] = route; - row[track_columns.strip] = strip; + route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context()); - if (route->order_key (N_("signal")) == -1) { - route->set_order_key (N_("signal"), track_model->children().size()-1); - } + /* 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); - route->NameChanged.connect (*this, boost::bind (&Mixer_UI::strip_name_changed, this, strip), gui_context()); + 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; - 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)); + if (!from_scratch) { + _selection.add (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 (...) { } no_track_list_redisplay = false; + track_display.set_model (track_model); + sync_order_keys_from_treeview (); redisplay_track_list (); +} + +void +Mixer_UI::deselect_all_strip_processors () +{ + for (list::iterator i = strips.begin(); i != strips.end(); ++i) { + (*i)->deselect_all_processors(); + } +} - strip_redisplay_does_not_sync_order_keys = false; +void +Mixer_UI::select_none () +{ + _selection.clear_routes(); + deselect_all_strip_processors(); } +void +Mixer_UI::delete_processors () +{ + for (list::iterator i = strips.begin(); i != strips.end(); ++i) { + (*i)->delete_processors(); + } +} + + void Mixer_UI::remove_strip (MixerStrip* strip) { @@ -356,10 +439,6 @@ Mixer_UI::remove_strip (MixerStrip* strip) return; } - ENSURE_GUI_THREAD (*this, &Mixer_UI::remove_strip, strip); - - cerr << "Mixer UI removing strip for " << strip << endl; - TreeModel::Children rows = track_model->children(); TreeModel::Children::iterator ri; list::iterator i; @@ -368,89 +447,297 @@ Mixer_UI::remove_strip (MixerStrip* strip) strips.erase (i); } - strip_redisplay_does_not_sync_order_keys = true; - for (ri = rows.begin(); ri != rows.end(); ++ri) { if ((*ri)[track_columns.strip] == strip) { + PBD::Unwinder uw (_route_deletion_in_progress, true); track_model->erase (ri); break; } } - - strip_redisplay_does_not_sync_order_keys = false; } void -Mixer_UI::sync_order_keys (string const & src) +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) { + + /* skip two special values */ + + if (rid == Route::MasterBusRemoteControlID) { + rid++; + } + + if (rid == Route::MonitorBusRemoteControlID) { + rid++; + } + + 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 (); + } +} - if (src == N_("signal") || !_session || (_session->state_of_the_state() & (Session::Loading|Session::Deletion)) || rows.empty()) { +void +Mixer_UI::sync_order_keys_from_treeview () +{ + if (ignore_reorder || !_session || _session->deletion_in_progress()) { return; } - std::map keys; + TreeModel::Children rows = track_model->children(); + if (rows.empty()) { + return; + } + + DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync order keys from model\n"); + + TreeModel::Children::iterator ri; bool changed = false; + bool rid_change = false; + uint32_t order = 0; + uint32_t rid = 1; + uint32_t invisible_key = UINT32_MAX; - unsigned order = 0; - for (ri = rows.begin(); ri != rows.end(); ++ri, ++order) { + for (ri = rows.begin(); ri != rows.end(); ++ri) { boost::shared_ptr route = (*ri)[track_columns.route]; - unsigned int old_key = order; - unsigned int new_key = route->order_key (N_("signal")); + bool visible = (*ri)[track_columns.visible]; - keys[new_key] = old_key; + uint32_t old_key = route->order_key (); - if (new_key != old_key) { + if (order != old_key) { + route->set_order_key (order); changed = true; } + + if ((Config->get_remote_model() == MixerOrdered) && !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++; + } + + } + + ++order; + } + + if (changed) { + /* tell everyone that we changed the mixer sort keys */ + _session->sync_order_keys (); } - if (keys.size() != rows.size()) { - PBD::stacktrace (cerr, 20); + if (rid_change) { + /* tell the world that we changed the remote control IDs */ + _session->notify_remote_id_change (); + } +} + +void +Mixer_UI::sync_treeview_from_order_keys () +{ + if (!_session || _session->deletion_in_progress()) { + return; } - assert(keys.size() == rows.size()); - // Remove any gaps in keys caused by automation children tracks + DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from order keys.\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 + * order for the GUI, so reorder the treeview model to match it. + */ + vector neworder; - for (std::map::const_iterator i = keys.begin(); i != keys.end(); ++i) { - neworder.push_back(i->second); + TreeModel::Children rows = track_model->children(); + uint32_t old_order = 0; + bool changed = false; + + if (rows.empty()) { + return; + } + + OrderKeySortedRoutes sorted_routes; + + 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 ())); + } + + SortByNewDisplayOrder cmp; + + sort (sorted_routes.begin(), sorted_routes.end(), cmp); + neworder.assign (sorted_routes.size(), 0); + + uint32_t n = 0; + + for (OrderKeySortedRoutes::iterator sr = sorted_routes.begin(); sr != sorted_routes.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)); } - assert(neworder.size() == rows.size()); if (changed) { - strip_redisplay_does_not_reset_order_keys = true; + Unwinder uw (ignore_reorder, true); track_model->reorder (neworder); - strip_redisplay_does_not_reset_order_keys = false; } + + redisplay_track_list (); } void -Mixer_UI::follow_strip_selection () +Mixer_UI::follow_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); + } + } + } + + _following_editor_selection = false; + _selection.block_routes_changed (false); +} + + +MixerStrip* +Mixer_UI::strip_by_route (boost::shared_ptr r) { for (list::iterator i = strips.begin(); i != strips.end(); ++i) { - (*i)->set_selected (_selection.selected ((*i)->route())); + if ((*i)->route() == r) { + return (*i); + } } + + return 0; } bool Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) { if (ev->button == 1) { - - /* this allows the user to click on the strip to terminate comment - editing. XXX it needs improving so that we don't select the strip - at the same time. - */ - - if (_selection.selected (strip->route())) { - _selection.remove (strip->route()); + if (_selection.selected (strip)) { + /* primary-click: toggle selection state of strip */ + if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { + _selection.remove (strip); + } else if (_selection.routes.size() > 1) { + /* de-select others */ + _selection.set (strip); + } } else { - if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { - _selection.add (strip->route()); + 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; + 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 { + 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->route()); + _selection.set (strip); } } } @@ -476,23 +763,24 @@ Mixer_UI::set_session (Session* sess) XMLNode* node = ARDOUR_UI::instance()->mixer_settings(); set_state (*node); - WindowTitle title(_session->name()); - title += _("Mixer"); - title += Glib::get_application_name(); - - set_title (title.get_string()); + update_title (); initial_track_display (); - _session->RouteAdded.connect (_session_connections, ui_bind (&Mixer_UI::add_strip, this, _1), gui_context()); - _session->route_group_added.connect (_session_connections, ui_bind (&Mixer_UI::add_route_group, this, _1), gui_context()); - _session->route_group_removed.connect (_session_connections, boost::bind (&Mixer_UI::route_groups_changed, this), gui_context()); - _session->config.ParameterChanged.connect (_session_connections, ui_bind (&Mixer_UI::parameter_changed, this, _1), gui_context()); + _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_strips, 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()); + _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context()); + _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()); + + Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ()); route_groups_changed (); if (_visible) { - show_window(); + show_window(); } start_updating (); @@ -501,24 +789,75 @@ Mixer_UI::set_session (Session* sess) void Mixer_UI::session_going_away () { - ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away) + ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away); + _in_group_rebuild_or_clear = true; group_model->clear (); + _in_group_rebuild_or_clear = false; + _selection.clear (); track_model->clear (); for (list::iterator i = strips.begin(); i != strips.end(); ++i) { delete (*i); } - strips.clear (); - WindowTitle title(Glib::get_application_name()); - title += _("Mixer"); - set_title (title.get_string()); + if (_monitor_section) { + _monitor_section->tearoff().hide_visible (); + } + + strips.clear (); stop_updating (); SessionHandlePtr::session_going_away (); + + _session = 0; + update_title (); +} + +void +Mixer_UI::track_visibility_changed (std::string const & path) +{ + if (_session && _session->deletion_in_progress()) { + return; + } + + 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 (); + } + } + } +} + +void +Mixer_UI::update_track_visibility () +{ + 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) { + MixerStrip *strip = (*i)[track_columns.strip]; + (*i)[track_columns.visible] = strip->marked_for_display (); + } + + /* force route order keys catch up with visibility changes + */ + + sync_order_keys_from_treeview (); + } + + redisplay_track_list (); } void @@ -532,6 +871,7 @@ Mixer_UI::show_strip (MixerStrip* ms) MixerStrip* strip = (*i)[track_columns.strip]; if (strip == ms) { (*i)[track_columns.visible] = true; + redisplay_track_list (); break; } } @@ -548,6 +888,7 @@ Mixer_UI::hide_strip (MixerStrip* ms) MixerStrip* strip = (*i)[track_columns.strip]; if (strip == ms) { (*i)[track_columns.visible] = false; + redisplay_track_list (); break; } } @@ -556,7 +897,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; } @@ -583,71 +924,80 @@ Mixer_UI::set_all_strips_visibility (bool yn) TreeModel::Children rows = track_model->children(); TreeModel::Children::iterator i; - no_track_list_redisplay = true; + { + Unwinder uw (no_track_list_redisplay, true); + + for (i = rows.begin(); i != rows.end(); ++i) { - for (i = rows.begin(); i != rows.end(); ++i) { + TreeModel::Row row = (*i); + MixerStrip* strip = row[track_columns.strip]; - TreeModel::Row row = (*i); - MixerStrip* strip = row[track_columns.strip]; + if (strip == 0) { + continue; + } - if (strip == 0) { - continue; - } + if (strip->route()->is_master() || strip->route()->is_monitor()) { + continue; + } - if (strip->route()->is_master() || strip->route()->is_control()) { - continue; + (*i)[track_columns.visible] = yn; } - - (*i)[track_columns.visible] = yn; } - no_track_list_redisplay = false; redisplay_track_list (); } 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; - no_track_list_redisplay = true; + { + 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]; + for (i = rows.begin(); i != rows.end(); ++i) { + TreeModel::Row row = (*i); + MixerStrip* strip = row[track_columns.strip]; - if (strip == 0) { - continue; - } + if (strip == 0) { + continue; + } - if (strip->route()->is_master() || strip->route()->is_control()) { - continue; - } + if (strip->route()->is_master() || strip->route()->is_monitor()) { + continue; + } - boost::shared_ptr at = strip->audio_track(); + boost::shared_ptr at = strip->audio_track(); + boost::shared_ptr mt = strip->midi_track(); - switch (tracks) { - case 0: - (*i)[track_columns.visible] = yn; - break; - - case 1: - if (at) { /* track */ + switch (tracks) { + case 0: (*i)[track_columns.visible] = yn; - } - break; + break; - case 2: - if (!at) { /* bus */ - (*i)[track_columns.visible] = yn; + case 1: + if (at) { /* track */ + (*i)[track_columns.visible] = yn; + } + break; + + case 2: + if (!at && !mt) { /* bus */ + (*i)[track_columns.visible] = yn; + } + break; + + case 3: + if (mt) { /* midi-track */ + (*i)[track_columns.visible] = yn; + } + break; } - break; } } - no_track_list_redisplay = false; redisplay_track_list (); } @@ -666,52 +1016,60 @@ 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::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/) +Mixer_UI::show_all_miditracks() { - strip_redisplay_does_not_sync_order_keys = true; - _session->set_remote_control_ids(); - redisplay_track_list (); - strip_redisplay_does_not_sync_order_keys = false; + 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_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&) +Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/) { - // never reset order keys because of a property change - strip_redisplay_does_not_reset_order_keys = true; - _session->set_remote_control_ids(); - redisplay_track_list (); - strip_redisplay_does_not_reset_order_keys = false; + DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n"); + sync_order_keys_from_treeview (); } void Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&) { - /* this could require an order sync */ - if (_session && !_session->deletion_in_progress()) { - _session->set_remote_control_ids(); - redisplay_track_list (); - } + /* 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 (); + + if (_route_deletion_in_progress) { + redisplay_track_list (); + } } void @@ -719,13 +1077,13 @@ Mixer_UI::redisplay_track_list () { TreeModel::Children rows = track_model->children(); TreeModel::Children::iterator i; - long order; if (no_track_list_redisplay) { return; } - for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) { + for (i = rows.begin(); i != rows.end(); ++i) { + MixerStrip* strip = (*i)[track_columns.strip]; if (strip == 0) { @@ -733,40 +1091,35 @@ Mixer_UI::redisplay_track_list () continue; } - bool visible = (*i)[track_columns.visible]; + bool const visible = (*i)[track_columns.visible]; if (visible) { - strip->set_marked_for_display (true); - strip->route()->set_order_key (N_("signal"), order); - - if (!strip_redisplay_does_not_reset_order_keys) { - strip->route()->set_order_key (N_("signal"), order); - } + strip->set_gui_property ("visible", true); if (strip->packed()) { - if (strip->route()->is_master() || strip->route()->is_control()) { + if (strip->route()->is_master() || strip->route()->is_monitor()) { out_packer.reorder_child (*strip, -1); + } else { strip_packer.reorder_child (*strip, -1); /* put at end */ } } else { - if (strip->route()->is_master() || strip->route()->is_control()) { + 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->set_packed (true); - //strip->show(); } } else { - strip->set_marked_for_display (false); + strip->set_gui_property ("visible", false); - if (strip->route()->is_master() || strip->route()->is_control()) { + if (strip->route()->is_master() || strip->route()->is_monitor()) { /* do nothing, these cannot be hidden */ } else { if (strip->packed()) { @@ -777,15 +1130,6 @@ Mixer_UI::redisplay_track_list () } } - if (!strip_redisplay_does_not_reset_order_keys && !strip_redisplay_does_not_sync_order_keys) { - _session->sync_order_keys (N_("signal")); - } - - // Resigc::bind all of the midi controls automatically - - if (auto_rebinding) - auto_rebind_midi_controls (); - _group_tabs->set_dirty (); } @@ -799,128 +1143,41 @@ Mixer_UI::strip_width_changed () TreeModel::Children::iterator i; long order; - for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) { - MixerStrip* strip = (*i)[track_columns.strip]; - - if (strip == 0) { - continue; - } - - bool visible = (*i)[track_columns.visible]; - - if (visible) { - strip->queue_draw(); - } - } -#endif - -} - -void -Mixer_UI::set_auto_rebinding( bool val ) -{ - if( val == TRUE ) - { - auto_rebinding = TRUE; - Session::AutoBindingOff(); - } - else - { - auto_rebinding = FALSE; - Session::AutoBindingOn(); - } -} - -void -Mixer_UI::toggle_auto_rebinding() -{ - if (auto_rebinding) - { - set_auto_rebinding( FALSE ); - } - - else - { - set_auto_rebinding( TRUE ); - } - - auto_rebind_midi_controls(); -} - -void -Mixer_UI::auto_rebind_midi_controls () -{ - TreeModel::Children rows = track_model->children(); - TreeModel::Children::iterator i; - int pos; - - // Create bindings for all visible strips and remove those that are not visible - pos = 1; // 0 is reserved for the master strip - for (i = rows.begin(); i != rows.end(); ++i) { - MixerStrip* strip = (*i)[track_columns.strip]; - - if ( (*i)[track_columns.visible] == true ) { // add bindings for - // make the actual binding - //cout<<"Auto Binding: Visible Strip Found: "<name()<route()->is_master() ) { - controlValue = 0; - } - else { - pos++; - } - - PBD::Controllable::CreateBinding ( strip->solo_button->get_controllable().get(), controlValue, 0); - PBD::Controllable::CreateBinding ( strip->mute_button->get_controllable().get(), controlValue, 1); - - if( strip->is_audio_track() ) { - PBD::Controllable::CreateBinding ( strip->rec_enable_button->get_controllable().get(), controlValue, 2); - } - - PBD::Controllable::CreateBinding ( strip->gpm.get_controllable().get(), controlValue, 3); - PBD::Controllable::CreateBinding ( strip->panners.get_controllable().get(), controlValue, 4); + for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) { + MixerStrip* strip = (*i)[track_columns.strip]; + if (strip == 0) { + continue; } - else { // Remove any existing binding - PBD::Controllable::DeleteBinding ( strip->solo_button->get_controllable().get() ); - PBD::Controllable::DeleteBinding ( strip->mute_button->get_controllable().get() ); - if( strip->is_audio_track() ) { - PBD::Controllable::DeleteBinding ( strip->rec_enable_button->get_controllable().get() ); - } + bool visible = (*i)[track_columns.visible]; - PBD::Controllable::DeleteBinding ( strip->gpm.get_controllable().get() ); - PBD::Controllable::DeleteBinding ( strip->panners.get_controllable().get() ); // This only takes the first panner if there are multiples... + if (visible) { + strip->queue_draw(); } - - } // for + } +#endif } -struct SignalOrderRouteSorter { - bool operator() (boost::shared_ptr a, boost::shared_ptr b) { - /* use of ">" forces the correct sort order */ - return a->order_key (N_("signal")) < b->order_key (N_("signal")); - } -}; - void Mixer_UI::initial_track_display () { boost::shared_ptr routes = _session->get_routes(); RouteList copy (*routes); - SignalOrderRouteSorter sorter; + ARDOUR::SignalOrderRouteSorter sorter; copy.sort (sorter); - no_track_list_redisplay = true; - - track_model->clear (); + { + Unwinder uw1 (no_track_list_redisplay, true); + Unwinder uw2 (ignore_reorder, true); - add_strip (copy); + track_model->clear (); + add_strips (copy); + } - no_track_list_redisplay = false; + _session->sync_order_keys (); redisplay_track_list (); } @@ -943,46 +1200,9 @@ Mixer_UI::track_display_button_press (GdkEventButton* ev) return true; } - TreeIter iter; - TreeModel::Path path; - TreeViewColumn* column; - int cellx; - int celly; - - if (!track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) { - return false; - } - - switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) { - case 0: - /* allow normal processing to occur */ - return false; - - case 1: /* visibility */ - - if ((iter = track_model->get_iter (path))) { - MixerStrip* strip = (*iter)[track_columns.strip]; - if (strip) { - - if (!strip->route()->is_master() && !strip->route()->is_control()) { - bool visible = (*iter)[track_columns.visible]; - (*iter)[track_columns.visible] = !visible; - } -#ifdef GTKOSX - track_display.queue_draw(); -#endif - } - } - return true; - - default: - break; - } - return false; } - void Mixer_UI::build_track_menu () { @@ -999,13 +1219,19 @@ 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_name_changed (MixerStrip* mx) +Mixer_UI::strip_property_changed (const PropertyChange& what_changed, MixerStrip* mx) { - ENSURE_GUI_THREAD (*this, &Mixer_UI::strip_name_changed, mx) + if (!what_changed.contains (ARDOUR::Properties::name)) { + return; + } + + ENSURE_GUI_THREAD (*this, &Mixer_UI::strip_name_changed, what_changed, mx) TreeModel::Children rows = track_model->children(); TreeModel::Children::iterator i; @@ -1020,72 +1246,54 @@ Mixer_UI::strip_name_changed (MixerStrip* mx) error << _("track display list item for renamed strip not found!") << endmsg; } - -void -Mixer_UI::build_route_group_context_menu () -{ - using namespace Gtk::Menu_Helpers; - - route_group_context_menu = new Menu; - route_group_context_menu->set_name ("ArdourContextMenu"); - MenuList& items = route_group_context_menu->items(); - - items.push_back (MenuElem (_("Activate All"), sigc::mem_fun(*this, &Mixer_UI::activate_all_route_groups))); - items.push_back (MenuElem (_("Disable All"), sigc::mem_fun(*this, &Mixer_UI::disable_all_route_groups))); - items.push_back (SeparatorElem()); - items.push_back (MenuElem (_("Add group"), sigc::mem_fun(*this, &Mixer_UI::new_route_group))); - -} - bool Mixer_UI::group_display_button_press (GdkEventButton* ev) { - if (Keyboard::is_context_menu_event (ev)) { - if (route_group_context_menu == 0) { - build_route_group_context_menu (); - } - route_group_context_menu->popup (1, ev->time); - return true; - } - - - RouteGroup* group; - TreeIter iter; TreeModel::Path path; TreeViewColumn* column; int cellx; 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) { + _group_tabs->get_menu(0)->popup (1, ev->time); + return true; + } + + RouteGroup* group = (*iter)[group_columns.group]; + + if (Keyboard::is_context_menu_event (ev)) { + _group_tabs->get_menu(group)->popup (1, ev->time); + return true; } switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) { case 0: if (Keyboard::is_edit_event (ev)) { - if ((iter = group_model->get_iter (path))) { - if ((group = (*iter)[group_columns.group]) != 0) { - // edit_route_group (group); + if (group) { + // edit_route_group (group); #ifdef GTKOSX - group_display.queue_draw(); + group_display.queue_draw(); #endif - return true; - } + return true; } - } break; case 1: - if ((iter = group_model->get_iter (path))) { - bool visible = (*iter)[group_columns.visible]; - (*iter)[group_columns.visible] = !visible; + { + bool visible = (*iter)[group_columns.visible]; + (*iter)[group_columns.visible] = !visible; #ifdef GTKOSX - group_display.queue_draw(); + group_display.queue_draw(); #endif - return true; - } - break; + return true; + } default: break; @@ -1109,12 +1317,22 @@ Mixer_UI::disable_all_route_groups () void Mixer_UI::route_groups_changed () { - ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed) + ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed); + + _in_group_rebuild_or_clear = true; /* just rebuild the while thing */ 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()); @@ -1122,14 +1340,20 @@ 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)); + + _group_tabs->set_dirty (); + _in_group_rebuild_or_clear = false; } void Mixer_UI::new_route_group () { - _session->add_route_group (new RouteGroup (*_session, "", RouteGroup::Active, (RouteGroup::Property) (RouteGroup::Gain |RouteGroup::Mute | RouteGroup::Solo))); + RouteList rl; + + _group_tabs->run_new_group_dialog (rl); } void @@ -1158,14 +1382,12 @@ Mixer_UI::remove_selected_route_group () } void -Mixer_UI::group_flags_changed (void* src, RouteGroup* group) +Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& change) { if (in_group_row_change) { return; } - ENSURE_GUI_THREAD (*this, &Mixer_UI::group_flags_changed, src, group) - /* force an update of any mixer strips that are using this group, otherwise mix group names don't change in mixer strips */ @@ -1192,11 +1414,23 @@ Mixer_UI::group_flags_changed (void* src, RouteGroup* group) in_group_row_change = false; - _group_tabs->set_dirty (); + if (change.contains (Properties::name)) { + _group_tabs->set_dirty (); + } + + for (list::iterator j = strips.begin(); j != strips.end(); ++j) { + if ((*j)->route_group() == group) { + if (group->is_hidden ()) { + hide_strip (*j); + } else { + show_strip (*j); + } + } + } } void -Mixer_UI::route_group_name_edit (const Glib::ustring& path, const Glib::ustring& new_text) +Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text) { RouteGroup* group; TreeIter iter; @@ -1226,28 +1460,46 @@ Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeMo return; } - if ((*iter)[group_columns.visible]) { - for (list::iterator i = strips.begin(); i != strips.end(); ++i) { - if ((*i)->route_group() == group) { - show_strip (*i); - } - } - } else { - for (list::iterator i = strips.begin(); i != strips.end(); ++i) { - if ((*i)->route_group() == group) { - hide_strip (*i); - } - } - } - - Glib::ustring name = (*iter)[group_columns.text]; + std::string name = (*iter)[group_columns.text]; if (name != group->name()) { group->set_name (name); } + bool hidden = !(*iter)[group_columns.visible]; + + if (hidden != group->is_hidden ()) { + group->set_hidden (hidden, this); + } +} + +/** Called when a group model row is deleted, but also when the model is + * reordered by a user drag-and-drop; the latter is what we are + * interested in here. + */ +void +Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &) +{ + if (_in_group_rebuild_or_clear) { + return; + } + + /* Re-write the session's route group list so that the new order is preserved */ + + list new_list; + + Gtk::TreeModel::Children children = group_model->children(); + for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) { + RouteGroup* g = (*i)[group_columns.group]; + if (g) { + new_list.push_back (g); + } + } + + _session->reorder_route_groups (new_list); } + void Mixer_UI::add_route_group (RouteGroup* group) { @@ -1257,7 +1509,7 @@ Mixer_UI::add_route_group (RouteGroup* group) in_group_row_change = true; TreeModel::Row row = *(group_model->append()); - row[group_columns.visible] = true; + row[group_columns.visible] = !group->is_hidden (); row[group_columns.group] = group; if (!group->name().empty()) { row[group_columns.text] = group->name(); @@ -1266,7 +1518,7 @@ Mixer_UI::add_route_group (RouteGroup* group) focus = true; } - group->FlagsChanged.connect (*this, ui_bind (&Mixer_UI::group_flags_changed, this, _1, group), gui_context()); + group->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::route_group_property_changed, this, group, _1), gui_context()); if (focus) { TreeViewColumn* col = group_display.get_column (0); @@ -1274,6 +1526,8 @@ Mixer_UI::add_route_group (RouteGroup* group) group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true); } + _group_tabs->set_dirty (); + in_group_row_change = false; } @@ -1291,12 +1545,12 @@ Mixer_UI::strip_scroller_button_release (GdkEventButton* ev) } void -Mixer_UI::set_strip_width (Width w) +Mixer_UI::set_strip_width (Width w, bool save) { _strip_width = w; for (list::iterator i = strips.begin(); i != strips.end(); ++i) { - (*i)->set_width_enum (w, this); + (*i)->set_width_enum (w, save ? (*i)->width_owner() : this); } } @@ -1373,6 +1627,19 @@ Mixer_UI::set_state (const XMLNode& node) } } + 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 (yn ^ fs) { + ActionManager::do_action ("Common", + "ToggleMaximalMixer"); + } + } + + return 0; } @@ -1415,6 +1682,8 @@ Mixer_UI::get_state (void) node->add_property ("show-mixer", _visible ? "yes" : "no"); + node->add_property ("maximised", _maximised ? "yes" : "no"); + return *node; } @@ -1427,21 +1696,13 @@ Mixer_UI::pane_allocation_handler (Allocation&, Gtk::Paned* which) char buf[32]; XMLNode* node = ARDOUR_UI::instance()->mixer_settings(); XMLNode* geometry; - int width, height; + int height; static int32_t done[3] = { 0, 0, 0 }; - width = default_width; height = default_height; if ((geometry = find_named_node (*node, "geometry")) != 0) { - - if ((prop = geometry->property ("x_size")) == 0) { - prop = geometry->property ("x-size"); - } - if (prop) { - width = atoi (prop->value()); - } if ((prop = geometry->property ("y_size")) == 0) { prop = geometry->property ("y-size"); } @@ -1473,10 +1734,11 @@ Mixer_UI::pane_allocation_handler (Allocation&, Gtk::Paned* which) return; } - if (!geometry || (prop = geometry->property("mixer-list-hpane-pos")) == 0) { - pos = 75; + if (!geometry) { + pos = 0; snprintf (buf, sizeof(buf), "%d", pos); } else { + prop = geometry->property("mixer-list-hpane-pos"); pos = atoi (prop->value()); } @@ -1486,8 +1748,9 @@ Mixer_UI::pane_allocation_handler (Allocation&, Gtk::Paned* which) } } void -Mixer_UI::scroll_left () +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())); @@ -1496,6 +1759,7 @@ Mixer_UI::scroll_left () void 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())); @@ -1504,29 +1768,40 @@ Mixer_UI::scroll_right () bool Mixer_UI::on_key_press_event (GdkEventKey* ev) { - switch (ev->keyval) { - case GDK_Left: - scroll_left (); - return true; + /* focus widget gets first shot, then bindings, otherwise + forward to main window + */ - case GDK_Right: - scroll_right (); + if (gtk_window_propagate_key_event (GTK_WINDOW(gobj()), ev)) { return true; + } - default: - break; + KeyboardKey k (ev->state, ev->keyval); + + if (bindings.activate (k, Bindings::Press)) { + return true; } - return key_press_focus_accelerator_handler (*this, ev); + return forward_key_press (ev); } bool Mixer_UI::on_key_release_event (GdkEventKey* ev) { - return Gtk::Window::on_key_release_event (ev); - // return key_press_focus_accelerator_handler (*this, ev); -} + if (gtk_window_propagate_key_event (GTK_WINDOW(gobj()), ev)) { + return true; + } + + KeyboardKey k (ev->state, ev->keyval); + + if (bindings.activate (k, Bindings::Release)) { + return true; + } + /* don't forward releases */ + + return true; +} bool Mixer_UI::on_scroll_event (GdkEventScroll* ev) @@ -1568,6 +1843,13 @@ Mixer_UI::parameter_changed (string const & p) } else { _group_tabs->hide (); } + } else if (p == "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 (); } } @@ -1580,5 +1862,184 @@ Mixer_UI::set_route_group_activation (RouteGroup* g, bool a) PluginSelector* Mixer_UI::plugin_selector() { +#ifdef DEFER_PLUGIN_SELECTOR_LOAD + if (!_plugin_selector) + _plugin_selector = new PluginSelector (PluginManager::instance()); +#endif + return _plugin_selector; } + +void +Mixer_UI::setup_track_display () +{ + track_model = ListStore::create (track_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.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_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)); + 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)); + + track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false); + + track_display_scroller.add (track_display); + track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); + + VBox* v = manage (new VBox); + 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); + + track_display_scroller.show(); + track_display_frame.show(); + track_display.show(); +} + +void +Mixer_UI::new_track_or_bus () +{ + ARDOUR_UI::instance()->add_route (this); +} + + +void +Mixer_UI::update_title () +{ + if (_session) { + string n; + + if (_session->snap_name() != _session->name()) { + n = _session->snap_name (); + } else { + n = _session->name (); + } + + if (_session->dirty ()) { + n = "*" + n; + } + + WindowTitle title (n); + title += S_("Window|Mixer"); + title += Glib::get_application_name (); + set_title (title.get_string()); + + } else { + + WindowTitle title (S_("Window|Mixer")); + title += Glib::get_application_name (); + set_title (title.get_string()); + } +} + +MixerStrip* +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); + x2 = x1 + (*i)->get_width(); + + if (x >= x1 && x <= x2) { + return (*i); + } + } + + return 0; +} + +void +Mixer_UI::set_route_targets_for_operation () +{ + _route_targets.clear (); + + if (!_selection.empty()) { + _route_targets = _selection.routes; + return; + } + +// removed "implicit" selections of strips, after discussion on IRC + +} + +void +Mixer_UI::monitor_section_going_away () +{ + if (_monitor_section) { + out_packer.remove (_monitor_section->tearoff()); + _monitor_section->set_session (0); + } +} + +void +Mixer_UI::toggle_midi_input_active (bool flip_others) +{ + boost::shared_ptr rl (new RouteList); + bool onoff = false; + + set_route_targets_for_operation (); + + for (RouteUISelection::iterator r = _route_targets.begin(); r != _route_targets.end(); ++r) { + boost::shared_ptr mt = (*r)->midi_track(); + + if (mt) { + rl->push_back ((*r)->route()); + onoff = !mt->input_active(); + } + } + + _session->set_exclusive_input_active (rl, onoff, flip_others); +} + +void +Mixer_UI::maximise_mixer_space () +{ + if (_maximised) { + return; + } + + fullscreen (); + + _maximised = true; +} + +void +Mixer_UI::restore_mixer_space () +{ + if (!_maximised) { + return; + } + + unfullscreen(); + + _maximised = false; +}