1 |
/* |
/* |
2 |
* Copyright (C) 2006-2017 Andreas Persson |
* Copyright (C) 2006-2019 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 |
17 |
* 02110-1301 USA. |
* 02110-1301 USA. |
18 |
*/ |
*/ |
19 |
|
|
20 |
|
#include "global.h" |
21 |
|
#include "compat.h" |
22 |
|
#include "Settings.h" |
23 |
#include <gtkmm/box.h> |
#include <gtkmm/box.h> |
24 |
#include "dimregionchooser.h" |
#include "dimregionchooser.h" |
25 |
#include <cairomm/context.h> |
#include <cairomm/context.h> |
26 |
#include <cairomm/surface.h> |
#include <cairomm/surface.h> |
27 |
#include <gdkmm/cursor.h> |
#include <gdkmm/cursor.h> |
28 |
#include <gdkmm/general.h> |
#include <gdkmm/general.h> |
29 |
|
#if HAS_GDKMM_SEAT |
30 |
|
# include <gdkmm/seat.h> |
31 |
|
#endif |
32 |
#include <glibmm/stringutils.h> |
#include <glibmm/stringutils.h> |
33 |
|
#if HAS_GTKMM_STOCK |
34 |
|
# include <gtkmm/stock.h> |
35 |
|
#endif |
36 |
#include <glibmm/ustring.h> |
#include <glibmm/ustring.h> |
37 |
#include <gtkmm/messagedialog.h> |
#include <gtkmm/messagedialog.h> |
38 |
#include <assert.h> |
#include <assert.h> |
39 |
|
|
|
#include "global.h" |
|
40 |
#include "gfx/builtinpix.h" |
#include "gfx/builtinpix.h" |
41 |
|
|
42 |
//TODO: this function and dimensionCaseOf() from global.h are duplicates, eliminate either one of them! |
//TODO: this function and dimensionCaseOf() from global.h are duplicates, eliminate either one of them! |
87 |
// make sure blue hatched pattern pixmap is loaded |
// make sure blue hatched pattern pixmap is loaded |
88 |
loadBuiltInPix(); |
loadBuiltInPix(); |
89 |
|
|
90 |
// create blue hatched pattern |
// create blue hatched pattern 1 |
91 |
{ |
{ |
92 |
const int width = blueHatchedPattern->get_width(); |
const int width = blueHatchedPattern->get_width(); |
93 |
const int height = blueHatchedPattern->get_height(); |
const int height = blueHatchedPattern->get_height(); |
111 |
} |
} |
112 |
|
|
113 |
Cairo::RefPtr<Cairo::ImageSurface> imageSurface = Cairo::ImageSurface::create( |
Cairo::RefPtr<Cairo::ImageSurface> imageSurface = Cairo::ImageSurface::create( |
114 |
|
#if HAS_CAIROMM_CPP11_ENUMS |
115 |
|
this->blueHatchedPatternARGB->get_pixels(), Cairo::Surface::Format::ARGB32, width, height, stride |
116 |
|
#else |
117 |
this->blueHatchedPatternARGB->get_pixels(), Cairo::FORMAT_ARGB32, width, height, stride |
this->blueHatchedPatternARGB->get_pixels(), Cairo::FORMAT_ARGB32, width, height, stride |
118 |
|
#endif |
119 |
); |
); |
120 |
this->blueHatchedSurfacePattern = Cairo::SurfacePattern::create(imageSurface); |
this->blueHatchedSurfacePattern = Cairo::SurfacePattern::create(imageSurface); |
121 |
|
#if HAS_CAIROMM_CPP11_ENUMS |
122 |
|
this->blueHatchedSurfacePattern->set_extend(Cairo::Pattern::Extend::REPEAT); |
123 |
|
#else |
124 |
this->blueHatchedSurfacePattern->set_extend(Cairo::EXTEND_REPEAT); |
this->blueHatchedSurfacePattern->set_extend(Cairo::EXTEND_REPEAT); |
125 |
|
#endif |
126 |
|
} |
127 |
|
|
128 |
|
// create blue hatched pattern 2 |
129 |
|
{ |
130 |
|
const int width = blueHatchedPattern2->get_width(); |
131 |
|
const int height = blueHatchedPattern2->get_height(); |
132 |
|
const int stride = blueHatchedPattern2->get_rowstride(); |
133 |
|
|
134 |
|
// manually convert from RGBA to ARGB |
135 |
|
this->blueHatchedPattern2ARGB = blueHatchedPattern2->copy(); |
136 |
|
const int pixelSize = stride / width; |
137 |
|
const int totalPixels = width * height; |
138 |
|
assert(pixelSize == 4); |
139 |
|
unsigned char* ptr = this->blueHatchedPattern2ARGB->get_pixels(); |
140 |
|
for (int iPixel = 0; iPixel < totalPixels; ++iPixel, ptr += pixelSize) { |
141 |
|
const unsigned char r = ptr[0]; |
142 |
|
const unsigned char g = ptr[1]; |
143 |
|
const unsigned char b = ptr[2]; |
144 |
|
const unsigned char a = ptr[3]; |
145 |
|
ptr[0] = b; |
146 |
|
ptr[1] = g; |
147 |
|
ptr[2] = r; |
148 |
|
ptr[3] = a; |
149 |
|
} |
150 |
|
|
151 |
|
Cairo::RefPtr<Cairo::ImageSurface> imageSurface = Cairo::ImageSurface::create( |
152 |
|
#if HAS_CAIROMM_CPP11_ENUMS |
153 |
|
this->blueHatchedPattern2ARGB->get_pixels(), Cairo::Surface::Format::ARGB32, width, height, stride |
154 |
|
#else |
155 |
|
this->blueHatchedPattern2ARGB->get_pixels(), Cairo::FORMAT_ARGB32, width, height, stride |
156 |
|
#endif |
157 |
|
); |
158 |
|
this->blueHatchedSurfacePattern2 = Cairo::SurfacePattern::create(imageSurface); |
159 |
|
#if HAS_CAIROMM_CPP11_ENUMS |
160 |
|
this->blueHatchedSurfacePattern2->set_extend(Cairo::Pattern::Extend::REPEAT); |
161 |
|
#else |
162 |
|
this->blueHatchedSurfacePattern2->set_extend(Cairo::EXTEND_REPEAT); |
163 |
|
#endif |
164 |
|
} |
165 |
|
|
166 |
|
// create gray blue hatched pattern |
167 |
|
{ |
168 |
|
const int width = grayBlueHatchedPattern->get_width(); |
169 |
|
const int height = grayBlueHatchedPattern->get_height(); |
170 |
|
const int stride = grayBlueHatchedPattern->get_rowstride(); |
171 |
|
|
172 |
|
// manually convert from RGBA to ARGB |
173 |
|
this->grayBlueHatchedPatternARGB = grayBlueHatchedPattern->copy(); |
174 |
|
const int pixelSize = stride / width; |
175 |
|
const int totalPixels = width * height; |
176 |
|
assert(pixelSize == 4); |
177 |
|
unsigned char* ptr = this->grayBlueHatchedPatternARGB->get_pixels(); |
178 |
|
for (int iPixel = 0; iPixel < totalPixels; ++iPixel, ptr += pixelSize) { |
179 |
|
const unsigned char r = ptr[0]; |
180 |
|
const unsigned char g = ptr[1]; |
181 |
|
const unsigned char b = ptr[2]; |
182 |
|
const unsigned char a = ptr[3]; |
183 |
|
ptr[0] = b; |
184 |
|
ptr[1] = g; |
185 |
|
ptr[2] = r; |
186 |
|
ptr[3] = a; |
187 |
|
} |
188 |
|
|
189 |
|
Cairo::RefPtr<Cairo::ImageSurface> imageSurface = Cairo::ImageSurface::create( |
190 |
|
#if HAS_CAIROMM_CPP11_ENUMS |
191 |
|
this->grayBlueHatchedPatternARGB->get_pixels(), Cairo::Surface::Format::ARGB32, width, height, stride |
192 |
|
#else |
193 |
|
this->grayBlueHatchedPatternARGB->get_pixels(), Cairo::FORMAT_ARGB32, width, height, stride |
194 |
|
#endif |
195 |
|
); |
196 |
|
this->grayBlueHatchedSurfacePattern = Cairo::SurfacePattern::create(imageSurface); |
197 |
|
#if HAS_CAIROMM_CPP11_ENUMS |
198 |
|
this->grayBlueHatchedSurfacePattern->set_extend(Cairo::Pattern::Extend::REPEAT); |
199 |
|
#else |
200 |
|
this->grayBlueHatchedSurfacePattern->set_extend(Cairo::EXTEND_REPEAT); |
201 |
|
#endif |
202 |
} |
} |
203 |
|
|
204 |
instrument = 0; |
instrument = 0; |
218 |
const Glib::ustring txtUseCheckBoxAllRegions = |
const Glib::ustring txtUseCheckBoxAllRegions = |
219 |
_("Use checkbox 'all regions' to control whether this should apply to all regions."); |
_("Use checkbox 'all regions' to control whether this should apply to all regions."); |
220 |
|
|
221 |
actionGroup = Gtk::ActionGroup::create(); |
actionGroup = ActionGroup::create(); |
222 |
actionSplitDimZone = Gtk::Action::create("SplitDimZone", _("Split Dimensions Zone"), txtUseCheckBoxAllRegions); |
#if USE_GLIB_ACTION |
223 |
|
actionSplitDimZone = actionGroup->add_action( |
224 |
|
"SplitDimZone", sigc::mem_fun(*this, &DimRegionChooser::split_dimension_zone) |
225 |
|
); |
226 |
|
actionDeleteDimZone = actionGroup->add_action( |
227 |
|
"DeleteDimZone", sigc::mem_fun(*this, &DimRegionChooser::delete_dimension_zone) |
228 |
|
); |
229 |
|
insert_action_group("PopupMenuInsideDimRegion", actionGroup); |
230 |
|
#else |
231 |
|
actionSplitDimZone = Action::create("SplitDimZone", _("Split Dimensions Zone"), txtUseCheckBoxAllRegions); |
232 |
actionSplitDimZone->set_tooltip(txtUseCheckBoxAllRegions); //FIXME: doesn't work? why??? |
actionSplitDimZone->set_tooltip(txtUseCheckBoxAllRegions); //FIXME: doesn't work? why??? |
233 |
actionGroup->add( |
actionGroup->add( |
234 |
actionSplitDimZone, |
actionSplitDimZone, |
240 |
actionDeleteDimZone, |
actionDeleteDimZone, |
241 |
sigc::mem_fun(*this, &DimRegionChooser::delete_dimension_zone) |
sigc::mem_fun(*this, &DimRegionChooser::delete_dimension_zone) |
242 |
); |
); |
243 |
|
#endif |
244 |
|
|
245 |
|
#if USE_GTKMM_BUILDER |
246 |
|
uiManager = Gtk::Builder::create(); |
247 |
|
Glib::ustring ui_info = |
248 |
|
"<interface>" |
249 |
|
" <menu id='menu-PopupMenuInsideDimRegion'>" |
250 |
|
" <section>" |
251 |
|
" <item id='item-split'>" |
252 |
|
" <attribute name='label' translatable='yes'>Split Dimensions Zone</attribute>" |
253 |
|
" <attribute name='action'>PopupMenuInsideDimRegion.SplitDimZone</attribute>" |
254 |
|
" </item>" |
255 |
|
" <item id='item-delete'>" |
256 |
|
" <attribute name='label' translatable='yes'>Delete Dimension Zone</attribute>" |
257 |
|
" <attribute name='action'>PopupMenuInsideDimRegion.DeleteDimZone</attribute>" |
258 |
|
" </item>" |
259 |
|
" </section>" |
260 |
|
" </menu>" |
261 |
|
"</interface>"; |
262 |
|
uiManager->add_from_string(ui_info); |
263 |
|
|
264 |
|
popup_menu_inside_dimregion = new Gtk::Menu( |
265 |
|
Glib::RefPtr<Gio::Menu>::cast_dynamic( |
266 |
|
uiManager->get_object("menu-PopupMenuInsideDimRegion") |
267 |
|
) |
268 |
|
); |
269 |
|
#else |
270 |
uiManager = Gtk::UIManager::create(); |
uiManager = Gtk::UIManager::create(); |
271 |
uiManager->insert_action_group(actionGroup); |
uiManager->insert_action_group(actionGroup); |
272 |
Glib::ustring ui_info = |
Glib::ustring ui_info = |
286 |
// popup_menu_outside_dimregion = dynamic_cast<Gtk::Menu*>( |
// popup_menu_outside_dimregion = dynamic_cast<Gtk::Menu*>( |
287 |
// uiManager->get_widget("/PopupMenuOutsideDimRegion")); |
// uiManager->get_widget("/PopupMenuOutsideDimRegion")); |
288 |
|
|
289 |
|
#endif // USE_GTKMM_BUILDER |
290 |
|
|
291 |
|
|
292 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
293 |
|
# warning GTKMM4 event registration code missing for dimregionchooser! |
294 |
|
//add_events(Gdk::EventMask::BUTTON_PRESS_MASK); |
295 |
|
#else |
296 |
add_events(Gdk::BUTTON_PRESS_MASK | Gdk::POINTER_MOTION_MASK | |
add_events(Gdk::BUTTON_PRESS_MASK | Gdk::POINTER_MOTION_MASK | |
297 |
Gdk::POINTER_MOTION_HINT_MASK); |
Gdk::POINTER_MOTION_HINT_MASK); |
298 |
|
#endif |
299 |
|
|
300 |
labels_changed = true; |
labels_changed = true; |
301 |
|
|
303 |
"Right click here for options on altering dimension zones. Press and " |
"Right click here for options on altering dimension zones. Press and " |
304 |
"hold CTRL key for selecting multiple dimension zones simultaniously." |
"hold CTRL key for selecting multiple dimension zones simultaniously." |
305 |
)); |
)); |
306 |
|
|
307 |
|
Settings::singleton()->showTooltips.get_proxy().signal_changed().connect( |
308 |
|
sigc::mem_fun(*this, &DimRegionChooser::on_show_tooltips_changed) |
309 |
|
); |
310 |
|
on_show_tooltips_changed(); |
311 |
|
|
312 |
window.signal_key_press_event().connect( |
window.signal_key_press_event().connect( |
313 |
sigc::mem_fun(*this, &DimRegionChooser::onKeyPressed) |
sigc::mem_fun(*this, &DimRegionChooser::onKeyPressed) |
321 |
{ |
{ |
322 |
} |
} |
323 |
|
|
324 |
|
void DimRegionChooser::on_show_tooltips_changed() { |
325 |
|
const bool b = Settings::singleton()->showTooltips; |
326 |
|
|
327 |
|
set_has_tooltip(b); |
328 |
|
} |
329 |
|
|
330 |
void DimRegionChooser::setModifyBothChannels(bool b) { |
void DimRegionChooser::setModifyBothChannels(bool b) { |
331 |
modifybothchannels = b; |
modifybothchannels = b; |
332 |
|
// redraw required parts |
333 |
|
queue_draw(); |
334 |
} |
} |
335 |
|
|
336 |
void DimRegionChooser::setModifyAllDimensionRegions(bool b) { |
void DimRegionChooser::setModifyAllDimensionRegions(bool b) { |
337 |
modifyalldimregs = b; |
modifyalldimregs = b; |
338 |
|
// redraw required parts |
339 |
|
queue_draw(); |
340 |
} |
} |
341 |
|
|
342 |
void DimRegionChooser::setModifyAllRegions(bool b) { |
void DimRegionChooser::setModifyAllRegions(bool b) { |
343 |
modifyallregions = b; |
modifyallregions = b; |
344 |
|
|
345 |
|
#if USE_GTKMM_BUILDER |
346 |
|
auto menuItemSplit = Glib::RefPtr<Gio::MenuItem>::cast_dynamic( |
347 |
|
uiManager->get_object("item-split") |
348 |
|
); |
349 |
|
auto menuItemDelete = Glib::RefPtr<Gio::MenuItem>::cast_dynamic( |
350 |
|
uiManager->get_object("item-delete") |
351 |
|
); |
352 |
|
menuItemDelete->set_label(b ? _("Delete Dimension Zone [ALL REGIONS]") : _("Delete Dimension Zone")); |
353 |
|
menuItemSplit->set_label(b ? _("Split Dimensions Zone [ALL REGIONS]") : _("Split Dimensions Zone")); |
354 |
|
#else |
355 |
actionDeleteDimZone->set_label(b ? _("Delete Dimension Zone [ALL REGIONS]") : _("Delete Dimension Zone")); |
actionDeleteDimZone->set_label(b ? _("Delete Dimension Zone [ALL REGIONS]") : _("Delete Dimension Zone")); |
356 |
actionSplitDimZone->set_label(b ? _("Split Dimensions Zone [ALL REGIONS]") : _("Split Dimensions Zone")); |
actionSplitDimZone->set_label(b ? _("Split Dimensions Zone [ALL REGIONS]") : _("Split Dimensions Zone")); |
357 |
|
#endif |
358 |
|
|
359 |
|
// redraw required parts |
360 |
|
queue_draw(); |
361 |
|
} |
362 |
|
|
363 |
|
void DimRegionChooser::drawIconsFor( |
364 |
|
gig::dimension_t dimension, uint zone, |
365 |
|
const Cairo::RefPtr<Cairo::Context>& cr, |
366 |
|
int x, int y, int w, int h) |
367 |
|
{ |
368 |
|
DimensionCase dimCase; |
369 |
|
dimCase[dimension] = zone; |
370 |
|
|
371 |
|
std::vector<gig::DimensionRegion*> dimregs = |
372 |
|
dimensionRegionsMatching(dimCase, region, true); |
373 |
|
|
374 |
|
if (dimregs.empty()) return; |
375 |
|
|
376 |
|
int iSampleRefs = 0; |
377 |
|
int iLoops = 0; |
378 |
|
|
379 |
|
for (uint i = 0; i < dimregs.size(); ++i) { |
380 |
|
if (dimregs[i]->pSample) iSampleRefs++; |
381 |
|
if (dimregs[i]->SampleLoops) iLoops++; |
382 |
|
} |
383 |
|
|
384 |
|
bool bShowLoopSymbol = (iLoops > 0); |
385 |
|
bool bShowSampleRefSymbol = (iSampleRefs < dimregs.size()); |
386 |
|
|
387 |
|
if (bShowLoopSymbol || bShowSampleRefSymbol) { |
388 |
|
const int margin = 1; |
389 |
|
|
390 |
|
cr->save(); |
391 |
|
cr->set_line_width(1); |
392 |
|
cr->rectangle(x, y + margin, w, h - 2*margin); |
393 |
|
cr->clip(); |
394 |
|
if (bShowSampleRefSymbol) { |
395 |
|
const int wPic = 8; |
396 |
|
const int hPic = 8; |
397 |
|
Gdk::Cairo::set_source_pixbuf( |
398 |
|
cr, (iSampleRefs) ? yellowDot : redDot, |
399 |
|
x + (w-wPic)/2.f, |
400 |
|
y + ( |
401 |
|
(bShowLoopSymbol) ? margin : (h-hPic)/2.f |
402 |
|
) |
403 |
|
); |
404 |
|
cr->paint(); |
405 |
|
} |
406 |
|
if (bShowLoopSymbol) { |
407 |
|
const int wPic = 12; |
408 |
|
const int hPic = 14; |
409 |
|
Gdk::Cairo::set_source_pixbuf( |
410 |
|
cr, (iLoops == dimregs.size()) ? blackLoop : grayLoop, |
411 |
|
x + (w-wPic)/2.f, |
412 |
|
y + ( |
413 |
|
(bShowSampleRefSymbol) ? h - hPic - margin : (h-hPic)/2.f |
414 |
|
) |
415 |
|
); |
416 |
|
cr->paint(); |
417 |
|
} |
418 |
|
cr->restore(); |
419 |
|
} |
420 |
} |
} |
421 |
|
|
422 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
530 |
const Gdk::Color fg = get_style()->get_fg(get_state()); |
const Gdk::Color fg = get_style()->get_fg(get_state()); |
531 |
#else |
#else |
532 |
const Gdk::RGBA fg = |
const Gdk::RGBA fg = |
533 |
|
# if GTKMM_MAJOR_VERSION >= 3 |
534 |
|
get_style_context()->get_color(); |
535 |
|
# else |
536 |
get_style_context()->get_color(get_state_flags()); |
get_style_context()->get_color(get_state_flags()); |
537 |
|
# endif |
538 |
#endif |
#endif |
539 |
Gdk::Cairo::set_source_rgba(cr, fg); |
Gdk::Cairo::set_source_rgba(cr, fg); |
540 |
cr->move_to(4, int(y + (h - text_h) / 2 + 0.5)); |
cr->move_to(4, int(y + (h - text_h) / 2 + 0.5)); |
633 |
bool isMainSelection = |
bool isMainSelection = |
634 |
this->maindimcase.find(dimension) != this->maindimcase.end() && |
this->maindimcase.find(dimension) != this->maindimcase.end() && |
635 |
this->maindimcase[dimension] == j; |
this->maindimcase[dimension] == j; |
636 |
|
bool isCheckBoxSelected = |
637 |
|
modifyalldimregs || |
638 |
|
(modifybothchannels && |
639 |
|
dimension == gig::dimension_samplechannel); |
640 |
if (isMainSelection) |
if (isMainSelection) |
641 |
Gdk::Cairo::set_source_rgba(cr, blue); |
Gdk::Cairo::set_source_rgba(cr, blue); |
642 |
else if (isSelectedZone) |
else if (isSelectedZone) |
643 |
|
cr->set_source(blueHatchedSurfacePattern2); |
644 |
|
else if (isCheckBoxSelected) |
645 |
cr->set_source(blueHatchedSurfacePattern); |
cr->set_source(blueHatchedSurfacePattern); |
646 |
else |
else |
647 |
Gdk::Cairo::set_source_rgba(cr, white); |
Gdk::Cairo::set_source_rgba(cr, white); |
648 |
|
|
649 |
cr->rectangle(prevX + 1, y + 1, x - prevX - 1, h - 1); |
const int wZone = x - prevX - 1; |
650 |
|
|
651 |
|
cr->rectangle(prevX + 1, y + 1, wZone, h - 1); |
652 |
cr->fill(); |
cr->fill(); |
653 |
|
|
654 |
|
// draw icons |
655 |
|
drawIconsFor(dimension, j, cr, prevX, y, wZone, h); |
656 |
|
|
657 |
// draw text showing the beginning of the dimension zone |
// draw text showing the beginning of the dimension zone |
658 |
// as numeric value to the user |
// as numeric value to the user |
659 |
{ |
{ |
706 |
cr->stroke(); |
cr->stroke(); |
707 |
|
|
708 |
if (j != 0) { |
if (j != 0) { |
709 |
|
const int wZone = x - prevX - 1; |
710 |
|
|
711 |
// draw fill for zone |
// draw fill for zone |
712 |
bool isSelectedZone = this->dimzones[dimension].count(j-1); |
bool isSelectedZone = this->dimzones[dimension].count(j-1); |
713 |
bool isMainSelection = |
bool isMainSelection = |
714 |
this->maindimcase.find(dimension) != this->maindimcase.end() && |
this->maindimcase.find(dimension) != this->maindimcase.end() && |
715 |
this->maindimcase[dimension] == (j-1); |
this->maindimcase[dimension] == (j-1); |
716 |
|
bool isCheckBoxSelected = |
717 |
|
modifyalldimregs || |
718 |
|
(modifybothchannels && |
719 |
|
dimension == gig::dimension_samplechannel); |
720 |
if (isMainSelection) |
if (isMainSelection) |
721 |
Gdk::Cairo::set_source_rgba(cr, blue); |
Gdk::Cairo::set_source_rgba(cr, blue); |
722 |
else if (isSelectedZone) |
else if (isSelectedZone) |
723 |
|
cr->set_source(blueHatchedSurfacePattern2); |
724 |
|
else if (isCheckBoxSelected) |
725 |
cr->set_source(blueHatchedSurfacePattern); |
cr->set_source(blueHatchedSurfacePattern); |
726 |
else |
else |
727 |
Gdk::Cairo::set_source_rgba(cr, white); |
Gdk::Cairo::set_source_rgba(cr, white); |
728 |
cr->rectangle(prevX + 1, y + 1, x - prevX - 1, h - 1); |
cr->rectangle(prevX + 1, y + 1, wZone, h - 1); |
729 |
cr->fill(); |
cr->fill(); |
730 |
|
|
731 |
|
// draw icons |
732 |
|
drawIconsFor(dimension, j - 1, cr, prevX, y, wZone, h); |
733 |
|
|
734 |
// draw text showing the beginning of the dimension zone |
// draw text showing the beginning of the dimension zone |
735 |
// as numeric value to the user |
// as numeric value to the user |
736 |
{ |
{ |
1019 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
1020 |
get_window()->pointer_ungrab(event->time); |
get_window()->pointer_ungrab(event->time); |
1021 |
#else |
#else |
1022 |
|
# if GTKMM_MAJOR_VERSION < 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION < 20) |
1023 |
Glib::wrap(event->device, true)->ungrab(event->time); |
Glib::wrap(event->device, true)->ungrab(event->time); |
1024 |
|
# else |
1025 |
|
Glib::wrap(event->device, true)->get_seat()->ungrab(); |
1026 |
|
# endif |
1027 |
#endif |
#endif |
1028 |
resize.active = false; |
resize.active = false; |
1029 |
|
|
1052 |
Gdk::Cursor(Gdk::SB_H_DOUBLE_ARROW), |
Gdk::Cursor(Gdk::SB_H_DOUBLE_ARROW), |
1053 |
event->time); |
event->time); |
1054 |
#else |
#else |
1055 |
|
# if GTKMM_MAJOR_VERSION < 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION < 20) |
1056 |
Glib::wrap(event->device, true)->grab(get_window(), |
Glib::wrap(event->device, true)->grab(get_window(), |
1057 |
Gdk::OWNERSHIP_NONE, |
Gdk::OWNERSHIP_NONE, |
1058 |
false, |
false, |
1061 |
Gdk::POINTER_MOTION_HINT_MASK, |
Gdk::POINTER_MOTION_HINT_MASK, |
1062 |
Gdk::Cursor::create(Gdk::SB_H_DOUBLE_ARROW), |
Gdk::Cursor::create(Gdk::SB_H_DOUBLE_ARROW), |
1063 |
event->time); |
event->time); |
1064 |
|
# else |
1065 |
|
Glib::wrap(event->device, true)->get_seat()->grab( |
1066 |
|
get_window(), |
1067 |
|
Gdk::SeatCapabilities::SEAT_CAPABILITY_ALL_POINTING, |
1068 |
|
false, |
1069 |
|
Gdk::Cursor::create( |
1070 |
|
Glib::wrap(event->device, true)->get_seat()->get_display(), |
1071 |
|
Gdk::SB_H_DOUBLE_ARROW |
1072 |
|
), |
1073 |
|
reinterpret_cast<GdkEvent*>(event) |
1074 |
|
); |
1075 |
|
# endif |
1076 |
#endif |
#endif |
1077 |
resize.active = true; |
resize.active = true; |
1078 |
} else { |
} else { |
1165 |
{ |
{ |
1166 |
Glib::RefPtr<Gdk::Window> window = get_window(); |
Glib::RefPtr<Gdk::Window> window = get_window(); |
1167 |
int x, y; |
int x, y; |
1168 |
|
#if HAS_GDKMM_SEAT |
1169 |
|
x = event->x; |
1170 |
|
y = event->y; |
1171 |
|
Gdk::ModifierType state = Gdk::ModifierType(event->state); |
1172 |
|
#else |
1173 |
Gdk::ModifierType state = Gdk::ModifierType(0); |
Gdk::ModifierType state = Gdk::ModifierType(0); |
1174 |
window->get_pointer(x, y, state); |
window->get_pointer(x, y, state); |
1175 |
|
#endif |
1176 |
|
|
1177 |
if (resize.active) { |
if (resize.active) { |
1178 |
int w = get_width(); |
int w = get_width(); |
1208 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
1209 |
window->set_cursor(Gdk::Cursor(Gdk::SB_H_DOUBLE_ARROW)); |
window->set_cursor(Gdk::Cursor(Gdk::SB_H_DOUBLE_ARROW)); |
1210 |
#else |
#else |
1211 |
window->set_cursor(Gdk::Cursor::create(Gdk::SB_H_DOUBLE_ARROW)); |
window->set_cursor( |
1212 |
|
# if GTKMM_MAJOR_VERSION < 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION < 20) |
1213 |
|
Gdk::Cursor::create(Gdk::SB_H_DOUBLE_ARROW) |
1214 |
|
# else |
1215 |
|
Gdk::Cursor::create( |
1216 |
|
Glib::wrap(event->device, true)->get_seat()->get_display(), |
1217 |
|
Gdk::SB_H_DOUBLE_ARROW |
1218 |
|
) |
1219 |
|
# endif |
1220 |
|
); |
1221 |
#endif |
#endif |
1222 |
cursor_is_resize = true; |
cursor_is_resize = true; |
1223 |
} |
} |
1491 |
GDK_KEY_Control_R; |
GDK_KEY_Control_R; |
1492 |
#endif |
#endif |
1493 |
|
|
1494 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
1495 |
|
bool DimRegionChooser::onKeyPressed(Gdk::EventKey& _key) { |
1496 |
|
GdkEventKey* key = _key.gobj(); |
1497 |
|
#else |
1498 |
bool DimRegionChooser::onKeyPressed(GdkEventKey* key) { |
bool DimRegionChooser::onKeyPressed(GdkEventKey* key) { |
1499 |
|
#endif |
1500 |
//printf("key down 0x%x\n", key->keyval); |
//printf("key down 0x%x\n", key->keyval); |
1501 |
if (key->keyval == GDK_KEY_Control_L || key->keyval == GDK_KEY_Control_R) |
if (key->keyval == GDK_KEY_Control_L || key->keyval == GDK_KEY_Control_R) |
1502 |
multiSelectKeyDown = true; |
multiSelectKeyDown = true; |
1517 |
return false; |
return false; |
1518 |
} |
} |
1519 |
|
|
1520 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
1521 |
|
bool DimRegionChooser::onKeyReleased(Gdk::EventKey& _key) { |
1522 |
|
GdkEventKey* key = _key.gobj(); |
1523 |
|
#else |
1524 |
bool DimRegionChooser::onKeyReleased(GdkEventKey* key) { |
bool DimRegionChooser::onKeyReleased(GdkEventKey* key) { |
1525 |
|
#endif |
1526 |
//printf("key up 0x%x\n", key->keyval); |
//printf("key up 0x%x\n", key->keyval); |
1527 |
if (key->keyval == GDK_KEY_Control_L || key->keyval == GDK_KEY_Control_R) |
if (key->keyval == GDK_KEY_Control_L || key->keyval == GDK_KEY_Control_R) |
1528 |
multiSelectKeyDown = false; |
multiSelectKeyDown = false; |
1537 |
// (which is supposed to switch between regions) |
// (which is supposed to switch between regions) |
1538 |
if (primaryKeyDown) return false; |
if (primaryKeyDown) return false; |
1539 |
|
|
1540 |
|
// avoid conflict with Alt+Shift+Left and Alt+Shift+Right accelerators on |
1541 |
|
// mainwindow |
1542 |
|
if (shiftKeyDown) return false; |
1543 |
|
|
1544 |
if (key->keyval == GDK_KEY_Left) |
if (key->keyval == GDK_KEY_Left) |
1545 |
select_prev_dimzone(); |
select_prev_dimzone(); |
1546 |
if (key->keyval == GDK_KEY_Right) |
if (key->keyval == GDK_KEY_Right) |
1601 |
return false; //.selection failed |
return false; //.selection failed |
1602 |
} |
} |
1603 |
|
|
1604 |
void DimRegionChooser::select_next_dimzone() { |
void DimRegionChooser::select_next_dimzone(bool add) { |
1605 |
select_dimzone_by_dir(+1); |
select_dimzone_by_dir(+1, add); |
1606 |
} |
} |
1607 |
|
|
1608 |
void DimRegionChooser::select_prev_dimzone() { |
void DimRegionChooser::select_prev_dimzone(bool add) { |
1609 |
select_dimzone_by_dir(-1); |
select_dimzone_by_dir(-1, add); |
1610 |
} |
} |
1611 |
|
|
1612 |
void DimRegionChooser::select_dimzone_by_dir(int dir) { |
void DimRegionChooser::select_dimzone_by_dir(int dir, bool add) { |
1613 |
if (!region) return; |
if (!region) return; |
1614 |
if (!region->Dimensions) return; |
if (!region->Dimensions) return; |
1615 |
if (focus_line < 0) focus_line = 0; |
if (focus_line < 0) focus_line = 0; |
1621 |
return; |
return; |
1622 |
} |
} |
1623 |
|
|
1624 |
if (maindimcase.empty()) { |
// commented out: re-evaluate maindimcase, since it might not been reset from a previous instrument which causes errors if it got different dimension types |
1625 |
|
//if (maindimcase.empty()) { |
1626 |
maindimcase = dimensionCaseOf(region->pDimensionRegions[maindimregno]); |
maindimcase = dimensionCaseOf(region->pDimensionRegions[maindimregno]); |
1627 |
if (maindimcase.empty()) { |
if (maindimcase.empty()) { |
1628 |
printf("caseOfDimregion(%d) -> empty\n", maindimregno); |
printf("caseOfDimregion(%d) -> empty\n", maindimregno); |
1629 |
return; |
return; |
1630 |
} |
} |
1631 |
} |
//} |
1632 |
|
|
1633 |
int z = (dir > 0) ? maindimcase[maindimtype] + 1 : maindimcase[maindimtype] - 1; |
int z = (dir > 0) ? maindimcase[maindimtype] + 1 : maindimcase[maindimtype] - 1; |
1634 |
if (z < 0) z = 0; |
if (z < 0) z = 0; |
1645 |
|
|
1646 |
maindimregno = getDimensionRegionIndex(dr); |
maindimregno = getDimensionRegionIndex(dr); |
1647 |
|
|
1648 |
// reset selected dimregion zones |
if (!add) { |
1649 |
dimzones.clear(); |
// reset selected dimregion zones |
1650 |
|
dimzones.clear(); |
1651 |
|
} |
1652 |
for (DimensionCase::const_iterator it = maindimcase.begin(); |
for (DimensionCase::const_iterator it = maindimcase.begin(); |
1653 |
it != maindimcase.end(); ++it) |
it != maindimcase.end(); ++it) |
1654 |
{ |
{ |