/[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 3146 by schoenebeck, Fri Apr 28 12:41:12 2017 UTC revision 3147 by schoenebeck, Wed May 3 21:23:16 2017 UTC
# 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);

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

  ViewVC Help
Powered by ViewVC