various fixes to MidiRegionView selection handling, key handling, drawing of ghost...
[ardour2.git] / gtk2_ardour / gtk_pianokeyboard.h
blob27d9a8a5c2eaccbaf4270bb73daeb9b4d8671995
1 #ifndef __PIANO_KEYBOARD_H__
2 #define __PIANO_KEYBOARD_H__
4 #include <glib.h>
5 #include <gtk/gtkdrawingarea.h>
7 G_BEGIN_DECLS
9 #define TYPE_PIANO_KEYBOARD (piano_keyboard_get_type ())
10 #define PIANO_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PIANO_KEYBOARD, PianoKeyboard))
11 #define PIANO_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PIANO_KEYBOARD, PianoKeyboardClass))
12 #define IS_PIANO_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PIANO_KEYBOARD))
13 #define IS_PIANO_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PIANO_KEYBOARD))
14 #define PIANO_KEYBOARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PIANO_KEYBOARD, PianoKeyboardClass))
16 typedef struct _PianoKeyboard PianoKeyboard;
17 typedef struct _PianoKeyboardClass PianoKeyboardClass;
19 #define NNOTES 127
21 #define OCTAVE_MIN -1
22 #define OCTAVE_MAX 7
24 struct Note {
25 int pressed; /* 1 if key is in pressed down state. */
26 int sustained; /* 1 if note is sustained. */
27 int x; /* Distance between the left edge of the key
28 * and the left edge of the widget, in pixels. */
29 int w; /* Width of the key, in pixels. */
30 int h; /* Height of the key, in pixels. */
31 int white; /* 1 if key is white; 0 otherwise. */
34 struct _PianoKeyboard
36 GtkDrawingArea da;
37 int maybe_stop_sustained_notes;
38 int sustain_new_notes;
39 int enable_keyboard_cue;
40 int octave;
41 int widget_margin;
42 int note_being_pressed_using_mouse;
43 volatile struct Note notes[NNOTES];
44 /* Table used to translate from PC keyboard character to MIDI note number. */
45 GHashTable *key_bindings;
48 struct _PianoKeyboardClass
50 GtkDrawingAreaClass parent_class;
53 GType piano_keyboard_get_type (void) G_GNUC_CONST;
54 GtkWidget* piano_keyboard_new (void);
55 void piano_keyboard_sustain_press (PianoKeyboard *pk);
56 void piano_keyboard_sustain_release (PianoKeyboard *pk);
57 void piano_keyboard_set_note_on (PianoKeyboard *pk, int note);
58 void piano_keyboard_set_note_off (PianoKeyboard *pk, int note);
59 void piano_keyboard_set_keyboard_cue (PianoKeyboard *pk, int enabled);
60 void piano_keyboard_set_octave (PianoKeyboard *pk, int octave);
61 gboolean piano_keyboard_set_keyboard_layout (PianoKeyboard *pk, const char *layout);
63 G_END_DECLS
65 #endif /* __PIANO_KEYBOARD_H__ */