[cairo-commit] gtkcairo/tests demo.c,1.1,1.2

Evan Martin commit at pdx.freedesktop.org
Wed Nov 19 10:57:49 PST 2003


Committed by: martine

Update of /cvs/cairo/gtkcairo/tests
In directory pdx:/tmp/cvs-serv22244/tests

Modified Files:
	demo.c 
Log Message:
No functionality changed here.
Removed INSTALL from CVS (it's generated by automake or whatever).

Wed, 19 Nov 2003 10:57:38 -0800  Evan Martin  <martine at danga.com>

	Merged local copy with the version Carl checked into CVS:
	* gtkcairo.c, gtkcairo.h:  Cosmetic changes.
	* demo.c:  Work with different sizes of windows.



Index: demo.c
===================================================================
RCS file: /cvs/cairo/gtkcairo/tests/demo.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** demo.c	18 Nov 2003 15:17:07 -0000	1.1
--- demo.c	19 Nov 2003 18:57:47 -0000	1.2
***************
*** 10,37 ****
  
  #define MARGIN 20
! #define BOX_SIZE 100
! 
! static void
! setup_transform(cairo_t *cairo) {
! 	cairo_default_matrix(cairo);
! 	cairo_translate(cairo, BOX_SIZE+MARGIN, BOX_SIZE+MARGIN);
! }
  
  static void
! expose(GtkCairo *gtkcairo) {
  	cairo_t *cairo = gtk_cairo_get_cairo(gtkcairo);
  
! 	cairo_rectangle (cairo, 0, 0, BOX_SIZE, BOX_SIZE);
! 	cairo_set_rgb_color (cairo, 1, 1, 1);
! 	cairo_fill (cairo);
  }
  
  static void
! slider_changed(GtkRange *range, GtkCairo *gtkcairo) {
! 	cairo_t *cairo = gtk_cairo_get_cairo(gtkcairo);
! 
! 	setup_transform(cairo);
! 	cairo_rotate(cairo, gtk_range_get_value(range));
! 	gtk_widget_queue_draw(GTK_WIDGET(gtkcairo));
  }
  
--- 10,36 ----
  
  #define MARGIN 20
! #define INITIAL_SIZE 200
  
  static void
! expose(GtkCairo *gtkcairo, gpointer event, GtkRange *range) {
! 	GtkWidget *widget = GTK_WIDGET(gtkcairo);
  	cairo_t *cairo = gtk_cairo_get_cairo(gtkcairo);
  
! 	gint width = widget->allocation.width;
! 	gint height = widget->allocation.height;
! 	gint box_size = (width+height)/6, box_overlap = (width+height)/32;
! 
! 	cairo_default_matrix(cairo);
! 	cairo_translate(cairo, width/2, height/2);
! 	cairo_rotate(cairo, gtk_range_get_value(range));
! 	cairo_translate(cairo, width/32, height/32);
! 	cairo_rectangle(cairo, -box_size, -box_size, box_size, box_size);
! 	cairo_set_rgb_color(cairo, 1, 1, 1);
! 	cairo_fill(cairo);
  }
  
  static void
! slider_changed(GtkRange *range, GtkWidget *gtkcairo) {
! 	gtk_widget_queue_draw(gtkcairo);
  }
  
***************
*** 72,86 ****
  	gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
  
  	gtkcairo = gtk_cairo_new();
! 	setup_transform(gtk_cairo_get_cairo(GTK_CAIRO(gtkcairo)));
! 	gtk_widget_set_usize(GTK_WIDGET(gtkcairo),
! 			2*(BOX_SIZE+MARGIN), 2*(BOX_SIZE+MARGIN));
  	g_signal_connect_after(G_OBJECT(gtkcairo), "expose-event",
! 	                 G_CALLBACK(expose), NULL);
  
  	gtk_container_add(GTK_CONTAINER(frame), gtkcairo);
  	gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
  
- 	slider = gtk_hscale_new_with_range(0, ROTATE_MAX, 0.05);
  	gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);
  	g_signal_connect(G_OBJECT(slider), "value-changed",
--- 71,84 ----
  	gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
  
+ 	slider = gtk_hscale_new_with_range(0, ROTATE_MAX, 0.05);
+ 
  	gtkcairo = gtk_cairo_new();
! 	gtk_widget_set_usize(GTK_WIDGET(gtkcairo), INITIAL_SIZE, INITIAL_SIZE);
  	g_signal_connect_after(G_OBJECT(gtkcairo), "expose-event",
! 	                 G_CALLBACK(expose), slider);
  
  	gtk_container_add(GTK_CONTAINER(frame), gtkcairo);
  	gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
  
  	gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);
  	g_signal_connect(G_OBJECT(slider), "value-changed",





More information about the cairo-commit mailing list