From a06ed852694209ed26985a28fc183b14573d47ee Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 27 Aug 2022 21:21:22 -0600 Subject: [PATCH] push2: prep for triggerbox property changes --- libs/surfaces/push2/cues.cc | 92 ++++++++++++++++++------------------- libs/surfaces/push2/cues.h | 1 + 2 files changed, 47 insertions(+), 46 deletions(-) diff --git a/libs/surfaces/push2/cues.cc b/libs/surfaces/push2/cues.cc index 2c94e062e1..ec039815ba 100644 --- a/libs/surfaces/push2/cues.cc +++ b/libs/surfaces/push2/cues.cc @@ -357,6 +357,35 @@ CueLayout::viewport_changed () boost::shared_ptr r = _route[n]; + boost::shared_ptr lower_button; + + switch (n) { + case 0: + lower_button = _p2.button_by_id (Push2::Lower1); + break; + case 1: + lower_button = _p2.button_by_id (Push2::Lower2); + break; + case 2: + lower_button = _p2.button_by_id (Push2::Lower3); + break; + case 3: + lower_button = _p2.button_by_id (Push2::Lower4); + break; + case 4: + lower_button = _p2.button_by_id (Push2::Lower5); + break; + case 5: + lower_button = _p2.button_by_id (Push2::Lower6); + break; + case 6: + lower_button = _p2.button_by_id (Push2::Lower7); + break; + case 7: + lower_button = _p2.button_by_id (Push2::Lower8); + break; + } + if (r) { _route[n]->DropReferences.connect (_route_connections, invalidator (*this), boost::bind (&CueLayout::viewport_changed, this), &_p2); _route[n]->presentation_info().PropertyChanged.connect (_route_connections, invalidator (*this), boost::bind (&CueLayout::route_property_change, this, _1, n), &_p2); @@ -398,57 +427,18 @@ CueLayout::viewport_changed () default: _controllables[n] = boost::shared_ptr (); } - } else { - _lower_text[n]->set (std::string()); - _controllables[n] = boost::shared_ptr (); - } - boost::shared_ptr b; + uint8_t color = _p2.get_color_index (r->presentation_info().color()); - switch (n) { - case 0: - b = _p2.button_by_id (Push2::Lower1); - break; - case 1: - b = _p2.button_by_id (Push2::Lower2); - break; - case 2: - b = _p2.button_by_id (Push2::Lower3); - break; - case 3: - b = _p2.button_by_id (Push2::Lower4); - break; - case 4: - b = _p2.button_by_id (Push2::Lower5); - break; - case 5: - b = _p2.button_by_id (Push2::Lower6); - break; - case 6: - b = _p2.button_by_id (Push2::Lower7); - break; - case 7: - b = _p2.button_by_id (Push2::Lower8); - break; - } + lower_button->set_color (color); + lower_button->set_state (Push2::LED::OneShot24th); + _p2.write (lower_button->state_msg()); - uint8_t color; - - if (r) { - color = _p2.get_color_index (r->presentation_info().color()); - } else { - color = Push2::LED::Black; - } - - b->set_color (color); - - b->set_state (Push2::LED::OneShot24th); - _p2.write (b->state_msg()); - - if (r) { boost::shared_ptr tb = r->triggerbox (); - /* total map size is only 64 so iterating over the whole thing is fine */ + if (tb) { + tb->PropertyChanged.connect (_route_connections, invalidator (*this), boost::bind (&CueLayout::triggerbox_property_change, this, _1, n), &_p2); + } for (int y = 0; y < 8; ++y) { boost::shared_ptr pad = _p2.pad_by_xy (n, y); @@ -472,6 +462,10 @@ CueLayout::viewport_changed () } else { + _lower_text[n]->set (std::string()); + lower_button->set_color (Push2::LED::Black); + _controllables[n] = boost::shared_ptr (); + /* turn this column off */ for (int y = 0; y < 8; ++y) { @@ -592,3 +586,9 @@ CueLayout::route_property_change (PropertyChange const& what_changed, uint32_t w } } + + +void +CueLayout::triggerbox_property_change (PropertyChange const& what_changed, uint32_t which) +{ +} diff --git a/libs/surfaces/push2/cues.h b/libs/surfaces/push2/cues.h index 802c3a4a2d..f237bcd1ef 100644 --- a/libs/surfaces/push2/cues.h +++ b/libs/surfaces/push2/cues.h @@ -98,6 +98,7 @@ class CueLayout : public Push2Layout void routes_added (); void route_property_change (PBD::PropertyChange const& what_changed, uint32_t which); + void triggerbox_property_change (PBD::PropertyChange const& what_changed, uint32_t which); ArdourCanvas::Arc* _progress[8]; boost::shared_ptr _controllables[8];