60 |
|
|
61 |
red = Gdk::Color("#8070ff"); |
red = Gdk::Color("#8070ff"); |
62 |
grey1 = Gdk::Color("#b0b0b0"); |
grey1 = Gdk::Color("#b0b0b0"); |
63 |
|
activeKeyColor = Gdk::Color("#ff0000"); |
64 |
|
white = Gdk::Color("#ffffff"); |
65 |
|
black = Gdk::Color("#000000"); |
66 |
|
|
67 |
colormap->alloc_color(red); |
colormap->alloc_color(red); |
68 |
colormap->alloc_color(grey1); |
colormap->alloc_color(grey1); |
69 |
|
colormap->alloc_color(activeKeyColor); |
70 |
|
colormap->alloc_color(white); |
71 |
|
colormap->alloc_color(black); |
72 |
instrument = 0; |
instrument = 0; |
73 |
region = 0; |
region = 0; |
74 |
resize.active = false; |
resize.active = false; |
128 |
{ |
{ |
129 |
} |
} |
130 |
|
|
131 |
|
void RegionChooser::on_note_on_event(int key, int velocity) { |
132 |
|
draw_region(key, key+1, activeKeyColor); |
133 |
|
} |
134 |
|
|
135 |
|
void RegionChooser::on_note_off_event(int key, int velocity) { |
136 |
|
if (is_black_key(key)) |
137 |
|
draw_region(key, key+1, black); |
138 |
|
else |
139 |
|
draw_region(key, key+1, white); |
140 |
|
} |
141 |
|
|
142 |
void RegionChooser::on_realize() |
void RegionChooser::on_realize() |
143 |
{ |
{ |
144 |
// We need to call the base on_realize() |
// We need to call the base on_realize() |
243 |
requisition->width = 500; |
requisition->width = 500; |
244 |
} |
} |
245 |
|
|
246 |
|
bool RegionChooser::is_black_key(int key) { |
247 |
|
const int note = (key + 3) % 12; |
248 |
|
return note == 1 || note == 4 || note == 6 || note == 9 || note == 11; |
249 |
|
} |
250 |
|
|
|
// not used |
|
251 |
void RegionChooser::draw_region(int from, int to, const Gdk::Color& color) |
void RegionChooser::draw_region(int from, int to, const Gdk::Color& color) |
252 |
{ |
{ |
253 |
const int h = 40; |
const int h = 40; |
266 |
int w1 = x3 - x; |
int w1 = x3 - x; |
267 |
switch (note) { |
switch (note) { |
268 |
case 0: case 5: case 10: |
case 0: case 5: case 10: |
269 |
window->draw_rectangle(gc, true, x, h1 + 1, w1, bh); |
window->draw_rectangle(gc, true, x - 1, h1 + 1, w1, bh); |
270 |
window->draw_rectangle(gc, true, x4, h1 + bh + 1, x2 - x4, h - bh - 2); |
window->draw_rectangle(gc, true, x4, h1 + bh + 1, x2 - x4 - 1, h - bh - 2); |
271 |
break; |
break; |
272 |
case 2: case 7: |
case 2: case 7: |
273 |
window->draw_rectangle(gc, true, x, h1 + 1, w1, bh); |
window->draw_rectangle(gc, true, x, h1 + 1, w1, bh); |
274 |
window->draw_rectangle(gc, true, x4, h1 + bh + 1, x3 - x4, h - bh - 2); |
window->draw_rectangle(gc, true, x4 - 1, h1 + bh + 1, x3 - x4 + 1, h - bh - 2); |
275 |
break; |
break; |
276 |
case 3: case 8: |
case 3: case 8: |
277 |
window->draw_rectangle(gc, true, x, h1 + 1, w1, bh); |
window->draw_rectangle(gc, true, x, h1 + 1, w1, bh); |
278 |
window->draw_rectangle(gc, true, x, h1 + bh + 1, x2 - x, h - bh - 2); |
window->draw_rectangle(gc, true, x, h1 + bh + 1, x2 - x, h - bh - 2); |
279 |
break; |
break; |
280 |
default: |
default: |
281 |
window->draw_rectangle(gc, true, x, h1 + 1, w1, bh - 1); |
window->draw_rectangle(gc, true, x, h1 + 1, w1 - 1, bh - 1); |
282 |
break; |
break; |
283 |
} |
} |
284 |
} |
} |