/[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 3286 by schoenebeck, Thu Jun 22 10:54:10 2017 UTC revision 3305 by schoenebeck, Mon Jul 10 20:27:44 2017 UTC
# Line 264  void DimRegionChooser::setModifyAllRegio Line 264  void DimRegionChooser::setModifyAllRegio
264      queue_draw();      queue_draw();
265  }  }
266    
267    void DimRegionChooser::drawIconsFor(
268        gig::dimension_t dimension, uint zone,
269        const Cairo::RefPtr<Cairo::Context>& cr,
270        int x, int y, int w, int h)
271    {
272        DimensionCase dimCase;
273        dimCase[dimension] = zone;
274    
275        std::vector<gig::DimensionRegion*> dimregs =
276            dimensionRegionsMatching(dimCase, region);
277    
278        if (dimregs.empty()) return;
279    
280        int iSampleRefs = 0;
281        int iLoops = 0;
282    
283        for (uint i = 0; i < dimregs.size(); ++i) {
284            if (dimregs[i]->pSample) iSampleRefs++;
285            if (dimregs[i]->SampleLoops) iLoops++;
286        }
287    
288        bool bShowLoopSymbol = (iLoops > 0);
289        bool bShowSampleRefSymbol = (iSampleRefs < dimregs.size());
290    
291        if (bShowLoopSymbol || bShowSampleRefSymbol) {
292            const int margin = 1;
293    
294            cr->save();
295            cr->set_line_width(1);
296            cr->rectangle(x, y + margin, w, h - 2*margin);
297            cr->clip();
298            if (bShowSampleRefSymbol) {
299                const int wPic = 8;
300                const int hPic = 8;
301                Gdk::Cairo::set_source_pixbuf(
302                    cr, (iSampleRefs) ? yellowDot : redDot,
303                    x + (w-wPic)/2.f,
304                    y + (
305                        (bShowLoopSymbol) ? margin : (h-hPic)/2.f
306                    )
307                );
308                cr->paint();
309            }
310            if (bShowLoopSymbol) {
311                const int wPic = 12;
312                const int hPic = 14;
313                Gdk::Cairo::set_source_pixbuf(
314                    cr, (iLoops == dimregs.size()) ? blackLoop : grayLoop,
315                    x + (w-wPic)/2.f,
316                    y + (
317                        (bShowSampleRefSymbol) ? h - hPic - margin : (h-hPic)/2.f
318                    )
319                );
320                cr->paint();
321            }
322            cr->restore();
323        }
324    }
325    
326  #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
327  bool DimRegionChooser::on_expose_event(GdkEventExpose* e)  bool DimRegionChooser::on_expose_event(GdkEventExpose* e)
328  {  {
# Line 487  bool DimRegionChooser::on_draw(const Cai Line 546  bool DimRegionChooser::on_draw(const Cai
546                          else                          else
547                              Gdk::Cairo::set_source_rgba(cr, white);                              Gdk::Cairo::set_source_rgba(cr, white);
548    
549                          cr->rectangle(prevX + 1, y + 1, x - prevX - 1, h - 1);                          const int wZone = x - prevX - 1;
550    
551                            cr->rectangle(prevX + 1, y + 1, wZone, h - 1);
552                          cr->fill();                          cr->fill();
553    
554                            // draw icons
555                            drawIconsFor(dimension, j, cr, prevX, y, wZone, h);
556    
557                          // draw text showing the beginning of the dimension zone                          // draw text showing the beginning of the dimension zone
558                          // as numeric value to the user                          // as numeric value to the user
559                          {                          {
# Line 542  bool DimRegionChooser::on_draw(const Cai Line 606  bool DimRegionChooser::on_draw(const Cai
606                          cr->stroke();                          cr->stroke();
607    
608                          if (j != 0) {                          if (j != 0) {
609                                const int wZone = x - prevX - 1;
610    
611                              // draw fill for zone                              // draw fill for zone
612                              bool isSelectedZone = this->dimzones[dimension].count(j-1);                              bool isSelectedZone = this->dimzones[dimension].count(j-1);
613                              bool isMainSelection =                              bool isMainSelection =
# Line 559  bool DimRegionChooser::on_draw(const Cai Line 625  bool DimRegionChooser::on_draw(const Cai
625                                  cr->set_source(blueHatchedSurfacePattern);                                  cr->set_source(blueHatchedSurfacePattern);
626                              else                              else
627                                  Gdk::Cairo::set_source_rgba(cr, white);                                  Gdk::Cairo::set_source_rgba(cr, white);
628                              cr->rectangle(prevX + 1, y + 1, x - prevX - 1, h - 1);                              cr->rectangle(prevX + 1, y + 1, wZone, h - 1);
629                              cr->fill();                              cr->fill();
630    
631                                // draw icons
632                                drawIconsFor(dimension, j - 1, cr, prevX, y, wZone, h);
633    
634                              // draw text showing the beginning of the dimension zone                              // draw text showing the beginning of the dimension zone
635                              // as numeric value to the user                              // as numeric value to the user
636                              {                              {

Legend:
Removed from v.3286  
changed lines
  Added in v.3305

  ViewVC Help
Powered by ViewVC