MCP: F1-7 jump to a given view; F8 closes any currently open dialog; in zoom mode...
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 9 Apr 2012 18:53:51 +0000 (18:53 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 9 Apr 2012 18:53:51 +0000 (18:53 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@11858 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_ops.cc
gtk2_ardour/time_axis_view.cc
gtk2_ardour/time_axis_view.h
libs/gtkmm2ext/gtkmm2ext/keyboard.h
libs/gtkmm2ext/keyboard.cc
libs/surfaces/control_protocol/control_protocol.cc
libs/surfaces/control_protocol/control_protocol/control_protocol.h
libs/surfaces/mackie/mackie_control_protocol.cc
libs/surfaces/mackie/mcp_buttons.cc

index d331b6aee1a85f0f05631497c7a897b38a4e6077..eb262ffb2452af790646e0b30758958e893d0aa5 100644 (file)
@@ -714,6 +714,13 @@ Editor::Editor ()
        ControlProtocol::ScrollTimeline.connect (*this, invalidator (*this), ui_bind (&Editor::control_scroll, this, _1), gui_context());
        ControlProtocol::SelectByRID.connect (*this, invalidator (*this), ui_bind (&Editor::control_select, this, _1), gui_context());
        ControlProtocol::UnselectTrack.connect (*this, invalidator (*this), ui_bind (&Editor::control_unselect, this), gui_context());
+       ControlProtocol::GotoView.connect (*this, invalidator (*this), ui_bind (&Editor::control_view, this, _1), gui_context());
+       ControlProtocol::CloseDialog.connect (*this, invalidator (*this), Keyboard::close_current_dialog, gui_context());
+       ControlProtocol::VerticalZoomInAll.connect (*this, invalidator (*this), ui_bind (&Editor::control_vertical_zoom_in_all, this), gui_context());
+       ControlProtocol::VerticalZoomOutAll.connect (*this, invalidator (*this), ui_bind (&Editor::control_vertical_zoom_out_all, this), gui_context());
+       ControlProtocol::VerticalZoomInSelected.connect (*this, invalidator (*this), ui_bind (&Editor::control_vertical_zoom_in_selected, this), gui_context());
+       ControlProtocol::VerticalZoomOutSelected.connect (*this, invalidator (*this), ui_bind (&Editor::control_vertical_zoom_out_selected, this), gui_context());
+
        BasicUI::AccessAction.connect (*this, invalidator (*this), ui_bind (&Editor::access_action, this, _1, _2), gui_context());
 
        /* problematic: has to return a value and thus cannot be x-thread */
@@ -922,6 +929,36 @@ Editor::zoom_adjustment_changed ()
        temporal_zoom (fpu);
 }
 
+void
+Editor::control_vertical_zoom_in_all ()
+{
+       tav_zoom_smooth (false, true);
+}
+
+void
+Editor::control_vertical_zoom_out_all ()
+{
+       tav_zoom_smooth (true, true);
+}
+
+void
+Editor::control_vertical_zoom_in_selected ()
+{
+       tav_zoom_smooth (false, false);
+}
+
+void
+Editor::control_vertical_zoom_out_selected ()
+{
+       tav_zoom_smooth (true, false);
+}
+
+void
+Editor::control_view (uint32_t view)
+{
+       goto_visual_state (view);
+}
+
 void
 Editor::control_unselect ()
 {
index 92675edb4eb8c3a0164fa7cf67f93c8529d30ef7..a3315b6c19c0beeff3bbbfa17d4b306b683c58f9 100644 (file)
@@ -318,6 +318,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void temporal_zoom_step (bool coarser);
        void tav_zoom_step (bool coarser);
+       void tav_zoom_smooth (bool coarser, bool force_all);
 
        /* stuff that AudioTimeAxisView and related classes use */
 
@@ -987,6 +988,11 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Gtk::VBox           edit_controls_vbox;
        Gtk::HBox           edit_controls_hbox;
 
+       void control_vertical_zoom_in_all ();
+       void control_vertical_zoom_out_all ();
+       void control_vertical_zoom_in_selected ();
+       void control_vertical_zoom_out_selected ();
+       void control_view (uint32_t);
        void control_scroll (float);
        void control_select (uint32_t rid);
        void control_unselect ();
index 1dbad3ac2e34c73a2363cf7bbf57a88dea5ef6ae..92d4ed63f5a2745e1c2eb1e556b095175826f05c 100644 (file)
@@ -1278,11 +1278,17 @@ Editor::scroll_tracks_up_line ()
 void
 Editor::tav_zoom_step (bool coarser)
 {
-       ENSURE_GUI_THREAD (*this, &Editor::temporal_zoom_step, coarser)
-
        _routes->suspend_redisplay ();
 
-       for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
+       TrackViewList* ts;
+
+       if (selection->tracks.empty()) {
+               ts = &track_views;
+       } else {
+               ts = &selection->tracks;
+       }
+       
+       for (TrackViewList::iterator i = ts->begin(); i != ts->end(); ++i) {
                TimeAxisView *tv = (static_cast<TimeAxisView*>(*i));
                        tv->step_height (coarser);
        }
@@ -1290,6 +1296,38 @@ Editor::tav_zoom_step (bool coarser)
        _routes->resume_redisplay ();
 }
 
+void
+Editor::tav_zoom_smooth (bool coarser, bool force_all)
+{
+       _routes->suspend_redisplay ();
+
+       TrackViewList* ts;
+
+       if (selection->tracks.empty() || force_all) {
+               ts = &track_views;
+       } else {
+               ts = &selection->tracks;
+       }
+       
+       for (TrackViewList::iterator i = ts->begin(); i != ts->end(); ++i) {
+               TimeAxisView *tv = (static_cast<TimeAxisView*>(*i));
+               uint32_t h = tv->current_height ();
+
+               if (coarser) {
+                       if (h > 5) {
+                               h -= 5; // pixels
+                               if (h >= TimeAxisView::preset_height (HeightSmall)) {
+                                       tv->set_height (h);
+                               }
+                       }
+               } else {
+                       tv->set_height (h + 5);
+               }
+       }
+
+       _routes->resume_redisplay ();
+}
+
 void
 Editor::temporal_zoom_step (bool coarser)
 {
index 104209d88498ac886c248b7ba78de637d4348562..52013a57474e48d093c4de1f1caa5ce41b0b0ce6 100644 (file)
@@ -495,16 +495,6 @@ TimeAxisView::step_height (bool coarser)
        }
 }
 
-void
-TimeAxisView::set_heights (uint32_t h)
-{
-       TrackSelection& ts (_editor.get_selection().tracks);
-
-       for (TrackSelection::iterator i = ts.begin(); i != ts.end(); ++i) {
-               (*i)->set_height (h);
-       }
-}
-
 void
 TimeAxisView::set_height_enum (Height h, bool apply_to_selection)
 {
index 52385b17aa169bb8104421e2bd358dac581a0cb5..03c50e7ccba9e7a4de88f62bee1e17930b43d538 100644 (file)
@@ -286,7 +286,6 @@ class TimeAxisView : public virtual AxisView
        bool in_destructor;
        NamePackingBits name_packing;
 
-       void set_heights (uint32_t h);
        void color_handler ();
 
        void conditionally_add_to_selection ();
index db8100c0814367a25e98c24277510596650adf95..9b083317e300d67ad85f41c931ce239fa25f1bac 100644 (file)
@@ -138,6 +138,8 @@ class Keyboard : public sigc::trackable, PBD::Stateful
        static void magic_widget_grab_focus ();
        static void magic_widget_drop_focus ();
 
+       static void close_current_dialog ();
+
        static void keybindings_changed ();
        static void save_keybindings ();
        static bool load_keybindings (std::string path);
index 0a3a1f7adc47e1586d723020db4261b344c3dfd9..e8f59af8c965da7830119f811c6f25040419e8dd 100644 (file)
@@ -299,11 +299,8 @@ Keyboard::snooper (GtkWidget *widget, GdkEventKey *event)
        if (event->type == GDK_KEY_RELEASE && modifier_state_equals (event->state, PrimaryModifier)) {
                switch (event->keyval) {
                case GDK_w:
-                       if (current_window) {
-                               current_window->hide ();
-                               current_window = 0;
-                               ret = true;
-                       }
+                       close_current_dialog ();
+                       ret = true;
                        break;
                }
        }
@@ -311,6 +308,15 @@ Keyboard::snooper (GtkWidget *widget, GdkEventKey *event)
        return ret;
 }
 
+void
+Keyboard::close_current_dialog ()
+{
+       if (current_window) {
+               current_window->hide ();
+               current_window = 0;
+       }
+}
+
 bool
 Keyboard::key_is_down (uint32_t keyval)
 {
@@ -556,4 +562,3 @@ Keyboard::load_keybindings (string path)
        return true;
 }
 
-
index fc98a3845ae6909b754ecb0d53c8b9969cf18371..debabe5bd7bf9c7f5417f722d63b4a046a3ca17e 100644 (file)
@@ -40,6 +40,12 @@ Signal0<void>       ControlProtocol::Redo;
 Signal1<void,float> ControlProtocol::ScrollTimeline;
 Signal1<void,uint32_t> ControlProtocol::SelectByRID;
 Signal0<void> ControlProtocol::UnselectTrack;
+Signal1<void,uint32_t> ControlProtocol::GotoView;
+Signal0<void> ControlProtocol::CloseDialog;
+PBD::Signal0<void> ControlProtocol::VerticalZoomInAll;
+PBD::Signal0<void> ControlProtocol::VerticalZoomOutAll;
+PBD::Signal0<void> ControlProtocol::VerticalZoomInSelected;
+PBD::Signal0<void> ControlProtocol::VerticalZoomOutSelected;
 
 ControlProtocol::ControlProtocol (Session& s, string str, EventLoop* evloop)
        : BasicUI (s),
index 956f8f814d7b15da9066265dd17109c1d38659c2..abbf73c396c2be741b5989586d2ed650c4fe7f7c 100644 (file)
@@ -65,6 +65,12 @@ class ControlProtocol : virtual public sigc::trackable, public PBD::Stateful, pu
        static PBD::Signal1<void,float> ScrollTimeline;
        static PBD::Signal1<void,uint32_t> SelectByRID;
        static PBD::Signal0<void> UnselectTrack;
+       static PBD::Signal1<void,uint32_t> GotoView;
+       static PBD::Signal0<void> CloseDialog;
+       static PBD::Signal0<void> VerticalZoomInAll;
+       static PBD::Signal0<void> VerticalZoomOutAll;
+       static PBD::Signal0<void> VerticalZoomInSelected;
+       static PBD::Signal0<void> VerticalZoomOutSelected;
 
        /* the model here is as follows:
 
index bef36974c7f5f00e1aff3d25978d9a8d1bb5325f..33809b494a0f14545c5548b3a0df2355be1beeef 100644 (file)
@@ -1276,176 +1276,6 @@ MackieControlProtocol::notify_transport_state_changed()
        mcu_port().write (builder.build_led (*rec, record_release (*rec)));
 }
 
-LedState 
-MackieControlProtocol::left_press (Button &)
-{
-       Sorted sorted = get_sorted_routes();
-       if (sorted.size() > route_table.size()) {
-               int new_initial = _current_initial_bank - route_table.size();
-               if (new_initial < 0) {
-                       new_initial = 0;
-               }
-               
-               if (new_initial != int (_current_initial_bank)) {
-                       session->set_dirty();
-                       switch_banks (new_initial);
-               }
-
-               return on;
-       } else {
-               return flashing;
-       }
-}
-
-LedState 
-MackieControlProtocol::left_release (Button &)
-{
-       return off;
-}
-
-LedState 
-MackieControlProtocol::right_press (Button &)
-{
-       return off;
-}
-
-LedState 
-MackieControlProtocol::right_release (Button &)
-{
-       if (_zoom_mode) {
-
-       }
-
-       return off;
-}
-
-LedState
-MackieControlProtocol::cursor_left_press (Button& )
-{
-       if (_zoom_mode) {
-
-               if (_modifier_state & MODIFIER_OPTION) {
-                       /* reset selected tracks to default vertical zoom */
-               } else {
-                       ZoomOut (); /* EMIT SIGNAL */
-               }
-       }
-
-       return off;
-}
-
-LedState
-MackieControlProtocol::cursor_left_release (Button&)
-{
-       return off;
-}
-
-LedState
-MackieControlProtocol::cursor_right_press (Button& )
-{
-       if (_zoom_mode) {
-               
-               if (_modifier_state & MODIFIER_OPTION) {
-                       /* reset selected tracks to default vertical zoom */
-               } else {
-                       ZoomIn (); /* EMIT SIGNAL */
-               }
-       }
-
-       return off;
-}
-
-LedState
-MackieControlProtocol::cursor_right_release (Button&)
-{
-       return off;
-}
-
-LedState
-MackieControlProtocol::cursor_up_press (Button&)
-{
-       return off;
-}
-
-LedState
-MackieControlProtocol::cursor_up_release (Button&)
-{
-       return off;
-}
-
-LedState
-MackieControlProtocol::cursor_down_press (Button&)
-{
-       return off;
-}
-
-LedState
-MackieControlProtocol::cursor_down_release (Button&)
-{
-       return off;
-}
-
-LedState 
-MackieControlProtocol::channel_left_press (Button &)
-{
-       Sorted sorted = get_sorted_routes();
-       if (sorted.size() > route_table.size()) {
-               prev_track();
-               return on;
-       } else {
-               return flashing;
-       }
-}
-
-LedState 
-MackieControlProtocol::channel_left_release (Button &)
-{
-       return off;
-}
-
-LedState 
-MackieControlProtocol::channel_right_press (Button &)
-{
-       Sorted sorted = get_sorted_routes();
-       if (sorted.size() > route_table.size()) {
-               next_track();
-               return on;
-       } else {
-               return flashing;
-       }
-}
-
-LedState 
-MackieControlProtocol::channel_right_release (Button &)
-{
-       return off;
-}
-
-/////////////////////////////////////
-// Functions
-/////////////////////////////////////
-LedState 
-MackieControlProtocol::marker_press (Button &)
-{
-       // cut'n'paste from LocationUI::add_new_location()
-       string markername;
-       framepos_t where = session->audible_frame();
-       session->locations()->next_available_name(markername,"mcu");
-       Location *location = new Location (*session, where, where, markername, Location::IsMark);
-       session->begin_reversible_command (_("add marker"));
-       XMLNode &before = session->locations()->get_state();
-       session->locations()->add (location, true);
-       XMLNode &after = session->locations()->get_state();
-       session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
-       session->commit_reversible_command ();
-       return on;
-}
-
-LedState 
-MackieControlProtocol::marker_release (Button &)
-{
-       return off;
-}
 
 void 
 jog_wheel_state_display (JogWheel::State state, SurfacePort & port)
index e05104fa322c350361e7aaf4174a231ff23f629d..27c38c472db08e7dba5f9ff64e2217575d6a339d 100644 (file)
@@ -17,6 +17,8 @@
        Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#include "pbd/memento_command.h"
+
 #include "ardour/session.h"
 #include "ardour/route.h"
 #include "ardour/location.h"
 
 #include "mackie_control_protocol.h"
 
+#include "i18n.h"
+
 /* handlers for all buttons, broken into a separate file to avoid clutter in
  * mackie_control_protocol.cc 
  */
 
 using namespace Mackie;
 using namespace ARDOUR;
+using std::string;
 
 LedState
 MackieControlProtocol::shift_press (Button &)
@@ -80,6 +85,192 @@ MackieControlProtocol::cmd_alt_release (Button &)
        return on;
 }
 
+LedState 
+MackieControlProtocol::left_press (Button &)
+{
+       Sorted sorted = get_sorted_routes();
+       if (sorted.size() > route_table.size()) {
+               int new_initial = _current_initial_bank - route_table.size();
+               if (new_initial < 0) {
+                       new_initial = 0;
+               }
+               
+               if (new_initial != int (_current_initial_bank)) {
+                       session->set_dirty();
+                       switch_banks (new_initial);
+               }
+
+               return on;
+       } else {
+               return flashing;
+       }
+}
+
+LedState 
+MackieControlProtocol::left_release (Button &)
+{
+       return off;
+}
+
+LedState 
+MackieControlProtocol::right_press (Button &)
+{
+       return off;
+}
+
+LedState 
+MackieControlProtocol::right_release (Button &)
+{
+       if (_zoom_mode) {
+
+       }
+
+       return off;
+}
+
+LedState
+MackieControlProtocol::cursor_left_press (Button& )
+{
+       if (_zoom_mode) {
+
+               if (_modifier_state & MODIFIER_OPTION) {
+                       /* reset selected tracks to default vertical zoom */
+               } else {
+                       ZoomOut (); /* EMIT SIGNAL */
+               }
+       }
+
+       return off;
+}
+
+LedState
+MackieControlProtocol::cursor_left_release (Button&)
+{
+       return off;
+}
+
+LedState
+MackieControlProtocol::cursor_right_press (Button& )
+{
+       if (_zoom_mode) {
+               
+               if (_modifier_state & MODIFIER_OPTION) {
+                       /* reset selected tracks to default vertical zoom */
+               } else {
+                       ZoomIn (); /* EMIT SIGNAL */
+               }
+       }
+
+       return off;
+}
+
+LedState
+MackieControlProtocol::cursor_right_release (Button&)
+{
+       return off;
+}
+
+LedState
+MackieControlProtocol::cursor_up_press (Button&)
+{
+       if (_zoom_mode) {
+               if (_modifier_state & MODIFIER_OPTION) {
+                       VerticalZoomOutSelected (); /* EMIT SIGNAL */
+               } else {
+                       VerticalZoomOutAll (); /* EMIT SIGNAL */
+               }
+       }
+       return off;
+}
+
+LedState
+MackieControlProtocol::cursor_up_release (Button&)
+{
+       return off;
+}
+
+LedState
+MackieControlProtocol::cursor_down_press (Button&)
+{
+       if (_zoom_mode) {
+               
+               if (_modifier_state & MODIFIER_OPTION) {
+                       VerticalZoomInSelected (); /* EMIT SIGNAL */
+               } else {
+                       VerticalZoomInAll (); /* EMIT SIGNAL */
+               }
+       }
+       return off;
+}
+
+LedState
+MackieControlProtocol::cursor_down_release (Button&)
+{
+       return off;
+}
+
+LedState 
+MackieControlProtocol::channel_left_press (Button &)
+{
+       Sorted sorted = get_sorted_routes();
+       if (sorted.size() > route_table.size()) {
+               prev_track();
+               return on;
+       } else {
+               return flashing;
+       }
+}
+
+LedState 
+MackieControlProtocol::channel_left_release (Button &)
+{
+       return off;
+}
+
+LedState 
+MackieControlProtocol::channel_right_press (Button &)
+{
+       Sorted sorted = get_sorted_routes();
+       if (sorted.size() > route_table.size()) {
+               next_track();
+               return on;
+       } else {
+               return flashing;
+       }
+}
+
+LedState 
+MackieControlProtocol::channel_right_release (Button &)
+{
+       return off;
+}
+
+/////////////////////////////////////
+// Functions
+/////////////////////////////////////
+LedState 
+MackieControlProtocol::marker_press (Button &)
+{
+       // cut'n'paste from LocationUI::add_new_location()
+       string markername;
+       framepos_t where = session->audible_frame();
+       session->locations()->next_available_name(markername,"mcu");
+       Location *location = new Location (*session, where, where, markername, Location::IsMark);
+       session->begin_reversible_command (_("add marker"));
+       XMLNode &before = session->locations()->get_state();
+       session->locations()->add (location, true);
+       XMLNode &after = session->locations()->get_state();
+       session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
+       session->commit_reversible_command ();
+       return on;
+}
+
+LedState 
+MackieControlProtocol::marker_release (Button &)
+{
+       return off;
+}
+
 /////////////////////////////////////
 // Transport Buttons
 /////////////////////////////////////
@@ -432,6 +623,7 @@ MackieControlProtocol::name_value_release (Button &)
 LedState
 MackieControlProtocol::F1_press (Button &) 
 { 
+       GotoView (0); /* EMIT SIGNAL */
        return off; 
 }
 LedState
@@ -442,6 +634,7 @@ MackieControlProtocol::F1_release (Button &)
 LedState
 MackieControlProtocol::F2_press (Button &) 
 { 
+       GotoView (1); /* EMIT SIGNAL */
        return off; 
 }
 LedState
@@ -452,6 +645,7 @@ MackieControlProtocol::F2_release (Button &)
 LedState
 MackieControlProtocol::F3_press (Button &) 
 { 
+       GotoView (2); /* EMIT SIGNAL */
        return off; 
 }
 LedState
@@ -462,6 +656,7 @@ MackieControlProtocol::F3_release (Button &)
 LedState
 MackieControlProtocol::F4_press (Button &) 
 { 
+       GotoView (3); /* EMIT SIGNAL */
        return off; 
 }
 LedState
@@ -472,6 +667,7 @@ MackieControlProtocol::F4_release (Button &)
 LedState
 MackieControlProtocol::F5_press (Button &) 
 { 
+       GotoView (4); /* EMIT SIGNAL */
        return off; 
 }
 LedState
@@ -482,6 +678,7 @@ MackieControlProtocol::F5_release (Button &)
 LedState
 MackieControlProtocol::F6_press (Button &) 
 { 
+       GotoView (5); /* EMIT SIGNAL */
        return off; 
 }
 LedState
@@ -492,6 +689,7 @@ MackieControlProtocol::F6_release (Button &)
 LedState
 MackieControlProtocol::F7_press (Button &) 
 { 
+       GotoView (6); /* EMIT SIGNAL */
        return off; 
 }
 LedState
@@ -502,6 +700,7 @@ MackieControlProtocol::F7_release (Button &)
 LedState
 MackieControlProtocol::F8_press (Button &) 
 { 
+       CloseDialog (); /* EMIT SIGNAL */
        return off; 
 }
 LedState
@@ -512,6 +711,7 @@ MackieControlProtocol::F8_release (Button &)
 LedState
 MackieControlProtocol::F9_press (Button &) 
 { 
+       GotoView (8); /* EMIT SIGNAL */
        return off; 
 }
 LedState