deleting pointers to incomplete types may cause undefined behavior
[ardour.git] / gtk2_ardour / mixer_ui.cc
index 1e175d2fd3628e590d4424e981d44d36b8d9ee7f..6a768f9e49eaa56e7b1bb5107e96131f4c4a2fa8 100644 (file)
@@ -57,6 +57,8 @@
 #include "actions.h"
 #include "gui_thread.h"
 #include "mixer_group_tabs.h"
+#include "timers.h"
+#include "ui_config.h"
 
 #include "i18n.h"
 
@@ -91,7 +93,8 @@ Mixer_UI::Mixer_UI ()
        , 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)
@@ -137,6 +140,7 @@ Mixer_UI::Mixer_UI ()
        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 */
 
@@ -200,7 +204,7 @@ Mixer_UI::Mixer_UI ()
 #else
        global_hpacker.pack_start (out_packer, false, false, 12);
 #endif
-       list_hpane.pack1(list_vpacker, true, true);
+       list_hpane.pack1(list_vpacker, false, false);
        list_hpane.pack2(global_hpacker, true, false);
 
        rhs_pane1.signal_size_allocate().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::pane_allocation_handler),
@@ -256,6 +260,7 @@ Mixer_UI::~Mixer_UI ()
        if (_monitor_section) {
                delete _monitor_section;
        }
+       delete _plugin_selector;
 }
 
 void
@@ -368,7 +373,7 @@ Mixer_UI::add_strips (RouteList& routes)
                        strip = new MixerStrip (*this, _session, route);
                        strips.push_back (strip);
 
-                       Config->get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
+                       UIConfiguration::instance().get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
                        
                        if (strip->width_owner() != strip) {
                                strip->set_width_enum (_strip_width, this);
@@ -472,6 +477,17 @@ Mixer_UI::reset_remote_control_ids ()
        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> route = (*ri)[track_columns.route];
                bool visible = (*ri)[track_columns.visible];
 
@@ -618,7 +634,7 @@ 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;
        }
 
@@ -664,7 +680,10 @@ 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.routes.size() > 1) {
+                               /* de-select others */
+                               _selection.set (strip);
+                       }
                } else {
                        if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
                                _selection.add (strip);
@@ -762,12 +781,6 @@ Mixer_UI::set_session (Session* sess)
 
        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 ("<Actions>/Common/toggle-mixer");
        }
 
        start_updating ();
@@ -884,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;
 }
 
@@ -936,7 +949,7 @@ 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;
@@ -957,6 +970,7 @@ Mixer_UI::set_all_audio_visibility (int tracks, bool yn)
                        }
                        
                        boost::shared_ptr<AudioTrack> at = strip->audio_track();
+                       boost::shared_ptr<MidiTrack> mt = strip->midi_track();
                        
                        switch (tracks) {
                        case 0:
@@ -970,7 +984,13 @@ Mixer_UI::set_all_audio_visibility (int tracks, bool yn)
                                break;
                                
                        case 2:
-                               if (!at) { /* bus */
+                               if (!at && !mt) { /* bus */
+                                       (*i)[track_columns.visible] = yn;
+                               }
+                               break;
+
+                       case 3:
+                               if (mt) { /* midi-track */
                                        (*i)[track_columns.visible] = yn;
                                }
                                break;
@@ -996,25 +1016,37 @@ 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*/)
 {
@@ -1187,6 +1219,8 @@ 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)));
 
 }
 
@@ -1221,12 +1255,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];
@@ -1289,6 +1325,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 +1340,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));
 
@@ -1798,7 +1843,7 @@ 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<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
                        (*i)->set_width_enum (s ? Narrow : Wide, this);
                }
@@ -1835,10 +1880,12 @@ Mixer_UI::setup_track_display ()
        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));