{
orientation = o;
hold_cnt = hold;
+ resized = true;
hold_state = 0;
current_peak = 0;
current_level = 0;
set_events (BUTTON_PRESS_MASK|BUTTON_RELEASE_MASK);
- pixrect.x = 0;
+ pixrect.x = 1;
pixrect.y = 0;
if (orientation == Vertical) {
}
if (orientation == Vertical) {
- pixrect.width = min (pixwidth, (gint) dimen);
+ pixrect.width = pixwidth;
pixrect.height = pixheight;
} else {
pixrect.width = pixwidth;
pixrect.height = min (pixheight, (gint) dimen);
}
- request_width = pixrect.width;
+ request_width = pixrect.width + 2;
request_height= pixrect.height;
}
{
guint8 r0,g0,b0,r1,g1,b1,r2,g2,b2,r3,g3,b3,a;
- /* clr0: color at top of the meter
- 1: color at the knee
- 2: color half-way between bottom and knee
- 3: color at the bottom of the meter
+ /*
+ The knee is the hard transition point (e.g. at 0dB where the colors
+ change dramatically to make clipping apparent). Thus there are two
+ gradients in the pattern, the "normal range" and the "clip range", which
+ are separated at the knee point.
+
+ clr0: color at bottom of normal range gradient
+ clr1: color at top of normal range gradient
+ clr2: color at bottom of clip range gradient
+ clr3: color at top of clip range gradient
*/
UINT_TO_RGBA (clr0, &r0, &g0, &b0, &a);
// return def / 115.0f
const int knee = (int)floor((float)height * 100.0f / 115.0f);
- cairo_pattern_t* _p = cairo_pattern_create_linear (0.0, 0.0, width, height);
+ cairo_pattern_t* pat = cairo_pattern_create_linear (0.0, 0.0, width, height);
- /* cairo coordinate space goes downwards as y value goes up, so invert
- * knee-based positions by using (1.0 - y)
- */
+ /*
+ Cairo coordinate space goes downwards as y value goes up, so invert
+ knee-based positions by using (1.0 - y)
+ */
+
+ // Clip range top
+ cairo_pattern_add_color_stop_rgb (pat, 0.0,
+ r3/255.0, g3/255.0, b3/255.0);
+
+ // Clip range bottom
+ cairo_pattern_add_color_stop_rgb (pat, 1.0 - (knee/(double)height),
+ r2/255.0, g2/255.0, b2/255.0);
- cairo_pattern_add_color_stop_rgb (_p, 0.0, r3/255.0, g3/255.0, b3/255.0); // bottom
- cairo_pattern_add_color_stop_rgb (_p, 1.0 - (knee/(double)height), r2/255.0, g2/255.0, b2/255.0); // mid-point to knee
- cairo_pattern_add_color_stop_rgb (_p, 1.0 - (knee/(2.0 * height)), r1/255.0, g1/255.0, b1/255.0); // knee to top
- cairo_pattern_add_color_stop_rgb (_p, 1.0, r0/255.0, g0/255.0, b0/255.0); // top
+ // Normal range top (double-stop at knee)
+ cairo_pattern_add_color_stop_rgb (pat, 1.0 - (knee/(double)height),
+ r1/255.0, g1/255.0, b1/255.0);
- Cairo::RefPtr<Cairo::Pattern> p (new Cairo::Pattern (_p, false));
+ // Normal range bottom
+ cairo_pattern_add_color_stop_rgb (pat, 1.0,
+ r0/255.0, g0/255.0, b0/255.0); // top
+
+ Cairo::RefPtr<Cairo::Pattern> p (new Cairo::Pattern (pat, false));
return p;
}
pattern = request_vertical_meter (
request_width, h, _clr0, _clr1, _clr2, _clr3);
pixheight = h;
- pixwidth = request_width;
+ pixwidth = request_width - 2;
}
} else {
}
DrawingArea::on_size_allocate (alloc);
+ resized = true;
}
bool
GdkRectangle background;
cairo_t* cr = gdk_cairo_create (get_window ()->gobj());
+
+ if (resized) {
+ cairo_set_source_rgb (cr, 0, 0, 0); // black
+ cairo_rectangle (cr, 0, 0, pixrect.width + 2, pixheight);
+ cairo_fill (cr);
+ }
+
cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
cairo_clip (cr);
background.x = 0;
background.y = 0;
- background.width = pixrect.width;
+ background.width = pixrect.width + 2;
background.height = pixheight - top_of_meter;
if (gdk_rectangle_intersect (&background, &ev->area, &intersection)) {
// draw peak bar
if (hold_state) {
- last_peak_rect.x = 0;
+ last_peak_rect.x = 1;
last_peak_rect.width = pixwidth;
last_peak_rect.y = pixheight - (gint) floor (pixheight * current_peak);
last_peak_rect.height = min(3, pixheight - last_peak_rect.y);
cairo_set_source (cr, pattern->cobj());
- cairo_rectangle (cr, 0, last_peak_rect.y, pixwidth, last_peak_rect.height);
+ cairo_rectangle (cr, 1, last_peak_rect.y, pixwidth, last_peak_rect.height);
cairo_fill (cr);
} else {
gint new_top = (gint) floor (pixheight * current_level);
- rect.x = 0;
+ rect.x = 1;
rect.width = pixwidth;
rect.height = new_top;
rect.y = pixheight - new_top;