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 ();
+ }
}
delete w;
}
}
- delete static_cast<P2GUI*> (gui);
+ delete gui;
gui = 0;
}
void
Push2::build_gui ()
{
- gui = (void*) new P2GUI (*this);
+ gui = new P2GUI (*this);
}
/*--------------------*/
/* 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 ()
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);
}
}
}
P2GUI (Push2&);
~P2GUI ();
+ void build_pad_table ();
+
private:
Push2& p2;
+ PBD::ScopedConnectionList p2_connections;
Gtk::HBox hpacker;
Gtk::Table table;
Gtk::Table action_table;
/* Pads */
Gtk::Table pad_table;
- void build_pad_table ();
};
}
#include "ardour/tempo.h"
#include "push2.h"
+#include "gui.h"
using namespace ARDOUR;
using namespace std;
{
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
~Push2Request () {}
};
+class P2GUI;
+
class Push2 : public ARDOUR::ControlProtocol
, public AbstractUI<Push2Request>
{
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;
/* GUI */
- mutable void *gui;
+ mutable P2GUI* gui;
void build_gui ();
/* pad mapping */