1 |
/* |
/* |
2 |
* Copyright (C) 2006-2014 Andreas Persson |
* Copyright (C) 2006-2015 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 |
29 |
#include <gtkmm/dialog.h> |
#include <gtkmm/dialog.h> |
30 |
|
|
31 |
#include "global.h" |
#include "global.h" |
32 |
|
#include "Settings.h" |
33 |
|
|
34 |
#define REGION_BLOCK_HEIGHT 20 |
#define REGION_BLOCK_HEIGHT 30 |
35 |
#define KEYBOARD_HEIGHT 40 |
#define KEYBOARD_HEIGHT 40 |
36 |
|
|
37 |
void SortedRegions::update(gig::Instrument* instrument) { |
void SortedRegions::update(gig::Instrument* instrument) { |
55 |
} |
} |
56 |
|
|
57 |
gig::Region* SortedRegions::next() { |
gig::Region* SortedRegions::next() { |
58 |
region_iterator++; |
++region_iterator; |
59 |
return region_iterator == regions.end() ? 0 : *region_iterator; |
return region_iterator == regions.end() ? 0 : *region_iterator; |
60 |
} |
} |
61 |
|
|
155 |
keyboard_key_released_signal.connect( |
keyboard_key_released_signal.connect( |
156 |
sigc::mem_fun(*this, &RegionChooser::on_note_off_event) |
sigc::mem_fun(*this, &RegionChooser::on_note_off_event) |
157 |
); |
); |
158 |
|
set_tooltip_text(_("Right click here for adding new region. Use mouse pointer for moving (dragging) or resizing existing regions (by pointing at region's boundary). Right click on an existing region for more actions.")); |
159 |
} |
} |
160 |
|
|
161 |
RegionChooser::~RegionChooser() |
RegionChooser::~RegionChooser() |
331 |
cr->line_to(x + 0.5, h1 - 1); |
cr->line_to(x + 0.5, h1 - 1); |
332 |
cr->stroke(); |
cr->stroke(); |
333 |
} |
} |
334 |
|
|
335 |
|
// if there is no region yet, show the user some hint text that he may |
336 |
|
// right click on this area to create a new region |
337 |
|
if (!regions.first()) { |
338 |
|
Glib::RefPtr<Pango::Context> context = get_pango_context(); |
339 |
|
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
340 |
|
layout->set_alignment(Pango::ALIGN_CENTER); |
341 |
|
layout->set_text(Glib::ustring("*** ") + _("Right click here to create a region.") + " ***"); |
342 |
|
layout->set_width(get_width() * Pango::SCALE); |
343 |
|
//layout->set_height(get_height() * Pango::SCALE); |
344 |
|
layout->set_spacing(10); |
345 |
|
Gdk::Cairo::set_source_rgba(cr, red); |
346 |
|
// get the text dimensions |
347 |
|
int text_width, text_height; |
348 |
|
layout->get_pixel_size(text_width, text_height); |
349 |
|
cr->move_to(0, (REGION_BLOCK_HEIGHT - text_height) / 2); |
350 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 16) || GTKMM_MAJOR_VERSION < 2 |
351 |
|
pango_cairo_show_layout(cr->cobj(), layout->gobj()); |
352 |
|
#else |
353 |
|
layout->show_in_cairo_context(cr); |
354 |
|
#endif |
355 |
|
} |
356 |
} |
} |
357 |
|
|
358 |
bool RegionChooser::is_black_key(int key) { |
bool RegionChooser::is_black_key(int key) { |
515 |
void RegionChooser::update_after_move(int pos) |
void RegionChooser::update_after_move(int pos) |
516 |
{ |
{ |
517 |
instrument_struct_to_be_changed_signal.emit(instrument); |
instrument_struct_to_be_changed_signal.emit(instrument); |
518 |
region->SetKeyRange(pos, pos + region->KeyRange.high - |
const int range = region->KeyRange.high - region->KeyRange.low; |
519 |
region->KeyRange.low); |
const int diff = pos - int(region->KeyRange.low); |
520 |
|
region->SetKeyRange(pos, pos + range); |
521 |
|
if (Settings::singleton()->moveRootNoteWithRegionMoved) { |
522 |
|
for (int i = 0; i < 256; ++i) { |
523 |
|
gig::DimensionRegion* dimrgn = region->pDimensionRegions[i]; |
524 |
|
if (!dimrgn || !dimrgn->pSample || !dimrgn->PitchTrack) continue; |
525 |
|
dimrgn->UnityNote += diff; |
526 |
|
} |
527 |
|
} |
528 |
regions.update(instrument); |
regions.update(instrument); |
529 |
instrument_changed.emit(); |
instrument_changed.emit(); |
530 |
instrument_struct_changed_signal.emit(instrument); |
instrument_struct_changed_signal.emit(instrument); |
546 |
} |
} |
547 |
} |
} |
548 |
|
|
549 |
|
// left mouse button double click |
550 |
|
if (event->type == GDK_2BUTTON_PRESS && event->button == 1) { |
551 |
|
if (event->y < REGION_BLOCK_HEIGHT) { |
552 |
|
// show dimension manager dialog for this region |
553 |
|
manage_dimensions(); |
554 |
|
} |
555 |
|
} |
556 |
|
|
557 |
if (event->y >= REGION_BLOCK_HEIGHT) return true; |
if (event->y >= REGION_BLOCK_HEIGHT) return true; |
558 |
if (event->type == GDK_BUTTON_PRESS && event->button == 3) { |
if (event->type == GDK_BUTTON_PRESS && event->button == 3) { |
559 |
gig::Region* r = get_region(k); |
gig::Region* r = get_region(k); |
629 |
return 0; |
return 0; |
630 |
} |
} |
631 |
|
|
632 |
|
void RegionChooser::set_region(gig::Region* region) { |
633 |
|
this->region = region; |
634 |
|
queue_draw(); |
635 |
|
region_selected(); |
636 |
|
dimensionManager.set_region(region); |
637 |
|
} |
638 |
|
|
639 |
void RegionChooser::motion_resize_region(int x, int y) |
void RegionChooser::motion_resize_region(int x, int y) |
640 |
{ |
{ |
641 |
const int w = get_width() - 1; |
const int w = get_width() - 1; |