/[svn]/gigedit/trunk/src/gigedit/dimregionchooser.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/dimregionchooser.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3131 by schoenebeck, Thu Apr 27 17:28:01 2017 UTC revision 3147 by schoenebeck, Wed May 3 21:23:16 2017 UTC
# Line 29  Line 29 
29  #include <assert.h>  #include <assert.h>
30    
31  #include "global.h"  #include "global.h"
32  #include "builtinpix.h"  #include "gfx/builtinpix.h"
33    
34  //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!
35  static DimensionCase caseOfDimRegion(gig::DimensionRegion* dr, bool* isValidZone) {  static DimensionCase caseOfDimRegion(gig::DimensionRegion* dr, bool* isValidZone) {
# Line 109  DimRegionChooser::DimRegionChooser(Gtk:: Line 109  DimRegionChooser::DimRegionChooser(Gtk::
109          this->blueHatchedSurfacePattern->set_extend(Cairo::EXTEND_REPEAT);          this->blueHatchedSurfacePattern->set_extend(Cairo::EXTEND_REPEAT);
110      }      }
111    
112        // create gray blue hatched pattern
113        {
114            const int width = grayBlueHatchedPattern->get_width();
115            const int height = grayBlueHatchedPattern->get_height();
116            const int stride = grayBlueHatchedPattern->get_rowstride();
117    
118            // manually convert from RGBA to ARGB
119            this->grayBlueHatchedPatternARGB = grayBlueHatchedPattern->copy();
120            const int pixelSize = stride / width;
121            const int totalPixels = width * height;
122            assert(pixelSize == 4);
123            unsigned char* ptr = this->grayBlueHatchedPatternARGB->get_pixels();
124            for (int iPixel = 0; iPixel < totalPixels; ++iPixel, ptr += pixelSize) {
125                const unsigned char r = ptr[0];
126                const unsigned char g = ptr[1];
127                const unsigned char b = ptr[2];
128                const unsigned char a = ptr[3];
129                ptr[0] = b;
130                ptr[1] = g;
131                ptr[2] = r;
132                ptr[3] = a;
133            }
134    
135            Cairo::RefPtr<Cairo::ImageSurface> imageSurface = Cairo::ImageSurface::create(
136                this->grayBlueHatchedPatternARGB->get_pixels(), Cairo::FORMAT_ARGB32, width, height, stride
137            );
138            this->grayBlueHatchedSurfacePattern = Cairo::SurfacePattern::create(imageSurface);
139            this->grayBlueHatchedSurfacePattern->set_extend(Cairo::EXTEND_REPEAT);
140        }
141    
142      instrument = 0;      instrument = 0;
143      region = 0;      region = 0;
144      maindimregno = -1;      maindimregno = -1;
# Line 183  DimRegionChooser::~DimRegionChooser() Line 213  DimRegionChooser::~DimRegionChooser()
213    
214  void DimRegionChooser::setModifyBothChannels(bool b) {  void DimRegionChooser::setModifyBothChannels(bool b) {
215      modifybothchannels = b;      modifybothchannels = b;
216        // redraw required parts
217        queue_draw();
218  }  }
219    
220  void DimRegionChooser::setModifyAllDimensionRegions(bool b) {  void DimRegionChooser::setModifyAllDimensionRegions(bool b) {
221      modifyalldimregs = b;      modifyalldimregs = b;
222        // redraw required parts
223        queue_draw();
224  }  }
225    
226  void DimRegionChooser::setModifyAllRegions(bool b) {  void DimRegionChooser::setModifyAllRegions(bool b) {
# Line 194  void DimRegionChooser::setModifyAllRegio Line 228  void DimRegionChooser::setModifyAllRegio
228    
229      actionDeleteDimZone->set_label(b ? _("Delete Dimension Zone [ALL REGIONS]") : _("Delete Dimension Zone"));      actionDeleteDimZone->set_label(b ? _("Delete Dimension Zone [ALL REGIONS]") : _("Delete Dimension Zone"));
230      actionSplitDimZone->set_label(b ? _("Split Dimensions Zone [ALL REGIONS]") : _("Split Dimensions Zone"));      actionSplitDimZone->set_label(b ? _("Split Dimensions Zone [ALL REGIONS]") : _("Split Dimensions Zone"));
231    
232        // redraw required parts
233        queue_draw();
234  }  }
235    
236  #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
# Line 406  bool DimRegionChooser::on_draw(const Cai Line 443  bool DimRegionChooser::on_draw(const Cai
443                          bool isMainSelection =                          bool isMainSelection =
444                              this->maindimcase.find(dimension) != this->maindimcase.end() &&                              this->maindimcase.find(dimension) != this->maindimcase.end() &&
445                              this->maindimcase[dimension] == j;                              this->maindimcase[dimension] == j;
446                            bool isCheckBoxSelected =
447                                modifyalldimregs ||
448                                (modifybothchannels &&
449                                    dimension == gig::dimension_samplechannel);
450                          if (isMainSelection)                          if (isMainSelection)
451                              Gdk::Cairo::set_source_rgba(cr, blue);                              Gdk::Cairo::set_source_rgba(cr, blue);
452                          else if (isSelectedZone)                          else if (isSelectedZone)
453                              cr->set_source(blueHatchedSurfacePattern);                              cr->set_source(blueHatchedSurfacePattern);
454                            else if (isCheckBoxSelected)
455                                cr->set_source(grayBlueHatchedSurfacePattern);
456                          else                          else
457                              Gdk::Cairo::set_source_rgba(cr, white);                              Gdk::Cairo::set_source_rgba(cr, white);
458    
# Line 473  bool DimRegionChooser::on_draw(const Cai Line 516  bool DimRegionChooser::on_draw(const Cai
516                              bool isMainSelection =                              bool isMainSelection =
517                                  this->maindimcase.find(dimension) != this->maindimcase.end() &&                                  this->maindimcase.find(dimension) != this->maindimcase.end() &&
518                                  this->maindimcase[dimension] == (j-1);                                  this->maindimcase[dimension] == (j-1);
519                                bool isCheckBoxSelected =
520                                    modifyalldimregs ||
521                                    (modifybothchannels &&
522                                        dimension == gig::dimension_samplechannel);
523                              if (isMainSelection)                              if (isMainSelection)
524                                  Gdk::Cairo::set_source_rgba(cr, blue);                                  Gdk::Cairo::set_source_rgba(cr, blue);
525                              else if (isSelectedZone)                              else if (isSelectedZone)
526                                  cr->set_source(blueHatchedSurfacePattern);                                  cr->set_source(blueHatchedSurfacePattern);
527                                else if (isCheckBoxSelected)
528                                    cr->set_source(grayBlueHatchedSurfacePattern);
529                              else                              else
530                                  Gdk::Cairo::set_source_rgba(cr, white);                                  Gdk::Cairo::set_source_rgba(cr, white);
531                              cr->rectangle(prevX + 1, y + 1, x - prevX - 1, h - 1);                              cr->rectangle(prevX + 1, y + 1, x - prevX - 1, h - 1);
# Line 1246  bool DimRegionChooser::onKeyReleased(Gdk Line 1295  bool DimRegionChooser::onKeyReleased(Gdk
1295      // (which is supposed to switch between regions)      // (which is supposed to switch between regions)
1296      if (primaryKeyDown) return false;      if (primaryKeyDown) return false;
1297    
1298        // avoid conflict with Alt+Shift+Left and Alt+Shift+Right accelerators on
1299        // mainwindow
1300        if (shiftKeyDown) return false;
1301    
1302      if (key->keyval == GDK_KEY_Left)      if (key->keyval == GDK_KEY_Left)
1303          select_prev_dimzone();          select_prev_dimzone();
1304      if (key->keyval == GDK_KEY_Right)      if (key->keyval == GDK_KEY_Right)
# Line 1306  bool DimRegionChooser::select_dimregion( Line 1359  bool DimRegionChooser::select_dimregion(
1359      return false; //.selection failed      return false; //.selection failed
1360  }  }
1361    
1362  void DimRegionChooser::select_next_dimzone() {  void DimRegionChooser::select_next_dimzone(bool add) {
1363      select_dimzone_by_dir(+1);      select_dimzone_by_dir(+1, add);
1364  }  }
1365    
1366  void DimRegionChooser::select_prev_dimzone() {  void DimRegionChooser::select_prev_dimzone(bool add) {
1367      select_dimzone_by_dir(-1);      select_dimzone_by_dir(-1, add);
1368  }  }
1369    
1370  void DimRegionChooser::select_dimzone_by_dir(int dir) {  void DimRegionChooser::select_dimzone_by_dir(int dir, bool add) {
1371      if (!region) return;      if (!region) return;
1372      if (!region->Dimensions) return;      if (!region->Dimensions) return;
1373      if (focus_line < 0) focus_line = 0;      if (focus_line < 0) focus_line = 0;
# Line 1349  void DimRegionChooser::select_dimzone_by Line 1402  void DimRegionChooser::select_dimzone_by
1402    
1403      maindimregno = getDimensionRegionIndex(dr);      maindimregno = getDimensionRegionIndex(dr);
1404    
1405      // reset selected dimregion zones      if (!add) {
1406      dimzones.clear();          // reset selected dimregion zones
1407            dimzones.clear();
1408        }
1409      for (DimensionCase::const_iterator it = maindimcase.begin();      for (DimensionCase::const_iterator it = maindimcase.begin();
1410           it != maindimcase.end(); ++it)           it != maindimcase.end(); ++it)
1411      {      {

Legend:
Removed from v.3131  
changed lines
  Added in v.3147

  ViewVC Help
Powered by ViewVC