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
This commit is contained in:
Paul Davis 2022-08-26 17:40:04 -06:00
parent 17b0764639
commit f57669fbde
6 changed files with 66 additions and 138 deletions

View File

@ -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);
}
}

View File

@ -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<Cairo::Context> context) const
CueLayout::render (Rect const & area, Cairo::RefPtr<Cairo::Context> 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);
}

View File

@ -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<Cairo::Context>) 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<ArdourCanvas::Text*> _upper_text;
std::vector<ArdourCanvas::Text*> _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 ();
};

View File

@ -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 ();
}

View File

@ -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;

View File

@ -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