catch up on TriggerReference API changes in GUI

This commit is contained in:
Paul Davis 2024-09-17 10:55:52 -06:00
parent 8baaa7eb66
commit ee305a7169
4 changed files with 41 additions and 33 deletions

View file

@ -601,19 +601,25 @@ SlotPropertyTable::on_trigger_set ()
void void
SlotPropertyTable::on_trigger_changed (PropertyChange const& pc) SlotPropertyTable::on_trigger_changed (PropertyChange const& pc)
{ {
std::shared_ptr<Trigger> trigr (trigger());
if (!trigr) {
return;
}
_ignore_changes = true; _ignore_changes = true;
int probability = trigger()->follow_action_probability(); int probability = trigr->follow_action_probability();
if (pc.contains (Properties::name)) { if (pc.contains (Properties::name)) {
_name_label.set_text (trigger()->name()); _name_label.set_text (trigr->name());
} }
if (pc.contains (Properties::color)) { if (pc.contains (Properties::color)) {
_color_button.set_custom_led_color (trigger()->color()); _color_button.set_custom_led_color (trigr->color());
} }
if (pc.contains (Properties::gain)) { if (pc.contains (Properties::gain)) {
float gain = accurate_coefficient_to_dB(trigger()->gain()); float gain = accurate_coefficient_to_dB(trigr->gain());
if (gain != _gain_adjustment.get_value()) { if (gain != _gain_adjustment.get_value()) {
_gain_adjustment.set_value (gain); _gain_adjustment.set_value (gain);
} }
@ -626,47 +632,47 @@ SlotPropertyTable::on_trigger_changed (PropertyChange const& pc)
} }
if (pc.contains (Properties::quantization)) { if (pc.contains (Properties::quantization)) {
BBT_Offset bbo (trigger()->quantization()); BBT_Offset bbo (trigr->quantization());
_quantize_button.set_active (quantize_length_to_string (bbo)); _quantize_button.set_active (quantize_length_to_string (bbo));
} }
if (pc.contains (Properties::follow_count)) { if (pc.contains (Properties::follow_count)) {
_follow_count_adjustment.set_value (trigger()->follow_count()); _follow_count_adjustment.set_value (trigr->follow_count());
} }
if (pc.contains (Properties::tempo_meter) || pc.contains (Properties::follow_length)) { if (pc.contains (Properties::tempo_meter) || pc.contains (Properties::follow_length)) {
int metrum_numerator = trigger()->meter().divisions_per_bar(); int metrum_numerator = trigr->meter().divisions_per_bar();
int bar_beats = metrum_numerator * trigger()->follow_length().bars; int bar_beats = metrum_numerator * trigr->follow_length().bars;
int beats = trigger()->follow_length().beats; int beats = trigr->follow_length().beats;
_follow_length_adjustment.set_value (bar_beats+beats); _follow_length_adjustment.set_value (bar_beats+beats);
} }
if (pc.contains (Properties::use_follow_length)) { if (pc.contains (Properties::use_follow_length)) {
_use_follow_length_button.set_active_state(trigger()->use_follow_length() ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off); _use_follow_length_button.set_active_state(trigr->use_follow_length() ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off);
} }
if (pc.contains (Properties::legato)) { if (pc.contains (Properties::legato)) {
_legato_button.set_active_state (trigger()->legato() ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off); _legato_button.set_active_state (trigr->legato() ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off);
} }
if (pc.contains (Properties::cue_isolated)) { if (pc.contains (Properties::cue_isolated)) {
_isolate_button.set_active_state (trigger()->cue_isolated() ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off); _isolate_button.set_active_state (trigr->cue_isolated() ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off);
} }
if (pc.contains (Properties::allow_patch_changes)) { if (pc.contains (Properties::allow_patch_changes)) {
_patch_button.set_sensitive(trigger()->allow_patch_changes()); _patch_button.set_sensitive(trigr->allow_patch_changes());
_allow_button.set_active_state (trigger()->allow_patch_changes() ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off); _allow_button.set_active_state (trigr->allow_patch_changes() ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off);
} }
if (pc.contains (Properties::launch_style)) { if (pc.contains (Properties::launch_style)) {
_launch_style_button.set_active (launch_style_to_string (trigger()->launch_style())); _launch_style_button.set_active (launch_style_to_string (trigr->launch_style()));
} }
if (pc.contains (Properties::follow_action0)) { if (pc.contains (Properties::follow_action0)) {
_follow_left.set_text (follow_action_to_string (trigger()->follow_action0 (), true)); _follow_left.set_text (follow_action_to_string (trigr->follow_action0 (), true));
/* set widget sensitivity based on 'left' follow action */ /* set widget sensitivity based on 'left' follow action */
bool follow_widgets_sensitive = trigger()->follow_action0 ().type != FollowAction::None; bool follow_widgets_sensitive = trigr->follow_action0 ().type != FollowAction::None;
if (follow_widgets_sensitive) { if (follow_widgets_sensitive) {
_follow_right.set_sensitive(true); _follow_right.set_sensitive(true);
_follow_count_spinner.set_sensitive(true); _follow_count_spinner.set_sensitive(true);
@ -693,11 +699,11 @@ SlotPropertyTable::on_trigger_changed (PropertyChange const& pc)
} }
if (pc.contains (Properties::follow_action1)) { if (pc.contains (Properties::follow_action1)) {
_follow_right.set_text (follow_action_to_string (trigger()->follow_action1 (), true)); _follow_right.set_text (follow_action_to_string (trigr->follow_action1 (), true));
} }
if (pc.contains (Properties::velocity_effect)) { if (pc.contains (Properties::velocity_effect)) {
_velocity_adjustment.set_value (trigger()->velocity_effect()); _velocity_adjustment.set_value (trigr->velocity_effect());
} }
if (pc.contains (Properties::follow_action_probability)) { if (pc.contains (Properties::follow_action_probability)) {
@ -724,6 +730,8 @@ SlotPropertyWindow::SlotPropertyWindow (TriggerReference tref)
{ {
TriggerPtr trigger (tref.trigger()); TriggerPtr trigger (tref.trigger());
assert (trigger);
set_title (string_compose (_("Trigger Slot: %1"), trigger->name())); set_title (string_compose (_("Trigger Slot: %1"), trigger->name()));
SlotPropertiesBox* slot_prop_box = manage (new SlotPropertiesBox ()); SlotPropertiesBox* slot_prop_box = manage (new SlotPropertiesBox ());

View file

@ -415,7 +415,7 @@ TriggerPage::selection_changed ()
std::shared_ptr<MidiRegion> mr = std::dynamic_pointer_cast<MidiRegion> (trigger->region()); std::shared_ptr<MidiRegion> mr = std::dynamic_pointer_cast<MidiRegion> (trigger->region());
if (mr) { if (mr) {
std::shared_ptr<MidiTrack> mt = std::dynamic_pointer_cast<MidiTrack> (entry->strip().stripable()); std::shared_ptr<MidiTrack> mt = std::dynamic_pointer_cast<MidiTrack> (entry->strip().stripable());
_midi_editor->set_region (mt, ref.slot, mr); _midi_editor->set_region (mt, ref.slot(), mr);
_midi_editor->viewport().show (); _midi_editor->viewport().show ();
} }
} }

View file

@ -129,14 +129,14 @@ TriggerUI::~TriggerUI()
void void
TriggerUI::trigger_swap (uint32_t n) TriggerUI::trigger_swap (uint32_t n)
{ {
if (n != tref.slot) { if (n != tref.slot()) {
/* some other slot in the same box got swapped. we don't care */ /* some other slot in the same box got swapped. we don't care */
return; return;
} }
trigger_connections.drop_connections (); trigger_connections.drop_connections ();
trigger()->PropertyChanged.connect (trigger_connections, invalidator (*this), boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context ()); trigger()->PropertyChanged.connect (trigger_connections, invalidator (*this), boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context ());
tref.box->PropertyChanged.connect (trigger_connections, invalidator (*this), boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context ()); tref.box()->PropertyChanged.connect (trigger_connections, invalidator (*this), boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context ());
trigger_changed (Properties::name); trigger_changed (Properties::name);
} }
@ -421,13 +421,13 @@ TriggerUI::trigger_midi_learn ()
return; return;
} }
tref.box->begin_midi_learn (trigger()->index()); tref.box()->begin_midi_learn (trigger()->index());
} }
void void
TriggerUI::trigger_midi_unlearn () TriggerUI::trigger_midi_unlearn ()
{ {
tref.box->midi_unlearn (trigger()->index()); tref.box()->midi_unlearn (trigger()->index());
} }
void void
@ -630,7 +630,7 @@ TriggerUI::edit_trigger ()
SlotPropertyWindow* tw = static_cast<SlotPropertyWindow*> (trigger()->ui ()); SlotPropertyWindow* tw = static_cast<SlotPropertyWindow*> (trigger()->ui ());
if (!tw) { if (!tw) {
tw = new SlotPropertyWindow (TriggerReference (trigger()->box(), trigger()->index())); tw = new SlotPropertyWindow (TriggerReference (trigger()->boxptr(), trigger()->index()));
trigger()->set_ui (tw); trigger()->set_ui (tw);
} }
@ -809,9 +809,9 @@ TriggerUI::set_trigger (ARDOUR::TriggerReference tr)
trigger_changed (TriggerBox::all_trigger_props()); trigger_changed (TriggerBox::all_trigger_props());
trigger()->PropertyChanged.connect (trigger_connections, invalidator (*this), boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context()); trigger()->PropertyChanged.connect (trigger_connections, invalidator (*this), boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context());
tref.box->PropertyChanged.connect (trigger_connections, invalidator (*this), boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context ()); tref.box()->PropertyChanged.connect (trigger_connections, invalidator (*this), boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context ());
tref.box->TriggerSwapped.connect (trigger_swap_connection, invalidator (*this), boost::bind (&TriggerUI::trigger_swap, this, _1), gui_context ()); tref.box()->TriggerSwapped.connect (trigger_swap_connection, invalidator (*this), boost::bind (&TriggerUI::trigger_swap, this, _1), gui_context ());
on_trigger_set(); //derived classes can do initialization here on_trigger_set(); //derived classes can do initialization here
} }

View file

@ -73,14 +73,14 @@ TriggerEntry::TriggerEntry (Item* item, TriggerStrip& s, TriggerReference tr)
{ {
set_layout_sensitive (true); // why??? set_layout_sensitive (true); // why???
name = string_compose ("trigger %1", tr.slot); name = string_compose ("trigger %1", tr.slot());
set_outline (false); set_outline (false);
play_button = new ArdourCanvas::Rectangle (this); play_button = new ArdourCanvas::Rectangle (this);
play_button->set_outline (true); play_button->set_outline (true);
play_button->set_fill (true); play_button->set_fill (true);
play_button->name = string_compose ("playbutton %1", tr.slot); play_button->name = string_compose ("playbutton %1", tr.slot());
play_button->show (); play_button->show ();
follow_button = new ArdourCanvas::Rectangle (this); follow_button = new ArdourCanvas::Rectangle (this);
@ -124,7 +124,7 @@ TriggerEntry::TriggerEntry (Item* item, TriggerStrip& s, TriggerReference tr)
set_widget_colors (); set_widget_colors ();
/* owner color changes (?) */ /* owner color changes (?) */
dynamic_cast<Stripable*> (tref.box->owner ())->presentation_info ().Change.connect (_owner_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::owner_prop_change, this, _1), gui_context ()); dynamic_cast<Stripable*> (tref.box()->owner ())->presentation_info ().Change.connect (_owner_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::owner_prop_change, this, _1), gui_context ());
selection_change (); selection_change ();
} }
@ -501,7 +501,7 @@ TriggerEntry::set_widget_colors (TriggerEntry::EnteredState es)
color_t bg_col = UIConfiguration::instance ().color ("theme:bg"); color_t bg_col = UIConfiguration::instance ().color ("theme:bg");
//alternating darker bands //alternating darker bands
if ((tref.slot / 2) % 2 == 0) { if ((tref.slot() / 2) % 2 == 0) {
bg_col = HSV (bg_col).darker (0.25).color (); bg_col = HSV (bg_col).darker (0.25).color ();
} }
@ -896,7 +896,7 @@ TriggerBoxUI::build ()
if (!t) { if (!t) {
break; break;
} }
TriggerEntry* te = new TriggerEntry (this, _strip, TriggerReference (_triggerbox, n)); TriggerEntry* te = new TriggerEntry (this, _strip, TriggerReference (_triggerbox.shared_from_this(), n));
_slots.push_back (te); _slots.push_back (te);