Consolidate code duplication

This commit is contained in:
Robin Gareus 2023-01-06 00:53:22 +01:00
parent 2226da1385
commit b410ed992b
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 7 additions and 17 deletions

View File

@ -44,6 +44,7 @@
#include "ardour/value_as_string.h"
#include "plugin_pin_dialog.h"
#include "plugin_setup_dialog.h"
#include "gui_thread.h"
#include "timers.h"
#include "ui_config.h"
@ -523,18 +524,7 @@ PluginPinWidget::refill_output_presets ()
for (PluginOutputConfiguration::const_iterator i = ppc.begin () ; i != ppc.end (); ++i) {
assert (*i > 0);
std::string tmp;
switch (*i) {
case 1:
tmp = _("Mono");
break;
case 2:
tmp = _("Stereo");
break;
default:
tmp = string_compose (P_("%1 Channel", "%1 Channels", *i), *i);
break;
}
std::string tmp = PluginSetupDialog::preset_label (*i);
_out_presets.AddMenuElem (MenuElem (tmp, sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::select_output_preset), *i)));
if (n_audio == *i) {
_out_presets.set_text (tmp);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2017 Robin Gareus <robin@gareus.org>
* Copyright (C) 2016-2023 Robin Gareus <robin@gareus.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -207,7 +207,7 @@ PluginSetupDialog::toggle_fan_out ()
}
std::string
PluginSetupDialog::preset_label (uint32_t n_audio) const
PluginSetupDialog::preset_label (uint32_t n_audio)
{
std::string rv;
switch (n_audio) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2017 Robin Gareus <robin@gareus.org>
* Copyright (C) 2016-2023 Robin Gareus <robin@gareus.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -34,6 +34,8 @@ public:
bool fan_out () const { return _fan_out.get_active () && _fan_out.get_sensitive (); }
static std::string preset_label (uint32_t);
private:
void setup_output_presets ();
void update_sensitivity (uint32_t);
@ -43,8 +45,6 @@ private:
void apply_mapping ();
void toggle_fan_out ();
std::string preset_label (uint32_t) const;
boost::shared_ptr<ARDOUR::Route> _route;
boost::shared_ptr<ARDOUR::PluginInsert> _pi;