synchronize preferences and monitor-section
[ardour.git] / gtk2_ardour / mixer_ui.cc
index 12cf87d7931a7f31341b7ea8296bf895e3e74b2f..626d2f68a84ef818fde41c706b945f5a2a4c85de 100644 (file)
@@ -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,7 +93,10 @@ 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);
@@ -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"));
                }
        }
        
@@ -401,6 +402,30 @@ Mixer_UI::add_strips (RouteList& routes)
        redisplay_track_list ();
 }
 
+void
+Mixer_UI::deselect_all_strip_processors ()
+{
+       for (list<MixerStrip *>::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<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
+               (*i)->delete_processors();
+       }
+}
+
+
 void
 Mixer_UI::remove_strip (MixerStrip* strip)
 {
@@ -419,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<bool> uw (_route_deletion_in_progress, true);
                        track_model->erase (ri);
                        break;
                }
@@ -996,9 +1022,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 +1123,12 @@ Mixer_UI::strip_width_changed ()
 
 }
 
-struct SignalOrderRouteSorter {
-    bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> 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 () < b->order_key ();
-
-    }
-};
-
 void
 Mixer_UI::initial_track_display ()
 {
        boost::shared_ptr<RouteList> routes = _session->get_routes();
        RouteList copy (*routes);
-       SignalOrderRouteSorter sorter;
+       ARDOUR::SignalOrderRouteSorter sorter;
 
        copy.sort (sorter);
 
@@ -1559,6 +1577,19 @@ Mixer_UI::set_state (const XMLNode& node)
                }
        }
 
+       if ((prop = node.property ("maximised"))) {
+               bool yn = string_is_affirmative (prop->value());
+               Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMaximalMixer"));
+               assert (act);
+               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
+               bool fs = tact && tact->get_active();
+               if (yn ^ fs) {
+                       ActionManager::do_action ("Common",
+                                       "ToggleMaximalMixer");
+               }
+       }
+
+
        return 0;
 }
 
@@ -1601,6 +1632,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 +1934,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 +1967,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;
+}