From cc5e110216f5a8f2d278420154cc195ea92d89eb Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 1 May 2025 09:33:06 -0600 Subject: [PATCH] change API of build_controller_menu() to allow clamping button name length --- gtk2_ardour/midi_util.cc | 17 +++++++++++++---- gtk2_ardour/midi_util.h | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/gtk2_ardour/midi_util.cc b/gtk2_ardour/midi_util.cc index 00436b551e..db68e64115 100644 --- a/gtk2_ardour/midi_util.cc +++ b/gtk2_ardour/midi_util.cc @@ -49,7 +49,8 @@ using namespace std; void build_controller_menu (Gtk::Menu& menu, InstrumentInfo const & instrument_info, uint16_t channel_mask, std::function add_single, - std::function add_multi) + std::function add_multi, + int button_name_length) { using namespace Menu_Helpers; @@ -106,10 +107,18 @@ build_controller_menu (Gtk::Menu& menu, InstrumentInfo const & instrument_info, } MenuList& ctl_items (ctl_menu->items()); - if (multi_channel) { - add_multi (ctl_items, channels, ctl, c->second->name()); + + std::string name; + if (button_name_length > 0) { + name = short_version (c->second->name(), button_name_length); } else { - add_single (ctl_items, ctl, c->second->name()); + name = c->second->name(); + } + + if (multi_channel) { + add_multi (ctl_items, channels, ctl, name); + } else { + add_single (ctl_items, ctl, name); } ctl_end = ctl; } diff --git a/gtk2_ardour/midi_util.h b/gtk2_ardour/midi_util.h index 4f3c5a31a4..6961aad6ac 100644 --- a/gtk2_ardour/midi_util.h +++ b/gtk2_ardour/midi_util.h @@ -46,4 +46,5 @@ inline static void clamp_to_0_127(uint8_t &val) void build_controller_menu (Gtk::Menu& menu, ARDOUR::InstrumentInfo const & instrument_info, uint16_t channel_mask, std::function add_single, - std::function add_multi); + std::function add_multi, + int button_name_length = 0);