]> git.notmuchmail.org Git - scherzo/blobdiff - score.c
Add some scaling controls with plus/minus keybindings.
[scherzo] / score.c
diff --git a/score.c b/score.c
index 598c298752d13d42634b487176dd90267419169c..5bb79096c394a45741810d3cb3b22e6ebeeeb552 100644 (file)
--- a/score.c
+++ b/score.c
@@ -28,6 +28,9 @@ struct score
     /* Height of one space within a staff */
     int space_height;
 
+    /* Minimal line width for staff lines */
+    int line_width;
+
     /* Full width of staff */
     int width;
 };
@@ -48,6 +51,11 @@ score_set_staff_height (score_t *score, int height)
 {
     score->space_height = (int) height / 4;
     score->staff_height = score->space_height * 4;
+
+    score->line_width = score->space_height / 15;
+    if (score->line_width == 0)
+       score->line_width = 1;
+
     return score->staff_height;
 }
 
@@ -96,15 +104,17 @@ _draw_staff (score_t *score, cairo_t *cr, score_clef_t clef)
     cairo_show_glyphs (cr, &glyph, 1);
 
     cairo_rectangle (cr,
-                    0.5, 0.5,
-                    score->width - 1.0, score->space_height * 4);
+                    score->line_width / 2.0,
+                    score->line_width / 2.0,
+                    score->width - score->line_width,
+                    score->space_height * 4);
     
     for (i = 1; i < 4; i++) {
-       cairo_move_to (cr, 0, i * score->space_height + 0.5);
+       cairo_move_to (cr, 0, i * score->space_height + score->line_width / 2.0);
        cairo_rel_line_to (cr, score->width, 0);
     }
 
-    cairo_set_line_width (cr, 1.0);
+    cairo_set_line_width (cr, score->line_width);
 
     cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */
     cairo_stroke (cr);
@@ -148,11 +158,12 @@ _draw_grand_staff (score_t *score, cairo_t *cr)
 
     /* Vertical lines at each end */
     cairo_rectangle (cr,
-                    0.5, 0.5,
-                    score->width - 1.0,
+                    score->line_width / 2.0,
+                    score->line_width / 2.0,
+                    score->width - score->line_width,
                     score->staff_height * 3);
     cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */
-    cairo_set_line_width (cr, 1.0);
+    cairo_set_line_width (cr, score->line_width);
     cairo_stroke (cr);
 
     /* Top staff */