change API of build_controller_menu() to allow clamping button name length

This commit is contained in:
Paul Davis 2025-05-01 09:33:06 -06:00
parent 868d8c1d51
commit cc5e110216
2 changed files with 15 additions and 5 deletions

View file

@ -49,7 +49,8 @@ using namespace std;
void
build_controller_menu (Gtk::Menu& menu, InstrumentInfo const & instrument_info, uint16_t channel_mask,
std::function<void (Menu_Helpers::MenuList&, int, const std::string&)> add_single,
std::function<void (Menu_Helpers::MenuList&, uint16_t, int, const std::string&)> add_multi)
std::function<void (Menu_Helpers::MenuList&, uint16_t, int, const std::string&)> 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;
}

View file

@ -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<void (Gtk::Menu_Helpers::MenuList&, int, const std::string&)> add_single,
std::function<void (Gtk::Menu_Helpers::MenuList&, uint16_t, int, const std::string&)> add_multi);
std::function<void (Gtk::Menu_Helpers::MenuList&, uint16_t, int, const std::string&)> add_multi,
int button_name_length = 0);