diff options
-rw-r--r-- | demo.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -19,7 +19,9 @@ static const pixman_rectangle32_t rects[] = { { 250, 350, 150, 50 }, { 450, 350, 50, 50 }, { 50, 450, 400, 50 }, - { 25, 135, 600, 25 } + { 25, 135, 600, 25 }, + { 25, 355, 600, 25 }, + { 125, 305, 300, 25 } }; #define N_RECTS (sizeof (rects) / sizeof (rects[0])) @@ -77,7 +79,8 @@ on_expose (GtkWidget *widget, GdkEvent *event, gpointer data) 50 + rects[i].x, 50 + rects[i].y, rects[i].width, rects[i].height); - cairo_set_source_rgba (cr, 0.4, 0.4, 0.0, 0.4); + cairo_set_source_rgba ( + cr, g_random_double(), g_random_double(), g_random_double(), 0.4); cairo_fill (cr); } @@ -100,7 +103,7 @@ on_expose (GtkWidget *widget, GdkEvent *event, gpointer data) } } - cairo_set_source_rgba (cr, 0.2, 0.8, 0.2, 0.6); + cairo_set_source_rgba (cr, 0.2, g_random_double(), 0.2, 0); cairo_fill_preserve (cr); @@ -116,6 +119,12 @@ on_expose (GtkWidget *widget, GdkEvent *event, gpointer data) return TRUE; } +static void +on_allocate (GtkWidget *widget, GtkAllocation *allocation) +{ + gtk_widget_queue_draw (widget); +} + int main (int argc, char **argv) { @@ -127,9 +136,10 @@ main (int argc, char **argv) gtk_window_set_default_size (window, 1200, 768); + g_signal_connect (window, "size_allocate", G_CALLBACK (on_allocate), NULL); g_signal_connect (window, "expose_event", G_CALLBACK (on_expose), NULL); - gtk_widget_show_all (window); + gtk_widget_show_all (GTK_WIDGET (window)); gtk_main (); |