1 |
/* |
/* |
2 |
* Copyright (C) 2006-2010 Andreas Persson |
* Copyright (C) 2006-2011 Andreas Persson |
3 |
* |
* |
4 |
* This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
* modify it under the terms of the GNU General Public License as |
20 |
#include "regionchooser.h" |
#include "regionchooser.h" |
21 |
|
|
22 |
#include <algorithm> |
#include <algorithm> |
|
#include <cmath> |
|
23 |
#include <sstream> |
#include <sstream> |
24 |
|
|
25 |
#include <cairomm/context.h> |
#include <cairomm/context.h> |
31 |
|
|
32 |
#include "global.h" |
#include "global.h" |
33 |
|
|
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 10) || GTKMM_MAJOR_VERSION < 2 |
|
|
|
|
|
#define create_cairo_context() \ |
|
|
gobj() ? Cairo::RefPtr<Cairo::Context>( \ |
|
|
new Cairo::Context(gdk_cairo_create(get_window()->gobj()))) : \ |
|
|
Cairo::RefPtr<Cairo::Context>() |
|
|
|
|
|
namespace Gdk { |
|
|
namespace Cairo { |
|
|
void set_source_color(const ::Cairo::RefPtr< ::Cairo::Context >& cr, |
|
|
const Gdk::Color& color) { |
|
|
gdk_cairo_set_source_color(cr->cobj(), |
|
|
const_cast<GdkColor*>(color.gobj())); |
|
|
} |
|
|
} |
|
|
} |
|
|
#endif |
|
|
|
|
34 |
#define REGION_BLOCK_HEIGHT 20 |
#define REGION_BLOCK_HEIGHT 20 |
35 |
#define KEYBOARD_HEIGHT 40 |
#define KEYBOARD_HEIGHT 40 |
36 |
|
|
62 |
|
|
63 |
|
|
64 |
RegionChooser::RegionChooser() : |
RegionChooser::RegionChooser() : |
65 |
|
activeKeyColor("red"), |
66 |
|
red("#8070ff"), |
67 |
|
grey1("grey69"), |
68 |
|
white("white"), |
69 |
|
black("black"), |
70 |
m_VirtKeybModeChoice(_("Virtual Keyboard Mode")), |
m_VirtKeybModeChoice(_("Virtual Keyboard Mode")), |
71 |
currentActiveKey(-1) |
currentActiveKey(-1) |
72 |
{ |
{ |
73 |
red = Gdk::Color("#8070ff"); |
set_size_request(500, KEYBOARD_HEIGHT + REGION_BLOCK_HEIGHT); |
|
grey1 = Gdk::Color("#b0b0b0"); |
|
|
activeKeyColor = Gdk::Color("#ff0000"); |
|
|
white = Gdk::Color("#ffffff"); |
|
|
black = Gdk::Color("#000000"); |
|
74 |
|
|
75 |
instrument = 0; |
instrument = 0; |
76 |
region = 0; |
region = 0; |
180 |
m_VirtKeybOffVelocityLabel.set_text(ToString(velocity)); |
m_VirtKeybOffVelocityLabel.set_text(ToString(velocity)); |
181 |
} |
} |
182 |
|
|
183 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
184 |
bool RegionChooser::on_expose_event(GdkEventExpose* event) |
bool RegionChooser::on_expose_event(GdkEventExpose* e) |
185 |
{ |
{ |
186 |
Glib::RefPtr<Gdk::Window> window = get_window(); |
return on_draw(get_window()->create_cairo_context()); |
187 |
if (window) { |
} |
188 |
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context(); |
#endif |
|
if (event) { |
|
|
cr->rectangle(event->area.x, event->area.y, |
|
|
event->area.width, event->area.height); |
|
|
cr->clip(); |
|
|
} |
|
|
const int h = KEYBOARD_HEIGHT; |
|
|
const int w = get_width() - 1; |
|
|
const int bh = int(h * 0.55); |
|
|
|
|
|
cr->save(); |
|
|
cr->set_line_width(1); |
|
|
|
|
|
const Gdk::Color bg = get_style()->get_bg(Gtk::STATE_NORMAL); |
|
|
Gdk::Cairo::set_source_color(cr, bg); |
|
|
cr->paint(); |
|
189 |
|
|
190 |
Gdk::Cairo::set_source_color(cr, black); |
bool RegionChooser::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) |
191 |
cr->rectangle(0.5, h1 + 0.5, w, h - 1); |
{ |
192 |
cr->stroke(); |
const int h = KEYBOARD_HEIGHT; |
193 |
|
const int w = get_width() - 1; |
194 |
|
const int bh = int(h * 0.55); |
195 |
|
|
196 |
int x1 = int(w * 20.5 / 128.0 + 0.5); |
cr->save(); |
197 |
int x2 = int(w * 109.5 / 128.0 + 0.5); |
cr->set_line_width(1); |
198 |
|
|
199 |
Gdk::Cairo::set_source_color(cr, grey1); |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
200 |
cr->rectangle(1, h1 + 1, x1 - 1, h - 2); |
const Gdk::Color bg = get_style()->get_bg(Gtk::STATE_NORMAL); |
201 |
cr->fill(); |
#else |
202 |
|
const Gdk::RGBA bg = get_style_context()->get_background_color(); |
203 |
|
#endif |
204 |
|
Gdk::Cairo::set_source_rgba(cr, bg); |
205 |
|
cr->paint(); |
206 |
|
|
207 |
Gdk::Cairo::set_source_color(cr, white); |
Gdk::Cairo::set_source_rgba(cr, black); |
208 |
cr->rectangle(x1 + 1, h1 + 1, x2 - x1 - 1, h - 2); |
cr->rectangle(0.5, h1 + 0.5, w, h - 1); |
209 |
cr->fill(); |
cr->stroke(); |
210 |
|
|
211 |
|
int x1 = int(w * 20.5 / 128.0 + 0.5); |
212 |
|
int x2 = int(w * 109.5 / 128.0 + 0.5); |
213 |
|
|
214 |
|
Gdk::Cairo::set_source_rgba(cr, grey1); |
215 |
|
cr->rectangle(1, h1 + 1, x1 - 1, h - 2); |
216 |
|
cr->fill(); |
217 |
|
|
218 |
|
Gdk::Cairo::set_source_rgba(cr, white); |
219 |
|
cr->rectangle(x1 + 1, h1 + 1, x2 - x1 - 1, h - 2); |
220 |
|
cr->fill(); |
221 |
|
|
222 |
|
Gdk::Cairo::set_source_rgba(cr, grey1); |
223 |
|
cr->rectangle(x2 + 1, h1 + 1, w - x2 - 1, h - 2); |
224 |
|
cr->fill(); |
225 |
|
|
226 |
|
Gdk::Cairo::set_source_rgba(cr, black); |
227 |
|
for (int i = 0 ; i < 128 ; i++) { |
228 |
|
int note = (i + 3) % 12; |
229 |
|
int x = int(w * i / 128.0 + 0.5); |
230 |
|
|
231 |
|
if (note == 1 || note == 4 || note == 6 || |
232 |
|
note == 9 || note == 11) { |
233 |
|
int x2 = int(w * (i + 0.5) / 128.0 + 0.5); |
234 |
|
cr->move_to(x2 + 0.5, h1 + bh + 0.5); |
235 |
|
cr->line_to(x2 + 0.5, h1 + h - 1); |
236 |
|
cr->stroke(); |
237 |
|
|
238 |
|
int x3 = int(w * (i + 1) / 128.0 + 0.5); |
239 |
|
cr->rectangle(x, h1 + 1, x3 - x + 1, bh); |
240 |
|
cr->fill(); |
241 |
|
} else if (note == 3 || note == 8) { |
242 |
|
cr->move_to(x + 0.5, h1 + 1); |
243 |
|
cr->line_to(x + 0.5, h1 + h - 1); |
244 |
|
cr->stroke(); |
245 |
|
|
246 |
Gdk::Cairo::set_source_color(cr, grey1); |
if (note == 3) draw_digit(i); |
247 |
cr->rectangle(x2 + 1, h1 + 1, w - x2 - 1, h - 2); |
} |
248 |
cr->fill(); |
} |
249 |
|
|
250 |
Gdk::Cairo::set_source_color(cr, black); |
if (instrument) { |
251 |
for (int i = 0 ; i < 128 ; i++) { |
int i = 0; |
252 |
int note = (i + 3) % 12; |
gig::Region* next_region; |
253 |
int x = int(w * i / 128.0 + 0.5); |
int x3 = -1; |
254 |
|
for (gig::Region* r = regions.first() ; r ; r = next_region) { |
255 |
|
|
256 |
if (note == 1 || note == 4 || note == 6 || |
if (x3 < 0) x3 = int(w * (r->KeyRange.low) / 128.0 + 0.5); |
257 |
note == 9 || note == 11) { |
next_region = regions.next(); |
258 |
int x2 = int(w * (i + 0.5) / 128.0 + 0.5); |
if (!next_region || |
259 |
cr->move_to(x2 + 0.5, h1 + bh + 0.5); |
r->KeyRange.high + 1 != next_region->KeyRange.low) { |
260 |
cr->line_to(x2 + 0.5, h1 + h - 1); |
int x2 = int(w * (r->KeyRange.high + 1) / 128.0 + 0.5); |
261 |
|
cr->move_to(x3, 0.5); |
262 |
|
cr->line_to(x2 + 0.5, 0.5); |
263 |
|
cr->line_to(x2 + 0.5, h1 - 0.5); |
264 |
|
cr->line_to(x3, h1 - 0.5); |
265 |
cr->stroke(); |
cr->stroke(); |
266 |
|
|
267 |
int x3 = int(w * (i + 1) / 128.0 + 0.5); |
Gdk::Cairo::set_source_rgba(cr, white); |
268 |
cr->rectangle(x, h1 + 1, x3 - x + 1, bh); |
cr->rectangle(x3 + 1, 1, x2 - x3 - 1, h1 - 2); |
269 |
cr->fill(); |
cr->fill(); |
270 |
} else if (note == 3 || note == 8) { |
Gdk::Cairo::set_source_rgba(cr, black); |
|
cr->move_to(x + 0.5, h1 + 1); |
|
|
cr->line_to(x + 0.5, h1 + h - 1); |
|
|
cr->stroke(); |
|
271 |
|
|
272 |
if (note == 3) draw_digit(i); |
x3 = -1; |
273 |
} |
} |
274 |
|
i++; |
275 |
} |
} |
276 |
|
|
277 |
if (instrument) { |
for (gig::Region* r = regions.first() ; r ; r = regions.next()) { |
278 |
int i = 0; |
int x = int(w * (r->KeyRange.low) / 128.0 + 0.5); |
279 |
gig::Region* next_region; |
cr->move_to(x + 0.5, 1); |
280 |
int x3 = -1; |
cr->line_to(x + 0.5, h1 - 1); |
281 |
for (gig::Region* r = regions.first() ; r ; r = next_region) { |
cr->stroke(); |
|
|
|
|
if (x3 < 0) x3 = int(w * (r->KeyRange.low) / 128.0 + 0.5); |
|
|
next_region = regions.next(); |
|
|
if (!next_region || |
|
|
r->KeyRange.high + 1 != next_region->KeyRange.low) { |
|
|
int x2 = int(w * (r->KeyRange.high + 1) / 128.0 + 0.5); |
|
|
cr->move_to(x3, 0.5); |
|
|
cr->line_to(x2 + 0.5, 0.5); |
|
|
cr->line_to(x2 + 0.5, h1 - 0.5); |
|
|
cr->line_to(x3, h1 - 0.5); |
|
|
cr->stroke(); |
|
|
|
|
|
Gdk::Cairo::set_source_color(cr, white); |
|
|
cr->rectangle(x3 + 1, 1, x2 - x3 - 1, h1 - 2); |
|
|
cr->fill(); |
|
|
Gdk::Cairo::set_source_color(cr, black); |
|
|
|
|
|
x3 = -1; |
|
|
} |
|
|
i++; |
|
|
} |
|
|
|
|
|
for (gig::Region* r = regions.first() ; r ; r = regions.next()) { |
|
|
int x = int(w * (r->KeyRange.low) / 128.0 + 0.5); |
|
|
cr->move_to(x + 0.5, 1); |
|
|
cr->line_to(x + 0.5, h1 - 1); |
|
|
cr->stroke(); |
|
|
} |
|
|
|
|
|
if (region) { |
|
|
int x1 = int(w * (region->KeyRange.low) / 128.0 + 0.5); |
|
|
int x2 = int(w * (region->KeyRange.high + 1) / 128.0 + 0.5); |
|
|
Gdk::Cairo::set_source_color(cr, red); |
|
|
cr->rectangle(x1 + 1, 1, x2 - x1 - 1, h1 - 2); |
|
|
cr->fill(); |
|
|
} |
|
282 |
} |
} |
283 |
|
|
284 |
cr->restore(); |
if (region) { |
285 |
|
int x1 = int(w * (region->KeyRange.low) / 128.0 + 0.5); |
286 |
|
int x2 = int(w * (region->KeyRange.high + 1) / 128.0 + 0.5); |
287 |
|
Gdk::Cairo::set_source_rgba(cr, red); |
288 |
|
cr->rectangle(x1 + 1, 1, x2 - x1 - 1, h1 - 2); |
289 |
|
cr->fill(); |
290 |
|
} |
291 |
} |
} |
292 |
|
|
293 |
|
cr->restore(); |
294 |
|
|
295 |
return true; |
return true; |
296 |
} |
} |
297 |
|
|
298 |
|
|
|
void RegionChooser::on_size_request(GtkRequisition* requisition) |
|
|
{ |
|
|
*requisition = GtkRequisition(); |
|
|
requisition->height = KEYBOARD_HEIGHT + REGION_BLOCK_HEIGHT; |
|
|
requisition->width = 500; |
|
|
} |
|
|
|
|
299 |
bool RegionChooser::is_black_key(int key) { |
bool RegionChooser::is_black_key(int key) { |
300 |
const int note = (key + 3) % 12; |
const int note = (key + 3) % 12; |
301 |
return note == 1 || note == 4 || note == 6 || note == 9 || note == 11; |
return note == 1 || note == 4 || note == 6 || note == 9 || note == 11; |
313 |
double text_h = double(rectangle.get_height()) / Pango::SCALE; |
double text_h = double(rectangle.get_height()) / Pango::SCALE; |
314 |
double x = w * (key + 0.75) / 128.0; |
double x = w * (key + 0.75) / 128.0; |
315 |
Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context(); |
Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context(); |
316 |
Gdk::Cairo::set_source_color(cr, black); |
Gdk::Cairo::set_source_rgba(cr, black); |
317 |
cr->move_to(int(x - text_w / 2 + 1), int(h1 + h - text_h + 0.5)); |
cr->move_to(int(x - text_w / 2 + 1), int(h1 + h - text_h + 0.5)); |
318 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 16) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 16) || GTKMM_MAJOR_VERSION < 2 |
319 |
pango_cairo_show_layout(cr->cobj(), layout->gobj()); |
pango_cairo_show_layout(cr->cobj(), layout->gobj()); |
322 |
#endif |
#endif |
323 |
} |
} |
324 |
|
|
325 |
void RegionChooser::draw_key(int key, const Gdk::Color& color) |
void RegionChooser::draw_key(int key, const Gdk::RGBA& color) |
326 |
{ |
{ |
327 |
const int h = KEYBOARD_HEIGHT; |
const int h = KEYBOARD_HEIGHT; |
328 |
const int w = get_width() - 1; |
const int w = get_width() - 1; |
329 |
const int bh = int(h * 0.55); |
const int bh = int(h * 0.55); |
330 |
|
|
331 |
Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context(); |
Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context(); |
332 |
Gdk::Cairo::set_source_color(cr, color); |
Gdk::Cairo::set_source_rgba(cr, color); |
333 |
|
|
334 |
int note = (key + 3) % 12; |
int note = (key + 3) % 12; |
335 |
int x = int(w * key / 128.0 + 0.5) + 1; |
int x = int(w * key / 128.0 + 0.5) + 1; |
399 |
} |
} |
400 |
|
|
401 |
if (resize.active) { |
if (resize.active) { |
402 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
403 |
get_window()->pointer_ungrab(event->time); |
get_window()->pointer_ungrab(event->time); |
404 |
|
#else |
405 |
|
Glib::wrap(event->device, true)->ungrab(event->time); |
406 |
|
#endif |
407 |
resize.active = false; |
resize.active = false; |
408 |
|
|
409 |
if (resize.mode == resize.moving_high_limit) { |
if (resize.mode == resize.moving_high_limit) { |
435 |
cursor_is_resize = false; |
cursor_is_resize = false; |
436 |
} |
} |
437 |
} else if (move.active) { |
} else if (move.active) { |
438 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
439 |
get_window()->pointer_ungrab(event->time); |
get_window()->pointer_ungrab(event->time); |
440 |
|
#else |
441 |
|
Glib::wrap(event->device, true)->ungrab(event->time); |
442 |
|
#endif |
443 |
move.active = false; |
move.active = false; |
444 |
|
|
445 |
if (move.pos) { |
if (move.pos) { |
454 |
} |
} |
455 |
|
|
456 |
if (is_in_resize_zone(event->x, event->y)) { |
if (is_in_resize_zone(event->x, event->y)) { |
457 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
458 |
get_window()->set_cursor(Gdk::Cursor(Gdk::SB_H_DOUBLE_ARROW)); |
get_window()->set_cursor(Gdk::Cursor(Gdk::SB_H_DOUBLE_ARROW)); |
459 |
|
#else |
460 |
|
get_window()->set_cursor(Gdk::Cursor::create(Gdk::SB_H_DOUBLE_ARROW)); |
461 |
|
#endif |
462 |
cursor_is_resize = true; |
cursor_is_resize = true; |
463 |
} |
} |
464 |
} |
} |
495 |
} |
} |
496 |
} else { |
} else { |
497 |
if (is_in_resize_zone(event->x, event->y)) { |
if (is_in_resize_zone(event->x, event->y)) { |
498 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
499 |
get_window()->pointer_grab(false, |
get_window()->pointer_grab(false, |
500 |
Gdk::BUTTON_RELEASE_MASK | |
Gdk::BUTTON_RELEASE_MASK | |
501 |
Gdk::POINTER_MOTION_MASK | |
Gdk::POINTER_MOTION_MASK | |
502 |
Gdk::POINTER_MOTION_HINT_MASK, |
Gdk::POINTER_MOTION_HINT_MASK, |
503 |
Gdk::Cursor(Gdk::SB_H_DOUBLE_ARROW), event->time); |
Gdk::Cursor(Gdk::SB_H_DOUBLE_ARROW), |
504 |
|
event->time); |
505 |
|
#else |
506 |
|
Glib::wrap(event->device, true)->grab(get_window(), |
507 |
|
Gdk::OWNERSHIP_NONE, |
508 |
|
false, |
509 |
|
Gdk::BUTTON_RELEASE_MASK | |
510 |
|
Gdk::POINTER_MOTION_MASK | |
511 |
|
Gdk::POINTER_MOTION_HINT_MASK, |
512 |
|
Gdk::Cursor::create(Gdk::SB_H_DOUBLE_ARROW), |
513 |
|
event->time); |
514 |
|
#endif |
515 |
resize.active = true; |
resize.active = true; |
516 |
} else { |
} else { |
517 |
gig::Region* r = get_region(k); |
gig::Region* r = get_region(k); |
521 |
region_selected(); |
region_selected(); |
522 |
dimensionManager.set_region(region); |
dimensionManager.set_region(region); |
523 |
|
|
524 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
525 |
get_window()->pointer_grab(false, |
get_window()->pointer_grab(false, |
526 |
Gdk::BUTTON_RELEASE_MASK | |
Gdk::BUTTON_RELEASE_MASK | |
527 |
Gdk::POINTER_MOTION_MASK | |
Gdk::POINTER_MOTION_MASK | |
528 |
Gdk::POINTER_MOTION_HINT_MASK, |
Gdk::POINTER_MOTION_HINT_MASK, |
529 |
Gdk::Cursor(Gdk::FLEUR), event->time); |
Gdk::Cursor(Gdk::FLEUR), |
530 |
|
event->time); |
531 |
|
#else |
532 |
|
Glib::wrap(event->device, true)->grab(get_window(), |
533 |
|
Gdk::OWNERSHIP_NONE, |
534 |
|
false, |
535 |
|
Gdk::BUTTON_RELEASE_MASK | |
536 |
|
Gdk::POINTER_MOTION_MASK | |
537 |
|
Gdk::POINTER_MOTION_HINT_MASK, |
538 |
|
Gdk::Cursor::create(Gdk::FLEUR), |
539 |
|
event->time); |
540 |
|
#endif |
541 |
move.active = true; |
move.active = true; |
542 |
move.from_x = event->x; |
move.from_x = event->x; |
543 |
move.pos = 0; |
move.pos = 0; |
590 |
resize.mode = resize.moving_low_limit; |
resize.mode = resize.moving_low_limit; |
591 |
} |
} |
592 |
} |
} |
593 |
const Gdk::Color white = |
const Gdk::RGBA white = region == resize.region ? red : this->white; |
594 |
region == resize.region ? red : get_style()->get_white(); |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
595 |
const Gdk::Color bg = get_style()->get_bg(Gtk::STATE_NORMAL); |
const Gdk::Color bg = get_style()->get_bg(Gtk::STATE_NORMAL); |
596 |
|
#else |
597 |
|
const Gdk::RGBA bg = get_style_context()->get_background_color(); |
598 |
|
#endif |
599 |
|
|
600 |
int prevx = int(w * resize.pos / 128.0 + 0.5); |
int prevx = int(w * resize.pos / 128.0 + 0.5); |
601 |
x = int(w * k / 128.0 + 0.5); |
x = int(w * k / 128.0 + 0.5); |
602 |
|
|
603 |
if (resize.mode == resize.moving_high_limit) { |
if (resize.mode == resize.moving_high_limit) { |
604 |
if (k > resize.pos) { |
if (k > resize.pos) { |
605 |
Gdk::Cairo::set_source_color(cr, white); |
Gdk::Cairo::set_source_rgba(cr, white); |
606 |
cr->rectangle(prevx, 1, x - prevx, h1 - 2); |
cr->rectangle(prevx, 1, x - prevx, h1 - 2); |
607 |
cr->fill(); |
cr->fill(); |
608 |
|
|
609 |
Gdk::Cairo::set_source_color(cr, black); |
Gdk::Cairo::set_source_rgba(cr, black); |
610 |
cr->move_to(prevx, 0.5); |
cr->move_to(prevx, 0.5); |
611 |
cr->line_to(x + 1, 0.5); |
cr->line_to(x + 1, 0.5); |
612 |
cr->move_to(prevx, h1 - 0.5); |
cr->move_to(prevx, h1 - 0.5); |
615 |
} else { |
} else { |
616 |
int xx = (resize.pos == resize.max && |
int xx = (resize.pos == resize.max && |
617 |
resize.max != 128) ? 1 : 0; |
resize.max != 128) ? 1 : 0; |
618 |
Gdk::Cairo::set_source_color(cr, bg); |
Gdk::Cairo::set_source_rgba(cr, bg); |
619 |
cr->rectangle(x + 1, 0, prevx - x - xx, h1); |
cr->rectangle(x + 1, 0, prevx - x - xx, h1); |
620 |
cr->fill(); |
cr->fill(); |
621 |
} |
} |
622 |
} else { |
} else { |
623 |
if (k < resize.pos) { |
if (k < resize.pos) { |
624 |
Gdk::Cairo::set_source_color(cr, white); |
Gdk::Cairo::set_source_rgba(cr, white); |
625 |
cr->rectangle(x + 1, 1, prevx - x, h1 - 2); |
cr->rectangle(x + 1, 1, prevx - x, h1 - 2); |
626 |
cr->fill(); |
cr->fill(); |
627 |
|
|
628 |
Gdk::Cairo::set_source_color(cr, black); |
Gdk::Cairo::set_source_rgba(cr, black); |
629 |
cr->move_to(x, 0.5); |
cr->move_to(x, 0.5); |
630 |
cr->line_to(prevx, 0.5); |
cr->line_to(prevx, 0.5); |
631 |
cr->move_to(x, h1 - 0.5); |
cr->move_to(x, h1 - 0.5); |
634 |
} else { |
} else { |
635 |
int xx = (resize.pos == resize.min && |
int xx = (resize.pos == resize.min && |
636 |
resize.min != 0) ? 1 : 0; |
resize.min != 0) ? 1 : 0; |
637 |
Gdk::Cairo::set_source_color(cr, bg); |
Gdk::Cairo::set_source_rgba(cr, bg); |
638 |
cr->rectangle(prevx + xx, 0, x - prevx - xx, h1); |
cr->rectangle(prevx + xx, 0, x - prevx - xx, h1); |
639 |
cr->fill(); |
cr->fill(); |
640 |
} |
} |
641 |
} |
} |
642 |
Gdk::Cairo::set_source_color(cr, black); |
Gdk::Cairo::set_source_rgba(cr, black); |
643 |
cr->move_to(x + 0.5, 1); |
cr->move_to(x + 0.5, 1); |
644 |
cr->line_to(x + 0.5, h1 - 1); |
cr->line_to(x + 0.5, h1 - 1); |
645 |
cr->stroke(); |
cr->stroke(); |
724 |
k = new_k; |
k = new_k; |
725 |
if (k == move.pos) return; |
if (k == move.pos) return; |
726 |
|
|
727 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
728 |
const Gdk::Color bg = get_style()->get_bg(Gtk::STATE_NORMAL); |
const Gdk::Color bg = get_style()->get_bg(Gtk::STATE_NORMAL); |
729 |
|
#else |
730 |
|
const Gdk::RGBA bg = get_style_context()->get_background_color(); |
731 |
|
#endif |
732 |
|
|
733 |
int prevx = int(w * (move.pos + region->KeyRange.low) / 128.0 + 0.5); |
int prevx = int(w * (move.pos + region->KeyRange.low) / 128.0 + 0.5); |
734 |
x = int(w * (k + region->KeyRange.low) / 128.0 + 0.5); |
x = int(w * (k + region->KeyRange.low) / 128.0 + 0.5); |
735 |
int prevx2 = int(w * (move.pos + region->KeyRange.high + 1) / 128.0 + 0.5); |
int prevx2 = int(w * (move.pos + region->KeyRange.high + 1) / 128.0 + 0.5); |
736 |
int x2 = int(w * (k + region->KeyRange.high + 1) / 128.0 + 0.5); |
int x2 = int(w * (k + region->KeyRange.high + 1) / 128.0 + 0.5); |
|
const Gdk::Color black = get_style()->get_black(); |
|
737 |
|
|
738 |
if (!new_touch_left) { |
if (!new_touch_left) { |
739 |
Gdk::Cairo::set_source_color(cr, black); |
Gdk::Cairo::set_source_rgba(cr, black); |
740 |
cr->move_to(x + 0.5, 1); |
cr->move_to(x + 0.5, 1); |
741 |
cr->line_to(x + 0.5, h1 - 1); |
cr->line_to(x + 0.5, h1 - 1); |
742 |
cr->stroke(); |
cr->stroke(); |
743 |
} |
} |
744 |
if (!new_touch_right) { |
if (!new_touch_right) { |
745 |
Gdk::Cairo::set_source_color(cr, black); |
Gdk::Cairo::set_source_rgba(cr, black); |
746 |
cr->move_to(x2 + 0.5, 1); |
cr->move_to(x2 + 0.5, 1); |
747 |
cr->line_to(x2 + 0.5, h1 - 1); |
cr->line_to(x2 + 0.5, h1 - 1); |
748 |
cr->stroke(); |
cr->stroke(); |
749 |
} |
} |
750 |
|
|
751 |
if (k > move.pos) { |
if (k > move.pos) { |
752 |
Gdk::Cairo::set_source_color(cr, bg); |
Gdk::Cairo::set_source_rgba(cr, bg); |
753 |
cr->rectangle(prevx + (move.touch_left ? 1 : 0), 0, |
cr->rectangle(prevx + (move.touch_left ? 1 : 0), 0, |
754 |
std::min(x, prevx2 + 1 - (move.touch_right ? 1 : 0)) - |
std::min(x, prevx2 + 1 - (move.touch_right ? 1 : 0)) - |
755 |
(prevx + (move.touch_left ? 1 : 0)), h1); |
(prevx + (move.touch_left ? 1 : 0)), h1); |
756 |
cr->fill(); |
cr->fill(); |
757 |
|
|
758 |
Gdk::Cairo::set_source_color(cr, black); |
Gdk::Cairo::set_source_rgba(cr, black); |
759 |
cr->move_to(std::max(x, prevx2 + 1), 0.5); |
cr->move_to(std::max(x, prevx2 + 1), 0.5); |
760 |
cr->line_to(x2 + 1, 0.5); |
cr->line_to(x2 + 1, 0.5); |
761 |
cr->move_to(std::max(x, prevx2 + 1), h1 - 0.5); |
cr->move_to(std::max(x, prevx2 + 1), h1 - 0.5); |
762 |
cr->line_to(x2 + 1, h1 - 0.5); |
cr->line_to(x2 + 1, h1 - 0.5); |
763 |
cr->stroke(); |
cr->stroke(); |
764 |
|
|
765 |
Gdk::Cairo::set_source_color(cr, red); |
Gdk::Cairo::set_source_rgba(cr, red); |
766 |
cr->rectangle(std::max(x + 1, prevx2), 1, |
cr->rectangle(std::max(x + 1, prevx2), 1, |
767 |
x2 - std::max(x + 1, prevx2), h1 - 2); |
x2 - std::max(x + 1, prevx2), h1 - 2); |
768 |
cr->fill(); |
cr->fill(); |
769 |
} else { |
} else { |
770 |
Gdk::Cairo::set_source_color(cr, bg); |
Gdk::Cairo::set_source_rgba(cr, bg); |
771 |
cr->rectangle(std::max(x2 + 1, prevx + (move.touch_left ? 1 : 0)), 0, |
cr->rectangle(std::max(x2 + 1, prevx + (move.touch_left ? 1 : 0)), 0, |
772 |
prevx2 + 1 - (move.touch_right ? 1 : 0) - |
prevx2 + 1 - (move.touch_right ? 1 : 0) - |
773 |
std::max(x2 + 1, prevx + (move.touch_left ? 1 : 0)), h1); |
std::max(x2 + 1, prevx + (move.touch_left ? 1 : 0)), h1); |
774 |
cr->fill(); |
cr->fill(); |
775 |
|
|
776 |
Gdk::Cairo::set_source_color(cr, black); |
Gdk::Cairo::set_source_rgba(cr, black); |
777 |
cr->move_to(x, 0.5); |
cr->move_to(x, 0.5); |
778 |
cr->line_to(std::min(x2, prevx - 1) + 1, 0.5); |
cr->line_to(std::min(x2, prevx - 1) + 1, 0.5); |
779 |
cr->move_to(x, h1 - 0.5); |
cr->move_to(x, h1 - 0.5); |
780 |
cr->line_to(std::min(x2, prevx - 1) + 1, h1 - 0.5); |
cr->line_to(std::min(x2, prevx - 1) + 1, h1 - 0.5); |
781 |
cr->stroke(); |
cr->stroke(); |
782 |
|
|
783 |
Gdk::Cairo::set_source_color(cr, red); |
Gdk::Cairo::set_source_rgba(cr, red); |
784 |
cr->rectangle(x + 1, 1, std::min(x2 - 1, prevx) - x, h1 - 2); |
cr->rectangle(x + 1, 1, std::min(x2 - 1, prevx) - x, h1 - 2); |
785 |
cr->fill(); |
cr->fill(); |
786 |
} |
} |
824 |
} else { |
} else { |
825 |
if (is_in_resize_zone(x, y)) { |
if (is_in_resize_zone(x, y)) { |
826 |
if (!cursor_is_resize) { |
if (!cursor_is_resize) { |
827 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
828 |
window->set_cursor(Gdk::Cursor(Gdk::SB_H_DOUBLE_ARROW)); |
window->set_cursor(Gdk::Cursor(Gdk::SB_H_DOUBLE_ARROW)); |
829 |
|
#else |
830 |
|
window->set_cursor(Gdk::Cursor::create(Gdk::SB_H_DOUBLE_ARROW)); |
831 |
|
#endif |
832 |
cursor_is_resize = true; |
cursor_is_resize = true; |
833 |
} |
} |
834 |
} else if (cursor_is_resize) { |
} else if (cursor_is_resize) { |
910 |
dialog.get_vbox()->pack_start(checkBoxKeygroup); |
dialog.get_vbox()->pack_start(checkBoxKeygroup); |
911 |
checkBoxKeygroup.show(); |
checkBoxKeygroup.show(); |
912 |
// add "Keygroup" spinbox |
// add "Keygroup" spinbox |
913 |
Gtk::Adjustment adjustment(1, 1, pow(2,32)); |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
914 |
|
Gtk::Adjustment adjustment(1, 1, 999); |
915 |
Gtk::SpinButton spinBox(adjustment); |
Gtk::SpinButton spinBox(adjustment); |
916 |
|
#else |
917 |
|
Gtk::SpinButton spinBox(Gtk::Adjustment::create(1, 1, 999)); |
918 |
|
#endif |
919 |
if (region->KeyGroup) spinBox.set_value(region->KeyGroup); |
if (region->KeyGroup) spinBox.set_value(region->KeyGroup); |
920 |
dialog.get_vbox()->pack_start(spinBox); |
dialog.get_vbox()->pack_start(spinBox); |
921 |
spinBox.show(); |
spinBox.show(); |