From 8b82de7ac1532230d65513000bbcc268f4d96d41 Mon Sep 17 00:00:00 2001 From: Caleb Potter Date: Tue, 12 Apr 2022 12:36:43 -0500 Subject: [PATCH] Prevents user from infinitely banking right in mackie plugin subview Changes handle_cursor_right_press() in PluginSubviewState to pure virtual function so that PluginSelect and PluginEdit can each have their own version. --- libs/surfaces/mackie/subview.cc | 36 ++++++++++++++++++++++++++------- libs/surfaces/mackie/subview.h | 6 +++++- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/libs/surfaces/mackie/subview.cc b/libs/surfaces/mackie/subview.cc index d4dc9d0f05..2345acd9c1 100644 --- a/libs/surfaces/mackie/subview.cc +++ b/libs/surfaces/mackie/subview.cc @@ -1027,13 +1027,6 @@ PluginSubviewState::shorten_display_text(const std::string& text, std::string::s return PBD::short_version (text, target_length); } -bool PluginSubviewState::handle_cursor_right_press() -{ - _current_bank = _current_bank + 1; - bank_changed(); - return true; -} - bool PluginSubviewState::handle_cursor_left_press() { if (_current_bank >= 1) @@ -1053,6 +1046,7 @@ uint32_t PluginSubviewState::calculate_virtual_strip_position(uint32_t strip_ind PluginSelect::PluginSelect(PluginSubview& context) : PluginSubviewState(context) + , _bank_size(_context.mcp().n_strips()) {} PluginSelect::~PluginSelect() @@ -1112,6 +1106,25 @@ void PluginSelect::handle_vselect_event(uint32_t global_strip_position, } } +bool PluginSelect::handle_cursor_right_press() +{ + boost::shared_ptr route = boost::dynamic_pointer_cast (_context.subview_stripable()); + if (!route) { + return true; + } + boost::shared_ptr plugin = route->nth_plugin(0); + uint32_t num_plugins = 0; + while (plugin) { + plugin = route->nth_plugin(++num_plugins); + } + + if (num_plugins > (_current_bank + 1) * _bank_size) { + _current_bank = _current_bank + 1; + bank_changed(); + } + return true; +} + void PluginSelect::bank_changed() { _context.mcp().redisplay_subview_mode(); @@ -1258,6 +1271,15 @@ void PluginEdit::handle_vselect_event(uint32_t global_strip_position, boost::sha { } +bool PluginEdit::handle_cursor_right_press() +{ + if (_plugin_input_parameter_indices.size() > (_current_bank + 1) * _bank_size) { + _current_bank = _current_bank + 1; + bank_changed(); + } + return true; +} + void PluginEdit::bank_changed() { _context.mcp().redisplay_subview_mode(); diff --git a/libs/surfaces/mackie/subview.h b/libs/surfaces/mackie/subview.h index b055b89b5c..dd6f5299ed 100644 --- a/libs/surfaces/mackie/subview.h +++ b/libs/surfaces/mackie/subview.h @@ -227,7 +227,7 @@ class PluginSubviewState { boost::shared_ptr subview_stripable) = 0; virtual void handle_vselect_event(uint32_t global_strip_position, boost::shared_ptr subview_stripable) = 0; static std::string shorten_display_text(const std::string& text, std::string::size_type target_length); - virtual bool handle_cursor_right_press(); + virtual bool handle_cursor_right_press() = 0; virtual bool handle_cursor_left_press(); virtual void bank_changed() = 0; @@ -251,7 +251,10 @@ class PluginSelect : public PluginSubviewState { uint32_t global_strip_position, boost::shared_ptr subview_stripable); virtual void handle_vselect_event(uint32_t global_strip_position, boost::shared_ptr subview_stripable); + virtual bool handle_cursor_right_press(); virtual void bank_changed(); + private: + const uint32_t _bank_size; }; class PluginEdit : public PluginSubviewState { @@ -267,6 +270,7 @@ class PluginEdit : public PluginSubviewState { uint32_t global_strip_position, boost::shared_ptr subview_stripable); virtual void handle_vselect_event(uint32_t global_strip_position, boost::shared_ptr subview_stripable); + virtual bool handle_cursor_right_press(); virtual void bank_changed(); void notify_parameter_change(Strip* strip, Pot* vpot, std::string pending_display[2], uint32_t global_strip_position);