commit ed9ae07778f1f7ca9da7d39267f0d965dcdf64b5
parent f7f3abc2fdb11c7bb92b5546d95c0fd6feaa7c20
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date: Sat, 8 May 2010 14:38:31 +1000
Use a padding when drawing the spectrogram
Diffstat:
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/src/spek-spectrogram.vala b/src/spek-spectrogram.vala
@@ -54,19 +54,38 @@ namespace Spek {
uint32 *p = &data[i];
*p = color;
}
- queue_draw_area (sample, 0, 1, allocation.height);
+ //queue_draw_area (sample, 0, 1, allocation.height);
+ queue_draw ();
}
private override bool expose_event (EventExpose event) {
+ double w = allocation.width;
+ double h = allocation.height;
var cr = cairo_create (this.window);
- if (image == null) {
- cr.set_source_rgb (0, 0, 0);
- } else {
+ // Clip to the exposed area.
+ cr.rectangle (event.area.x, event.area.y, event.area.width, event.area.height);
+ cr.clip ();
+
+ // Clean the background.
+ cr.set_source_rgb (0, 0, 0);
+ cr.paint ();
+
+ // Draw the spectrogram.
+ if (image != null) {
+ cr.translate (40, 40);
+ cr.scale ((w - 80) / w, (h - 80) / h);
cr.set_source_surface (image, 0, 0);
+ cr.paint ();
+ cr.identity_matrix ();
}
- cr.rectangle (event.area.x, event.area.y, event.area.width, event.area.height);
- cr.fill ();
+
+ // Border around the spectrogram.
+ cr.set_source_rgb (1, 1, 1);
+ cr.set_line_width (1);
+ cr.set_antialias (Antialias.NONE);
+ cr.rectangle (40, 40, w - 80, h - 80);
+ cr.stroke ();
return true;
}