X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fcanvas%2Fmeter.cc;h=833ab8c4041d3beb745a4fedc20fc75d1950534d;hb=eb5161b6012a73eae0a288d71727edcfd161d16a;hp=d71370ad48d97e25018860f42094bc22ecf34315;hpb=29b80725559c8fd60ae51bf33270963e647d0c1c;p=ardour.git diff --git a/libs/canvas/meter.cc b/libs/canvas/meter.cc index d71370ad48..833ab8c404 100644 --- a/libs/canvas/meter.cc +++ b/libs/canvas/meter.cc @@ -140,9 +140,6 @@ Meter::init (int clr0, int clr1, int clr2, int clr3, _stp[2] = stp2; _stp[3] = stp3; - pixrect.x = 1; - pixrect.y = 1; - if (!len) { len = 250; } @@ -159,15 +156,23 @@ Meter::init (int clr0, int clr1, int clr2, int clr3, bgpattern = horizontal_background (pixwidth + 2, pixheight + 2, _bgc, false); } - pixrect.width = pixwidth; pixrect.height = pixheight; + pixrect.x = 1; + + if (orientation == Vertical) { + pixrect.width = pixwidth; + pixrect.y = pixheight; /* bottom of meter, so essentially "show zero" */ + } else { + pixrect.width = 0; /* right of meter, so essentially "show zero" */ + pixrect.y = 1; + } } void Meter::compute_bounding_box () const { if (!_canvas) { - _bounding_box = boost::optional (); + _bounding_box = Rect (); _bounding_box_dirty = false; return; } @@ -505,10 +510,13 @@ Meter::vertical_expose (ArdourCanvas::Rect const & area, Cairo::RefPtrset_source_rgb (0, 0, 0); // black rounded_rectangle (context, 0, 0, pixwidth + 2, pixheight + 2, 2); @@ -516,10 +524,17 @@ Meter::vertical_expose (ArdourCanvas::Rect const & area, Cairo::RefPtrempty()) { Cairo::RectangleInt i (r1->get_extents ()); - context->rectangle (i.x, i.y, i.width, i.height); context->set_source (bgpattern); + context->rectangle (i.x, i.y, i.width, i.height); context->fill (); } @@ -548,8 +563,8 @@ Meter::vertical_expose (ArdourCanvas::Rect const & area, Cairo::RefPtrempty()) { // draw the part of the meter image that we need. the area we draw is bounded "in reverse" (top->bottom) Cairo::RectangleInt i (r2->get_extents ()); - context->rectangle (i.x, i.y, i.width, i.height); context->set_source (fgpattern); + context->rectangle (i.x, i.y, i.width, i.height); context->fill (); } @@ -595,7 +610,6 @@ Meter::horizontal_expose (ArdourCanvas::Rect const & area, Cairo::RefPtr old_level) { - /* colored/pixbuf got larger, just draw the new section */ - /* rect.y stays where it is because of X coordinates */ - /* height of invalidated area is between new.y (smaller) and old.y - (larger). - X coordinates just make my brain hurt. + /* filled area got taller, just draw the new section */ + + /* rect.y (new y origin) is smaller or equal to pixrect.y (old + * y origin) because the top of the meter is higher (X/Cairo: + * coordinates grow down). + * + * Leave rect.y alone, and recompute the height to be just the + * difference between the new bottom and the top of the previous + * pattern area. + * + * The old pattern area extended DOWN from pixrect.y to + * pixrect.y + pixrect.height. + * + * The new pattern area extends DOWN from rect.y to + * rect.y + rect.height + * + * The area needing to be drawn is the difference between the + * old top (pixrect.y) and the new top (rect.y) */ rect.height = pixrect.y - rect.y; } else {