push2: various changes in support of menus and scale mode
This commit is contained in:
@@ -239,13 +239,13 @@ Push2::button_recenable ()
|
||||
void
|
||||
Push2::button_up ()
|
||||
{
|
||||
scroll_up_1_track ();
|
||||
_current_layout->button_up ();
|
||||
}
|
||||
|
||||
void
|
||||
Push2::button_down ()
|
||||
{
|
||||
scroll_dn_1_track ();
|
||||
_current_layout->button_down ();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -563,9 +563,11 @@ void
|
||||
Push2::button_scale_press ()
|
||||
{
|
||||
if (_current_layout != scale_layout) {
|
||||
set_current_layout (_current_layout);
|
||||
set_current_layout (scale_layout);
|
||||
} else {
|
||||
set_current_layout (mix_layout);
|
||||
if (ControlProtocol::first_selected_stripable()) {
|
||||
set_current_layout (mix_layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -573,11 +575,9 @@ void
|
||||
Push2::button_mix_press ()
|
||||
{
|
||||
if (_current_layout == track_mix_layout) {
|
||||
cerr << "back to mix\n";
|
||||
set_current_layout (mix_layout);
|
||||
} else {
|
||||
if (ControlProtocol::first_selected_stripable()) {
|
||||
cerr << "back to trackmix\n";
|
||||
set_current_layout (track_mix_layout);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ Push2Canvas::request_redraw (Rect const & r)
|
||||
cr.width = r.width();
|
||||
cr.height = r.height();
|
||||
|
||||
DEBUG_TRACE (DEBUG::Push2, string_compose ("invalidate rect %1\n", r));
|
||||
// DEBUG_TRACE (DEBUG::Push2, string_compose ("invalidate rect %1\n", r));
|
||||
|
||||
expose_region->do_union (cr);
|
||||
|
||||
@@ -123,7 +123,7 @@ Push2Canvas::expose ()
|
||||
|
||||
const int nrects = expose_region->get_num_rectangles ();
|
||||
|
||||
DEBUG_TRACE (DEBUG::Push2, string_compose ("expose with %1 rects\n", nrects));
|
||||
//DEBUG_TRACE (DEBUG::Push2, string_compose ("expose with %1 rects\n", nrects));
|
||||
|
||||
for (int n = 0; n < nrects; ++n) {
|
||||
Cairo::RectangleInt r = expose_region->get_rectangle (n);
|
||||
@@ -135,9 +135,13 @@ Push2Canvas::expose ()
|
||||
Push2Layout* layout = p2.current_layout();
|
||||
|
||||
if (layout) {
|
||||
/* all layouts cover (at least) the full size of the video
|
||||
display, so we do not need to check if the layout intersects
|
||||
the bounding box of the full expose region.
|
||||
*/
|
||||
Cairo::RectangleInt r = expose_region->get_extents();
|
||||
Rect rr (r.x, r.y, r.x + r.width, r.y + r.height);
|
||||
DEBUG_TRACE (DEBUG::Push2, string_compose ("render layout with %1\n", rr));
|
||||
//DEBUG_TRACE (DEBUG::Push2, string_compose ("render layout with %1\n", rr));
|
||||
layout->render (Rect (r.x, r.y, r.x + r.width, r.y + r.height), context);
|
||||
}
|
||||
|
||||
|
||||
@@ -708,3 +708,15 @@ MixLayout::stripables_added ()
|
||||
/* reload current bank */
|
||||
switch_bank (bank_start);
|
||||
}
|
||||
|
||||
void
|
||||
MixLayout::button_down ()
|
||||
{
|
||||
p2.scroll_dn_1_track ();
|
||||
}
|
||||
|
||||
void
|
||||
MixLayout::button_up ()
|
||||
{
|
||||
p2.scroll_up_1_track ();
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ class MixLayout : public Push2Layout
|
||||
|
||||
void button_upper (uint32_t n);
|
||||
void button_lower (uint32_t n);
|
||||
void button_down ();
|
||||
void button_up ();
|
||||
void button_left ();
|
||||
void button_right ();
|
||||
void button_select_press ();
|
||||
|
||||
@@ -127,6 +127,7 @@ Push2::Push2 (ARDOUR::Session& s)
|
||||
, _modifier_state (None)
|
||||
, splash_start (0)
|
||||
, _current_layout (0)
|
||||
, _previous_layout (0)
|
||||
, connection_state (ConnectionState (0))
|
||||
, gui (0)
|
||||
, _mode (MusicalMode::IonianMajor)
|
||||
@@ -337,6 +338,22 @@ Push2::close ()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Push2::strip_buttons_off ()
|
||||
{
|
||||
ButtonID strip_buttons[] = { Upper1, Upper2, Upper3, Upper4, Upper5, Upper6, Upper7, Upper8,
|
||||
Lower1, Lower2, Lower3, Lower4, Lower5, Lower6, Lower7, Lower8, };
|
||||
|
||||
for (size_t n = 0; n < sizeof (strip_buttons) / sizeof (strip_buttons[0]); ++n) {
|
||||
Button* b = id_button_map[strip_buttons[n]];
|
||||
|
||||
b->set_color (LED::Black);
|
||||
b->set_state (LED::OneShot24th);
|
||||
write (b->state_msg());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Push2::init_buttons (bool startup)
|
||||
{
|
||||
@@ -365,16 +382,7 @@ Push2::init_buttons (bool startup)
|
||||
* color to reflect various conditions
|
||||
*/
|
||||
|
||||
ButtonID strip_buttons[] = { Upper1, Upper2, Upper3, Upper4, Upper5, Upper6, Upper7, Upper8,
|
||||
Lower1, Lower2, Lower3, Lower4, Lower5, Lower6, Lower7, Lower8, };
|
||||
|
||||
for (size_t n = 0; n < sizeof (strip_buttons) / sizeof (strip_buttons[0]); ++n) {
|
||||
Button* b = id_button_map[strip_buttons[n]];
|
||||
|
||||
b->set_color (LED::Black);
|
||||
b->set_state (LED::OneShot24th);
|
||||
write (b->state_msg());
|
||||
}
|
||||
strip_buttons_off ();
|
||||
|
||||
if (startup) {
|
||||
|
||||
@@ -434,7 +442,6 @@ Push2::request_factory (uint32_t num_requests)
|
||||
void
|
||||
Push2::do_request (Push2Request * req)
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::Push2, string_compose ("doing request type %1\n", req->type));
|
||||
if (req->type == CallSlot) {
|
||||
|
||||
call_slot (MISSING_INVALIDATOR, req->the_slot);
|
||||
@@ -466,9 +473,9 @@ Push2::vblank ()
|
||||
{
|
||||
if (splash_start) {
|
||||
|
||||
/* display splash for 3 seconds */
|
||||
/* display splash for 2 seconds */
|
||||
|
||||
if (get_microseconds() - splash_start > 3000000) {
|
||||
if (get_microseconds() - splash_start > 2000000) {
|
||||
splash_start = 0;
|
||||
DEBUG_TRACE (DEBUG::Push2, "splash interval ended, switch to mix layout\n");
|
||||
set_current_layout (mix_layout);
|
||||
@@ -1370,14 +1377,14 @@ Push2::set_pad_scale (int root, int octave, MusicalMode::Type mode, bool inkey)
|
||||
}
|
||||
}
|
||||
|
||||
PadChange (); /* EMIT SIGNAL */
|
||||
|
||||
/* store state */
|
||||
|
||||
_scale_root = original_root;
|
||||
_root_octave = octave;
|
||||
_in_key = inkey;
|
||||
_mode = mode;
|
||||
|
||||
ScaleChange (); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1417,8 +1424,6 @@ Push2::set_percussive_mode (bool yn)
|
||||
}
|
||||
|
||||
percussion = true;
|
||||
|
||||
PadChange (); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
Push2Layout*
|
||||
@@ -1588,18 +1593,33 @@ Push2::set_current_layout (Push2Layout* layout)
|
||||
if (_current_layout) {
|
||||
_current_layout->hide ();
|
||||
_canvas->root()->remove (_current_layout);
|
||||
_previous_layout = _current_layout;
|
||||
}
|
||||
|
||||
/* turn off all strip buttons - let new layout set them if it
|
||||
* wants/needs to
|
||||
*/
|
||||
|
||||
strip_buttons_off ();
|
||||
|
||||
_current_layout = layout;
|
||||
|
||||
if (_current_layout) {
|
||||
_current_layout->show ();
|
||||
_canvas->root()->add (_current_layout);
|
||||
_current_layout->show ();
|
||||
}
|
||||
|
||||
_canvas->request_redraw ();
|
||||
}
|
||||
|
||||
void
|
||||
Push2::use_previous_layout ()
|
||||
{
|
||||
if (_previous_layout) {
|
||||
set_current_layout (_previous_layout);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Push2::request_pressure_mode ()
|
||||
{
|
||||
|
||||
@@ -328,6 +328,7 @@ class Push2 : public ARDOUR::ControlProtocol
|
||||
PBD::Signal0<void> PadChange;
|
||||
|
||||
void set_pad_scale (int root, int octave, MusicalMode::Type mode, bool inkey);
|
||||
PBD::Signal0<void> ScaleChange;
|
||||
|
||||
MusicalMode::Type mode() const { return _mode; }
|
||||
int scale_root() const { return _scale_root; }
|
||||
@@ -335,6 +336,8 @@ class Push2 : public ARDOUR::ControlProtocol
|
||||
bool in_key() const { return _in_key; }
|
||||
|
||||
Push2Layout* current_layout() const;
|
||||
void use_previous_layout ();
|
||||
|
||||
Push2Canvas* canvas() const { return _canvas; }
|
||||
|
||||
enum ModifierState {
|
||||
@@ -348,6 +351,8 @@ class Push2 : public ARDOUR::ControlProtocol
|
||||
Button* button_by_id (ButtonID);
|
||||
static std::string button_name_by_id (ButtonID);
|
||||
|
||||
void strip_buttons_off ();
|
||||
|
||||
void write (const MidiByteArray&);
|
||||
|
||||
uint8_t get_color_index (uint32_t rgb);
|
||||
@@ -516,6 +521,7 @@ class Push2 : public ARDOUR::ControlProtocol
|
||||
|
||||
mutable Glib::Threads::Mutex layout_lock;
|
||||
Push2Layout* _current_layout;
|
||||
Push2Layout* _previous_layout;
|
||||
Push2Layout* mix_layout;
|
||||
Push2Layout* scale_layout;
|
||||
Push2Layout* track_mix_layout;
|
||||
|
||||
Reference in New Issue
Block a user