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.
This commit is contained in:
Caleb Potter 2022-04-12 12:36:43 -05:00 committed by Paul Davis
parent f3bd740913
commit 8b82de7ac1
2 changed files with 34 additions and 8 deletions

View File

@ -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> route = boost::dynamic_pointer_cast<Route> (_context.subview_stripable());
if (!route) {
return true;
}
boost::shared_ptr<Processor> 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();

View File

@ -227,7 +227,7 @@ class PluginSubviewState {
boost::shared_ptr<ARDOUR::Stripable> subview_stripable) = 0;
virtual void handle_vselect_event(uint32_t global_strip_position, boost::shared_ptr<ARDOUR::Stripable> 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<ARDOUR::Stripable> subview_stripable);
virtual void handle_vselect_event(uint32_t global_strip_position, boost::shared_ptr<ARDOUR::Stripable> 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<ARDOUR::Stripable> subview_stripable);
virtual void handle_vselect_event(uint32_t global_strip_position, boost::shared_ptr<ARDOUR::Stripable> 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);