[cairo-commit] cairo-demo/gtkcairo_slide ChangeLog, 1.3, 1.4 cairo_custom.c, 1.2, 1.3 cairo_custom.h, 1.2, 1.3 puzzle.c, 1.2, 1.3

OEyvind Kolaas commit at pdx.freedesktop.org
Tue May 11 07:50:17 PDT 2004


Committed by: pippin

Update of /cvs/cairo/cairo-demo/gtkcairo_slide
In directory pdx:/tmp/cvs-serv17733

Modified Files:
	ChangeLog cairo_custom.c cairo_custom.h puzzle.c 
Log Message:
replacing ct with cr


Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-demo/gtkcairo_slide/ChangeLog,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** a/ChangeLog	1 May 2004 15:03:18 -0000	1.3
--- b/ChangeLog	11 May 2004 14:50:15 -0000	1.4
***************
*** 1,10 ****
! 2004-01-03 OEyvind Kolaas <pippin at freedesktop.org>
!     * cairo_custom.[ch], puzzle.c : replaced cairo_set_gtk_color with
                                      gdk_cairo_set_color
  
! 2004-15-02 OEyvind Kolaas <pippin at freedesktop.org>
  	* gtkcairo_slide.c : removed superflous cairo_save/cairo_restor pairs
  
! 2004-14-02 OEyvind Kolaas <pippin at freedesktop.org> 
  
  	Initial import
--- 1,13 ----
! 2004-05-11 OEyvind Kolaas <pippin at freedesktop.org>
! 	* *.[ch] : replacing ct with cr
! 
! 2004-03-01 OEyvind Kolaas <pippin at freedesktop.org>
! 	* cairo_custom.[ch], puzzle.c : replaced cairo_set_gtk_color with
                                      gdk_cairo_set_color
  
! 2004-02-15 OEyvind Kolaas <pippin at freedesktop.org>
  	* gtkcairo_slide.c : removed superflous cairo_save/cairo_restor pairs
  
! 2004-02-14 OEyvind Kolaas <pippin at freedesktop.org> 
  
  	Initial import

Index: cairo_custom.c
===================================================================
RCS file: /cvs/cairo/cairo-demo/gtkcairo_slide/cairo_custom.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** a/cairo_custom.c	1 May 2004 15:03:18 -0000	1.2
--- b/cairo_custom.c	11 May 2004 14:50:15 -0000	1.3
***************
*** 2,6 ****
  
  void
! cairo_rectangle_round ( cairo_t * ct, double x0, double y0, double width, double height, double radius) {
      double x1,y1;
      x1=x0+width;
--- 2,6 ----
  
  void
! cairo_rectangle_round ( cairo_t *cr, double x0, double y0, double width, double height, double radius) {
      double x1,y1;
      x1=x0+width;
***************
*** 10,51 ****
      if (width/2<radius) {
          if (height/2<radius) {
!             cairo_move_to  (ct, x0, (y0 + y1)/2);
!             cairo_curve_to (ct, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
!             cairo_curve_to (ct, x1, y0, x1, y0, x1, (y0 + y1)/2);
!             cairo_curve_to (ct, x1, y1, x1, y1, (x1 + x0)/2, y1);
!             cairo_curve_to (ct, x0, y1, x0, y1, x0, (y0 + y1)/2);
          } else {
!             cairo_move_to  (ct, x0, y0 + radius);
!             cairo_curve_to (ct, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
!             cairo_curve_to (ct, x1, y0, x1, y0, x1, y0 + radius);
!             cairo_line_to (ct, x1 , y1 - radius);
!             cairo_curve_to (ct, x1, y1, x1, y1, (x1 + x0)/2, y1);
!             cairo_curve_to (ct, x0, y1, x0, y1, x0, y1- radius);
          }
      } else {
          if (height/2<radius) {
!             cairo_move_to  (ct, x0, (y0 + y1)/2);
!             cairo_curve_to (ct, x0 , y0, x0 , y0, x0 + radius, y0);
!             cairo_line_to (ct, x1 - radius, y0);
!             cairo_curve_to (ct, x1, y0, x1, y0, x1, (y0 + y1)/2);
!             cairo_curve_to (ct, x1, y1, x1, y1, x1 - radius, y1);
!             cairo_line_to (ct, x0 + radius, y1);
!             cairo_curve_to (ct, x0, y1, x0, y1, x0, (y0 + y1)/2);
          } else {
!             cairo_move_to  (ct, x0, y0 + radius);
!             cairo_curve_to (ct, x0 , y0, x0 , y0, x0 + radius, y0);
!             cairo_line_to (ct, x1 - radius, y0);
!             cairo_curve_to (ct, x1, y0, x1, y0, x1, y0 + radius);
!             cairo_line_to (ct, x1 , y1 - radius);
!             cairo_curve_to (ct, x1, y1, x1, y1, x1 - radius, y1);
!             cairo_line_to (ct, x0 + radius, y1);
!             cairo_curve_to (ct, x0, y1, x0, y1, x0, y1- radius);
          }
      }
!     cairo_close_path (ct);
  }
  
  void
! cairo_edgeline (cairo_t * ct,
                  double x0,
                  double y0,
--- 10,51 ----
      if (width/2<radius) {
          if (height/2<radius) {
!             cairo_move_to  (cr, x0, (y0 + y1)/2);
!             cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
!             cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2);
!             cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1);
!             cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2);
          } else {
!             cairo_move_to  (cr, x0, y0 + radius);
!             cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
!             cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
!             cairo_line_to (cr, x1 , y1 - radius);
!             cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1);
!             cairo_curve_to (cr, x0, y1, x0, y1, x0, y1- radius);
          }
      } else {
          if (height/2<radius) {
!             cairo_move_to  (cr, x0, (y0 + y1)/2);
!             cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0);
!             cairo_line_to (cr, x1 - radius, y0);
!             cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2);
!             cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
!             cairo_line_to (cr, x0 + radius, y1);
!             cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2);
          } else {
!             cairo_move_to  (cr, x0, y0 + radius);
!             cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0);
!             cairo_line_to (cr, x1 - radius, y0);
!             cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
!             cairo_line_to (cr, x1 , y1 - radius);
!             cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
!             cairo_line_to (cr, x0 + radius, y1);
!             cairo_curve_to (cr, x0, y1, x0, y1, x0, y1- radius);
          }
      }
!     cairo_close_path (cr);
  }
  
  void
! cairo_edgeline (cairo_t *cr,
                  double x0,
                  double y0,
***************
*** 56,65 ****
      y1 = y1 + 1;
  
!     cairo_move_to (ct, x0, y0);
      if (y1 > y0 + backoff / 2) {
!         cairo_curve_to (ct, x0, (y0 + y1) / 2, x1, (y0 + y1) / 2, x1, y1);
      } else {
  
!         cairo_curve_to (ct, x0,
                          y0 + (backoff / 4 + (y0 + backoff / 2 - y1)), x1,
                          y1 - (backoff / 4 + (y0 + backoff / 2 - y1)), x1,
--- 56,65 ----
      y1 = y1 + 1;
  
!     cairo_move_to (cr, x0, y0);
      if (y1 > y0 + backoff / 2) {
!         cairo_curve_to (cr, x0, (y0 + y1) / 2, x1, (y0 + y1) / 2, x1, y1);
      } else {
  
!         cairo_curve_to (cr, x0,
                          y0 + (backoff / 4 + (y0 + backoff / 2 - y1)), x1,
                          y1 - (backoff / 4 + (y0 + backoff / 2 - y1)), x1,
***************
*** 69,73 ****
  
  void
! gdk_cairo_set_color (cairo_t *ct,
                       GdkColor *color)
  {
--- 69,73 ----
  
  void
! gdk_cairo_set_color (cairo_t *cr,
                       GdkColor *color)
  {
***************
*** 78,81 ****
      blue  = color->blue  / 65535.0;
  
!     cairo_set_rgb_color (ct, red, green, blue);
  }
--- 78,81 ----
      blue  = color->blue  / 65535.0;
  
!     cairo_set_rgb_color (cr, red, green, blue);
  }

Index: cairo_custom.h
===================================================================
RCS file: /cvs/cairo/cairo-demo/gtkcairo_slide/cairo_custom.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** a/cairo_custom.h	1 May 2004 15:03:18 -0000	1.2
--- b/cairo_custom.h	11 May 2004 14:50:15 -0000	1.3
***************
*** 4,12 ****
  
  void
! gdk_cairo_set_color (cairo_t  *ct,
                       GdkColor *color);
  
  void
! cairo_rectangle_round ( cairo_t * ct,
                          double x0,
                          double y0,
--- 4,12 ----
  
  void
! gdk_cairo_set_color (cairo_t  *cr,
                       GdkColor *color);
  
  void
! cairo_rectangle_round ( cairo_t * cr,
                          double x0,
                          double y0,
***************
*** 16,20 ****
  
  void
! cairo_edgeline (cairo_t * ct,
                  double x0,
                  double y0,
--- 16,20 ----
  
  void
! cairo_edgeline (cairo_t * cr,
                  double x0,
                  double y0,

Index: puzzle.c
===================================================================
RCS file: /cvs/cairo/cairo-demo/gtkcairo_slide/puzzle.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** a/puzzle.c	1 May 2004 15:03:18 -0000	1.2
--- b/puzzle.c	11 May 2004 14:50:15 -0000	1.3
***************
*** 25,29 ****
  static void
  draw_board (Puzzle *puzzle, 
!            cairo_t *ct);
  
  static gint
--- 25,29 ----
  static void
  draw_board (Puzzle *puzzle, 
!            cairo_t *cr);
  
  static gint
***************
*** 247,251 ****
  
  static void redraw (GtkCairo *gtkcairo,
!                     cairo_t  *ct,
                      gpointer  user_data);
  
--- 247,251 ----
  
  static void redraw (GtkCairo *gtkcairo,
!                     cairo_t  *cr,
                      gpointer  user_data);
  
***************
*** 353,357 ****
  static void
  redraw (GtkCairo *gtkcairo,
!         cairo_t  *ct,
          gpointer  user_data)
  {
--- 353,357 ----
  static void
  redraw (GtkCairo *gtkcairo,
!         cairo_t  *cr,
          gpointer  user_data)
  {
***************
*** 362,370 ****
      puzzle->ratio_y = (double) widget->allocation.height/puzzle->rows;
  
!     draw_board (puzzle, ct);
  
!     if (cairo_status (ct)) {
          fprintf (stderr, "Cairo is unhappy: %s\n",
!                  cairo_status_string (ct));
      }
  
--- 362,370 ----
      puzzle->ratio_y = (double) widget->allocation.height/puzzle->rows;
  
!     draw_board (puzzle, cr);
  
!     if (cairo_status (cr)) {
          fprintf (stderr, "Cairo is unhappy: %s\n",
!                  cairo_status_string (cr));
      }
  
***************
*** 529,554 ****
  {
      int item_no;
!     cairo_t *ct = gtk_cairo_get_cairo (GTK_CAIRO (puzzle));
  
!     cairo_save (ct);
  
!     cairo_scale (ct, puzzle->ratio_x, puzzle->ratio_y);
!     cairo_translate (ct, 0.5, 0.5);
  
      for (item_no=0;item_no<puzzle->rows*puzzle->cols-1;item_no++) {
          struct PuzzleItem *item= & (puzzle->item [item_no]);
  
!         cairo_save (ct);
!         cairo_rectangle_round (ct, item->x-0.4, item->y-0.4, 0.8, 0.8, 0.4);
  
!         if (cairo_in_fill (ct, (x)/ puzzle->ratio_x -0.5, (y) / puzzle->ratio_y -0.5)){
!                 cairo_restore (ct);
!                 cairo_restore (ct);
              return item_no;
          }
!         cairo_restore (ct);
      }
  
!     cairo_restore (ct);
      return -1;
  }
--- 529,554 ----
  {
      int item_no;
!     cairo_t *cr = gtk_cairo_get_cairo (GTK_CAIRO (puzzle));
  
!     cairo_save (cr);
  
!     cairo_scale (cr, puzzle->ratio_x, puzzle->ratio_y);
!     cairo_translate (cr, 0.5, 0.5);
  
      for (item_no=0;item_no<puzzle->rows*puzzle->cols-1;item_no++) {
          struct PuzzleItem *item= & (puzzle->item [item_no]);
  
!         cairo_save (cr);
!         cairo_rectangle_round (cr, item->x-0.4, item->y-0.4, 0.8, 0.8, 0.4);
  
!         if (cairo_in_fill (cr, (x)/ puzzle->ratio_x -0.5, (y) / puzzle->ratio_y -0.5)){
!                 cairo_restore (cr);
!                 cairo_restore (cr);
              return item_no;
          }
!         cairo_restore (cr);
      }
  
!     cairo_restore (cr);
      return -1;
  }
***************
*** 558,562 ****
  static void
  draw_board (Puzzle  *puzzle,
!             cairo_t *ct)
  {
      int item_no;
--- 558,562 ----
  static void
  draw_board (Puzzle  *puzzle,
!             cairo_t *cr)
  {
      int item_no;
***************
*** 565,637 ****
      style = GTK_WIDGET (puzzle)->style;
  
!     cairo_save (ct);
!     cairo_scale (ct, puzzle->ratio_x, puzzle->ratio_y);
!     cairo_translate (ct, 0.5, 0.5);
  
          for (item_no=0;item_no<puzzle->rows*puzzle->cols-1;item_no++) {
              struct PuzzleItem *item= & (puzzle->item [item_no]);
!                cairo_rectangle_round (ct, item->x-0.36, item->y-0.36, 0.8, 0.8, 0.4);
!                cairo_set_line_width (ct, 0.07);
                 if (item_no==puzzle->grabbed) {
  
!                   gdk_cairo_set_color (ct, &style->dark[GTK_STATE_NORMAL]);
  
                 } else {
                    if ( fabs(floor(item->x)-item->x)<0.01 && fabs(floor(item->y)-item->y)<0.01) {
!                       gdk_cairo_set_color (ct, &style->dark[GTK_STATE_NORMAL]);
                    } else {
!                       gdk_cairo_set_color (ct, &style->dark[GTK_STATE_ACTIVE]);
                    }
                 }
  
!                cairo_stroke (ct);
  
!                cairo_rectangle_round (ct, item->x-0.4, item->y-0.4, 0.8, 0.8, 0.4);
!                cairo_save (ct);
                    if (item_no==puzzle->grabbed) {
!                      gdk_cairo_set_color (ct, &style->base[GTK_STATE_SELECTED]);
                    } else {
                       if ( fabs(floor(item->x)-item->x)<0.01 && fabs(floor(item->y)-item->y)<0.01) {
!                          gdk_cairo_set_color (ct, &style->base[GTK_STATE_NORMAL]);
                       } else {
!                          gdk_cairo_set_color (ct, &style->base[GTK_STATE_NORMAL]);
                       }
                    }
!                   cairo_fill (ct);
!                cairo_restore (ct);
                 if (item_no==puzzle->grabbed) {
!                  gdk_cairo_set_color (ct, &style->mid[GTK_STATE_SELECTED]);
                 } else {
                    if ( fabs(floor(item->x)-item->x)<0.01 && fabs(floor(item->y)-item->y)<0.01) {
!                       gdk_cairo_set_color (ct, &style->mid[GTK_STATE_NORMAL]);
                    } else {
!                       gdk_cairo_set_color (ct, &style->dark[GTK_STATE_ACTIVE]);
                    }
                 }
!                cairo_set_line_width (ct, 0.05);
!                cairo_stroke (ct);
  
                  {
                    cairo_text_extents_t extents;
!                   cairo_select_font (ct, "sans", 0, 0);
!                   cairo_scale_font (ct, 0.35);
!                   cairo_text_extents (ct, item->label, &extents);
  
!                   cairo_move_to (ct, item->x-extents.width/2 - extents.x_bearing   , item->y - extents.height/2 - extents.y_bearing);
  
                  }
                 if (item_no==puzzle->grabbed) {
!                   gdk_cairo_set_color (ct, &style->text[GTK_STATE_SELECTED]);
                 } else {
                    if ( fabs(floor(item->x)-item->x)<0.01 && fabs(floor(item->y)-item->y)<0.01) {
!                       gdk_cairo_set_color (ct, &style->text[GTK_STATE_NORMAL]);
                    } else {
!                       gdk_cairo_set_color (ct, &style->text[GTK_STATE_NORMAL]);
                    }
                 }
!                cairo_show_text (ct, item->label);
          }
  
!     cairo_restore (ct);
  }
  
--- 565,637 ----
      style = GTK_WIDGET (puzzle)->style;
  
!     cairo_save (cr);
!     cairo_scale (cr, puzzle->ratio_x, puzzle->ratio_y);
!     cairo_translate (cr, 0.5, 0.5);
  
          for (item_no=0;item_no<puzzle->rows*puzzle->cols-1;item_no++) {
              struct PuzzleItem *item= & (puzzle->item [item_no]);
!                cairo_rectangle_round (cr, item->x-0.36, item->y-0.36, 0.8, 0.8, 0.4);
!                cairo_set_line_width (cr, 0.07);
                 if (item_no==puzzle->grabbed) {
  
!                   gdk_cairo_set_color (cr, &style->dark[GTK_STATE_NORMAL]);
  
                 } else {
                    if ( fabs(floor(item->x)-item->x)<0.01 && fabs(floor(item->y)-item->y)<0.01) {
!                       gdk_cairo_set_color (cr, &style->dark[GTK_STATE_NORMAL]);
                    } else {
!                       gdk_cairo_set_color (cr, &style->dark[GTK_STATE_ACTIVE]);
                    }
                 }
  
!                cairo_stroke (cr);
  
!                cairo_rectangle_round (cr, item->x-0.4, item->y-0.4, 0.8, 0.8, 0.4);
!                cairo_save (cr);
                    if (item_no==puzzle->grabbed) {
!                      gdk_cairo_set_color (cr, &style->base[GTK_STATE_SELECTED]);
                    } else {
                       if ( fabs(floor(item->x)-item->x)<0.01 && fabs(floor(item->y)-item->y)<0.01) {
!                          gdk_cairo_set_color (cr, &style->base[GTK_STATE_NORMAL]);
                       } else {
!                          gdk_cairo_set_color (cr, &style->base[GTK_STATE_NORMAL]);
                       }
                    }
!                   cairo_fill (cr);
!                cairo_restore (cr);
                 if (item_no==puzzle->grabbed) {
!                  gdk_cairo_set_color (cr, &style->mid[GTK_STATE_SELECTED]);
                 } else {
                    if ( fabs(floor(item->x)-item->x)<0.01 && fabs(floor(item->y)-item->y)<0.01) {
!                       gdk_cairo_set_color (cr, &style->mid[GTK_STATE_NORMAL]);
                    } else {
!                       gdk_cairo_set_color (cr, &style->dark[GTK_STATE_ACTIVE]);
                    }
                 }
!                cairo_set_line_width (cr, 0.05);
!                cairo_stroke (cr);
  
                  {
                    cairo_text_extents_t extents;
!                   cairo_select_font (cr, "sans", 0, 0);
!                   cairo_scale_font (cr, 0.35);
!                   cairo_text_extents (cr, item->label, &extents);
  
!                   cairo_move_to (cr, item->x-extents.width/2 - extents.x_bearing   , item->y - extents.height/2 - extents.y_bearing);
  
                  }
                 if (item_no==puzzle->grabbed) {
!                   gdk_cairo_set_color (cr, &style->text[GTK_STATE_SELECTED]);
                 } else {
                    if ( fabs(floor(item->x)-item->x)<0.01 && fabs(floor(item->y)-item->y)<0.01) {
!                       gdk_cairo_set_color (cr, &style->text[GTK_STATE_NORMAL]);
                    } else {
!                       gdk_cairo_set_color (cr, &style->text[GTK_STATE_NORMAL]);
                    }
                 }
!                cairo_show_text (cr, item->label);
          }
  
!     cairo_restore (cr);
  }
  





More information about the cairo-commit mailing list