--- gigedit/trunk/src/gigedit/dimregionchooser.cpp 2017/04/27 17:31:50 3132 +++ gigedit/trunk/src/gigedit/dimregionchooser.cpp 2017/05/22 18:58:46 3202 @@ -17,6 +17,7 @@ * 02110-1301 USA. */ +#include "global.h" #include #include "dimregionchooser.h" #include @@ -24,11 +25,11 @@ #include #include #include +#include #include #include #include -#include "global.h" #include "gfx/builtinpix.h" //TODO: this function and dimensionCaseOf() from global.h are duplicates, eliminate either one of them! @@ -109,6 +110,36 @@ this->blueHatchedSurfacePattern->set_extend(Cairo::EXTEND_REPEAT); } + // create gray blue hatched pattern + { + const int width = grayBlueHatchedPattern->get_width(); + const int height = grayBlueHatchedPattern->get_height(); + const int stride = grayBlueHatchedPattern->get_rowstride(); + + // manually convert from RGBA to ARGB + this->grayBlueHatchedPatternARGB = grayBlueHatchedPattern->copy(); + const int pixelSize = stride / width; + const int totalPixels = width * height; + assert(pixelSize == 4); + unsigned char* ptr = this->grayBlueHatchedPatternARGB->get_pixels(); + for (int iPixel = 0; iPixel < totalPixels; ++iPixel, ptr += pixelSize) { + const unsigned char r = ptr[0]; + const unsigned char g = ptr[1]; + const unsigned char b = ptr[2]; + const unsigned char a = ptr[3]; + ptr[0] = b; + ptr[1] = g; + ptr[2] = r; + ptr[3] = a; + } + + Cairo::RefPtr imageSurface = Cairo::ImageSurface::create( + this->grayBlueHatchedPatternARGB->get_pixels(), Cairo::FORMAT_ARGB32, width, height, stride + ); + this->grayBlueHatchedSurfacePattern = Cairo::SurfacePattern::create(imageSurface); + this->grayBlueHatchedSurfacePattern->set_extend(Cairo::EXTEND_REPEAT); + } + instrument = 0; region = 0; maindimregno = -1; @@ -183,10 +214,14 @@ void DimRegionChooser::setModifyBothChannels(bool b) { modifybothchannels = b; + // redraw required parts + queue_draw(); } void DimRegionChooser::setModifyAllDimensionRegions(bool b) { modifyalldimregs = b; + // redraw required parts + queue_draw(); } void DimRegionChooser::setModifyAllRegions(bool b) { @@ -194,6 +229,9 @@ actionDeleteDimZone->set_label(b ? _("Delete Dimension Zone [ALL REGIONS]") : _("Delete Dimension Zone")); actionSplitDimZone->set_label(b ? _("Split Dimensions Zone [ALL REGIONS]") : _("Split Dimensions Zone")); + + // redraw required parts + queue_draw(); } #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 @@ -406,10 +444,16 @@ bool isMainSelection = this->maindimcase.find(dimension) != this->maindimcase.end() && this->maindimcase[dimension] == j; + bool isCheckBoxSelected = + modifyalldimregs || + (modifybothchannels && + dimension == gig::dimension_samplechannel); if (isMainSelection) Gdk::Cairo::set_source_rgba(cr, blue); else if (isSelectedZone) cr->set_source(blueHatchedSurfacePattern); + else if (isCheckBoxSelected) + cr->set_source(grayBlueHatchedSurfacePattern); else Gdk::Cairo::set_source_rgba(cr, white); @@ -473,10 +517,16 @@ bool isMainSelection = this->maindimcase.find(dimension) != this->maindimcase.end() && this->maindimcase[dimension] == (j-1); + bool isCheckBoxSelected = + modifyalldimregs || + (modifybothchannels && + dimension == gig::dimension_samplechannel); if (isMainSelection) Gdk::Cairo::set_source_rgba(cr, blue); else if (isSelectedZone) cr->set_source(blueHatchedSurfacePattern); + else if (isCheckBoxSelected) + cr->set_source(grayBlueHatchedSurfacePattern); else Gdk::Cairo::set_source_rgba(cr, white); cr->rectangle(prevX + 1, y + 1, x - prevX - 1, h - 1); @@ -1246,6 +1296,10 @@ // (which is supposed to switch between regions) if (primaryKeyDown) return false; + // avoid conflict with Alt+Shift+Left and Alt+Shift+Right accelerators on + // mainwindow + if (shiftKeyDown) return false; + if (key->keyval == GDK_KEY_Left) select_prev_dimzone(); if (key->keyval == GDK_KEY_Right) @@ -1306,15 +1360,15 @@ return false; //.selection failed } -void DimRegionChooser::select_next_dimzone() { - select_dimzone_by_dir(+1); +void DimRegionChooser::select_next_dimzone(bool add) { + select_dimzone_by_dir(+1, add); } -void DimRegionChooser::select_prev_dimzone() { - select_dimzone_by_dir(-1); +void DimRegionChooser::select_prev_dimzone(bool add) { + select_dimzone_by_dir(-1, add); } -void DimRegionChooser::select_dimzone_by_dir(int dir) { +void DimRegionChooser::select_dimzone_by_dir(int dir, bool add) { if (!region) return; if (!region->Dimensions) return; if (focus_line < 0) focus_line = 0; @@ -1349,8 +1403,10 @@ maindimregno = getDimensionRegionIndex(dr); - // reset selected dimregion zones - dimzones.clear(); + if (!add) { + // reset selected dimregion zones + dimzones.clear(); + } for (DimensionCase::const_iterator it = maindimcase.begin(); it != maindimcase.end(); ++it) {