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) { |
340 |
layout->set_alignment(Pango::ALIGN_CENTER); |
layout->set_alignment(Pango::ALIGN_CENTER); |
341 |
layout->set_text(Glib::ustring("*** ") + _("Right click here to create a region.") + " ***"); |
layout->set_text(Glib::ustring("*** ") + _("Right click here to create a region.") + " ***"); |
342 |
layout->set_width(get_width() * Pango::SCALE); |
layout->set_width(get_width() * Pango::SCALE); |
343 |
Gdk::Cairo::set_source_rgba(cr, red); |
//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 |
|
Pango::Rectangle rect = layout->get_logical_extents(); |
348 |
|
int text_width, text_height; |
349 |
|
layout->get_pixel_size(text_width, text_height); |
350 |
|
cr->move_to(0, (REGION_BLOCK_HEIGHT - text_height) / 2); |
351 |
#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 |
352 |
pango_cairo_show_layout(cr->cobj(), layout->gobj()); |
pango_cairo_show_layout(cr->cobj(), layout->gobj()); |
353 |
#else |
#else |
516 |
void RegionChooser::update_after_move(int pos) |
void RegionChooser::update_after_move(int pos) |
517 |
{ |
{ |
518 |
instrument_struct_to_be_changed_signal.emit(instrument); |
instrument_struct_to_be_changed_signal.emit(instrument); |
519 |
region->SetKeyRange(pos, pos + region->KeyRange.high - |
const int range = region->KeyRange.high - region->KeyRange.low; |
520 |
region->KeyRange.low); |
const int diff = pos - int(region->KeyRange.low); |
521 |
|
region->SetKeyRange(pos, pos + range); |
522 |
|
if (Settings::singleton()->moveRootNoteWithRegionMoved) { |
523 |
|
for (int i = 0; i < 256; ++i) { |
524 |
|
gig::DimensionRegion* dimrgn = region->pDimensionRegions[i]; |
525 |
|
if (!dimrgn || !dimrgn->pSample || !dimrgn->PitchTrack) continue; |
526 |
|
dimrgn->UnityNote += diff; |
527 |
|
} |
528 |
|
} |
529 |
regions.update(instrument); |
regions.update(instrument); |
530 |
instrument_changed.emit(); |
instrument_changed.emit(); |
531 |
instrument_struct_changed_signal.emit(instrument); |
instrument_struct_changed_signal.emit(instrument); |
547 |
} |
} |
548 |
} |
} |
549 |
|
|
550 |
|
// left mouse button double click |
551 |
|
if (event->type == GDK_2BUTTON_PRESS && event->button == 1) { |
552 |
|
if (event->y < REGION_BLOCK_HEIGHT) { |
553 |
|
// show dimension manager dialog for this region |
554 |
|
manage_dimensions(); |
555 |
|
} |
556 |
|
} |
557 |
|
|
558 |
if (event->y >= REGION_BLOCK_HEIGHT) return true; |
if (event->y >= REGION_BLOCK_HEIGHT) return true; |
559 |
if (event->type == GDK_BUTTON_PRESS && event->button == 3) { |
if (event->type == GDK_BUTTON_PRESS && event->button == 3) { |
560 |
gig::Region* r = get_region(k); |
gig::Region* r = get_region(k); |
630 |
return 0; |
return 0; |
631 |
} |
} |
632 |
|
|
633 |
|
void RegionChooser::set_region(gig::Region* region) { |
634 |
|
this->region = region; |
635 |
|
queue_draw(); |
636 |
|
region_selected(); |
637 |
|
dimensionManager.set_region(region); |
638 |
|
} |
639 |
|
|
640 |
void RegionChooser::motion_resize_region(int x, int y) |
void RegionChooser::motion_resize_region(int x, int y) |
641 |
{ |
{ |
642 |
const int w = get_width() - 1; |
const int w = get_width() - 1; |