push2: bug fixes for pad color mgmt and other fixes/improvements

This commit is contained in:
Paul Davis 2022-09-02 17:57:46 -06:00
parent a5b7290e3a
commit 96a9c1df7f
4 changed files with 44 additions and 56 deletions

View file

@ -804,16 +804,14 @@ Push2::button_mix_press ()
/* toggle between global mix and track mix layouts */
if (_current_layout == _track_mix_layout) {
set_current_layout (_mix_layout);
restore_pad_scale ();
} else {
if (ControlProtocol::first_selected_stripable()) {
set_current_layout (_track_mix_layout);
restore_pad_scale ();
} else {
set_current_layout (_mix_layout);
restore_pad_scale ();
}
}
restore_pad_scale ();
}
void

View file

@ -159,6 +159,8 @@ CueLayout::~CueLayout ()
void
CueLayout::show ()
{
Push2Layout::show ();
Push2::ButtonID lower_buttons[] = {
Push2::Lower1, Push2::Lower2, Push2::Lower3, Push2::Lower4,
Push2::Lower5, Push2::Lower6, Push2::Lower7, Push2::Lower8
@ -183,16 +185,15 @@ CueLayout::show ()
_p2.write (b->state_msg());
}
show_state ();
viewport_changed ();
show_knob_function ();
Container::show ();
}
void
CueLayout::hide ()
{
Push2Layout::hide ();
Push2::ButtonID scene_buttons[] = {
Push2::Fwd32ndT, Push2::Fwd32nd, Push2::Fwd16th, Push2::Fwd16thT,
Push2::Fwd8thT, Push2::Fwd8th, Push2::Fwd4trT, Push2::Fwd4tr
@ -290,7 +291,6 @@ CueLayout::button_left ()
if (track_base > 0) {
track_base--;
viewport_changed ();
show_state ();
}
}
@ -300,7 +300,6 @@ CueLayout::button_page_left ()
if (track_base > 8) {
track_base -= 8; /* XXX get back to zero when appropriate */
viewport_changed ();
show_state ();
}
}
@ -309,7 +308,6 @@ CueLayout::button_right ()
{
track_base++;
viewport_changed ();
show_state ();
}
void
@ -317,7 +315,6 @@ CueLayout::button_page_right ()
{
track_base += 8; /* XXX limit to number of tracks */
viewport_changed ();
show_state ();
}
void
@ -326,7 +323,6 @@ CueLayout::button_up ()
if (scene_base > 0) {
scene_base--;
viewport_changed ();
show_state ();
}
}
@ -336,7 +332,6 @@ CueLayout::button_octave_up ()
if (scene_base > 8) {
scene_base -= 8;
viewport_changed ();
show_state ();
}
}
@ -345,14 +340,12 @@ CueLayout::button_down ()
{
scene_base++;
viewport_changed ();
show_state ();
}
void
CueLayout::button_octave_down ()
{
scene_base++;
show_state ();
}
void
@ -467,14 +460,6 @@ CueLayout::viewport_changed ()
}
}
void
CueLayout::show_state ()
{
if (!parent()) {
return;
}
}
void
CueLayout::strip_vpot (int n, int delta)
{
@ -506,7 +491,6 @@ CueLayout::button_stop_press ()
void
CueLayout::button_stop_release ()
{
std::cerr << "BS release, ls = " << _long_stop << std::endl;
if (_long_stop) {
_long_stop = 0;
show_running_boxen (false);
@ -556,13 +540,24 @@ CueLayout::show_running_boxen (bool yn)
lower_button->set_state (Push2::LED::Blinking4th);
} else {
std::cerr << "no blink " << n << std::endl;
lower_button->set_color (_p2.get_color_index (_route[n]->presentation_info().color()));
lower_button->set_state (Push2::LED::NoTransition);
}
_p2.write (lower_button->state_msg());
}
boost::shared_ptr<Push2::Button> stop = _p2.button_by_id (Push2::Stop);
assert (stop);
if (yn) {
stop->set_color (Push2::LED::Red);
stop->set_state (Push2::LED::Blinking4th);
} else {
stop->set_color (Push2::LED::White);
stop->set_state (Push2::LED::NoTransition);
}
_p2.write (stop->state_msg());
}
void
@ -669,6 +664,10 @@ CueLayout::trigger_property_change (PropertyChange const& what_changed, uint32_t
{
assert (_route[col]);
if (!visible()) {
return;
}
TriggerPtr trig;
if (what_changed.contains (Properties::running)) {
@ -702,6 +701,10 @@ CueLayout::triggerbox_property_change (PropertyChange const& what_changed, uint3
{
assert (_route[col]);
if (!visible()) {
return;
}
if (what_changed.contains (Properties::currently_playing) || what_changed.contains (Properties::queued)) {
boost::shared_ptr<TriggerBox> tb = _route[col]->triggerbox ();
@ -756,6 +759,10 @@ CueLayout::triggerbox_property_change (PropertyChange const& what_changed, uint3
void
CueLayout::set_pad_color_from_trigger_state (int col, boost::shared_ptr<Push2::Pad> pad, TriggerPtr trig)
{
if (!visible()) {
return;
}
if (trig->region()) {
if (trig->active()) {
@ -979,4 +986,3 @@ FollowActionIcon::render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::
}
} /* namespace */

View file

@ -117,7 +117,6 @@ class CueLayout : public Push2Layout
void viewport_changed ();
void show_state ();
void update_clip_progress (int);
void show_knob_function ();
void set_pad_color_from_trigger_state (int col, boost::shared_ptr<Push2::Pad>, ARDOUR::TriggerPtr);

View file

@ -206,7 +206,7 @@ Push2::begin_using_device ()
{
DEBUG_TRACE (DEBUG::Push2, "begin using device\n");
/* set up periodic task used to push a sample buffer to the
/* set up periodic task used to push a frame buffer to the
* device (25fps). The device can handle 60fps, but we don't
* need that frame rate.
*/
@ -219,7 +219,7 @@ Push2::begin_using_device ()
init_buttons (true);
init_touch_strip ();
set_pad_scale (_scale_root, _root_octave, _mode, _note_grid_origin, _row_interval, _in_key);
reset_pad_colors ();
splash ();
/* catch current selection, if any so that we can wire up the pads if appropriate */
@ -449,12 +449,6 @@ Push2::init_buttons (bool startup)
_current_layout->hide ();
}
for (auto & pad : _xy_pad_map) {
pad->set_color (LED::Black);
pad->set_state (LED::OneShot24th);
write (pad->state_msg());
}
for (auto & b : _id_button_map) {
b.second->set_color (LED::Black);
b.second->set_state (LED::NoTransition);
@ -829,16 +823,15 @@ Push2::handle_midi_note_on_message (MIDI::Parser& parser, MIDI::EventTwoBytes* e
return;
}
for (FNPadMap::iterator pi = pads_with_note.first; pi != pads_with_note.second; ++pi) {
boost::shared_ptr<Pad> pad = pi->second;
if (pad->do_when_pressed == Pad::FlashOn) {
pad->set_color (_contrast_color);
pad->set_state (LED::OneShot24th);
pad->set_state (LED::NoTransition);
} else if (pad->do_when_pressed == Pad::FlashOff) {
pad->set_color (LED::Black);
pad->set_state (LED::OneShot24th);
pad->set_state (LED::NoTransition);
}
write (pad->state_msg());
}
@ -877,7 +870,6 @@ Push2::handle_midi_note_off_message (MIDI::Parser&, MIDI::EventTwoBytes* ev)
return;
}
for (FNPadMap::iterator pi = pads_with_note.first; pi != pads_with_note.second; ++pi) {
boost::shared_ptr<Pad> pad = pi->second;
@ -1373,7 +1365,7 @@ Push2::set_pad_note_kind (Pad& pad, const PadNoteKind kind)
break;
}
pad.set_state (LED::OneShot24th);
pad.set_state (LED::NoTransition);
}
/** Return a bitset of notes in a musical mode.
@ -1556,34 +1548,28 @@ Push2::set_pad_scale (const int scale_root,
// Clear the pad map and reset all pad state (in memory, not on the device yet)
_fn_pad_map.clear ();
for (int row = 0; row < 8; ++row) {
for (int col = 0; col < 8; ++col) {
const int index = 36 + (row * 8) + col;
const boost::shared_ptr<Pad>& pad = _nn_pad_map[index];
pad->set_color (LED::Black);
pad->filtered = -1;
pad->do_when_pressed = Pad::FlashOn;
}
for (auto & p : _nn_pad_map) {
p.second->set_color (LED::Black);
p.second->set_state (LED::NoTransition);
p.second->perma_color = LED::Black;
p.second->filtered = -1;
p.second->do_when_pressed = Pad::FlashOn;
}
// Call the appropriate method to set up active pads
const int vertical_semitones = row_interval_semitones(row_interval, inkey);
if (inkey) {
set_pad_scale_in_key(scale_root, octave, mode, origin, vertical_semitones);
set_pad_scale_in_key (scale_root, octave, mode, origin, vertical_semitones);
} else {
set_pad_scale_chromatic(scale_root, octave, mode, origin, vertical_semitones);
set_pad_scale_chromatic (scale_root, octave, mode, origin, vertical_semitones);
}
// Write the state message for every pad
for (int row = 0; row < 8; ++row) {
for (int col = 0; col < 8; ++col) {
const int index = 36 + (row * 8) + col;
const boost::shared_ptr<Pad>& pad = _nn_pad_map[index];
write (pad->state_msg ());
}
for (auto const & p : _nn_pad_map) {
write (p.second->state_msg ());
}
// Store state
@ -1878,7 +1864,6 @@ Push2::set_current_layout (Push2Layout* layout)
_current_layout->show ();
}
_canvas->request_redraw ();
}
}