]> git.cworth.org Git - scherzo/blobdiff - scherzo.c
Start drawing something
[scherzo] / scherzo.c
index 77db9bb74b481ff09e48175dc0e4ebfbc7e5e0ab..fbb23f0ed34da8efa4df50f9309258ca6c4840d7 100644 (file)
--- a/scherzo.c
+++ b/scherzo.c
@@ -18,6 +18,8 @@
 
 #include <gtk/gtk.h>
 
+#include "score.h"
+
 #define unused(foo) foo __attribute__((unused))
 
 static int
@@ -35,19 +37,29 @@ on_delete_event_quit (unused (GtkWidget *widget),
 static int
 on_expose_event_draw (GtkWidget        *widget,
                      unused (GdkEventExpose *event),
-                     unused (gpointer user_data))
+                     void * user_data)
 {
+    score_t *score = user_data;
     cairo_t *cr;
     GtkAllocation allocation;
+    static const int pad = 10;
+    int widget_width, staff_width;
 
     gtk_widget_get_allocation (widget, &allocation);
+    widget_width = allocation.width;
 
     cr = gdk_cairo_create (widget->window);
 
-    /* Paint in medium sea green */
-    cairo_set_source_rgb (cr, 60/255.0, 179/255.0, 113/255.0);
-
+    /* White background */
+    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
     cairo_paint (cr);
+
+    /* Add some padding on the left/right */
+    cairo_translate (cr, pad, pad);
+
+    score_set_width (score, widget_width - 2 * pad);
+
+    score_draw (score, cr);
  
     return TRUE;
 }
@@ -57,9 +69,12 @@ main (int argc, char *argv[])
 {
     GtkWidget *window;
     GtkWidget *drawing_area;
+    score_t score;
 
     gtk_init (&argc, &argv);
 
+    score_init (&score);
+
     window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
     gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
@@ -72,8 +87,8 @@ main (int argc, char *argv[])
     gtk_container_add (GTK_CONTAINER (window), drawing_area);
 
     g_signal_connect (drawing_area, "expose-event",  
-                     G_CALLBACK (on_expose_event_draw), NULL);
-
+                     G_CALLBACK (on_expose_event_draw),
+                     &score);
     
     gtk_widget_show_all (window);