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

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

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

revision 3226 by schoenebeck, Fri May 26 22:15:06 2017 UTC revision 3307 by schoenebeck, Tue Jul 11 23:06:38 2017 UTC
# Line 40  Line 40 
40  struct RegionFeatures {  struct RegionFeatures {
41      int sampleRefs;      int sampleRefs;
42      int loops;      int loops;
43        int validDimRegs;
44    
45      RegionFeatures() {      RegionFeatures() {
46          sampleRefs = loops = 0;          sampleRefs = loops = validDimRegs = 0;
47      }      }
48  };  };
49    
# Line 50  static RegionFeatures regionFeatures(gig Line 51  static RegionFeatures regionFeatures(gig
51      RegionFeatures f;      RegionFeatures f;
52      for (int i = 0; i < rgn->DimensionRegions; ++i) {      for (int i = 0; i < rgn->DimensionRegions; ++i) {
53          gig::DimensionRegion* dr = rgn->pDimensionRegions[i];          gig::DimensionRegion* dr = rgn->pDimensionRegions[i];
54            DimensionCase c = dimensionCaseOf(dr);
55            if (!isUsedCase(c, rgn)) continue;
56            f.validDimRegs++;
57          if (dr->pSample) f.sampleRefs++;          if (dr->pSample) f.sampleRefs++;
58          // the user doesn't care about loop if there is no valid sample reference          // the user doesn't care about loop if there is no valid sample reference
59          if (dr->pSample && dr->SampleLoops) f.loops++;          if (dr->pSample && dr->SampleLoops) f.loops++;
# Line 98  RegionChooser::RegionChooser() : Line 102  RegionChooser::RegionChooser() :
102    
103      loadBuiltInPix();      loadBuiltInPix();
104    
105      // create gray blue hatched pattern      // create blue hatched pattern
106      {      {
107          const int width = grayBlueHatchedPattern->get_width();          const int width = blueHatchedPattern->get_width();
108          const int height = grayBlueHatchedPattern->get_height();          const int height = blueHatchedPattern->get_height();
109          const int stride = grayBlueHatchedPattern->get_rowstride();          const int stride = blueHatchedPattern->get_rowstride();
110    
111          // manually convert from RGBA to ARGB          // manually convert from RGBA to ARGB
112          this->grayBlueHatchedPatternARGB = grayBlueHatchedPattern->copy();          this->blueHatchedPatternARGB = blueHatchedPattern->copy();
113          const int pixelSize = stride / width;          const int pixelSize = stride / width;
114          const int totalPixels = width * height;          const int totalPixels = width * height;
115          assert(pixelSize == 4);          assert(pixelSize == 4);
116          unsigned char* ptr = this->grayBlueHatchedPatternARGB->get_pixels();          unsigned char* ptr = this->blueHatchedPatternARGB->get_pixels();
117          for (int iPixel = 0; iPixel < totalPixels; ++iPixel, ptr += pixelSize) {          for (int iPixel = 0; iPixel < totalPixels; ++iPixel, ptr += pixelSize) {
118              const unsigned char r = ptr[0];              const unsigned char r = ptr[0];
119              const unsigned char g = ptr[1];              const unsigned char g = ptr[1];
# Line 122  RegionChooser::RegionChooser() : Line 126  RegionChooser::RegionChooser() :
126          }          }
127    
128          Cairo::RefPtr<Cairo::ImageSurface> imageSurface = Cairo::ImageSurface::create(          Cairo::RefPtr<Cairo::ImageSurface> imageSurface = Cairo::ImageSurface::create(
129              this->grayBlueHatchedPatternARGB->get_pixels(), Cairo::FORMAT_ARGB32, width, height, stride              this->blueHatchedPatternARGB->get_pixels(), Cairo::FORMAT_ARGB32, width, height, stride
130          );          );
131          this->grayBlueHatchedSurfacePattern = Cairo::SurfacePattern::create(imageSurface);          this->blueHatchedSurfacePattern = Cairo::SurfacePattern::create(imageSurface);
132          this->grayBlueHatchedSurfacePattern->set_extend(Cairo::EXTEND_REPEAT);          this->blueHatchedSurfacePattern->set_extend(Cairo::EXTEND_REPEAT);
133      }      }
134    
135      instrument = 0;      instrument = 0;
# Line 377  void RegionChooser::draw_regions(const C Line 381  void RegionChooser::draw_regions(const C
381                  if (region == r)                  if (region == r)
382                      Gdk::Cairo::set_source_rgba(cr, blue);                      Gdk::Cairo::set_source_rgba(cr, blue);
383                  else if (modifyallregions)                  else if (modifyallregions)
384                      cr->set_source(grayBlueHatchedSurfacePattern);                      cr->set_source(blueHatchedSurfacePattern);
385                  else                  else
386                      Gdk::Cairo::set_source_rgba(cr, white);                      Gdk::Cairo::set_source_rgba(cr, white);
387    
# Line 396  void RegionChooser::draw_regions(const C Line 400  void RegionChooser::draw_regions(const C
400          RegionFeatures features = regionFeatures(r);          RegionFeatures features = regionFeatures(r);
401    
402          const bool bShowLoopSymbol = features.loops > 0;          const bool bShowLoopSymbol = features.loops > 0;
403          const bool bShowSampleRefSymbol = features.sampleRefs < r->DimensionRegions;          const bool bShowSampleRefSymbol = features.sampleRefs < features.validDimRegs;
404          if (bShowLoopSymbol || bShowSampleRefSymbol) {          if (bShowLoopSymbol || bShowSampleRefSymbol) {
405              const int margin = 2;              const int margin = 2;
406              const int wRgn = x2 - x;              const int wRgn = x2 - x;
# Line 420  void RegionChooser::draw_regions(const C Line 424  void RegionChooser::draw_regions(const C
424                  const int wPic = 12;                  const int wPic = 12;
425                  const int hPic = 14;                  const int hPic = 14;
426                  Gdk::Cairo::set_source_pixbuf(                  Gdk::Cairo::set_source_pixbuf(
427                      cr, (features.loops == r->DimensionRegions) ? blackLoop : grayLoop,                      cr, (features.loops == features.validDimRegs) ? blackLoop : grayLoop,
428                      x + (wRgn-wPic)/2.f,                      x + (wRgn-wPic)/2.f,
429                      (bShowSampleRefSymbol) ? h1 - hPic - margin : (h1-hPic)/2.f                      (bShowSampleRefSymbol) ? h1 - hPic - margin : (h1-hPic)/2.f
430                  );                  );

Legend:
Removed from v.3226  
changed lines
  Added in v.3307

  ViewVC Help
Powered by ViewVC