X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmixer_ui.cc;h=1e175d2fd3628e590d4424e981d44d36b8d9ee7f;hb=2449fc9681ba62eda3f3a42904a3691fe022954d;hp=7e8188cac9a5aeda61793017285933c3d25fb515;hpb=6a436fd826d1c9d88b60287696cc0836ccce35aa;p=ardour.git diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index 7e8188cac9..1e175d2fd3 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -41,6 +41,7 @@ #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 "keyboard.h" @@ -60,6 +61,7 @@ #include "i18n.h" using namespace ARDOUR; +using namespace ARDOUR_UI_UTILS; using namespace PBD; using namespace Gtk; using namespace Glib; @@ -91,12 +93,15 @@ Mixer_UI::Mixer_UI () , _monitor_section (0) , _strip_width (Config->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, _1), gui_context()); + 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); @@ -115,7 +120,7 @@ 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 (); @@ -239,12 +244,8 @@ Mixer_UI::Mixer_UI () list_hpane.show(); group_display.show(); - _in_group_rebuild_or_clear = false; - MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context()); - MonitorSection::setup_knob_images (); - #ifndef DEFER_PLUGIN_SELECTOR_LOAD _plugin_selector = new PluginSelector (PluginManager::instance ()); #endif @@ -290,7 +291,7 @@ Mixer_UI::show_window () 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")); + ms->parameter_changed (X_("mixer-element-visibility")); } } @@ -313,6 +314,22 @@ Mixer_UI::hide_window (GdkEventAny *ev) void Mixer_UI::add_strips (RouteList& 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; try { @@ -359,11 +376,15 @@ Mixer_UI::add_strips (RouteList& routes) show_strip (strip); - TreeModel::Row row = *(track_model->append()); + 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); + } route->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::strip_property_changed, this, _1, strip), gui_context()); @@ -381,6 +402,30 @@ Mixer_UI::add_strips (RouteList& routes) redisplay_track_list (); } +void +Mixer_UI::deselect_all_strip_processors () +{ + for (list::iterator i = strips.begin(); i != strips.end(); ++i) { + (*i)->deselect_all_processors(); + } +} + +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) { @@ -399,6 +444,7 @@ Mixer_UI::remove_strip (MixerStrip* strip) 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; } @@ -408,7 +454,7 @@ Mixer_UI::remove_strip (MixerStrip* strip) void Mixer_UI::reset_remote_control_ids () { - if (Config->get_remote_model() != MixerOrdered || !_session || _session->deletion_in_progress()) { + if (Config->get_remote_model() == UserOrdered || !_session || _session->deletion_in_progress()) { return; } @@ -434,7 +480,7 @@ Mixer_UI::reset_remote_control_ids () uint32_t new_rid = (visible ? rid : invisible_key--); if (new_rid != route->remote_control_id()) { - route->set_remote_control_id_from_order_key (MixerSort, new_rid); + route->set_remote_control_id_explicit (new_rid); rid_change = true; } @@ -476,10 +522,10 @@ Mixer_UI::sync_order_keys_from_treeview () boost::shared_ptr route = (*ri)[track_columns.route]; bool visible = (*ri)[track_columns.visible]; - uint32_t old_key = route->order_key (MixerSort); + uint32_t old_key = route->order_key (); if (order != old_key) { - route->set_order_key (MixerSort, order); + route->set_order_key (order); changed = true; } @@ -488,7 +534,7 @@ Mixer_UI::sync_order_keys_from_treeview () uint32_t new_rid = (visible ? rid : invisible_key--); if (new_rid != route->remote_control_id()) { - route->set_remote_control_id_from_order_key (MixerSort, new_rid); + route->set_remote_control_id_explicit (new_rid); rid_change = true; } @@ -503,7 +549,7 @@ Mixer_UI::sync_order_keys_from_treeview () if (changed) { /* tell everyone that we changed the mixer sort keys */ - _session->sync_order_keys (MixerSort); + _session->sync_order_keys (); } if (rid_change) { @@ -513,33 +559,13 @@ Mixer_UI::sync_order_keys_from_treeview () } void -Mixer_UI::sync_treeview_from_order_keys (RouteSortOrderKey src) +Mixer_UI::sync_treeview_from_order_keys () { if (!_session || _session->deletion_in_progress()) { return; } - DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("mixer sync model from order keys, src = %1\n", enum_2_string (src))); - - if (src == EditorSort) { - - if (!Config->get_sync_all_route_ordering()) { - /* editor sort keys changed - we don't care */ - return; - } - - DEBUG_TRACE (DEBUG::OrderKeys, "reset mixer order key to match editor\n"); - - /* editor sort keys were changed, update the mixer sort - * keys since "sync mixer+editor order" is enabled. - */ - - boost::shared_ptr r = _session->get_routes (); - - for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { - (*i)->sync_order_keys (src); - } - } + 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 @@ -559,7 +585,7 @@ Mixer_UI::sync_treeview_from_order_keys (RouteSortOrderKey src) 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 (MixerSort))); + sorted_routes.push_back (RoutePlusOrderKey (route, old_order, route->order_key ())); } SortByNewDisplayOrder cmp; @@ -650,6 +676,7 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) vector tmp; bool accumulate = false; + bool found_another = false; tmp.push_back (strip); @@ -668,6 +695,7 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) /* hit selected strip. if currently accumulating others, we're done. if not accumulating others, start doing so. */ + found_another = true; if (accumulate) { /* done */ break; @@ -681,9 +709,12 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) } } - for (vector::iterator i = tmp.begin(); i != tmp.end(); ++i) { - _selection.add (*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 { @@ -996,9 +1027,17 @@ 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 (); + + if (_route_deletion_in_progress) { + redisplay_track_list (); + } } void @@ -1089,28 +1128,12 @@ Mixer_UI::strip_width_changed () } -struct SignalOrderRouteSorter { - bool operator() (boost::shared_ptr a, boost::shared_ptr b) { - if (a->is_master() || a->is_monitor()) { - /* "a" is a special route (master, monitor, etc), and comes - * last in the mixer ordering - */ - return false; - } else if (b->is_master() || b->is_monitor()) { - /* everything comes before b */ - return true; - } - return a->order_key (MixerSort) < b->order_key (MixerSort); - - } -}; - void Mixer_UI::initial_track_display () { boost::shared_ptr routes = _session->get_routes(); RouteList copy (*routes); - SignalOrderRouteSorter sorter; + ARDOUR::SignalOrderRouteSorter sorter; copy.sort (sorter); @@ -1122,7 +1145,7 @@ Mixer_UI::initial_track_display () add_strips (copy); } - _session->sync_order_keys (MixerSort); + _session->sync_order_keys (); redisplay_track_list (); } @@ -1559,6 +1582,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; } @@ -1601,6 +1637,8 @@ Mixer_UI::get_state (void) node->add_property ("show-mixer", _visible ? "yes" : "no"); + node->add_property ("maximised", _maximised ? "yes" : "no"); + return *node; } @@ -1901,16 +1939,8 @@ Mixer_UI::set_route_targets_for_operation () return; } - /* nothing selected ... try to get mixer strip at mouse */ +// removed "implicit" selections of strips, after discussion on IRC - int x, y; - get_pointer (x, y); - - MixerStrip* ms = strip_by_x (x); - - if (ms) { - _route_targets.insert (ms); - } } void @@ -1942,3 +1972,26 @@ Mixer_UI::toggle_midi_input_active (bool flip_others) _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; +}