commit 0a943b44ece9549f0e2a2f54fa7b4b6153396afb
parent c04c76a0b6eb03389c4a682acf6104c4b012b552
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date: Mon, 17 May 2010 10:57:08 +1000
Tweak the rulers
Diffstat:
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/spek-ruler.vala b/src/spek-ruler.vala
@@ -24,6 +24,7 @@ namespace Spek {
private string sample_label;
private int[] factors;
private int units;
+ private double spacing;
private UnitToPixel unit_to_pixel;
private FormatTick format_tick;
@@ -31,11 +32,12 @@ namespace Spek {
public delegate string FormatTick (int unit);
public Ruler (
- string sample_label, int[] factors, int units,
+ string sample_label, int[] factors, int units, double spacing,
UnitToPixel unit_to_pixel, FormatTick format_tick) {
this.sample_label = sample_label;
this.factors = factors;
this.units = units;
+ this.spacing = spacing;
this.unit_to_pixel = unit_to_pixel;
this.format_tick = format_tick;
}
@@ -49,7 +51,7 @@ namespace Spek {
// Select the factor to use, we want some space between the labels.
int factor = 0;
foreach (var f in factors) {
- if (unit_to_pixel (f) >= 1.5 * size) {
+ if (unit_to_pixel (f) >= spacing * size) {
factor = f;
break;
}
@@ -59,7 +61,7 @@ namespace Spek {
int[] ticks = { 0, units };
if (factor > 0) {
for (var tick = factor; tick < units; tick += factor) {
- if (unit_to_pixel (units - tick) < size) {
+ if (unit_to_pixel (units - tick) < size * 1.2) {
break;
}
ticks += tick;
diff --git a/src/spek-spectrogram.vala b/src/spek-spectrogram.vala
@@ -30,7 +30,7 @@ namespace Spek {
private ImageSurface image;
private ImageSurface palette;
- private const int PADDING = 60;
+ private const int PADDING = 50;
private const int GAP = 10;
private const int RULER = 10;
@@ -133,6 +133,7 @@ namespace Spek {
"00:00",
{1, 2, 5, 10, 20, 30, 1*60, 2*60, 5*60, 10*60, 20*60, 30*60},
duration_seconds,
+ 1.5,
unit => (w - 2 * PADDING) * unit / duration_seconds,
unit => "%d:%02d".printf (unit / 60, unit % 60));
cr.translate (PADDING, h - PADDING);
@@ -142,11 +143,12 @@ namespace Spek {
// Frequency ruler.
var freq = source.rate / 2;
var rate_ruler = new Ruler (
- "00.0 kHz",
+ "00 kHz",
{1000, 2000, 5000, 10000, 20000},
freq,
+ 4.0,
unit => (h - 2 * PADDING) * unit / freq,
- unit => "%d.%01d kHz".printf (unit / 1000, (unit % 1000) / 100));
+ unit => "%d kHz".printf (unit / 1000));
cr.translate (PADDING, PADDING);
rate_ruler.draw (cr, false);
cr.identity_matrix ();