push2: update GUI pad display when octave shift is used, or pad map is changed
This commit is contained in:
parent
eff67c8a8f
commit
66453868cd
@ -593,13 +593,19 @@ Push2::start_press_timeout (Button& button, ButtonID id)
|
||||
void
|
||||
Push2::button_octave_down ()
|
||||
{
|
||||
octave_shift = (max (-4, octave_shift - 1));
|
||||
build_pad_table ();
|
||||
int os = (max (-4, octave_shift - 1));
|
||||
if (os != octave_shift) {
|
||||
octave_shift = os;
|
||||
build_pad_table ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Push2::button_octave_up ()
|
||||
{
|
||||
octave_shift = (max (4, octave_shift + 1));
|
||||
build_pad_table ();
|
||||
int os = (min (4, octave_shift + 1));
|
||||
if (os != octave_shift) {
|
||||
octave_shift = os;
|
||||
build_pad_table ();
|
||||
}
|
||||
}
|
||||
|
@ -64,14 +64,14 @@ Push2::tear_down_gui ()
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
delete static_cast<P2GUI*> (gui);
|
||||
delete gui;
|
||||
gui = 0;
|
||||
}
|
||||
|
||||
void
|
||||
Push2::build_gui ()
|
||||
{
|
||||
gui = (void*) new P2GUI (*this);
|
||||
gui = new P2GUI (*this);
|
||||
}
|
||||
|
||||
/*--------------------*/
|
||||
@ -139,6 +139,7 @@ P2GUI::P2GUI (Push2& p)
|
||||
/* catch future changes to connection state */
|
||||
|
||||
// p2.ConnectionChange.connect (connection_change_connection, invalidator (*this), boost::bind (&P2GUI::connection_handler, this), gui_context());
|
||||
p2.PadChange.connect (p2_connections, invalidator (*this), boost::bind (&P2GUI::build_pad_table, this), gui_context());
|
||||
}
|
||||
|
||||
P2GUI::~P2GUI ()
|
||||
@ -407,14 +408,15 @@ P2GUI::active_port_changed (Gtk::ComboBox* combo, bool for_input)
|
||||
void
|
||||
P2GUI::build_pad_table ()
|
||||
{
|
||||
Gtk::Label* l;
|
||||
container_clear (pad_table);
|
||||
|
||||
for (int row = 0; row < 8; ++row) {
|
||||
for (int col = 0; col < 8; ++col) {
|
||||
l = manage (new Label);
|
||||
l->set_text (string_compose ("%1", (int) p2.pad_note (row, col)));
|
||||
l->show ();
|
||||
pad_table.attach (*l, col, col+1, row, row + 1);
|
||||
|
||||
Gtk::Button* b = manage (new Button (string_compose ("%1", (int) p2.pad_note (row, col))));
|
||||
b->show ();
|
||||
|
||||
pad_table.attach (*b, col, col+1, row, row + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,8 +44,11 @@ public:
|
||||
P2GUI (Push2&);
|
||||
~P2GUI ();
|
||||
|
||||
void build_pad_table ();
|
||||
|
||||
private:
|
||||
Push2& p2;
|
||||
PBD::ScopedConnectionList p2_connections;
|
||||
Gtk::HBox hpacker;
|
||||
Gtk::Table table;
|
||||
Gtk::Table action_table;
|
||||
@ -91,7 +94,6 @@ private:
|
||||
/* Pads */
|
||||
|
||||
Gtk::Table pad_table;
|
||||
void build_pad_table ();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "ardour/tempo.h"
|
||||
|
||||
#include "push2.h"
|
||||
#include "gui.h"
|
||||
|
||||
using namespace ARDOUR;
|
||||
using namespace std;
|
||||
@ -1596,13 +1597,17 @@ Push2::build_pad_table ()
|
||||
{
|
||||
for (int row = 0; row < 8; ++row ) {
|
||||
for (int col = 0; col < 8; ++col) {
|
||||
|
||||
/* top left pad sends note number 92 by default */
|
||||
|
||||
int note_number = 92 - (row*8+col);
|
||||
note_number += (octave_shift * 12);
|
||||
note_number = max (0, min (127, note_number));
|
||||
pad_table[row][col] = note_number;
|
||||
}
|
||||
}
|
||||
|
||||
PadChange (); /* emit signal */
|
||||
}
|
||||
|
||||
uint8_t
|
||||
|
@ -64,6 +64,8 @@ public:
|
||||
~Push2Request () {}
|
||||
};
|
||||
|
||||
class P2GUI;
|
||||
|
||||
class Push2 : public ARDOUR::ControlProtocol
|
||||
, public AbstractUI<Push2Request>
|
||||
{
|
||||
@ -88,6 +90,7 @@ class Push2 : public ARDOUR::ControlProtocol
|
||||
boost::shared_ptr<ARDOUR::Port> output_port();
|
||||
|
||||
uint8_t pad_note (int row, int col) const;
|
||||
PBD::Signal0<void> PadChange;
|
||||
|
||||
private:
|
||||
libusb_device_handle *handle;
|
||||
@ -480,7 +483,7 @@ class Push2 : public ARDOUR::ControlProtocol
|
||||
|
||||
/* GUI */
|
||||
|
||||
mutable void *gui;
|
||||
mutable P2GUI* gui;
|
||||
void build_gui ();
|
||||
|
||||
/* pad mapping */
|
||||
|
Loading…
Reference in New Issue
Block a user