use session stripable selection API
[ardour.git] / libs / surfaces / mackie / mackie_control_protocol.h
index df758074be7e130bb345a812ef521944616ecafa..76da4fe5e8d43e352f3dce8de468f8a8a9539c9d 100644 (file)
@@ -63,26 +63,6 @@ namespace Mackie {
 
 gboolean ipmidi_input_handler (GIOChannel*, GIOCondition condition, void *data);
 
-/**
-       This handles the plugin duties, and the midi encoding and decoding,
-       and the signal callbacks, mostly from ARDOUR::Route.
-
-       The model of the control surface is handled by classes in controls.h
-
-       What happens is that each strip on the control surface has
-       a corresponding route in ControlProtocol::route_table. When
-       an incoming midi message is signaled, the correct route
-       is looked up, and the relevant changes made to it.
-
-       For each route currently in route_table, there's a RouteSignal object
-       which encapsulates the signals that indicate that there are changes
-       to be sent to the surface. The signals are handled by this class.
-
-       Calls to signal handlers pass a Route object which is used to look
-       up the relevant Strip in Surface. Then the state is retrieved from
-       the Route and encoded as the correct midi message.
-*/
-
 struct MackieControlUIRequest : public BaseUI::BaseRequestObject {
 public:
        MackieControlUIRequest () {}
@@ -100,6 +80,8 @@ class MackieControlProtocol
        static const int MODIFIER_CMDALT;
        static const int MODIFIER_ZOOM;
        static const int MODIFIER_SCRUB;
+       static const int MODIFIER_MARKER;
+       static const int MODIFIER_NUDGE;
        static const int MAIN_MODIFIER_MASK;
 
        enum ViewMode {
@@ -117,12 +99,8 @@ class MackieControlProtocol
                None,
                EQ,
                Dynamics,
-       };
-
-       enum PotMode {
-               Trim,
-               Send,
-               Pan,
+               Sends,
+               TrackView,
        };
 
        enum FlipMode {
@@ -152,23 +130,27 @@ class MackieControlProtocol
        FlipMode flip_mode () const { return _flip_mode; }
        ViewMode view_mode () const { return _view_mode; }
        SubViewMode subview_mode () const { return _subview_mode; }
-       boost::shared_ptr<ARDOUR::Route> subview_route() const;
-       PotMode pot_mode () const { return _pot_mode; }
+       static bool subview_mode_would_be_ok (SubViewMode, boost::shared_ptr<ARDOUR::Stripable>);
+       boost::shared_ptr<ARDOUR::Stripable> subview_stripable() const;
        bool zoom_mode () const { return modifier_state() & MODIFIER_ZOOM; }
        bool     metering_active () const { return _metering_active; }
 
-       bool is_track (boost::shared_ptr<ARDOUR::Route>) const;
-       bool is_audio_track (boost::shared_ptr<ARDOUR::Route>) const;
-       bool is_midi_track (boost::shared_ptr<ARDOUR::Route>) const;
-       bool selected (boost::shared_ptr<ARDOUR::Route>) const;
-       bool is_hidden (boost::shared_ptr<ARDOUR::Route>) const;
-       boost::shared_ptr<ARDOUR::Route> first_selected_route () const;
+       bool is_track (boost::shared_ptr<ARDOUR::Stripable>) const;
+       bool is_audio_track (boost::shared_ptr<ARDOUR::Stripable>) const;
+       bool is_midi_track (boost::shared_ptr<ARDOUR::Stripable>) const;
+       bool selected (boost::shared_ptr<ARDOUR::Stripable>) const;
+       bool is_hidden (boost::shared_ptr<ARDOUR::Stripable>) const;
+       bool is_mapped (boost::shared_ptr<ARDOUR::Stripable>) const;
+       boost::shared_ptr<ARDOUR::Stripable> first_selected_stripable () const;
+       void update_selected (boost::shared_ptr<ARDOUR::Stripable>, bool selected);
+
+       void check_fader_automation_state ();
+       void update_fader_automation_state ();
+       void set_automation_state (ARDOUR::AutoState);
 
        void set_view_mode (ViewMode);
-       void set_subview_mode (SubViewMode, boost::shared_ptr<ARDOUR::Route>);
+       int set_subview_mode (SubViewMode, boost::shared_ptr<ARDOUR::Stripable>);
        void set_flip_mode (FlipMode);
-       void set_pot_mode (PotMode);
-       void pot_mode_globals ();
        void display_view_mode ();
 
        XMLNode& get_state ();
@@ -204,18 +186,19 @@ class MackieControlProtocol
 
        void handle_button_event (Mackie::Surface&, Mackie::Button& button, Mackie::ButtonState);
 
-       void notify_subview_route_deleted ();
-       void notify_route_added_or_removed ();
-       void notify_route_added (ARDOUR::RouteList &);
-       void notify_remote_id_changed();
-       void notify_group_property_changed (PBD::PropertyChange);
+       void notify_subview_stripable_deleted ();
+       void notify_stripable_removed ();
+       void notify_routes_added (ARDOUR::RouteList &);
+       void notify_vca_added (ARDOUR::VCAList &);
+
+       void notify_presentation_info_changed();
 
        void recalibrate_faders ();
        void toggle_backlight ();
        void set_touch_sensitivity (int);
 
-       /// rebuild the current bank. Called on route added/removed and
-       /// remote id changed.
+       /// rebuild the current bank. Called on route or vca added/removed and
+       /// presentation info changed.
        void refresh_current_bank();
 
        // button-related signals
@@ -274,14 +257,14 @@ class MackieControlProtocol
        void zero_all();
 
        /**
-          Fetch the set of routes to be considered for control by the
+          Fetch the set of Stripables to be considered for control by the
           surface. Excluding master, hidden and control routes, and inactive routes
        */
-       typedef std::vector<boost::shared_ptr<ARDOUR::Route> > Sorted;
-       Sorted get_sorted_routes();
+       typedef std::vector<boost::shared_ptr<ARDOUR::Stripable> > Sorted;
+       Sorted get_sorted_stripables();
 
        // bank switching
-       void switch_banks (uint32_t first_remote_id, bool force = false);
+       int switch_banks (uint32_t first_remote_id, bool force = false);
        void prev_track ();
        void next_track ();
 
@@ -296,7 +279,7 @@ class MackieControlProtocol
 
        void thread_init ();
 
-       bool route_is_locked_to_strip (boost::shared_ptr<ARDOUR::Route>) const;
+       bool stripable_is_locked_to_strip (boost::shared_ptr<ARDOUR::Stripable>) const;
 
   private:
 
@@ -314,6 +297,8 @@ class MackieControlProtocol
 
        static MackieControlProtocol* _instance;
 
+       bool profile_exists (std::string const&) const;
+
        Mackie::DeviceInfo       _device_info;
        Mackie::DeviceProfile    _device_profile;
        sigc::connection          periodic_connection;
@@ -322,9 +307,10 @@ class MackieControlProtocol
        uint32_t                 _current_initial_bank;
        PBD::ScopedConnectionList audio_engine_connections;
        PBD::ScopedConnectionList session_connections;
-       PBD::ScopedConnectionList route_connections;
-       PBD::ScopedConnectionList subview_route_connections;
+       PBD::ScopedConnectionList stripable_connections;
+       PBD::ScopedConnectionList subview_stripable_connections;
        PBD::ScopedConnectionList gui_connections;
+       PBD::ScopedConnectionList fader_automation_connections;
        // timer for two quick marker left presses
        Mackie::Timer            _frm_left_last;
        // last written timecode string
@@ -341,8 +327,7 @@ class MackieControlProtocol
        FlipMode                 _flip_mode;
        ViewMode                 _view_mode;
        SubViewMode              _subview_mode;
-       boost::shared_ptr<ARDOUR::Route> _subview_route;
-       PotMode                  _pot_mode;
+       boost::shared_ptr<ARDOUR::Stripable> _subview_stripable;
        int                      _current_selected_track;
        int                      _modifier_state;
        ButtonMap                 button_map;
@@ -350,10 +335,13 @@ class MackieControlProtocol
        bool                      needs_ipmidi_restart;
        bool                     _metering_active;
        bool                     _initialized;
-       ARDOUR::RouteNotificationList _last_selected_routes;
+       typedef std::vector<boost::weak_ptr<ARDOUR::Stripable> > Selection;
+       Selection                _last_selected_stripables;
        XMLNode*                 configuration_state;
        int                      state_version;
        int                      _last_bank[9];
+       bool                     marker_modifier_consumed_by_button;
+       bool                     nudge_modifier_consumed_by_button;
 
        boost::shared_ptr<ArdourSurface::Mackie::Surface>       _master_surface;
 
@@ -367,15 +355,16 @@ class MackieControlProtocol
        int create_surfaces ();
        bool periodic();
        bool redisplay();
+       bool redisplay_subview_mode ();
        bool hui_heartbeat ();
        void build_gui ();
        bool midi_input_handler (Glib::IOCondition ioc, MIDI::Port* port);
        void clear_ports ();
        void clear_surfaces ();
-       void force_special_route_to_strip (boost::shared_ptr<ARDOUR::Route> r, uint32_t surface, uint32_t strip_number);
+       void force_special_stripable_to_strip (boost::shared_ptr<ARDOUR::Stripable> r, uint32_t surface, uint32_t strip_number);
        void build_button_map ();
-       void gui_track_selection_changed (ARDOUR::RouteNotificationListPtr, bool save_list);
-       void _gui_track_selection_changed (ARDOUR::RouteNotificationList*, bool save_list, bool gui_did_change);
+       void gui_track_selection_changed (ARDOUR::StripableNotificationListPtr, bool save_list);
+       void _gui_track_selection_changed (ARDOUR::StripableNotificationList*, bool save_list, bool gui_did_change);
        int ipmidi_restart ();
         void initialize ();
         int set_device_info (const std::string& device_name);
@@ -393,7 +382,7 @@ class MackieControlProtocol
        DownButtonMap  _down_buttons;
        DownButtonList _down_select_buttons;
 
-       void pull_route_range (DownButtonList&, ARDOUR::RouteList&);
+       void pull_stripable_range (DownButtonList&, ARDOUR::StripableList&);
 
        /* implemented button handlers */
        Mackie::LedState stop_press(Mackie::Button &);
@@ -424,8 +413,6 @@ class MackieControlProtocol
        Mackie::LedState channel_left_release(Mackie::Button &);
        Mackie::LedState channel_right_press(Mackie::Button &);
        Mackie::LedState channel_right_release(Mackie::Button &);
-       Mackie::LedState clicking_press(Mackie::Button &);
-       Mackie::LedState clicking_release(Mackie::Button &);
        Mackie::LedState marker_press(Mackie::Button &);
        Mackie::LedState marker_release(Mackie::Button &);
        Mackie::LedState save_press(Mackie::Button &);