Update fr.po
[ardour.git] / gtk2_ardour / mixer_ui.cc
index 54d97c36dee5a3a1e58effe3007b4d7a58a4d81b..e58a61948db0ecdc02bbacb7a170e746884becca 100644 (file)
@@ -58,6 +58,7 @@
 #include "gui_thread.h"
 #include "mixer_group_tabs.h"
 #include "timers.h"
+#include "ui_config.h"
 
 #include "i18n.h"
 
@@ -75,11 +76,11 @@ 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;
 }
@@ -92,7 +93,8 @@ Mixer_UI::Mixer_UI ()
        , in_group_row_change (false)
        , track_menu (0)
        , _monitor_section (0)
-       , _strip_width (ARDOUR_UI::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)
@@ -138,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 */
 
@@ -201,7 +204,7 @@ Mixer_UI::Mixer_UI ()
 #else
        global_hpacker.pack_start (out_packer, false, false, 12);
 #endif
-       list_hpane.pack1(list_vpacker, false, false);
+       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),
@@ -257,6 +260,7 @@ Mixer_UI::~Mixer_UI ()
        if (_monitor_section) {
                delete _monitor_section;
        }
+       delete _plugin_selector;
 }
 
 void
@@ -295,7 +299,7 @@ Mixer_UI::show_window ()
                        ms->parameter_changed (X_("mixer-element-visibility"));
                }
        }
-       
+
        /* force focus into main area */
        scroller_base.grab_focus ();
 
@@ -339,44 +343,44 @@ Mixer_UI::add_strips (RouteList& routes)
 
                for (RouteList::iterator x = routes.begin(); x != routes.end(); ++x) {
                        boost::shared_ptr<Route> 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);
                                        }
-                               } 
-                               
+                               }
+
                                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);
 
-                       ARDOUR_UI::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);
                        }
-                       
+
                        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();
@@ -386,9 +390,9 @@ Mixer_UI::add_strips (RouteList& routes)
                        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));
                }
@@ -398,7 +402,7 @@ Mixer_UI::add_strips (RouteList& routes)
 
        no_track_list_redisplay = false;
        track_display.set_model (track_model);
-       
+
        sync_order_keys_from_treeview ();
        redisplay_track_list ();
 }
@@ -438,11 +442,11 @@ Mixer_UI::remove_strip (MixerStrip* strip)
        TreeModel::Children rows = track_model->children();
        TreeModel::Children::iterator ri;
        list<MixerStrip *>::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) {
                         PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
@@ -460,7 +464,7 @@ Mixer_UI::reset_remote_control_ids ()
        }
 
        TreeModel::Children rows = track_model->children();
-       
+
        if (rows.empty()) {
                return;
        }
@@ -475,11 +479,11 @@ Mixer_UI::reset_remote_control_ids ()
        for (ri = rows.begin(); ri != rows.end(); ++ri) {
 
                /* skip two special values */
-               
+
                if (rid == Route::MasterBusRemoteControlID) {
                        rid++;
                }
-               
+
                if (rid == Route::MonitorBusRemoteControlID) {
                        rid++;
                }
@@ -488,14 +492,14 @@ Mixer_UI::reset_remote_control_ids ()
                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);        
+                               route->set_remote_control_id_explicit (new_rid);
                                rid_change = true;
                        }
-                       
+
                        if (visible) {
                                rid++;
                        }
@@ -516,7 +520,7 @@ Mixer_UI::sync_order_keys_from_treeview ()
        }
 
        TreeModel::Children rows = track_model->children();
-       
+
        if (rows.empty()) {
                return;
        }
@@ -546,10 +550,10 @@ 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_explicit (new_rid);        
+                               route->set_remote_control_id_explicit (new_rid);
                                rid_change = true;
                        }
-                       
+
                        if (visible) {
                                rid++;
                        }
@@ -606,7 +610,7 @@ Mixer_UI::sync_treeview_from_order_keys ()
        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;
@@ -636,7 +640,7 @@ Mixer_UI::follow_editor_selection ()
 
        _following_editor_selection = true;
        _selection.block_routes_changed (true);
-       
+
        TrackSelection& s (PublicEditor::instance().get_selection().tracks);
 
        _selection.clear_routes ();
@@ -676,25 +680,28 @@ 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);
                        } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
 
                                if (!_selection.selected(strip)) {
-                               
+
                                        /* extend selection */
-                                       
+
                                        vector<MixerStrip*> tmp;
                                        bool accumulate = false;
                                        bool found_another = false;
-                                       
+
                                        tmp.push_back (strip);
 
                                        for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
                                                if ((*i) == strip) {
-                                                       /* hit clicked strip, start accumulating till we hit the first 
+                                                       /* hit clicked strip, start accumulating till we hit the first
                                                           selected strip
                                                        */
                                                        if (accumulate) {
@@ -774,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 ();
@@ -844,15 +845,15 @@ Mixer_UI::update_track_visibility ()
 
        {
                Unwinder<bool> 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 ();
        }
 
@@ -925,20 +926,20 @@ Mixer_UI::set_all_strips_visibility (bool yn)
 
        {
                Unwinder<bool> 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) {
                                continue;
                        }
-                       
+
                        if (strip->route()->is_master() || strip->route()->is_monitor()) {
                                continue;
                        }
-                       
+
                        (*i)[track_columns.visible] = yn;
                }
        }
@@ -948,41 +949,48 @@ 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<bool> 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) {
                                continue;
                        }
-                       
+
                        if (strip->route()->is_master() || strip->route()->is_monitor()) {
                                continue;
                        }
-                       
+
                        boost::shared_ptr<AudioTrack> at = strip->audio_track();
-                       
+                       boost::shared_ptr<MidiTrack> mt = strip->midi_track();
+
                        switch (tracks) {
                        case 0:
                                (*i)[track_columns.visible] = yn;
                                break;
-                               
+
                        case 1:
                                if (at) { /* track */
                                        (*i)[track_columns.visible] = 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;
@@ -1008,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*/)
 {
@@ -1039,7 +1059,7 @@ 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.
        */
@@ -1057,7 +1077,7 @@ Mixer_UI::redisplay_track_list ()
 {
        TreeModel::Children rows = track_model->children();
        TreeModel::Children::iterator i;
-       
+
        if (no_track_list_redisplay) {
                return;
        }
@@ -1156,7 +1176,7 @@ Mixer_UI::initial_track_display ()
                track_model->clear ();
                add_strips (copy);
        }
-       
+
        _session->sync_order_keys ();
 
        redisplay_track_list ();
@@ -1199,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)));
 
 }
 
@@ -1233,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];
@@ -1714,7 +1738,7 @@ Mixer_UI::pane_allocation_handler (Allocation&, Gtk::Paned* which)
                        pos = 75;
                        snprintf (buf, sizeof(buf), "%d", pos);
                } else {
-                       pos = atoi (prop->value());
+                       pos = max (36, atoi (prop->value ()));
                }
 
                if ((done[2] = GTK_WIDGET(list_hpane.gobj())->allocation.width > pos)) {
@@ -1768,7 +1792,7 @@ Mixer_UI::on_key_release_event (GdkEventKey* ev)
        }
 
        KeyboardKey k (ev->state, ev->keyval);
-       
+
        if (bindings.activate (k, Bindings::Release)) {
                return true;
        }
@@ -1819,7 +1843,7 @@ Mixer_UI::parameter_changed (string const & p)
                        _group_tabs->hide ();
                }
        } else if (p == "default-narrow_ms") {
-               bool const s = ARDOUR_UI::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);
                }
@@ -1861,6 +1885,7 @@ Mixer_UI::setup_track_display ()
        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));
@@ -1910,7 +1935,7 @@ Mixer_UI::update_title ()
 {
        if (_session) {
                string n;
-               
+
                if (_session->snap_name() != _session->name()) {
                        n = _session->snap_name ();
                } else {
@@ -1920,14 +1945,14 @@ 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());
 
        } else {
-               
+
                WindowTitle title (S_("Window|Mixer"));
                title += Glib::get_application_name ();
                set_title (title.get_string());
@@ -1990,7 +2015,7 @@ Mixer_UI::toggle_midi_input_active (bool flip_others)
                        onoff = !mt->input_active();
                }
        }
-       
+
        _session->set_exclusive_input_active (rl, onoff, flip_others);
 }