23#ifndef CALF_CTL_KEYBOARD_H
24#define CALF_CTL_KEYBOARD_H
30#define CALF_TYPE_KEYBOARD (calf_keyboard_get_type())
31#define CALF_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_KEYBOARD, CalfKeyboard))
32#define CALF_IS_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_KEYBOARD))
33#define CALF_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_KEYBOARD, CalfKeyboardClass))
34#define CALF_IS_KEYBOARD_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_KEYBOARD))
66 virtual void note_on(
int note,
int vel) = 0;
82 virtual void note_on(
int note,
int vel) {}
89 virtual bool pre_draw(cairo_t *
c,
KeyInfo &ki) {
if (ki.
note == 60) cairo_set_source_rgb(
c, 1.0, 1.0, 0.5);
return false; }
91 if (ki.
note % 12 != 0 && ki.
note % 12 != 3 && ki.
note % 12 != 7)
93 cairo_rectangle(
c, ki.
x + ki.
width / 2 - 2, ki.
y + ki.
height - 8, 4, 4);
95 cairo_set_source_rgb(
c, 1.0, 1.0, 1.0);
97 cairo_set_source_rgb(
c, 0.0, 0.0, 0.0);
100 virtual void note_on(
int note,
int vel) { g_message(
"note on %d %d", note, vel); }
101 virtual void note_off(
int note) { g_message(
"note off %d", note); }
GtkWidget * calf_keyboard_new()
Create new keyboard object;.
Definition ctl_keyboard.cpp:32
GType calf_keyboard_get_type()
Return a GType for CalfKeyboard.
Definition ctl_keyboard.cpp:273
Null implementation of CalfKeyboard::EventSink.
Definition ctl_keyboard.h:75
virtual void post_draw(cairo_t *c, KeyInfo &ki)
called after key is drawn using standard method (but not if drawing is skipped)
Definition ctl_keyboard.h:80
virtual void note_off(int note)
key was released
Definition ctl_keyboard.h:83
virtual void post_all(cairo_t *c)
called after key is drawn
Definition ctl_keyboard.h:81
virtual bool pre_draw(cairo_t *c, KeyInfo &ki)
Definition ctl_keyboard.h:78
virtual bool pre_draw_outline(cairo_t *c, KeyInfo &ki)
Definition ctl_keyboard.h:79
virtual void set_instance(CalfKeyboard *_kb)
(will be) called on attachment of sink to CalfKeyboard object
Definition ctl_keyboard.h:77
virtual void note_on(int note, int vel)
key was pressed
Definition ctl_keyboard.h:82
CalfKeyboard * kb
Definition ctl_keyboard.h:76
Set of user-defined callbacks for customizing display and operation of CalfKeyboard.
Definition ctl_keyboard.h:52
virtual void note_off(int note)=0
key was released
virtual void set_instance(CalfKeyboard *kb)=0
(will be) called on attachment of sink to CalfKeyboard object
virtual bool pre_draw(cairo_t *c, KeyInfo &ki)=0
virtual void post_all(cairo_t *c)=0
called after key is drawn
virtual void note_on(int note, int vel)=0
key was pressed
virtual ~EventSink()
Definition ctl_keyboard.h:70
virtual void post_draw(cairo_t *c, KeyInfo &ki)=0
called after key is drawn using standard method (but not if drawing is skipped)
virtual bool pre_draw_outline(cairo_t *c, KeyInfo &ki)=0
Debug/example implementation of CalfKeyboard::EventSink.
Definition ctl_keyboard.h:88
virtual void note_off(int note)
key was released
Definition ctl_keyboard.h:101
virtual void note_on(int note, int vel)
key was pressed
Definition ctl_keyboard.h:100
virtual void post_draw(cairo_t *c, KeyInfo &ki)
called after key is drawn using standard method (but not if drawing is skipped)
Definition ctl_keyboard.h:90
virtual bool pre_draw(cairo_t *c, KeyInfo &ki)
Definition ctl_keyboard.h:89
Structure with information needed for drawing a single key.
Definition ctl_keyboard.h:41
double width
key width
Definition ctl_keyboard.h:44
bool black
true if it's a black key, false if it's a white key
Definition ctl_keyboard.h:47
double height
key height
Definition ctl_keyboard.h:45
double x
X coordinate of the top-left point of the key.
Definition ctl_keyboard.h:42
double y
Y coordinate of the top-left point of the key.
Definition ctl_keyboard.h:43
int note
MIDI note number.
Definition ctl_keyboard.h:46
Class-specific data for CalfKeyboard.
Definition ctl_keyboard.h:117
GtkWidgetClass parent_class
Parent class members.
Definition ctl_keyboard.h:119
Instance-specific data for CalfKeyboard.
Definition ctl_keyboard.h:38
int last_key
The note currently pressed via mouse selection.
Definition ctl_keyboard.h:110
int nkeys
Range (number of white keys = number of octaves * 7 + 1).
Definition ctl_keyboard.h:107
EventSink * sink
Definition ctl_keyboard.h:108
bool interactive
If true, the keyboard accepts mouse clicks and keys.
Definition ctl_keyboard.h:112
GtkWidget parent
Parent instance members.
Definition ctl_keyboard.h:105
return c
Definition crypt.c:175