22 |
#include <gtkmm/stock.h> |
#include <gtkmm/stock.h> |
23 |
#include <gtkmm/spinbutton.h> |
#include <gtkmm/spinbutton.h> |
24 |
#include <gtkmm/dialog.h> |
#include <gtkmm/dialog.h> |
|
#include <libintl.h> |
|
25 |
#include <math.h> |
#include <math.h> |
26 |
|
|
27 |
#define _(String) gettext(String) |
#include "global.h" |
28 |
|
|
29 |
RegionChooser::RegionChooser() |
RegionChooser::RegionChooser() |
30 |
{ |
{ |
257 |
|
|
258 |
if (resize.mode == resize.moving_high_limit) { |
if (resize.mode == resize.moving_high_limit) { |
259 |
if (resize.region->KeyRange.high != resize.pos - 1) { |
if (resize.region->KeyRange.high != resize.pos - 1) { |
260 |
resize.region->KeyRange.high = resize.pos - 1; |
instrument_struct_to_be_changed_signal.emit(instrument); |
261 |
instrument_changed(); |
resize.region->SetKeyRange( |
262 |
|
resize.region->KeyRange.low, // low |
263 |
|
resize.pos - 1 // high |
264 |
|
); |
265 |
|
instrument_changed.emit(); |
266 |
|
instrument_struct_changed_signal.emit(instrument); |
267 |
} |
} |
268 |
} else if (resize.mode == resize.moving_low_limit) { |
} else if (resize.mode == resize.moving_low_limit) { |
269 |
if (resize.region->KeyRange.low != resize.pos) { |
if (resize.region->KeyRange.low != resize.pos) { |
270 |
resize.region->KeyRange.low = resize.pos; |
instrument_struct_to_be_changed_signal.emit(instrument); |
271 |
instrument_changed(); |
resize.region->SetKeyRange( |
272 |
|
resize.pos, // low |
273 |
|
resize.region->KeyRange.high // high |
274 |
|
); |
275 |
|
instrument_changed.emit(); |
276 |
|
instrument_struct_changed_signal.emit(instrument); |
277 |
} |
} |
278 |
} |
} |
279 |
|
|
286 |
move.active = false; |
move.active = false; |
287 |
|
|
288 |
if (move.pos) { |
if (move.pos) { |
289 |
region->KeyRange.low += move.pos; |
instrument_struct_to_be_changed_signal.emit(instrument); |
290 |
region->KeyRange.high += move.pos; |
region->SetKeyRange( |
291 |
|
region->KeyRange.low + move.pos, |
292 |
// find the r which is the first one to the right of region |
region->KeyRange.high + move.pos |
293 |
// at its new position |
); |
294 |
gig::Region* r; |
instrument_struct_changed_signal.emit(instrument); |
|
gig::Region* prev_region = 0; |
|
|
for (r = instrument->GetFirstRegion() ; r ; r = instrument->GetNextRegion()) { |
|
|
if (r->KeyRange.low > region->KeyRange.low) break; |
|
|
prev_region = r; |
|
|
} |
|
|
|
|
|
// place region before r if it's not already there |
|
|
if (prev_region != region) { |
|
|
instrument_struct_to_be_changed_signal.emit(instrument); |
|
|
instrument->MoveRegion(region, r); |
|
|
instrument_struct_changed_signal.emit(instrument); |
|
|
} |
|
295 |
} |
} |
296 |
|
|
297 |
if (is_in_resize_zone(event->x, event->y)) { |
if (is_in_resize_zone(event->x, event->y)) { |
615 |
return false; |
return false; |
616 |
} |
} |
617 |
|
|
618 |
sigc::signal<void> RegionChooser::signal_region_selected() |
sigc::signal<void>& RegionChooser::signal_region_selected() |
619 |
{ |
{ |
620 |
return region_selected; |
return region_selected; |
621 |
} |
} |
622 |
|
|
623 |
sigc::signal<void> RegionChooser::signal_instrument_changed() |
sigc::signal<void>& RegionChooser::signal_instrument_changed() |
624 |
{ |
{ |
625 |
return instrument_changed; |
return instrument_changed; |
626 |
} |
} |
652 |
|
|
653 |
void RegionChooser::add_region() |
void RegionChooser::add_region() |
654 |
{ |
{ |
|
gig::Region* r; |
|
|
for (r = instrument->GetFirstRegion() ; r ; r = instrument->GetNextRegion()) { |
|
|
if (r->KeyRange.low > new_region_pos) break; |
|
|
} |
|
|
|
|
655 |
instrument_struct_to_be_changed_signal.emit(instrument); |
instrument_struct_to_be_changed_signal.emit(instrument); |
656 |
|
|
657 |
region = instrument->AddRegion(); |
region = instrument->AddRegion(); |
658 |
region->KeyRange.low = region->KeyRange.high = new_region_pos; |
region->SetKeyRange(new_region_pos, new_region_pos); |
|
|
|
|
instrument->MoveRegion(region, r); |
|
659 |
|
|
660 |
instrument_struct_changed_signal.emit(instrument); |
instrument_struct_changed_signal.emit(instrument); |
661 |
|
|
688 |
instrument_changed(); |
instrument_changed(); |
689 |
} |
} |
690 |
|
|
691 |
sigc::signal<void, gig::Instrument*> RegionChooser::signal_instrument_struct_to_be_changed() { |
sigc::signal<void, gig::Instrument*>& RegionChooser::signal_instrument_struct_to_be_changed() { |
692 |
return instrument_struct_to_be_changed_signal; |
return instrument_struct_to_be_changed_signal; |
693 |
} |
} |
694 |
|
|
695 |
sigc::signal<void, gig::Instrument*> RegionChooser::signal_instrument_struct_changed() { |
sigc::signal<void, gig::Instrument*>& RegionChooser::signal_instrument_struct_changed() { |
696 |
return instrument_struct_changed_signal; |
return instrument_struct_changed_signal; |
697 |
} |
} |
698 |
|
|
699 |
sigc::signal<void, gig::Region*> RegionChooser::signal_region_to_be_changed() { |
sigc::signal<void, gig::Region*>& RegionChooser::signal_region_to_be_changed() { |
700 |
return region_to_be_changed_signal; |
return region_to_be_changed_signal; |
701 |
} |
} |
702 |
|
|
703 |
sigc::signal<void, gig::Region*> RegionChooser::signal_region_changed_signal() { |
sigc::signal<void, gig::Region*>& RegionChooser::signal_region_changed_signal() { |
704 |
return region_changed_signal; |
return region_changed_signal; |
705 |
} |
} |