]> git.notmuchmail.org Git - scherzo/blobdiff - scherzo.c
Add some (particularly cheesy) drawing of a brace and clefs on the grand staff.
[scherzo] / scherzo.c
index 77db9bb74b481ff09e48175dc0e4ebfbc7e5e0ab..c49584c2465e2c153f3f6690fa2df3045e829751 100644 (file)
--- a/scherzo.c
+++ b/scherzo.c
 
 #include <gtk/gtk.h>
 
+#include "score.h"
+
 #define unused(foo) foo __attribute__((unused))
 
+typedef struct scherzo
+{
+    score_t *score;
+    int staff_height;
+} scherzo_t;
+
 static int
 on_delete_event_quit (unused (GtkWidget *widget),
                      unused (GdkEvent *event),
@@ -35,19 +43,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)
 {
+    scherzo_t *scherzo = user_data;
+    score_t *score = scherzo->score;
     cairo_t *cr;
     GtkAllocation allocation;
+    static const int pad = 10;
+    int widget_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 +75,14 @@ main (int argc, char *argv[])
 {
     GtkWidget *window;
     GtkWidget *drawing_area;
+    scherzo_t scherzo;
 
     gtk_init (&argc, &argv);
 
+    scherzo.score = score_create (NULL);
+    scherzo.staff_height = 20;
+    score_set_staff_height (scherzo.score, scherzo.staff_height);
+
     window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
     gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
@@ -72,8 +95,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),
+                     &scherzo);
     
     gtk_widget_show_all (window);