From f57669fbde658fea07d698b5099a00b37e548637 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 26 Aug 2022 17:40:04 -0600 Subject: [PATCH] push2: rename things to match the rest of ardour, and use Session button not Clip the clip button is intended to "look at" a single clip and edit it --- libs/surfaces/push2/buttons.cc | 12 +- libs/surfaces/push2/{clip_view.cc => cues.cc} | 165 +++++------------- libs/surfaces/push2/{clip_view.h => cues.h} | 14 +- libs/surfaces/push2/push2.cc | 8 +- libs/surfaces/push2/push2.h | 3 +- libs/surfaces/push2/wscript | 2 +- 6 files changed, 66 insertions(+), 138 deletions(-) rename libs/surfaces/push2/{clip_view.cc => cues.cc} (50%) rename libs/surfaces/push2/{clip_view.h => cues.h} (86%) diff --git a/libs/surfaces/push2/buttons.cc b/libs/surfaces/push2/buttons.cc index 476877cfbf..b7b0b98591 100644 --- a/libs/surfaces/push2/buttons.cc +++ b/libs/surfaces/push2/buttons.cc @@ -205,7 +205,7 @@ Push2::build_maps () MAKE_WHITE_BUTTON_PRESS (Scale, 58, &Push2::button_scale_press); MAKE_WHITE_BUTTON_PRESS (Layout, 31, &Push2::button_layout_press); MAKE_WHITE_BUTTON (Note, 50); - MAKE_WHITE_BUTTON (Session, 51); + MAKE_WHITE_BUTTON_PRESS (Session, 51, &Push2::button_session); MAKE_WHITE_BUTTON (Layout, 31); MAKE_WHITE_BUTTON_PRESS (OctaveUp, 55, &Push2::button_octave_up); MAKE_WHITE_BUTTON_PRESS (PageRight, 63, &Push2::button_page_right); @@ -503,9 +503,13 @@ Push2::button_browse () void Push2::button_clip () { - if (_current_layout != _clip_view_layout) { - std::cerr << "go clip\n"; - set_current_layout (_clip_view_layout); +} + +void +Push2::button_session () +{ + if (_current_layout != _cue_layout) { + set_current_layout (_cue_layout); } } diff --git a/libs/surfaces/push2/clip_view.cc b/libs/surfaces/push2/cues.cc similarity index 50% rename from libs/surfaces/push2/clip_view.cc rename to libs/surfaces/push2/cues.cc index a11adf8766..5a4cb8728a 100644 --- a/libs/surfaces/push2/clip_view.cc +++ b/libs/surfaces/push2/cues.cc @@ -59,10 +59,10 @@ #include "canvas/types.h" #include "canvas.h" +#include "cues.h" #include "knob.h" #include "level_meter.h" #include "push2.h" -#include "clip_view.h" #include "utils.h" #include "pbd/i18n.h" @@ -77,8 +77,10 @@ using namespace Glib; using namespace ArdourSurface; using namespace ArdourCanvas; -ClipViewLayout::ClipViewLayout (Push2& p, Session & s, std::string const & name) +CueLayout::CueLayout (Push2& p, Session & s, std::string const & name) : Push2Layout (p, s, name) + , left_edge_index (0) + , top_edge_index (0) { Pango::FontDescription fd ("Sans 10"); @@ -93,13 +95,11 @@ ClipViewLayout::ClipViewLayout (Push2& p, Session & s, std::string const & name) for (int n = 0; n < 8; ++n) { Text* t; - if (n < 4) { - t = new Text (this); - t->set_font_description (fd); - t->set_color (_p2.get_color (Push2::ParameterName)); - t->set_position ( Duple (10 + (n*Push2Canvas::inter_button_spacing()), 2)); - _upper_text.push_back (t); - } + t = new Text (this); + t->set_font_description (fd); + t->set_color (_p2.get_color (Push2::ParameterName)); + t->set_position ( Duple (10 + (n*Push2Canvas::inter_button_spacing()), 2)); + _upper_text.push_back (t); t = new Text (this); t->set_font_description (fd); @@ -108,62 +108,14 @@ ClipViewLayout::ClipViewLayout (Push2& p, Session & s, std::string const & name) _lower_text.push_back (t); - switch (n) { - case 0: - _upper_text[n]->set (_("Track Volume")); - _lower_text[n]->set (_("Mute")); - break; - case 1: - _upper_text[n]->set (_("Track Pan")); - _lower_text[n]->set (_("Solo")); - break; - case 2: - _upper_text[n]->set (_("Track Width")); - _lower_text[n]->set (_("Rec-enable")); - break; - case 3: - _upper_text[n]->set (_("Track Trim")); - _lower_text[n]->set (_("In")); - break; - case 4: - _lower_text[n]->set (_("Disk")); - break; - case 5: - _lower_text[n]->set (_("Solo Iso")); - break; - case 6: - _lower_text[n]->set (_("Solo Lock")); - break; - case 7: - _lower_text[n]->set (_("")); - break; - } - _knobs[n] = new Push2Knob (_p2, this); _knobs[n]->set_position (Duple (60 + (Push2Canvas::inter_button_spacing()*n), 95)); _knobs[n]->set_radius (25); } - - _name_text = new Text (this); - _name_text->set_font_description (fd); - _name_text->set_position (Duple (10 + (4*Push2Canvas::inter_button_spacing()), 2)); - - _meter = new LevelMeter (_p2, this, 300, ArdourCanvas::Meter::Horizontal); - _meter->set_position (Duple (10 + (4 * Push2Canvas::inter_button_spacing()), 30)); - - Pango::FontDescription fd2 ("Sans 18"); - _bbt_text = new Text (this); - _bbt_text->set_font_description (fd2); - _bbt_text->set_color (_p2.get_color (Push2::LightBackground)); - _bbt_text->set_position (Duple (10 + (4 * Push2Canvas::inter_button_spacing()), 60)); - - _minsec_text = new Text (this); - _minsec_text->set_font_description (fd2); - _minsec_text->set_color (_p2.get_color (Push2::LightBackground)); - _minsec_text->set_position (Duple (10 + (4 * Push2Canvas::inter_button_spacing()), 90)); } -ClipViewLayout::~ClipViewLayout () + +CueLayout::~CueLayout () { for (int n = 0; n < 8; ++n) { delete _knobs[n]; @@ -171,7 +123,7 @@ ClipViewLayout::~ClipViewLayout () } void -ClipViewLayout::show () +CueLayout::show () { Push2::ButtonID lower_buttons[] = { Push2::Lower1, Push2::Lower2, Push2::Lower3, Push2::Lower4, Push2::Lower5, Push2::Lower6, Push2::Lower7, Push2::Lower8 }; @@ -189,39 +141,61 @@ ClipViewLayout::show () } void -ClipViewLayout::hide () +CueLayout::hide () { } void -ClipViewLayout::render (Rect const & area, Cairo::RefPtr context) const +CueLayout::render (Rect const & area, Cairo::RefPtr context) const { Container::render (area, context); } void -ClipViewLayout::button_upper (uint32_t n) +CueLayout::button_upper (uint32_t n) { } void -ClipViewLayout::button_lower (uint32_t n) +CueLayout::button_lower (uint32_t n) { } void -ClipViewLayout::button_left () +CueLayout::button_left () { + if (left_edge_index > 0) { + left_edge_index--; + } + show_state (); } void -ClipViewLayout::button_right () +CueLayout::button_right () { + left_edge_index++; + show_state (); } void -ClipViewLayout::show_state () +CueLayout::button_up () +{ + if (top_edge_index > 0) { + top_edge_index--; + } + show_state (); +} + +void +CueLayout::button_down () +{ + top_edge_index++; + show_state (); +} + +void +CueLayout::show_state () { if (!parent()) { return; @@ -229,68 +203,17 @@ ClipViewLayout::show_state () } void -ClipViewLayout::strip_vpot (int n, int delta) +CueLayout::strip_vpot (int n, int delta) { } void -ClipViewLayout::strip_vpot_touch (int n, bool touching) +CueLayout::strip_vpot_touch (int n, bool touching) { } void -ClipViewLayout::update_meters () +CueLayout::update_meters () { } -void -ClipViewLayout::update_clocks () -{ - samplepos_t pos = _session.audible_sample(); - bool negative = false; - - if (pos < 0) { - pos = -pos; - negative = true; - } - - char buf[16]; - Temporal::BBT_Time BBT = Temporal::TempoMap::fetch()->bbt_at (timepos_t (pos)); - -#define BBT_BAR_CHAR "|" - - if (negative) { - snprintf (buf, sizeof (buf), "-%03" PRIu32 BBT_BAR_CHAR "%02" PRIu32 BBT_BAR_CHAR "%04" PRIu32, - BBT.bars, BBT.beats, BBT.ticks); - } else { - snprintf (buf, sizeof (buf), " %03" PRIu32 BBT_BAR_CHAR "%02" PRIu32 BBT_BAR_CHAR "%04" PRIu32, - BBT.bars, BBT.beats, BBT.ticks); - } - - _bbt_text->set (buf); - - samplecnt_t left; - int hrs; - int mins; - int secs; - int millisecs; - - const double sample_rate = _session.sample_rate (); - - left = pos; - hrs = (int) floor (left / (sample_rate * 60.0f * 60.0f)); - left -= (samplecnt_t) floor (hrs * sample_rate * 60.0f * 60.0f); - mins = (int) floor (left / (sample_rate * 60.0f)); - left -= (samplecnt_t) floor (mins * sample_rate * 60.0f); - secs = (int) floor (left / (float) sample_rate); - left -= (samplecnt_t) floor ((double)(secs * sample_rate)); - millisecs = floor (left * 1000.0 / (float) sample_rate); - - if (negative) { - snprintf (buf, sizeof (buf), "-%02" PRId32 ":%02" PRId32 ":%02" PRId32 ".%03" PRId32, hrs, mins, secs, millisecs); - } else { - snprintf (buf, sizeof (buf), " %02" PRId32 ":%02" PRId32 ":%02" PRId32 ".%03" PRId32, hrs, mins, secs, millisecs); - } - - _minsec_text->set (buf); -} diff --git a/libs/surfaces/push2/clip_view.h b/libs/surfaces/push2/cues.h similarity index 86% rename from libs/surfaces/push2/clip_view.h rename to libs/surfaces/push2/cues.h index e3724f74f2..235a710b1f 100644 --- a/libs/surfaces/push2/clip_view.h +++ b/libs/surfaces/push2/cues.h @@ -41,11 +41,11 @@ namespace ArdourSurface { class Push2Knob; class LevelMeter; -class ClipViewLayout : public Push2Layout +class CueLayout : public Push2Layout { public: - ClipViewLayout (Push2& p, ARDOUR::Session&, std::string const &); - ~ClipViewLayout (); + CueLayout (Push2& p, ARDOUR::Session&, std::string const &); + ~CueLayout (); void render (ArdourCanvas::Rect const &, Cairo::RefPtr) const; @@ -55,6 +55,8 @@ class ClipViewLayout : public Push2Layout void button_lower (uint32_t n); void button_left (); void button_right (); + void button_up(); + void button_down (); void strip_vpot (int, int); void strip_vpot_touch (int, bool); @@ -68,13 +70,11 @@ class ClipViewLayout : public Push2Layout ArdourCanvas::Line* _upper_line; std::vector _upper_text; std::vector _lower_text; - ArdourCanvas::Text* _name_text; - ArdourCanvas::Text* _bbt_text; - ArdourCanvas::Text* _minsec_text; uint8_t _selection_color; + uint32_t left_edge_index; + uint32_t top_edge_index; Push2Knob* _knobs[8]; - LevelMeter* _meter; void show_state (); }; diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc index 301fc0a516..6a8a2a6617 100644 --- a/libs/surfaces/push2/push2.cc +++ b/libs/surfaces/push2/push2.cc @@ -53,7 +53,7 @@ #include "gtkmm2ext/colors.h" #include "canvas.h" -#include "clip_view.h" +#include "cues.h" #include "gui.h" #include "layout.h" #include "mix.h" @@ -136,7 +136,7 @@ Push2::Push2 (ARDOUR::Session& s) _mix_layout = new MixLayout (*this, *session, "globalmix"); _scale_layout = new ScaleLayout (*this, *session, "scale"); _track_mix_layout = new TrackMixLayout (*this, *session, "trackmix"); - _clip_view_layout = new ClipViewLayout (*this, *session, "clipview"); + _cue_layout = new CueLayout (*this, *session, "cues"); _splash_layout = new SplashLayout (*this, *session, "splash"); run_event_loop (); @@ -179,8 +179,8 @@ Push2::~Push2 () _splash_layout = 0; delete _track_mix_layout; _track_mix_layout = 0; - delete _clip_view_layout; - _clip_view_layout = 0; + delete _cue_layout; + _cue_layout = 0; stop_event_loop (); } diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h index 4bb3931f50..3b6bd004f5 100644 --- a/libs/surfaces/push2/push2.h +++ b/libs/surfaces/push2/push2.h @@ -547,6 +547,7 @@ class Push2 : public ARDOUR::ControlProtocol void button_new (); void button_browse (); void button_clip (); + void button_session (); void button_undo (); void button_fwd32t (); void button_fwd32 (); @@ -626,7 +627,7 @@ class Push2 : public ARDOUR::ControlProtocol Push2Layout* _scale_layout; Push2Layout* _track_mix_layout; Push2Layout* _splash_layout; - Push2Layout* _clip_view_layout; + Push2Layout* _cue_layout; void set_current_layout (Push2Layout*); bool pad_filter (ARDOUR::MidiBuffer& in, ARDOUR::MidiBuffer& out) const; diff --git a/libs/surfaces/push2/wscript b/libs/surfaces/push2/wscript index 4aa19994c3..a85da85ec0 100644 --- a/libs/surfaces/push2/wscript +++ b/libs/surfaces/push2/wscript @@ -19,7 +19,7 @@ def build(bld): push2.cc buttons.cc canvas.cc - clip_view.cc + cues.cc interface.cc midi_byte_array.cc leds.cc