Remove ArdourPrompter wrapper
[ardour.git] / gtk2_ardour / mixer_ui.cc
index 39ab929c8ee80a6ddebb6c2ec2a58395c8ab2998..1a4a897a72de5924e289a668bed814bed495bcf2 100644 (file)
 
 #include <boost/foreach.hpp>
 
+#include <glibmm/threads.h>
+
 #include <gtkmm/accelmap.h>
+#include <gtkmm/stock.h>
 
 #include "pbd/convert.h"
 #include "pbd/stacktrace.h"
 #include "pbd/unwind.h"
 
-#include <glibmm/threads.h>
-
-#include <gtkmm2ext/gtk_ui.h>
-#include <gtkmm2ext/keyboard.h>
-#include <gtkmm2ext/utils.h>
-#include <gtkmm2ext/tearoff.h>
-#include <gtkmm2ext/window_title.h>
-#include <gtkmm2ext/doi.h>
-
 #include "ardour/amp.h"
 #include "ardour/debug.h"
 #include "ardour/audio_track.h"
 #include "ardour/vca.h"
 #include "ardour/vca_manager.h"
 
+#include "gtkmm2ext/gtk_ui.h"
+#include "gtkmm2ext/keyboard.h"
+#include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/window_title.h"
+#include "gtkmm2ext/doi.h"
+
+#include "widgets/tearoff.h"
+
 #include "keyboard.h"
 #include "mixer_ui.h"
 #include "mixer_strip.h"
@@ -61,7 +63,6 @@
 #include "public_editor.h"
 #include "mouse_cursors.h"
 #include "ardour_ui.h"
-#include "prompter.h"
 #include "utils.h"
 #include "route_sorter.h"
 #include "actions.h"
@@ -106,8 +107,8 @@ Mixer_UI::Mixer_UI ()
        , _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)
+       , _in_group_rebuild_or_clear (false)
+       , _route_deletion_in_progress (false)
        , _maximised (false)
        , _show_mixer_list (true)
        , myactions (X_("mixer"))
@@ -280,33 +281,28 @@ Mixer_UI::Mixer_UI ()
        list_hpane.add (global_hpacker);
        list_hpane.set_child_minsize (list_vpacker, 1);
 
-
        XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings();
        float fract;
 
-       {
-               LocaleGuard lg;
-
-               if (!settings || !settings->get_property ("mixer-rhs-pane1-pos", fract) || fract  > 1.0) {
-                       fract = 0.6f;
-               }
-               rhs_pane1.set_divider (0, fract);
+       if (!settings || !settings->get_property ("mixer-rhs-pane1-pos", fract) || fract > 1.0) {
+               fract = 0.6f;
+       }
+       rhs_pane1.set_divider (0, fract);
 
-               if (!settings || !settings->get_property ("mixer-rhs-pane2-pos", fract) || fract > 1.0) {
-                       fract = 0.7f;
-               }
-               rhs_pane2.set_divider (0, fract);
+       if (!settings || !settings->get_property ("mixer-rhs-pane2-pos", fract) || fract > 1.0) {
+               fract = 0.7f;
+       }
+       rhs_pane2.set_divider (0, fract);
 
-               if (!settings || !settings->get_property ("mixer-list-hpane-pos", fract) || fract > 1.0) {
-                       fract = 0.2f;
-               }
-               list_hpane.set_divider (0, fract);
+       if (!settings || !settings->get_property ("mixer-list-hpane-pos", fract) || fract > 1.0) {
+               fract = 0.2f;
+       }
+       list_hpane.set_divider (0, fract);
 
-               if (!settings || !settings->get_property ("mixer-inner-pane-pos", fract) || fract > 1.0) {
-                       fract = 0.8f;
-               }
-               inner_pane.set_divider (0, fract);
+       if (!settings || !settings->get_property ("mixer-inner-pane-pos", fract) || fract > 1.0) {
+               fract = 0.8f;
        }
+       inner_pane.set_divider (0, fract);
 
        rhs_pane1.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
        rhs_pane2.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
@@ -447,7 +443,7 @@ Mixer_UI::remove_master (VCAMasterStrip* vms)
 
        for (ri = rows.begin(); ri != rows.end(); ++ri) {
                if ((*ri)[stripable_columns.strip] == vms) {
-                        PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
+                       PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
                        track_model->erase (ri);
                        break;
                }
@@ -636,6 +632,12 @@ Mixer_UI::deselect_all_strip_processors ()
        }
 }
 
+void
+Mixer_UI::select_all_tracks ()
+{
+       PublicEditor::instance().select_all_tracks ();
+}
+
 void
 Mixer_UI::select_none ()
 {
@@ -672,7 +674,7 @@ Mixer_UI::remove_strip (MixerStrip* strip)
 
        for (ri = rows.begin(); ri != rows.end(); ++ri) {
                if ((*ri)[stripable_columns.strip] == strip) {
-                        PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
+                       PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
                        track_model->erase (ri);
                        break;
                }
@@ -716,9 +718,6 @@ Mixer_UI::sync_presentation_info_from_treeview ()
 
        PresentationInfo::order_t master_key = _session->master_order_key ();
        PresentationInfo::order_t order = 0;
-       uint32_t count = 0;
-
-       TreeOrderKeys sorted;
 
        PresentationInfo::ChangeSuspender cs;
 
@@ -752,10 +751,7 @@ Mixer_UI::sync_presentation_info_from_treeview ()
                        stripable->set_presentation_order (order);
                        change = true;
                }
-
-               sorted.push_back (TreeOrderKey (count, stripable));
                ++order;
-               ++count;
        }
 
        change |= _session->ensure_stripable_sort_order ();
@@ -902,14 +898,14 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
                if (_selection.selected (strip)) {
                        /* primary-click: toggle selection state of strip */
                        if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
-                               _selection.remove (strip);
+                               _selection.remove (strip, true);
                        } else if (_selection.axes.size() > 1) {
                                /* de-select others */
                                _selection.set (strip);
                        }
                } else {
                        if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
-                               _selection.add (strip);
+                               _selection.add (strip, true);
                        } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
 
                                /* extend selection */
@@ -957,7 +953,7 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
                                if (found_another) {
                                        PresentationInfo::ChangeSuspender cs;
                                        for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
-                                               _selection.add (*i);
+                                               _selection.add (*i, true);
                                        }
                                } else {
                                        _selection.set (strip);  //user wants to start a range selection, but there aren't any others selected yet
@@ -1143,15 +1139,15 @@ Mixer_UI::hide_strip (MixerStrip* ms)
 gint
 Mixer_UI::start_updating ()
 {
-    fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
-    return 0;
+       fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
+       return 0;
 }
 
 gint
 Mixer_UI::stop_updating ()
 {
-    fast_screen_update_connection.disconnect();
-    return 0;
+       fast_screen_update_connection.disconnect();
+       return 0;
 }
 
 void
@@ -1313,9 +1309,9 @@ Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
        DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n");
        sync_presentation_info_from_treeview ();
 
-        if (_route_deletion_in_progress) {
-                redisplay_track_list ();
-        }
+       if (_route_deletion_in_progress) {
+               redisplay_track_list ();
+       }
 }
 
 void
@@ -2066,7 +2062,6 @@ private:
 int
 Mixer_UI::set_state (const XMLNode& node, int version)
 {
-       LocaleGuard lg;
        bool yn;
 
        Tabbable::set_state (node, version);
@@ -2136,7 +2131,6 @@ XMLNode&
 Mixer_UI::get_state ()
 {
        XMLNode* node = new XMLNode (X_("Mixer"));
-       LocaleGuard lg;
 
        node->add_child_nocopy (Tabbable::get_state());
 
@@ -2937,6 +2931,7 @@ Mixer_UI::register_actions ()
        myactions.register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
        myactions.register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
        myactions.register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
+       myactions.register_action (group, "select-all-tracks", _("Select All Tracks"), sigc::mem_fun (*this, &Mixer_UI::select_all_tracks));
 
        myactions.register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
        myactions.register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
@@ -2996,29 +2991,44 @@ Mixer_UI::rec_enable_action ()
        control_action (&Stripable::rec_enable_control);
 }
 
-void
-Mixer_UI::step_gain_up_action ()
+AutomationControlSet
+Mixer_UI::selected_gaincontrols ()
 {
        set_axis_targets_for_operation ();
-
+       AutomationControlSet rv;
        BOOST_FOREACH(AxisView* r, _axis_targets) {
                MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
                if (ms) {
-                       ms->step_gain_up ();
+                       boost::shared_ptr<GainControl> ac (ms->route()->gain_control());
+                       ControlList cl (ac->grouped_controls());
+                       for (ControlList::const_iterator c = cl.begin(); c != cl.end (); ++c) {
+                               rv.insert (*c);
+                       }
+                       rv.insert (ac);
                }
        }
+       return rv;
 }
 
 void
-Mixer_UI::step_gain_down_action ()
+Mixer_UI::step_gain_up_action ()
 {
-       set_axis_targets_for_operation ();
+       AutomationControlSet acs = selected_gaincontrols ();
+       for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
+               boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
+               assert (ac);
+               ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) + 0.1), Controllable::NoGroup);
+       }
+}
 
-       BOOST_FOREACH(AxisView* r, _axis_targets) {
-               MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
-               if (ms) {
-                       ms->step_gain_down ();
-               }
+void
+Mixer_UI::step_gain_down_action ()
+{
+       AutomationControlSet acs = selected_gaincontrols ();
+       for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
+               boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
+               assert (ac);
+               ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) - 0.1), Controllable::NoGroup);
        }
 }