28 |
|
|
29 |
#include "global.h" |
#include "global.h" |
30 |
|
|
31 |
DimRegionChooser::DimRegionChooser() : |
// taken from gdk/gdkkeysyms.h |
32 |
|
// (define on demand, to avoid unnecessary dev lib package build dependency) |
33 |
|
#ifndef GDK_KEY_Control_L |
34 |
|
# define GDK_KEY_Control_L 0xffe3 |
35 |
|
#endif |
36 |
|
#ifndef GDK_KEY_Control_R |
37 |
|
# define GDK_KEY_Control_R 0xffe4 |
38 |
|
#endif |
39 |
|
|
40 |
|
static std::map<gig::dimension_t,int> caseOfDimRegion(gig::DimensionRegion* dr, bool* isValidZone) { |
41 |
|
std::map<gig::dimension_t,int> dimCase; |
42 |
|
if (!dr) { |
43 |
|
*isValidZone = false; |
44 |
|
return dimCase; |
45 |
|
} |
46 |
|
|
47 |
|
gig::Region* rgn = (gig::Region*) dr->GetParent(); |
48 |
|
|
49 |
|
// find the dimension region index of the passed dimension region |
50 |
|
int drIndex; |
51 |
|
for (drIndex = 0; drIndex < 256; ++drIndex) |
52 |
|
if (rgn->pDimensionRegions[drIndex] == dr) |
53 |
|
break; |
54 |
|
|
55 |
|
// not found in region, something's horribly wrong |
56 |
|
if (drIndex == 256) { |
57 |
|
fprintf(stderr, "DimRegionChooser: ERROR: index of dim region not found!\n"); |
58 |
|
*isValidZone = false; |
59 |
|
return std::map<gig::dimension_t,int>(); |
60 |
|
} |
61 |
|
|
62 |
|
for (int d = 0, baseBits = 0; d < rgn->Dimensions; ++d) { |
63 |
|
const int bits = rgn->pDimensionDefinitions[d].bits; |
64 |
|
dimCase[rgn->pDimensionDefinitions[d].dimension] = |
65 |
|
(drIndex >> baseBits) & ((1 << bits) - 1); |
66 |
|
baseBits += bits; |
67 |
|
// there are also DimensionRegion objects of unused zones, skip them |
68 |
|
if (dimCase[rgn->pDimensionDefinitions[d].dimension] >= rgn->pDimensionDefinitions[d].zones) { |
69 |
|
*isValidZone = false; |
70 |
|
return std::map<gig::dimension_t,int>(); |
71 |
|
} |
72 |
|
} |
73 |
|
|
74 |
|
*isValidZone = true; |
75 |
|
return dimCase; |
76 |
|
} |
77 |
|
|
78 |
|
DimRegionChooser::DimRegionChooser(Gtk::Window& window) : |
79 |
red("#8070ff"), |
red("#8070ff"), |
80 |
black("black"), |
black("black"), |
81 |
white("white") |
white("white") |
82 |
{ |
{ |
83 |
instrument = 0; |
instrument = 0; |
84 |
region = 0; |
region = 0; |
85 |
dimregno = -1; |
maindimregno = -1; |
86 |
focus_line = 0; |
focus_line = 0; |
87 |
resize.active = false; |
resize.active = false; |
88 |
cursor_is_resize = false; |
cursor_is_resize = false; |
89 |
h = 20; |
h = 20; |
90 |
|
multiSelectKeyDown = false; |
91 |
set_can_focus(); |
set_can_focus(); |
92 |
|
|
93 |
actionGroup = Gtk::ActionGroup::create(); |
actionGroup = Gtk::ActionGroup::create(); |
122 |
add_events(Gdk::BUTTON_PRESS_MASK | Gdk::POINTER_MOTION_MASK | |
add_events(Gdk::BUTTON_PRESS_MASK | Gdk::POINTER_MOTION_MASK | |
123 |
Gdk::POINTER_MOTION_HINT_MASK); |
Gdk::POINTER_MOTION_HINT_MASK); |
124 |
|
|
|
for (int i = 0 ; i < 256 ; i++) dimvalue[i] = 0; |
|
125 |
labels_changed = true; |
labels_changed = true; |
126 |
|
|
127 |
set_tooltip_text(_("Right click here for options on altering dimension zones.")); |
set_tooltip_text(_( |
128 |
|
"Right click here for options on altering dimension zones. Press and " |
129 |
|
"hold CTRL key for selecting multiple dimension zones simultaniously." |
130 |
|
)); |
131 |
|
|
132 |
|
window.signal_key_press_event().connect( |
133 |
|
sigc::mem_fun(*this, &DimRegionChooser::onKeyPressed) |
134 |
|
); |
135 |
|
window.signal_key_release_event().connect( |
136 |
|
sigc::mem_fun(*this, &DimRegionChooser::onKeyReleased) |
137 |
|
); |
138 |
} |
} |
139 |
|
|
140 |
DimRegionChooser::~DimRegionChooser() |
DimRegionChooser::~DimRegionChooser() |
151 |
|
|
152 |
const Cairo::RefPtr<Cairo::Context>& cr = |
const Cairo::RefPtr<Cairo::Context>& cr = |
153 |
get_window()->create_cairo_context(); |
get_window()->create_cairo_context(); |
|
#if 0 |
|
|
} |
|
|
#endif |
|
154 |
#else |
#else |
155 |
bool DimRegionChooser::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) |
bool DimRegionChooser::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) |
156 |
{ |
{ |
266 |
for (int i = 0 ; i < region->Dimensions ; i++) { |
for (int i = 0 ; i < region->Dimensions ; i++) { |
267 |
int nbZones = region->pDimensionDefinitions[i].zones; |
int nbZones = region->pDimensionDefinitions[i].zones; |
268 |
if (nbZones) { |
if (nbZones) { |
269 |
|
const gig::dimension_t dimension = region->pDimensionDefinitions[i].dimension; |
270 |
|
|
271 |
if (y >= clipy2) break; |
if (y >= clipy2) break; |
272 |
if (y + h > clipy1) { |
if (y + h > clipy1) { |
273 |
// draw focus rectangle around dimension's label and zones |
// draw focus rectangle around dimension's label and zones |
298 |
cr->fill(); |
cr->fill(); |
299 |
|
|
300 |
int c = 0; |
int c = 0; |
301 |
if (dimregno >= 0) { |
if (maindimregno >= 0) { |
302 |
int mask = |
int mask = |
303 |
~(((1 << region->pDimensionDefinitions[i].bits) - 1) << |
~(((1 << region->pDimensionDefinitions[i].bits) - 1) << |
304 |
bitpos); |
bitpos); |
305 |
c = dimregno & mask; // mask away this dimension |
c = maindimregno & mask; // mask away this dimension |
306 |
} |
} |
307 |
bool customsplits = |
bool customsplits = |
308 |
((region->pDimensionDefinitions[i].split_type == |
((region->pDimensionDefinitions[i].split_type == |
312 |
gig::dimension_velocity && |
gig::dimension_velocity && |
313 |
region->pDimensionRegions[c]->VelocityUpperLimit)); |
region->pDimensionRegions[c]->VelocityUpperLimit)); |
314 |
|
|
315 |
// draw dimension's zone borders |
// draw dimension zones |
316 |
Gdk::Cairo::set_source_rgba(cr, black); |
Gdk::Cairo::set_source_rgba(cr, black); |
317 |
if (customsplits) { |
if (customsplits) { |
318 |
cr->move_to(label_width + 0.5, y + 1); |
cr->move_to(label_width + 0.5, y + 1); |
319 |
cr->line_to(label_width + 0.5, y + h - 1); |
cr->line_to(label_width + 0.5, y + h - 1); |
320 |
|
int prevX = label_width; |
321 |
|
int prevUpperLimit = 0; |
322 |
|
|
323 |
for (int j = 0 ; j < nbZones ; j++) { |
for (int j = 0 ; j < nbZones ; j++) { |
324 |
|
// draw dimension zone's borders for custom splits |
325 |
gig::DimensionRegion* d = |
gig::DimensionRegion* d = |
326 |
region->pDimensionRegions[c + (j << bitpos)]; |
region->pDimensionRegions[c + (j << bitpos)]; |
327 |
int upperLimit = d->DimensionUpperLimits[i]; |
int upperLimit = d->DimensionUpperLimits[i]; |
331 |
label_width; |
label_width; |
332 |
if (x >= clipx2) break; |
if (x >= clipx2) break; |
333 |
if (x < clipx1) continue; |
if (x < clipx1) continue; |
334 |
|
Gdk::Cairo::set_source_rgba(cr, black); |
335 |
cr->move_to(x + 0.5, y + 1); |
cr->move_to(x + 0.5, y + 1); |
336 |
cr->line_to(x + 0.5, y + h - 1); |
cr->line_to(x + 0.5, y + h - 1); |
337 |
|
cr->stroke(); |
338 |
|
|
339 |
|
// draw fill for zone |
340 |
|
bool isSelectedZone = this->dimzones[dimension].count(j); |
341 |
|
Gdk::Cairo::set_source_rgba(cr, isSelectedZone ? red : white); |
342 |
|
cr->rectangle(prevX + 1, y + 1, x - prevX - 1, h - 1); |
343 |
|
cr->fill(); |
344 |
|
|
345 |
|
// draw text showing the beginning of the dimension zone |
346 |
|
// as numeric value to the user |
347 |
|
{ |
348 |
|
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
349 |
|
layout->set_text(Glib::Ascii::dtostr(prevUpperLimit)); |
350 |
|
Gdk::Cairo::set_source_rgba(cr, black); |
351 |
|
Pango::Rectangle rect = layout->get_logical_extents(); |
352 |
|
// get the text dimensions |
353 |
|
int text_width, text_height; |
354 |
|
layout->get_pixel_size(text_width, text_height); |
355 |
|
// move text to the left end of the dimension zone |
356 |
|
cr->move_to(prevX + 3, y + 1); |
357 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 16) || GTKMM_MAJOR_VERSION < 2 |
358 |
|
pango_cairo_show_layout(cr->cobj(), layout->gobj()); |
359 |
|
#else |
360 |
|
layout->show_in_cairo_context(cr); |
361 |
|
#endif |
362 |
|
} |
363 |
|
// draw text showing the end of the dimension zone |
364 |
|
// as numeric value to the user |
365 |
|
{ |
366 |
|
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
367 |
|
layout->set_text(Glib::Ascii::dtostr(upperLimit)); |
368 |
|
Gdk::Cairo::set_source_rgba(cr, black); |
369 |
|
Pango::Rectangle rect = layout->get_logical_extents(); |
370 |
|
// get the text dimensions |
371 |
|
int text_width, text_height; |
372 |
|
layout->get_pixel_size(text_width, text_height); |
373 |
|
// move text to the left end of the dimension zone |
374 |
|
cr->move_to(x - 3 - text_width, y + 1); |
375 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 16) || GTKMM_MAJOR_VERSION < 2 |
376 |
|
pango_cairo_show_layout(cr->cobj(), layout->gobj()); |
377 |
|
#else |
378 |
|
layout->show_in_cairo_context(cr); |
379 |
|
#endif |
380 |
|
} |
381 |
|
|
382 |
|
prevX = x; |
383 |
|
prevUpperLimit = upperLimit; |
384 |
} |
} |
385 |
} else { |
} else { |
386 |
|
int prevX = 0; |
387 |
for (int j = 0 ; j <= nbZones ; j++) { |
for (int j = 0 ; j <= nbZones ; j++) { |
388 |
|
// draw dimension zone's borders for normal splits |
389 |
int x = int((w - label_width - 1) * j / |
int x = int((w - label_width - 1) * j / |
390 |
double(nbZones) + 0.5) + label_width; |
double(nbZones) + 0.5) + label_width; |
391 |
if (x >= clipx2) break; |
if (x >= clipx2) break; |
392 |
if (x < clipx1) continue; |
if (x < clipx1) continue; |
393 |
|
Gdk::Cairo::set_source_rgba(cr, black); |
394 |
cr->move_to(x + 0.5, y + 1); |
cr->move_to(x + 0.5, y + 1); |
395 |
cr->line_to(x + 0.5, y + h - 1); |
cr->line_to(x + 0.5, y + h - 1); |
396 |
} |
cr->stroke(); |
|
} |
|
|
cr->stroke(); |
|
397 |
|
|
398 |
// draw fill for currently selected zone |
if (j != 0) { |
399 |
if (dimregno >= 0) { |
// draw fill for zone |
400 |
Gdk::Cairo::set_source_rgba(cr, red); |
bool isSelectedZone = this->dimzones[dimension].count(j-1); |
401 |
int dr = (dimregno >> bitpos) & |
Gdk::Cairo::set_source_rgba(cr, isSelectedZone ? red : white); |
402 |
((1 << region->pDimensionDefinitions[i].bits) - 1); |
cr->rectangle(prevX + 1, y + 1, x - prevX - 1, h - 1); |
|
|
|
|
int x1 = -1, x2 = -1; |
|
|
if (customsplits) { |
|
|
x1 = label_width; |
|
|
for (int j = 0 ; j < nbZones && x1 + 1 < clipx2 ; j++) { |
|
|
gig::DimensionRegion* d = |
|
|
region->pDimensionRegions[c + (j << bitpos)]; |
|
|
int upperLimit = d->DimensionUpperLimits[i]; |
|
|
if (!upperLimit) { |
|
|
upperLimit = d->VelocityUpperLimit; |
|
|
} |
|
|
int v = upperLimit + 1; |
|
|
x2 = int((w - label_width - 1) * v / 128.0 + |
|
|
0.5) + label_width; |
|
|
if (j == dr && x1 < x2) { |
|
|
cr->rectangle(x1 + 1, y + 1, |
|
|
(x2 - x1) - 1, h - 2); |
|
|
cr->fill(); |
|
|
break; |
|
|
} |
|
|
x1 = x2; |
|
|
} |
|
|
} else { |
|
|
if (dr < nbZones) { |
|
|
x1 = int((w - label_width - 1) * dr / |
|
|
double(nbZones) + 0.5); |
|
|
x2 = int((w - label_width - 1) * (dr + 1) / |
|
|
double(nbZones) + 0.5); |
|
|
cr->rectangle(label_width + x1 + 1, y + 1, |
|
|
(x2 - x1) - 1, h - 2); |
|
403 |
cr->fill(); |
cr->fill(); |
|
} |
|
|
} |
|
404 |
|
|
405 |
// draw text showing the beginning of the dimension zone |
// draw text showing the beginning of the dimension zone |
406 |
// as numeric value to the user |
// as numeric value to the user |
407 |
if (x1 >= 0) { |
{ |
408 |
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
409 |
int v = roundf(float(x1 - label_width) / float(w - label_width) * 127.f); |
layout->set_text(Glib::Ascii::dtostr((j-1) * 128/nbZones)); |
410 |
if (dr > 0) v++; |
Gdk::Cairo::set_source_rgba(cr, black); |
411 |
layout->set_text(Glib::Ascii::dtostr(v)); |
Pango::Rectangle rect = layout->get_logical_extents(); |
412 |
Gdk::Cairo::set_source_rgba(cr, black); |
// get the text dimensions |
413 |
Pango::Rectangle rect = layout->get_logical_extents(); |
int text_width, text_height; |
414 |
|
layout->get_pixel_size(text_width, text_height); |
415 |
int text_width, text_height; |
// move text to the left end of the dimension zone |
416 |
// get the text dimensions |
cr->move_to(prevX + 3, y + 1); |
|
layout->get_pixel_size(text_width, text_height); |
|
|
// move text to the right end of the dimension zone |
|
|
cr->move_to(x1 + 1, y + 1); |
|
417 |
#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 |
418 |
pango_cairo_show_layout(cr->cobj(), layout->gobj()); |
pango_cairo_show_layout(cr->cobj(), layout->gobj()); |
419 |
#else |
#else |
420 |
layout->show_in_cairo_context(cr); |
layout->show_in_cairo_context(cr); |
421 |
#endif |
#endif |
422 |
} |
} |
423 |
// draw text showing the end of the dimension zone |
// draw text showing the end of the dimension zone |
424 |
// as numeric value to the user |
// as numeric value to the user |
425 |
if (x2 >= 0) { |
{ |
426 |
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
427 |
const int v = roundf(float(x2 - label_width) / float(w - label_width) * 127.f); |
layout->set_text(Glib::Ascii::dtostr(j * 128/nbZones - 1)); |
428 |
layout->set_text(Glib::Ascii::dtostr(v)); |
Gdk::Cairo::set_source_rgba(cr, black); |
429 |
Gdk::Cairo::set_source_rgba(cr, black); |
Pango::Rectangle rect = layout->get_logical_extents(); |
430 |
Pango::Rectangle rect = layout->get_logical_extents(); |
// get the text dimensions |
431 |
|
int text_width, text_height; |
432 |
int text_width, text_height; |
layout->get_pixel_size(text_width, text_height); |
433 |
// get the text dimensions |
// move text to the left end of the dimension zone |
434 |
layout->get_pixel_size(text_width, text_height); |
cr->move_to(x - 3 - text_width, y + 1); |
|
// move text to the right end of the dimension zone |
|
|
cr->move_to(x2 - text_width - 1, y + 1); |
|
435 |
#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 |
436 |
pango_cairo_show_layout(cr->cobj(), layout->gobj()); |
pango_cairo_show_layout(cr->cobj(), layout->gobj()); |
437 |
#else |
#else |
438 |
layout->show_in_cairo_context(cr); |
layout->show_in_cairo_context(cr); |
439 |
#endif |
#endif |
440 |
} |
} |
441 |
|
} |
442 |
|
prevX = x; |
443 |
|
} |
444 |
} |
} |
445 |
} |
} |
|
|
|
446 |
y += h; |
y += h; |
447 |
} |
} |
448 |
bitpos += region->pDimensionDefinitions[i].bits; |
bitpos += region->pDimensionDefinitions[i].bits; |
454 |
void DimRegionChooser::set_region(gig::Region* region) |
void DimRegionChooser::set_region(gig::Region* region) |
455 |
{ |
{ |
456 |
this->region = region; |
this->region = region; |
457 |
dimregno = 0; |
maindimregno = 0; |
458 |
nbDimensions = 0; |
nbDimensions = 0; |
459 |
if (region) { |
if (region) { |
460 |
int bitcount = 0; |
int bitcount = 0; |
462 |
if (region->pDimensionDefinitions[dim].bits == 0) continue; |
if (region->pDimensionDefinitions[dim].bits == 0) continue; |
463 |
nbDimensions++; |
nbDimensions++; |
464 |
|
|
465 |
int z = std::min(dimvalue[region->pDimensionDefinitions[dim].dimension], |
int z = std::min(maindimcase[region->pDimensionDefinitions[dim].dimension], |
466 |
region->pDimensionDefinitions[dim].zones - 1); |
region->pDimensionDefinitions[dim].zones - 1); |
467 |
dimregno |= (z << bitcount); |
maindimregno |= (z << bitcount); |
468 |
bitcount += region->pDimensionDefinitions[dim].bits; |
bitcount += region->pDimensionDefinitions[dim].bits; |
469 |
} |
} |
|
dimreg = region->pDimensionRegions[dimregno]; |
|
|
} else { |
|
|
dimreg = 0; |
|
470 |
} |
} |
471 |
dimregion_selected(); |
dimregion_selected(); |
472 |
set_size_request(800, region ? nbDimensions * 20 : 0); |
set_size_request(800, region ? nbDimensions * 20 : 0); |
473 |
|
|
474 |
labels_changed = true; |
labels_changed = true; |
475 |
queue_resize(); |
queue_resize(); |
476 |
|
queue_draw(); |
477 |
} |
} |
478 |
|
|
479 |
void DimRegionChooser::refresh_all() { |
void DimRegionChooser::refresh_all() { |
483 |
void DimRegionChooser::get_dimregions(const gig::Region* region, bool stereo, |
void DimRegionChooser::get_dimregions(const gig::Region* region, bool stereo, |
484 |
std::set<gig::DimensionRegion*>& dimregs) const |
std::set<gig::DimensionRegion*>& dimregs) const |
485 |
{ |
{ |
486 |
int dimregno = 0; |
for (int iDimRgn = 0; iDimRgn < 256; ++iDimRgn) { |
487 |
int bitcount = 0; |
gig::DimensionRegion* dimRgn = region->pDimensionRegions[iDimRgn]; |
488 |
int stereo_bit = 0; |
if (!dimRgn) continue; |
489 |
for (int dim = 0 ; dim < region->Dimensions ; dim++) { |
bool isValidZone; |
490 |
if (region->pDimensionDefinitions[dim].bits == 0) continue; |
std::map<gig::dimension_t,int> dimCase = caseOfDimRegion(dimRgn, &isValidZone); |
491 |
if (stereo && |
if (!isValidZone) continue; |
492 |
region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) { |
for (std::map<gig::dimension_t,int>::const_iterator it = dimCase.begin(); |
493 |
stereo_bit = (1 << bitcount); |
it != dimCase.end(); ++it) |
494 |
} else { |
{ |
495 |
int z = std::min(dimvalue[region->pDimensionDefinitions[dim].dimension], |
if (stereo && it->first == gig::dimension_samplechannel) continue; // is selected |
496 |
region->pDimensionDefinitions[dim].zones - 1); |
|
497 |
dimregno |= (z << bitcount); |
std::map<gig::dimension_t, std::set<int> >::const_iterator itSelectedDimension = |
498 |
|
this->dimzones.find(it->first); |
499 |
|
if (itSelectedDimension != this->dimzones.end() && |
500 |
|
itSelectedDimension->second.count(it->second)) continue; // is selected |
501 |
|
|
502 |
|
goto notSelected; |
503 |
} |
} |
504 |
bitcount += region->pDimensionDefinitions[dim].bits; |
|
505 |
|
dimregs.insert(dimRgn); |
506 |
|
|
507 |
|
notSelected: |
508 |
|
; |
509 |
} |
} |
|
dimregs.insert(region->pDimensionRegions[dimregno]); |
|
|
if (stereo_bit) dimregs.insert(region->pDimensionRegions[dimregno | stereo_bit]); |
|
510 |
} |
} |
511 |
|
|
512 |
void DimRegionChooser::update_after_resize() |
void DimRegionChooser::update_after_resize() |
519 |
} |
} |
520 |
int mask = |
int mask = |
521 |
~(((1 << region->pDimensionDefinitions[resize.dimension].bits) - 1) << bitpos); |
~(((1 << region->pDimensionDefinitions[resize.dimension].bits) - 1) << bitpos); |
522 |
int c = dimregno & mask; // mask away this dimension |
int c = maindimregno & mask; // mask away this dimension |
523 |
|
|
524 |
if (region->pDimensionRegions[c]->DimensionUpperLimits[resize.dimension] == 0) { |
if (region->pDimensionRegions[c]->DimensionUpperLimits[resize.dimension] == 0) { |
525 |
// the velocity dimension didn't previously have |
// the velocity dimension didn't previously have |
646 |
} |
} |
647 |
|
|
648 |
int i = dim; |
int i = dim; |
649 |
if (dimregno < 0) dimregno = 0; |
if (maindimregno < 0) maindimregno = 0; |
650 |
int mask = ~(((1 << region->pDimensionDefinitions[i].bits) - 1) << bitpos); |
int mask = ~(((1 << region->pDimensionDefinitions[i].bits) - 1) << bitpos); |
651 |
int c = dimregno & mask; // mask away this dimension |
int c = this->maindimregno & mask; // mask away this dimension |
652 |
|
|
653 |
bool customsplits = |
bool customsplits = |
654 |
((region->pDimensionDefinitions[i].split_type == gig::split_type_normal && |
((region->pDimensionDefinitions[i].split_type == gig::split_type_normal && |
678 |
region->pDimensionDefinitions[dim].split_type, |
region->pDimensionDefinitions[dim].split_type, |
679 |
region->pDimensionDefinitions[dim].zones, |
region->pDimensionDefinitions[dim].zones, |
680 |
region->pDimensionDefinitions[dim].zone_size); |
region->pDimensionDefinitions[dim].zone_size); |
681 |
dimvalue[region->pDimensionDefinitions[dim].dimension] = z; |
this->maindimcase[region->pDimensionDefinitions[dim].dimension] = z; |
682 |
|
this->maindimregno = c | (z << bitpos); |
683 |
dimregno = c | (z << bitpos); |
this->maindimtype = region->pDimensionDefinitions[dim].dimension; |
684 |
|
|
685 |
this->dimtype = dim; |
if (multiSelectKeyDown) { |
686 |
this->dimzone = z; |
if (dimzones[this->maindimtype].count(z)) { |
687 |
|
if (dimzones[this->maindimtype].size() > 1) { |
688 |
|
dimzones[this->maindimtype].erase(z); |
689 |
|
} |
690 |
|
} else { |
691 |
|
dimzones[this->maindimtype].insert(z); |
692 |
|
} |
693 |
|
} else { |
694 |
|
this->dimzones.clear(); |
695 |
|
for (std::map<gig::dimension_t,int>::const_iterator it = this->maindimcase.begin(); |
696 |
|
it != this->maindimcase.end(); ++it) |
697 |
|
{ |
698 |
|
this->dimzones[it->first].insert(it->second); |
699 |
|
} |
700 |
|
} |
701 |
|
|
702 |
focus_line = dim; |
focus_line = dim; |
703 |
if (has_focus()) queue_draw(); |
if (has_focus()) queue_draw(); |
704 |
else grab_focus(); |
else grab_focus(); |
|
dimreg = region->pDimensionRegions[dimregno]; |
|
705 |
dimregion_selected(); |
dimregion_selected(); |
706 |
|
|
707 |
if (event->button == 3) { |
if (event->button == 3) { |
708 |
printf("dimregion right click\n"); |
printf("dimregion right click\n"); |
709 |
popup_menu_inside_dimregion->popup(event->button, event->time); |
popup_menu_inside_dimregion->popup(event->button, event->time); |
710 |
} |
} |
711 |
|
|
712 |
|
queue_draw(); |
713 |
} |
} |
714 |
} |
} |
715 |
return true; |
return true; |
747 |
|
|
748 |
resize.pos = k; |
resize.pos = k; |
749 |
update_after_resize(); |
update_after_resize(); |
750 |
get_window()->invalidate_rect(rect, false); |
get_window()->invalidate_rect(rect, false); // not sufficient ... |
751 |
|
queue_draw(); // ... so do a complete redraw instead. |
752 |
} |
} |
753 |
} else { |
} else { |
754 |
if (is_in_resize_zone(x, y)) { |
if (is_in_resize_zone(x, y)) { |
784 |
int nbZones = region->pDimensionDefinitions[dim].zones; |
int nbZones = region->pDimensionDefinitions[dim].zones; |
785 |
|
|
786 |
int c = 0; |
int c = 0; |
787 |
if (dimregno >= 0) { |
if (maindimregno >= 0) { |
788 |
int mask = ~(((1 << region->pDimensionDefinitions[dim].bits) - 1) << bitpos); |
int mask = ~(((1 << region->pDimensionDefinitions[dim].bits) - 1) << bitpos); |
789 |
c = dimregno & mask; // mask away this dimension |
c = maindimregno & mask; // mask away this dimension |
790 |
} |
} |
791 |
const bool customsplits = |
const bool customsplits = |
792 |
((region->pDimensionDefinitions[dim].split_type == gig::split_type_normal && |
((region->pDimensionDefinitions[dim].split_type == gig::split_type_normal && |
813 |
resize.pos = limit; |
resize.pos = limit; |
814 |
resize.min = prev_limit; |
resize.min = prev_limit; |
815 |
|
|
816 |
int dr = (dimregno >> bitpos) & |
int dr = (maindimregno >> bitpos) & |
817 |
((1 << region->pDimensionDefinitions[dim].bits) - 1); |
((1 << region->pDimensionDefinitions[dim].bits) - 1); |
818 |
resize.selected = dr == iZone ? resize.left : |
resize.selected = dr == iZone ? resize.left : |
819 |
dr == iZone + 1 ? resize.right : resize.none; |
dr == iZone + 1 ? resize.right : resize.none; |
891 |
} |
} |
892 |
} |
} |
893 |
|
|
894 |
void DimRegionChooser::split_dimension_zone() { |
void DimRegionChooser::split_dimension_zone() { |
895 |
printf("split_dimension_zone() type=%d, zone=%d\n", dimtype, dimzone); |
printf("split_dimension_zone() type=%d, zone=%d\n", maindimtype, maindimcase[maindimtype]); |
896 |
try { |
try { |
897 |
region->SplitDimensionZone( |
region->SplitDimensionZone(maindimtype, maindimcase[maindimtype]); |
|
region->pDimensionDefinitions[dimtype].dimension, |
|
|
dimzone |
|
|
); |
|
898 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
899 |
Gtk::MessageDialog msg(e.Message, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(e.Message, false, Gtk::MESSAGE_ERROR); |
900 |
msg.run(); |
msg.run(); |
907 |
} |
} |
908 |
|
|
909 |
void DimRegionChooser::delete_dimension_zone() { |
void DimRegionChooser::delete_dimension_zone() { |
910 |
printf("delete_dimension_zone() type=%d, zone=%d\n", dimtype, dimzone); |
printf("delete_dimension_zone() type=%d, zone=%d\n", maindimtype, maindimcase[maindimtype]); |
911 |
try { |
try { |
912 |
region->DeleteDimensionZone( |
region->DeleteDimensionZone(maindimtype, maindimcase[maindimtype]); |
|
region->pDimensionDefinitions[dimtype].dimension, |
|
|
dimzone |
|
|
); |
|
913 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
914 |
Gtk::MessageDialog msg(e.Message, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(e.Message, false, Gtk::MESSAGE_ERROR); |
915 |
msg.run(); |
msg.run(); |
920 |
} |
} |
921 |
refresh_all(); |
refresh_all(); |
922 |
} |
} |
923 |
|
|
924 |
|
bool DimRegionChooser::onKeyPressed(GdkEventKey* key) { |
925 |
|
//printf("key down\n"); |
926 |
|
if (key->keyval == GDK_KEY_Control_L || key->keyval == GDK_KEY_Control_R) |
927 |
|
multiSelectKeyDown = true; |
928 |
|
} |
929 |
|
|
930 |
|
bool DimRegionChooser::onKeyReleased(GdkEventKey* key) { |
931 |
|
//printf("key up\n"); |
932 |
|
if (key->keyval == GDK_KEY_Control_L || key->keyval == GDK_KEY_Control_R) |
933 |
|
multiSelectKeyDown = false; |
934 |
|
} |
935 |
|
|
936 |
|
gig::DimensionRegion* DimRegionChooser::get_main_dimregion() const { |
937 |
|
if (!region) return NULL; |
938 |
|
return region->pDimensionRegions[maindimregno]; |
939 |
|
} |