*/
+#include <iostream>
+
+#include "gtkmm2ext/keyboard.h"
+
#include "midi_time_axis.h"
#include "step_entry.h"
#include "utils.h"
((StepEntry*)arg)->note_off_event_handler (note);
}
+static void
+_rest_event_handler (GtkWidget* widget, gpointer arg)
+{
+ ((StepEntry*)arg)->rest_event_handler ();
+}
StepEntry::StepEntry (MidiTimeAxisView& mtv)
- : ArdourDialog (_("Step Entry Editor"))
+ : ArdourDialog (string_compose (_("Step Entry: %1"), mtv.name()))
, triplet_button ("3")
, sustain_button ("sustain")
, rest_button ("rest")
_piano = (PianoKeyboard*) piano_keyboard_new ();
piano = Glib::wrap ((GtkWidget*) _piano);
- g_signal_connect(G_OBJECT(_piano), "note-off", G_CALLBACK(_note_off_event_handler), this);
+ piano->set_flags (Gtk::CAN_FOCUS);
+ piano->signal_enter_notify_event().connect (sigc::mem_fun (*this, &StepEntry::piano_enter_notify_event), false);
+ g_signal_connect(G_OBJECT(_piano), "note-off", G_CALLBACK(_note_off_event_handler), this);
+ g_signal_connect(G_OBJECT(_piano), "rest", G_CALLBACK(_rest_event_handler), this);
+
rest_button.signal_clicked().connect (sigc::mem_fun (*this, &StepEntry::rest_click));
+ chord_button.signal_toggled().connect (sigc::mem_fun (*this, &StepEntry::chord_toggled));
+ triplet_button.signal_toggled().connect (sigc::mem_fun (*this, &StepEntry::triplet_toggled));
packer.set_spacing (6);
packer.pack_start (upper_box, false, false);
{
}
+bool
+StepEntry::on_key_press_event (GdkEventKey* ev)
+{
+ int ret;
+ g_signal_emit_by_name (G_OBJECT(_piano), "key-press-event", ev, &ret);
+ return ret;
+}
+
+bool
+StepEntry::on_key_release_event (GdkEventKey* ev)
+{
+ int ret;
+ g_signal_emit_by_name (G_OBJECT(_piano), "key-release-event", ev, &ret);
+ return ret;
+}
+
+void
+StepEntry::rest_event_handler ()
+{
+ _mtv->step_edit_rest();
+}
+
void
StepEntry::note_off_event_handler (int note)
{
velocity = 127;
}
- if (!triplet_button.get_active()) {
- _mtv->step_add_note (channel_adjustment.get_value(), note, velocity, length);
- } else {
+ if (_mtv->step_edit_within_triplet()) {
length *= 2.0/3.0;
- _mtv->step_add_note (channel_adjustment.get_value(), note, velocity, length);
- _mtv->step_add_note (channel_adjustment.get_value(), note, velocity, length);
- _mtv->step_add_note (channel_adjustment.get_value(), note, velocity, length);
}
+
+ _mtv->step_add_note (channel_adjustment.get_value(), note, velocity, length);
}
void
{
_mtv->step_edit_rest ();
}
+
+void
+StepEntry::triplet_toggled ()
+{
+ if (triplet_button.get_active () != _mtv->step_edit_within_triplet()) {
+ _mtv->step_edit_toggle_triplet ();
+ }
+}
+
+void
+StepEntry::chord_toggled ()
+{
+ if (chord_button.get_active() != _mtv->step_edit_within_chord ()) {
+ _mtv->step_edit_toggle_chord ();
+ }
+}
+
+bool
+StepEntry::piano_enter_notify_event (GdkEventCrossing *ev)
+{
+ piano->grab_focus ();
+ return false;
+}
+