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 |
24 |
#include <cairomm/context.h> |
#include <cairomm/context.h> |
25 |
#include <gdkmm/general.h> |
#include <gdkmm/general.h> |
26 |
#include <gdkmm/cursor.h> |
#include <gdkmm/cursor.h> |
|
#include <gtkmm/stock.h> |
|
27 |
#include <gtkmm/spinbutton.h> |
#include <gtkmm/spinbutton.h> |
28 |
#include <gtkmm/dialog.h> |
#include <gtkmm/dialog.h> |
29 |
|
|
30 |
#include "global.h" |
#include "global.h" |
31 |
|
#include "Settings.h" |
32 |
|
|
33 |
#define REGION_BLOCK_HEIGHT 20 |
#define REGION_BLOCK_HEIGHT 30 |
34 |
#define KEYBOARD_HEIGHT 40 |
#define KEYBOARD_HEIGHT 40 |
35 |
|
|
36 |
void SortedRegions::update(gig::Instrument* instrument) { |
void SortedRegions::update(gig::Instrument* instrument) { |
54 |
} |
} |
55 |
|
|
56 |
gig::Region* SortedRegions::next() { |
gig::Region* SortedRegions::next() { |
57 |
region_iterator++; |
++region_iterator; |
58 |
return region_iterator == regions.end() ? 0 : *region_iterator; |
return region_iterator == regions.end() ? 0 : *region_iterator; |
59 |
} |
} |
60 |
|
|
103 |
for (int i = 0 ; i < 128 ; i++) key_pressed[i] = false; |
for (int i = 0 ; i < 128 ; i++) key_pressed[i] = false; |
104 |
|
|
105 |
actionGroup = Gtk::ActionGroup::create(); |
actionGroup = Gtk::ActionGroup::create(); |
106 |
actionGroup->add(Gtk::Action::create("Properties", |
actionGroup->add(Gtk::Action::create("Properties", _("_Properties")), |
|
Gtk::Stock::PROPERTIES), |
|
107 |
sigc::mem_fun(*this, |
sigc::mem_fun(*this, |
108 |
&RegionChooser::show_region_properties)); |
&RegionChooser::show_region_properties)); |
109 |
actionGroup->add(Gtk::Action::create("Remove", Gtk::Stock::REMOVE), |
actionGroup->add(Gtk::Action::create("Remove", _("_Remove")), |
110 |
sigc::mem_fun(*this, &RegionChooser::delete_region)); |
sigc::mem_fun(*this, &RegionChooser::delete_region)); |
111 |
actionGroup->add(Gtk::Action::create("Add", Gtk::Stock::ADD), |
actionGroup->add(Gtk::Action::create("Add", _("_Add")), |
112 |
sigc::mem_fun(*this, &RegionChooser::add_region)); |
sigc::mem_fun(*this, &RegionChooser::add_region)); |
113 |
actionGroup->add(Gtk::Action::create("Dimensions", _("Dimensions...")), |
actionGroup->add(Gtk::Action::create("Dimensions", _("Dimensions...")), |
114 |
sigc::mem_fun(*this, &RegionChooser::manage_dimensions)); |
sigc::mem_fun(*this, &RegionChooser::manage_dimensions)); |
338 |
layout->set_alignment(Pango::ALIGN_CENTER); |
layout->set_alignment(Pango::ALIGN_CENTER); |
339 |
layout->set_text(Glib::ustring("*** ") + _("Right click here to create a region.") + " ***"); |
layout->set_text(Glib::ustring("*** ") + _("Right click here to create a region.") + " ***"); |
340 |
layout->set_width(get_width() * Pango::SCALE); |
layout->set_width(get_width() * Pango::SCALE); |
341 |
Gdk::Cairo::set_source_rgba(cr, red); |
//layout->set_height(get_height() * Pango::SCALE); |
342 |
|
layout->set_spacing(10); |
343 |
|
Gdk::Cairo::set_source_rgba(cr, red); |
344 |
|
// get the text dimensions |
345 |
|
int text_width, text_height; |
346 |
|
layout->get_pixel_size(text_width, text_height); |
347 |
|
cr->move_to(0, (REGION_BLOCK_HEIGHT - text_height) / 2); |
348 |
#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 |
349 |
pango_cairo_show_layout(cr->cobj(), layout->gobj()); |
pango_cairo_show_layout(cr->cobj(), layout->gobj()); |
350 |
#else |
#else |
513 |
void RegionChooser::update_after_move(int pos) |
void RegionChooser::update_after_move(int pos) |
514 |
{ |
{ |
515 |
instrument_struct_to_be_changed_signal.emit(instrument); |
instrument_struct_to_be_changed_signal.emit(instrument); |
516 |
region->SetKeyRange(pos, pos + region->KeyRange.high - |
const int range = region->KeyRange.high - region->KeyRange.low; |
517 |
region->KeyRange.low); |
const int diff = pos - int(region->KeyRange.low); |
518 |
|
region->SetKeyRange(pos, pos + range); |
519 |
|
if (Settings::singleton()->moveRootNoteWithRegionMoved) { |
520 |
|
for (int i = 0; i < 256; ++i) { |
521 |
|
gig::DimensionRegion* dimrgn = region->pDimensionRegions[i]; |
522 |
|
if (!dimrgn || !dimrgn->pSample || !dimrgn->PitchTrack) continue; |
523 |
|
dimrgn->UnityNote += diff; |
524 |
|
} |
525 |
|
} |
526 |
regions.update(instrument); |
regions.update(instrument); |
527 |
instrument_changed.emit(); |
instrument_changed.emit(); |
528 |
instrument_struct_changed_signal.emit(instrument); |
instrument_struct_changed_signal.emit(instrument); |
544 |
} |
} |
545 |
} |
} |
546 |
|
|
547 |
|
// left mouse button double click |
548 |
|
if (event->type == GDK_2BUTTON_PRESS && event->button == 1) { |
549 |
|
if (event->y < REGION_BLOCK_HEIGHT) { |
550 |
|
// show dimension manager dialog for this region |
551 |
|
manage_dimensions(); |
552 |
|
} |
553 |
|
} |
554 |
|
|
555 |
if (event->y >= REGION_BLOCK_HEIGHT) return true; |
if (event->y >= REGION_BLOCK_HEIGHT) return true; |
556 |
if (event->type == GDK_BUTTON_PRESS && event->button == 3) { |
if (event->type == GDK_BUTTON_PRESS && event->button == 3) { |
557 |
gig::Region* r = get_region(k); |
gig::Region* r = get_region(k); |
627 |
return 0; |
return 0; |
628 |
} |
} |
629 |
|
|
630 |
|
void RegionChooser::set_region(gig::Region* region) { |
631 |
|
this->region = region; |
632 |
|
queue_draw(); |
633 |
|
region_selected(); |
634 |
|
dimensionManager.set_region(region); |
635 |
|
} |
636 |
|
|
637 |
void RegionChooser::motion_resize_region(int x, int y) |
void RegionChooser::motion_resize_region(int x, int y) |
638 |
{ |
{ |
639 |
const int w = get_width() - 1; |
const int w = get_width() - 1; |
896 |
dialog.get_vbox()->pack_start(spinBox); |
dialog.get_vbox()->pack_start(spinBox); |
897 |
spinBox.show(); |
spinBox.show(); |
898 |
// add OK and CANCEL buttons to the dialog |
// add OK and CANCEL buttons to the dialog |
899 |
dialog.add_button(Gtk::Stock::OK, 0); |
dialog.add_button(_("_OK"), 0); |
900 |
dialog.add_button(Gtk::Stock::CANCEL, 1); |
dialog.add_button(_("_Cancel"), 1); |
901 |
dialog.show_all_children(); |
dialog.show_all_children(); |
902 |
if (!dialog.run()) { // OK selected ... |
if (!dialog.run()) { // OK selected ... |
903 |
region->KeyGroup = |
region->KeyGroup = |