Consolidate automation and meter-point strings

This also properly selects texts in dropdown-menus on the mixer-strip,
panner and plugin-controls, gain-meters.
This commit is contained in:
Robin Gareus 2019-10-31 15:55:46 +01:00
parent 3cae11936f
commit ab298f035a
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
6 changed files with 60 additions and 123 deletions

View File

@ -182,21 +182,22 @@ GainMeterBase::GainMeterBase (Session* s, bool horizontal, int fader_length, int
meter_point_menu.set_reserve_toggle_size(false);
meter_point_menu.items().clear ();
meter_point_menu.items().push_back (MenuElem(_("Input"),
meter_point_menu.items().push_back (MenuElem(meterpt_string(MeterInput),
sigc::bind (sigc::mem_fun (*this,
&GainMeterBase::meter_point_clicked), (MeterPoint) MeterInput)));
meter_point_menu.items().push_back (MenuElem(_("Pre Fader"),
meter_point_menu.items().push_back (MenuElem(meterpt_string(MeterPreFader),
sigc::bind (sigc::mem_fun (*this,
&GainMeterBase::meter_point_clicked), (MeterPoint) MeterPreFader)));
meter_point_menu.items().push_back (MenuElem(_("Post Fader"),
meter_point_menu.items().push_back (MenuElem(meterpt_string (MeterPostFader),
sigc::bind (sigc::mem_fun (*this,
&GainMeterBase::meter_point_clicked), (MeterPoint) MeterPostFader)));
meter_point_menu.items().push_back (MenuElem(_("Output"),
meter_point_menu.items().push_back (MenuElem(meterpt_string (MeterOutput),
sigc::bind (sigc::mem_fun (*this,
&GainMeterBase::meter_point_clicked), (MeterPoint) MeterOutput)));
meter_point_menu.items().push_back (MenuElem(_("Custom"),
meter_point_menu.items().push_back (MenuElem(meterpt_string (MeterCustom),
sigc::bind (sigc::mem_fun (*this,
&GainMeterBase::meter_point_clicked), (MeterPoint) MeterCustom)));
meter_point_button.signal_button_press_event().connect (sigc::mem_fun (*this, &GainMeter::meter_press), false);
gain_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &GainMeterBase::fader_moved));
@ -263,15 +264,15 @@ GainMeterBase::set_controls (boost::shared_ptr<Route> r,
gain_astate_menu.items().clear ();
gain_astate_menu.items().push_back (MenuElem (S_("Automation|Manual"),
gain_astate_menu.items().push_back (MenuElem (astate_string (ARDOUR::Off),
sigc::bind (sigc::mem_fun (*this, &GainMeterBase::set_gain_astate), (AutoState) ARDOUR::Off)));
gain_astate_menu.items().push_back (MenuElem (_("Play"),
gain_astate_menu.items().push_back (MenuElem (astate_string (ARDOUR::Play),
sigc::bind (sigc::mem_fun (*this, &GainMeterBase::set_gain_astate), (AutoState) ARDOUR::Play)));
gain_astate_menu.items().push_back (MenuElem (_("Write"),
gain_astate_menu.items().push_back (MenuElem (astate_string (ARDOUR::Write),
sigc::bind (sigc::mem_fun (*this, &GainMeterBase::set_gain_astate), (AutoState) ARDOUR::Write)));
gain_astate_menu.items().push_back (MenuElem (_("Touch"),
gain_astate_menu.items().push_back (MenuElem (astate_string (ARDOUR::Touch),
sigc::bind (sigc::mem_fun (*this, &GainMeterBase::set_gain_astate), (AutoState) ARDOUR::Touch)));
gain_astate_menu.items().push_back (MenuElem (_("Latch"),
gain_astate_menu.items().push_back (MenuElem (astate_string (ARDOUR::Latch),
sigc::bind (sigc::mem_fun (*this, &GainMeterBase::set_gain_astate), (AutoState) ARDOUR::Latch)));
connections.push_back (gain_automation_state_button.signal_button_press_event().connect (sigc::mem_fun(*this, &GainMeterBase::gain_automation_state_button_event), false));
@ -682,7 +683,8 @@ GainMeterBase::meter_press(GdkEventButton* ev)
}
Gtkmm2ext::anchored_menu_popup(&meter_point_menu,
&meter_point_button,
"", 1, ev->time);
meterpt_string (_route->meter_point()),
1, ev->time);
break;
default:
break;
@ -752,7 +754,8 @@ GainMeterBase::gain_automation_state_button_event (GdkEventButton *ev)
gain_astate_propagate = Keyboard::modifier_state_contains (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier | Keyboard::TertiaryModifier));
Gtkmm2ext::anchored_menu_popup(&gain_astate_menu,
&gain_automation_state_button,
"", 1, ev->time);
astate_string(_control->alist()->automation_state()),
1, ev->time);
break;
default:
break;
@ -781,38 +784,49 @@ GainMeterBase::_astate_string (AutoState state, bool shrt)
switch (state) {
case ARDOUR::Off:
sstr = (shrt ? "M" : S_("Manual|M"));
sstr = shrt ? S_("Manual|M") : S_("Automation|Manual");
break;
case Play:
sstr = (shrt ? "P" : S_("Play|P"));
sstr = shrt ? S_("Play|P") : _("Play");
break;
case Touch:
sstr = (shrt ? "T" : S_("Trim|T"));
sstr = shrt ? S_("Trim|T") : _("Write");
break;
case Latch:
sstr = (shrt ? "L" : S_("Latch|L"));
sstr = shrt ? S_("Latch|L") : _("Touch");
break;
case Write:
sstr = (shrt ? "W" : S_("Write|W"));
sstr = shrt ? S_("Write|W"): _("Latch");
break;
}
return sstr;
}
string
GainMeterBase::meterpt_string (MeterPoint mp)
{
switch (mp) {
case MeterInput:
return _("Input");
case MeterPreFader:
return _("Pre Fader");
case MeterPostFader:
return _("Post Fader");
case MeterOutput:
return _("Output");
case MeterCustom:
return _("Custom");
}
assert (0);
return _("Custom"); // make gcc happy
}
void
GainMeterBase::gain_automation_state_changed ()
{
ENSURE_GUI_THREAD (*this, &GainMeterBase::gain_automation_state_changed);
switch (_width) {
case Wide:
gain_automation_state_button.set_text (astate_string(_control->alist()->automation_state()));
break;
case Narrow:
gain_automation_state_button.set_text (short_astate_string(_control->alist()->automation_state()));
break;
}
gain_automation_state_button.set_text (short_astate_string(_control->alist()->automation_state()));
const bool automation_watch_required = (_control->alist()->automation_state() != ARDOUR::Off);

View File

@ -107,6 +107,7 @@ public:
*/
PBD::Signal1<bool, GdkEventButton *> LevelMeterButtonPress;
static std::string meterpt_string (ARDOUR::MeterPoint);
static std::string astate_string (ARDOUR::AutoState);
static std::string short_astate_string (ARDOUR::AutoState);
static std::string _astate_string (ARDOUR::AutoState, bool);

View File

@ -876,30 +876,9 @@ GenericPluginUI::automation_state_changed (ControlUI* cui)
cui->automate_button.set_active((state != ARDOUR::Off));
if (cui->short_autostate) {
cui->automate_button.set_text (
GainMeterBase::astate_string (state));
return;
}
switch (state & (ARDOUR::Off|Play|Touch|Write|Latch)) {
case ARDOUR::Off:
cui->automate_button.set_text (S_("Automation|Manual"));
break;
case Play:
cui->automate_button.set_text (_("Play"));
break;
case Write:
cui->automate_button.set_text (_("Write"));
break;
case Touch:
cui->automate_button.set_text (_("Touch"));
break;
case Latch:
cui->automate_button.set_text (_("Latch"));
break;
default:
cui->automate_button.set_text (_("???"));
break;
cui->automate_button.set_text (GainMeterBase::short_astate_string (state));
} else {
cui->automate_button.set_text (GainMeterBase::astate_string (state));
}
}
@ -1215,19 +1194,20 @@ GenericPluginUI::astate_button_event (GdkEventButton* ev, ControlUI* cui)
MenuList& items (automation_menu->items());
items.clear ();
items.push_back (MenuElem (S_("Automation|Manual"),
items.push_back (MenuElem (GainMeterBase::astate_string (ARDOUR::Off),
sigc::bind (sigc::mem_fun(*this, &GenericPluginUI::set_automation_state), (AutoState) ARDOUR::Off, cui)));
items.push_back (MenuElem (_("Play"),
items.push_back (MenuElem (GainMeterBase::astate_string (Play),
sigc::bind (sigc::mem_fun(*this, &GenericPluginUI::set_automation_state), (AutoState) Play, cui)));
items.push_back (MenuElem (_("Write"),
items.push_back (MenuElem (GainMeterBase::astate_string (Write),
sigc::bind (sigc::mem_fun(*this, &GenericPluginUI::set_automation_state), (AutoState) Write, cui)));
items.push_back (MenuElem (_("Touch"),
items.push_back (MenuElem (GainMeterBase::astate_string (Touch),
sigc::bind (sigc::mem_fun(*this, &GenericPluginUI::set_automation_state), (AutoState) Touch, cui)));
items.push_back (MenuElem (_("Latch"),
items.push_back (MenuElem (GainMeterBase::astate_string (Latch),
sigc::bind (sigc::mem_fun(*this, &GenericPluginUI::set_automation_state), (AutoState) Latch, cui)));
anchored_menu_popup(automation_menu, &cui->automate_button, cui->automate_button.get_text(),
1, ev->time);
anchored_menu_popup (automation_menu, &cui->automate_button,
GainMeterBase::astate_string (insert->get_parameter_automation_state (cui->parameter())),
1, ev->time);
return true;
}

View File

@ -782,6 +782,12 @@ MixerStrip::set_width_enum (Width w, void* owner)
const float scale = std::max(1.f, UIConfiguration::instance().get_ui_scale());
gpm.gain_automation_state_button.set_text (GainMeterBase::short_astate_string (gain_automation->automation_state()));
if (_route->panner()) {
((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (GainMeterBase::short_astate_string (_route->panner()->automation_state()));
}
switch (w) {
case Wide:
@ -789,14 +795,6 @@ MixerStrip::set_width_enum (Width w, void* owner)
show_sends_button->set_text (_("Aux"));
}
gpm.gain_automation_state_button.set_text (
gpm.astate_string(gain_automation->automation_state()));
if (_route->panner()) {
((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
panners.astate_string(_route->panner()->automation_state()));
}
{
// panners expect an even number of horiz. pixels
int width = rintf (max (110.f * scale, gpm.get_gm_width() + 10.f * scale)) + 1;
@ -811,15 +809,8 @@ MixerStrip::set_width_enum (Width w, void* owner)
show_sends_button->set_text (_("Snd"));
}
gpm.gain_automation_state_button.set_text (
gpm.short_astate_string(gain_automation->automation_state()));
gain_meter().setup_meters (); // recalc meter width
if (_route->panner()) {
((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
panners.short_astate_string(_route->panner()->automation_state()));
}
{
// panners expect an even number of horiz. pixels
int width = rintf (max (60.f * scale, gpm.get_gm_width() + 10.f * scale)) + 1;

View File

@ -37,6 +37,7 @@
#include "widgets/tooltips.h"
#include "gain_meter.h"
#include "panner_ui.h"
#include "panner2d.h"
#include "gui_thread.h"
@ -526,15 +527,7 @@ void
PannerUI::pan_automation_state_changed ()
{
boost::shared_ptr<Pannable> pannable (_panner->pannable());
switch (_width) {
case Wide:
pan_automation_state_button.set_label (astate_string(pannable->automation_state()));
break;
case Narrow:
pan_automation_state_button.set_label (short_astate_string(pannable->automation_state()));
break;
}
pan_automation_state_button.set_label (GainMeterBase::short_astate_string(pannable->automation_state()));
bool x = (pannable->automation_state() != ARDOUR::Off);
@ -547,44 +540,6 @@ PannerUI::pan_automation_state_changed ()
update_pan_sensitive ();
}
string
PannerUI::astate_string (AutoState state)
{
return _astate_string (state, false);
}
string
PannerUI::short_astate_string (AutoState state)
{
return _astate_string (state, true);
}
string
PannerUI::_astate_string (AutoState state, bool shrt)
{
string sstr;
switch (state) {
case ARDOUR::Off:
sstr = (shrt ? "M" : S_("Manual|M"));
break;
case Play:
sstr = (shrt ? "P" : S_("Play|P"));
break;
case Touch:
sstr = (shrt ? "T" : S_("Touch|T"));
break;
case Latch:
sstr = (shrt ? "L" : S_("Latch|L"));
break;
case Write:
sstr = (shrt ? "W" : S_("Write|W"));
break;
}
return sstr;
}
void
PannerUI::show_width ()
{

View File

@ -144,10 +144,6 @@ private:
void pan_automation_state_changed();
gint pan_automation_state_button_event (GdkEventButton *);
std::string astate_string (ARDOUR::AutoState);
std::string short_astate_string (ARDOUR::AutoState);
std::string _astate_string (ARDOUR::AutoState, bool);
void start_touch (boost::weak_ptr<ARDOUR::AutomationControl>);
void stop_touch (boost::weak_ptr<ARDOUR::AutomationControl>);