161 |
Glib::RefPtr<const Gdk::GC> black = get_style()->get_black_gc(); |
Glib::RefPtr<const Gdk::GC> black = get_style()->get_black_gc(); |
162 |
Glib::RefPtr<const Gdk::GC> white = get_style()->get_white_gc(); |
Glib::RefPtr<const Gdk::GC> white = get_style()->get_white_gc(); |
163 |
|
|
|
Glib::RefPtr<Pango::Context> context = get_pango_context(); |
|
|
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
|
|
|
|
164 |
window->draw_rectangle(black, false, 0, h1, w, h - 1); |
window->draw_rectangle(black, false, 0, h1, w, h - 1); |
165 |
gc->set_foreground(grey1); |
gc->set_foreground(grey1); |
166 |
int x1 = int(w * 20.5 / 128.0 + 0.5); |
int x1 = int(w * 20.5 / 128.0 + 0.5); |
170 |
window->draw_rectangle(white, true, x1 + 1, h1 + 1, x2 - x1 - 1, h - 2); |
window->draw_rectangle(white, true, x1 + 1, h1 + 1, x2 - x1 - 1, h - 2); |
171 |
window->draw_rectangle(gc, true, x2 + 1, h1 + 1, |
window->draw_rectangle(gc, true, x2 + 1, h1 + 1, |
172 |
w - x2 - 1, h - 2); |
w - x2 - 1, h - 2); |
|
int octave = -1; |
|
173 |
for (int i = 0 ; i < 128 ; i++) { |
for (int i = 0 ; i < 128 ; i++) { |
174 |
int note = (i + 3) % 12; |
int note = (i + 3) % 12; |
175 |
int x = int(w * i / 128.0 + 0.5); |
int x = int(w * i / 128.0 + 0.5); |
183 |
} else if (note == 3 || note == 8) { |
} else if (note == 3 || note == 8) { |
184 |
window->draw_line(black, x, h1 + 1, x, h1 + h); |
window->draw_line(black, x, h1 + 1, x, h1 + h); |
185 |
} |
} |
186 |
if (note == 3) { |
if (note == 3) draw_digit(i); |
|
char buf[30]; |
|
|
sprintf(buf, "<span size=\"8000\">%d</span>", octave); |
|
|
layout->set_markup(buf); |
|
|
Pango::Rectangle rectangle = layout->get_logical_extents(); |
|
|
double text_w = double(rectangle.get_width()) / Pango::SCALE; |
|
|
double text_h = double(rectangle.get_height()) / Pango::SCALE; |
|
|
double x2 = w * (i + 0.75) / 128.0; |
|
|
window->draw_layout(black, int(x2 - text_w / 2 + 1), |
|
|
int(h1 + h - text_h + 0.5), layout); |
|
|
octave++; |
|
|
} |
|
187 |
} |
} |
188 |
|
|
189 |
if (instrument) { |
if (instrument) { |
233 |
return note == 1 || note == 4 || note == 6 || note == 9 || note == 11; |
return note == 1 || note == 4 || note == 6 || note == 9 || note == 11; |
234 |
} |
} |
235 |
|
|
236 |
|
void RegionChooser::draw_digit(int key) { |
237 |
|
const int h = 40; |
238 |
|
const int w = get_width() - 1; |
239 |
|
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(get_pango_context()); |
240 |
|
char buf[30]; |
241 |
|
sprintf(buf, "<span size=\"8000\">%d</span>", key / 12 - 1); |
242 |
|
layout->set_markup(buf); |
243 |
|
Pango::Rectangle rectangle = layout->get_logical_extents(); |
244 |
|
double text_w = double(rectangle.get_width()) / Pango::SCALE; |
245 |
|
double text_h = double(rectangle.get_height()) / Pango::SCALE; |
246 |
|
double x = w * (key + 0.75) / 128.0; |
247 |
|
get_window()->draw_layout(get_style()->get_black_gc(), int(x - text_w / 2 + 1), |
248 |
|
int(h1 + h - text_h + 0.5), layout); |
249 |
|
} |
250 |
|
|
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; |
254 |
const int w = get_width(); |
const int w = get_width() - 1; |
255 |
const int bh = int(h * 0.55); |
const int bh = int(h * 0.55); |
256 |
|
|
257 |
Glib::RefPtr<Gdk::Window> window = get_window(); |
Glib::RefPtr<Gdk::Window> window = get_window(); |
262 |
int x = int(w * i / 128.0 + 0.5) + 1; |
int x = int(w * i / 128.0 + 0.5) + 1; |
263 |
int x2 = int(w * (i + 1.5) / 128.0 + 0.5); |
int x2 = int(w * (i + 1.5) / 128.0 + 0.5); |
264 |
int x3 = int(w * (i + 1) / 128.0 + 0.5); |
int x3 = int(w * (i + 1) / 128.0 + 0.5); |
265 |
int x4 = int(w * (i - 0.5) / 128 + 0.5) + 1; |
int x4 = int(w * (i - 0.5) / 128.0 + 0.5); |
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 - 1, h1 + 1, w1, bh); |
window->draw_rectangle(gc, true, x, h1 + 1, w1, bh); |
270 |
window->draw_rectangle(gc, true, x4, h1 + bh + 1, x2 - x4 - 1, h - bh - 2); |
window->draw_rectangle(gc, true, x4 + 1, 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 - 1, h1 + bh + 1, x3 - x4 + 1, 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 |
|
if (note == 3) draw_digit(i); |
280 |
break; |
break; |
281 |
default: |
default: |
282 |
window->draw_rectangle(gc, true, x, h1 + 1, w1 - 1, bh - 1); |
window->draw_rectangle(gc, true, x, h1 + 1, w1, bh - 1); |
283 |
break; |
break; |
284 |
} |
} |
285 |
} |
} |