[gimp] plug-ins: port color-rotate drawing to cairo and simplify the code



commit a0d3d8d7631151712b1cfc1c65815913e386804b
Author: Michael Natterer <mitch gimp org>
Date:   Thu Sep 9 21:50:55 2010 +0200

    plug-ins: port color-rotate drawing to cairo and simplify the code

 plug-ins/color-rotate/color-rotate-callbacks.c |  214 +++---------------------
 plug-ins/color-rotate/color-rotate-dialog.c    |    6 +-
 plug-ins/color-rotate/color-rotate-draw.c      |  178 ++++++++++++--------
 plug-ins/color-rotate/color-rotate-draw.h      |   15 +--
 plug-ins/color-rotate/color-rotate.h           |    1 -
 5 files changed, 136 insertions(+), 278 deletions(-)
---
diff --git a/plug-ins/color-rotate/color-rotate-callbacks.c b/plug-ins/color-rotate/color-rotate-callbacks.c
index c218b89..eca631b 100644
--- a/plug-ins/color-rotate/color-rotate-callbacks.c
+++ b/plug-ins/color-rotate/color-rotate-callbacks.c
@@ -83,15 +83,10 @@ void
 rcm_360_degrees (GtkWidget *button,
 		 RcmCircle *circle)
 {
-  GtkStyle *style = gtk_widget_get_style (circle->preview);
-
-  circle->action_flag = DO_NOTHING;
   gtk_widget_queue_draw (circle->preview);
+
   circle->angle->beta = circle->angle->alpha-circle->angle->cw_ccw * 0.001;
-  color_rotate_draw_arrows (gtk_widget_get_window (circle->preview),
-                            style->black_gc,
-                            circle->angle);
-  circle->action_flag = VIRGIN;
+
   rcm_render_preview (Current.Bna->after);
 }
 
@@ -116,18 +111,10 @@ void
 rcm_a_to_b (GtkWidget *button,
 	    RcmCircle *circle)
 {
-  GtkStyle *style = gtk_widget_get_style (circle->preview);
-
-  circle->action_flag = DO_NOTHING;
   gtk_widget_queue_draw (circle->preview);
 
   SWAP (circle->angle->alpha, circle->angle->beta);
 
-  color_rotate_draw_arrows (gtk_widget_get_window (circle->preview),
-                            style->black_gc,
-                            circle->angle);
-
-  circle->action_flag = VIRGIN;
   rcm_render_preview (Current.Bna->after);
 }
 
@@ -181,10 +168,6 @@ rcm_switch_to_degrees (GtkWidget *button,
       rcm_spinbutton_to_degrees (Current.Gray->hue_entry,
                                  Current.Gray->hue,
                                  Current.Gray->hue_units_label);
-
-      Current.From->action_flag = VIRGIN;
-      Current.To->action_flag   = VIRGIN;
-      Current.Gray->action_flag = VIRGIN;
     }
 }
 
@@ -235,10 +218,6 @@ rcm_switch_to_radians (GtkWidget *button,
       rcm_spinbutton_to_radians (Current.Gray->hue_entry,
                                  Current.Gray->hue,
                                  Current.Gray->hue_units_label);
-
-      Current.From->action_flag = VIRGIN;
-      Current.To->action_flag   = VIRGIN;
-      Current.Gray->action_flag = VIRGIN;
     }
 }
 
@@ -289,10 +268,6 @@ rcm_switch_to_radians_over_PI (GtkWidget *button,
       rcm_spinbutton_to_radians_over_PI (Current.Gray->hue_entry,
                                          Current.Gray->hue,
                                          Current.Gray->hue_units_label);
-
-      Current.From->action_flag = VIRGIN;
-      Current.To->action_flag   = VIRGIN;
-      Current.Gray->action_flag = VIRGIN;
     }
 }
 
@@ -360,14 +335,13 @@ rcm_expose_event (GtkWidget      *widget,
 		  GdkEventExpose *event,
 		  RcmCircle      *circle)
 {
-  if (circle->action_flag == VIRGIN)
-    {
-      GtkStyle *style = gtk_widget_get_style (widget);
+  cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
 
-      color_rotate_draw_arrows (gtk_widget_get_window (widget),
-                                style->black_gc,
-                                circle->angle);
-    }
+  cairo_translate (cr, 0.5, 0.5);
+
+  color_rotate_draw_arrows (cr, circle->angle);
+
+  cairo_destroy (cr);
 
   return TRUE;
 }
@@ -384,7 +358,6 @@ rcm_button_press_event (GtkWidget      *widget,
   alpha  = &circle->angle->alpha;
   beta   = &circle->angle->beta;
 
-  circle->action_flag = DRAG_START;
   clicked_angle = angle_mod_2PI (arctg (CENTER - event->y, event->x - CENTER));
   circle->prev_clicked = clicked_angle;
 
@@ -397,13 +370,8 @@ rcm_button_press_event (GtkWidget      *widget,
 
       if (*(circle->target) != clicked_angle)
         {
-          GtkStyle *style = gtk_widget_get_style (widget);
-
           *(circle->target) = clicked_angle;
           gtk_widget_queue_draw (circle->preview);
-          color_rotate_draw_arrows (gtk_widget_get_window (widget),
-                                    style->black_gc,
-                                    circle->angle);
 
           gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->alpha_entry),
                                      circle->angle->alpha *
@@ -428,18 +396,6 @@ rcm_release_event (GtkWidget      *widget,
 		   GdkEventButton *event,
 		   RcmCircle      *circle)
 {
-  if (circle->action_flag == DRAGING)
-    {
-      GtkStyle *style = gtk_widget_get_style (widget);
-
-      gtk_widget_queue_draw (circle->preview);
-      color_rotate_draw_arrows (gtk_widget_get_window (widget),
-                                style->black_gc,
-                                circle->angle);
-    }
-
-  circle->action_flag = VIRGIN;
-
   rcm_render_preview (Current.Bna->after);
 
   return TRUE;
@@ -450,20 +406,15 @@ rcm_motion_notify_event (GtkWidget      *widget,
 			 GdkEventMotion *event,
 			 RcmCircle      *circle)
 {
-  gfloat       clicked_angle, delta;
-  gfloat      *alpha, *beta;
-  gint         cw_ccw;
-  GdkGCValues  values;
+  gfloat  clicked_angle, delta;
+  gfloat *alpha, *beta;
+  gint    cw_ccw;
 
   alpha  = &(circle->angle->alpha);
   beta   = &(circle->angle->beta);
   cw_ccw = circle->angle->cw_ccw;
   delta  = angle_mod_2PI (cw_ccw * (*beta - *alpha));
 
-  values.function = GDK_INVERT;
-  xor_gc = gdk_gc_new_with_values (gtk_widget_get_window (Current.From->preview),
-                                   &values,
-                                   GDK_GC_FUNCTION);
 
   clicked_angle = angle_mod_2PI (arctg (CENTER - event->y, event->x - CENTER));
 
@@ -472,31 +423,18 @@ rcm_motion_notify_event (GtkWidget      *widget,
 
   if (delta)
     {
-      if (circle->action_flag == DRAG_START)
-        {
-          gtk_widget_queue_draw (circle->preview);
-          circle->action_flag = DRAGING;
-        }
-      else
-        {
-          /* this should be erasing entire angle */
-          color_rotate_draw_arrows (gtk_widget_get_window (widget),
-                                    xor_gc, circle->angle);
-        }
-
       if (circle->mode == EACH)
         {
-          *(circle->target)=clicked_angle;
+          *(circle->target) = clicked_angle;
         }
       else
         {
-          circle->angle->alpha=angle_mod_2PI(circle->angle->alpha + delta);
-          circle->angle->beta =angle_mod_2PI(circle->angle->beta  + delta);
+          circle->angle->alpha = angle_mod_2PI (circle->angle->alpha + delta);
+          circle->angle->beta  = angle_mod_2PI (circle->angle->beta  + delta);
         }
 
+      gtk_widget_queue_draw (widget);
       gdk_window_process_updates (gtk_widget_get_window (widget), FALSE);
-      color_rotate_draw_arrows (gtk_widget_get_window (widget),
-                                xor_gc, circle->angle);
 
       gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->alpha_entry),
                                  circle->angle->alpha *
@@ -523,19 +461,14 @@ rcm_gray_expose_event (GtkWidget      *widget,
 		       GdkEventExpose *event,
 		       RcmGray        *circle)
 {
-  if (circle->action_flag == VIRGIN)
-    {
-      GtkStyle  *style  = gtk_widget_get_style (widget);
-      GdkWindow *window = gtk_widget_get_window (widget);
+  cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
 
-      color_rotate_draw_little_circle (window,
-                                       style->black_gc,
-                                       circle->hue, circle->satur);
+  cairo_translate (cr, 0.5, 0.5);
 
-      color_rotate_draw_large_circle (window,
-                                      style->black_gc,
-                                      circle->gray_sat);
-    }
+  color_rotate_draw_little_circle (cr, circle->hue, circle->satur);
+  color_rotate_draw_large_circle (cr, circle->gray_sat);
+
+  cairo_destroy (cr);
 
   return TRUE;
 }
@@ -545,27 +478,18 @@ rcm_gray_button_press_event (GtkWidget      *widget,
 			     GdkEventButton *event,
 			     RcmGray        *circle)
 {
-  GtkStyle *style = gtk_widget_get_style (widget);
-  int       x, y;
+  gint x, y;
 
   x = event->x - GRAY_CENTER - LITTLE_RADIUS;
   y = GRAY_CENTER - event->y + LITTLE_RADIUS;
 
-  circle->action_flag = DRAG_START;
-  circle->hue         = angle_mod_2PI(arctg(y, x));
-  circle->satur       = sqrt (SQR (x) + SQR (y)) / GRAY_RADIUS;
+  circle->hue   = angle_mod_2PI(arctg(y, x));
+  circle->satur = sqrt (SQR (x) + SQR (y)) / GRAY_RADIUS;
 
   if (circle->satur > 1.0)
     circle->satur = 1;
 
   gtk_widget_queue_draw (circle->preview);
-  color_rotate_draw_little_circle (gtk_widget_get_window (widget),
-                                   style->black_gc,
-                                   circle->hue, circle->satur);
-
-  color_rotate_draw_large_circle (gtk_widget_get_window (circle->preview),
-                                  gtk_widget_get_style (circle->preview)->black_gc,
-                                  circle->gray_sat);
 
   gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->hue_entry),
                              circle->hue * rcm_units_factor (Current.Units));
@@ -584,18 +508,6 @@ rcm_gray_release_event (GtkWidget      *widget,
 			GdkEventButton *event,
 			RcmGray        *circle)
 {
-  if (circle->action_flag == DRAGING)
-    {
-      GtkStyle *style = gtk_widget_get_style (widget);
-
-      color_rotate_draw_little_circle (gtk_widget_get_window (widget),
-                                       style->black_gc,
-                                       circle->hue,
-                                       circle->satur);
-    }
-
-  circle->action_flag = VIRGIN;
-
   rcm_render_preview (Current.Bna->after);
 
   return TRUE;
@@ -606,30 +518,9 @@ rcm_gray_motion_notify_event (GtkWidget      *widget,
 			      GdkEventMotion *event,
 			      RcmGray        *circle)
 {
-  gint        x, y;
-  GdkGCValues values;
-
-  values.function = GDK_INVERT;
-  xor_gc = gdk_gc_new_with_values (gtk_widget_get_window (Current.From->preview),
-				   &values,
-                                   GDK_GC_FUNCTION);
-
-  if (circle->action_flag == DRAG_START)
-    {
-      GtkStyle *style = gtk_widget_get_style (circle->preview);
+  gint x, y;
 
-      gtk_widget_queue_draw (circle->preview);
-      color_rotate_draw_large_circle (gtk_widget_get_window (circle->preview),
-                                      style->black_gc,
-                                      circle->gray_sat);
-
-      circle->action_flag = DRAGING;
-    }
-  else
-    {
-      color_rotate_draw_little_circle (gtk_widget_get_window (widget), xor_gc,
-                                       circle->hue, circle->satur); /* erase */
-    }
+  gtk_widget_queue_draw (circle->preview);
 
   x = event->x - GRAY_CENTER - LITTLE_RADIUS;
   y = GRAY_CENTER - event->y + LITTLE_RADIUS;
@@ -640,9 +531,6 @@ rcm_gray_motion_notify_event (GtkWidget      *widget,
   if (circle->satur > 1.0)
     circle->satur = 1;
 
-  color_rotate_draw_little_circle (gtk_widget_get_window (widget), xor_gc,
-                                   circle->hue, circle->satur);
-
   gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->hue_entry),
                              circle->hue * rcm_units_factor(Current.Units));
 
@@ -664,20 +552,11 @@ void
 rcm_set_alpha (GtkWidget *entry,
                RcmCircle *circle)
 {
-  GtkStyle *style = gtk_widget_get_style (circle->preview);
-
-  if (circle->action_flag != VIRGIN)
-    return;
-
   circle->angle->alpha = (gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry)) /
                           rcm_units_factor (Current.Units));
 
   gtk_widget_queue_draw (circle->preview);
 
-  color_rotate_draw_arrows (gtk_widget_get_window (circle->preview),
-                            style->black_gc,
-                            circle->angle);
-
   rcm_render_preview (Current.Bna->after);
 }
 
@@ -685,20 +564,11 @@ void
 rcm_set_beta (GtkWidget *entry,
               RcmCircle *circle)
 {
-  GtkStyle *style = gtk_widget_get_style (circle->preview);
-
-  if (circle->action_flag != VIRGIN)
-    return;
-
   circle->angle->beta = (gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry)) /
                          rcm_units_factor(Current.Units));
 
   gtk_widget_queue_draw (circle->preview);
 
-  color_rotate_draw_arrows (gtk_widget_get_window (circle->preview),
-                            style->black_gc,
-                            circle->angle);
-
   rcm_render_preview (Current.Bna->after);
 }
 
@@ -706,24 +576,11 @@ void
 rcm_set_hue (GtkWidget *entry,
              RcmGray   *circle)
 {
-  GtkStyle *style = gtk_widget_get_style (circle->preview);
-
-  if (circle->action_flag != VIRGIN)
-    return;
-
   circle->hue = (gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry)) /
                  rcm_units_factor(Current.Units));
 
   gtk_widget_queue_draw (circle->preview);
 
-  color_rotate_draw_little_circle (gtk_widget_get_window (circle->preview),
-                                   style->black_gc,
-                                   circle->hue, circle->satur);
-
-  color_rotate_draw_large_circle (gtk_widget_get_window (circle->preview),
-                                  style->black_gc,
-                                  circle->gray_sat);
-
   rcm_render_preview (Current.Bna->after);
 }
 
@@ -731,23 +588,10 @@ void
 rcm_set_satur (GtkWidget *entry,
                RcmGray   *circle)
 {
-  GtkStyle *style = gtk_widget_get_style (circle->preview);
-
-  if (circle->action_flag != VIRGIN)
-    return;
-
   circle->satur = gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry));
 
   gtk_widget_queue_draw (circle->preview);
 
-  color_rotate_draw_little_circle (gtk_widget_get_window (circle->preview),
-                                   style->black_gc,
-                                   circle->hue, circle->satur);
-
-  color_rotate_draw_large_circle (gtk_widget_get_window (circle->preview),
-                                  style->black_gc,
-                                  circle->gray_sat);
-
   rcm_render_preview (Current.Bna->after);
 }
 
@@ -755,15 +599,9 @@ void
 rcm_set_gray_sat (GtkWidget *entry,
                   RcmGray   *circle)
 {
-  GtkStyle *style = gtk_widget_get_style (circle->preview);
-
   circle->gray_sat = gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry));
 
   gtk_widget_queue_draw (circle->preview);
 
-  color_rotate_draw_large_circle (gtk_widget_get_window (circle->preview),
-                                  style->black_gc,
-                                  circle->gray_sat);
-
   rcm_render_preview (Current.Bna->after);
 }
diff --git a/plug-ins/color-rotate/color-rotate-dialog.c b/plug-ins/color-rotate/color-rotate-dialog.c
index be75a55..2e950b4 100644
--- a/plug-ins/color-rotate/color-rotate-dialog.c
+++ b/plug-ins/color-rotate/color-rotate-dialog.c
@@ -200,7 +200,6 @@ rcm_create_one_circle (gint         height,
 
   st = g_new (RcmCircle, 1);
 
-  st->action_flag   = VIRGIN;
   st->angle         = g_new (RcmAngle, 1);
   st->angle->alpha  = INITIAL_ALPHA;
   st->angle->beta   = INITIAL_BETA;
@@ -407,9 +406,8 @@ rcm_create_gray (void)
   GtkAdjustment *adj;
 
   Current.Gray = st = g_new (RcmGray, 1);
-  st->hue         = 0;
-  st->satur       = 0;
-  st->action_flag = VIRGIN;
+  st->hue   = 0;
+  st->satur = 0;
 
   top_vbox = gtk_vbox_new (FALSE, 12);
   gtk_container_set_border_width (GTK_CONTAINER (top_vbox), 12);
diff --git a/plug-ins/color-rotate/color-rotate-draw.c b/plug-ins/color-rotate/color-rotate-draw.c
index 1a72b4c..e8c08dd 100644
--- a/plug-ins/color-rotate/color-rotate-draw.c
+++ b/plug-ins/color-rotate/color-rotate-draw.c
@@ -46,55 +46,59 @@
 #include "color-rotate-draw.h"
 
 
-/* Global variables */
-
-GdkGC *xor_gc;
-
-
 /* Drawing routines */
 
 void
-color_rotate_draw_little_circle (GdkWindow *window,
-                                 GdkGC     *color,
-                                 gfloat     hue,
-                                 gfloat     satur)
+color_rotate_draw_little_circle (cairo_t *cr,
+                                 gfloat   hue,
+                                 gfloat   satur)
 {
-  gint x,y;
+  gint x, y;
 
   x = GRAY_CENTER + GRAY_RADIUS * satur * cos(hue);
   y = GRAY_CENTER - GRAY_RADIUS * satur * sin(hue);
 
-  gdk_draw_arc (window, color, 0, x-LITTLE_RADIUS, y-LITTLE_RADIUS,
-                2*LITTLE_RADIUS, 2*LITTLE_RADIUS, 0, 360*64);
+  cairo_new_sub_path (cr);
+  cairo_arc (cr, x, y, LITTLE_RADIUS, 0, 2 * G_PI);
+
+  cairo_set_line_width (cr, 3.0);
+  cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6);
+  cairo_stroke_preserve (cr);
+
+  cairo_set_line_width (cr, 1.0);
+  cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.8);
+  cairo_stroke (cr);
 }
 
 void
-color_rotate_draw_large_circle (GdkWindow *window,
-                                GdkGC     *color,
-                                gfloat     gray_sat)
+color_rotate_draw_large_circle (cairo_t *cr,
+                                gfloat   gray_sat)
 {
   gint x, y;
 
   x = GRAY_CENTER;
   y = GRAY_CENTER;
 
-  gdk_draw_arc (window, color, 0,
-                ROUND (x - GRAY_RADIUS * gray_sat),
-                ROUND (y - GRAY_RADIUS * gray_sat),
-                ROUND (2 * GRAY_RADIUS * gray_sat),
-                ROUND (2 * GRAY_RADIUS * gray_sat),
-                0, 360 * 64);
+  cairo_new_sub_path (cr);
+  cairo_arc (cr, x, y, GRAY_RADIUS * gray_sat, 0, 2 * G_PI);
+
+  cairo_set_line_width (cr, 3.0);
+  cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6);
+  cairo_stroke_preserve (cr);
+
+  cairo_set_line_width (cr, 1.0);
+  cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.8);
+  cairo_stroke (cr);
 }
 
 
-#define REL .8
-#define DEL .1
+#define REL  0.8
+#define DEL  0.1
 #define TICK 10
 
 void
-color_rotate_draw_arrows (GdkWindow *window,
-                          GdkGC     *color,
-                          RcmAngle  *angle)
+color_rotate_draw_arrows (cairo_t  *cr,
+                          RcmAngle *angle)
 {
   gint   dist;
   gfloat alpha, beta, cw_ccw, delta;
@@ -102,58 +106,86 @@ color_rotate_draw_arrows (GdkWindow *window,
   alpha  = angle->alpha;
   beta   = angle->beta;
   cw_ccw = angle->cw_ccw;
-  delta  = angle_mod_2PI(beta - alpha);
+  delta  = angle_mod_2PI (beta - alpha);
 
   if (cw_ccw == -1)
     delta = delta - TP;
 
-  gdk_draw_line (window,color,
-                 CENTER,
+  cairo_move_to (cr, CENTER, CENTER);
+  cairo_line_to (cr,
+                 ROUND (CENTER + RADIUS * cos (alpha)),
+                 ROUND (CENTER - RADIUS * sin (alpha)));
+
+  cairo_move_to (cr,
+                 CENTER + RADIUS * cos (alpha),
+                 CENTER - RADIUS * sin (alpha));
+  cairo_line_to (cr,
+                 ROUND (CENTER + RADIUS * REL * cos (alpha - DEL)),
+                 ROUND (CENTER - RADIUS * REL * sin (alpha - DEL)));
+
+  cairo_move_to (cr,
+                 CENTER + RADIUS * cos (alpha),
+                 CENTER - RADIUS * sin (alpha));
+  cairo_line_to (cr,
+                 ROUND (CENTER + RADIUS * REL * cos (alpha + DEL)),
+                 ROUND (CENTER - RADIUS * REL * sin (alpha + DEL)));
+
+  cairo_move_to (cr,
                  CENTER,
-                 ROUND (CENTER + RADIUS * cos(alpha)),
-                 ROUND (CENTER - RADIUS * sin(alpha)));
-
-  gdk_draw_line( window,color,
-                 CENTER + RADIUS * cos(alpha),
-                 CENTER - RADIUS * sin(alpha),
-                 ROUND (CENTER + RADIUS * REL * cos(alpha - DEL)),
-                 ROUND (CENTER - RADIUS * REL * sin(alpha - DEL)));
-
-  gdk_draw_line (window,color,
-                 CENTER + RADIUS * cos(alpha),
-                 CENTER - RADIUS * sin(alpha),
-                 ROUND (CENTER + RADIUS * REL * cos(alpha + DEL)),
-                 ROUND (CENTER - RADIUS * REL * sin(alpha + DEL)));
-
-  gdk_draw_line (window,color,
+                 CENTER);
+  cairo_line_to (cr,
+                 ROUND (CENTER + RADIUS * cos (beta)),
+                 ROUND (CENTER - RADIUS * sin (beta)));
+
+  cairo_move_to (cr,
+                 CENTER + RADIUS * cos (beta),
+                 CENTER - RADIUS * sin (beta));
+  cairo_line_to (cr,
+                 ROUND (CENTER + RADIUS * REL * cos (beta - DEL)),
+                 ROUND (CENTER - RADIUS * REL * sin (beta - DEL)));
+
+  cairo_move_to (cr,
+                 CENTER + RADIUS * cos (beta),
+                 CENTER - RADIUS * sin (beta));
+  cairo_line_to (cr,
+                 ROUND (CENTER + RADIUS * REL * cos (beta + DEL)),
+                 ROUND (CENTER - RADIUS * REL * sin (beta + DEL)));
+
+  dist = RADIUS * EACH_OR_BOTH;
+
+  cairo_move_to (cr,
+                 CENTER + dist * cos (beta),
+                 CENTER - dist * sin (beta));
+  cairo_line_to (cr,
+                 ROUND (CENTER + dist * cos(beta) + cw_ccw * TICK * sin (beta)),
+                 ROUND (CENTER - dist * sin(beta) + cw_ccw * TICK * cos (beta)));
+
+  cairo_new_sub_path (cr);
+
+  if (cw_ccw > 0)
+    {
+      cairo_arc_negative (cr,
+                          CENTER,
+                          CENTER,
+                          dist,
+                          -alpha,
+                          -beta);
+    }
+  else
+    {
+      cairo_arc (cr,
                  CENTER,
                  CENTER,
-                 ROUND (CENTER + RADIUS * cos(beta)),
-                 ROUND (CENTER - RADIUS * sin(beta)));
-
-  gdk_draw_line (window,color,
-                 CENTER + RADIUS * cos(beta),
-                 CENTER - RADIUS * sin(beta),
-                 ROUND (CENTER + RADIUS * REL * cos(beta - DEL)),
-                 ROUND (CENTER - RADIUS * REL * sin(beta - DEL)));
-
-  gdk_draw_line (window,color,
-                 CENTER + RADIUS * cos(beta),
-                 CENTER - RADIUS * sin(beta),
-                 ROUND (CENTER + RADIUS * REL * cos(beta + DEL)),
-                 ROUND (CENTER - RADIUS * REL * sin(beta + DEL)));
-
-  dist   = RADIUS * EACH_OR_BOTH;
-
-  gdk_draw_line (window,color,
-                 CENTER + dist * cos(beta),
-                 CENTER - dist * sin(beta),
-                 ROUND (CENTER + dist * cos(beta) + cw_ccw * TICK * sin(beta)),
-                 ROUND (CENTER - dist * sin(beta) + cw_ccw * TICK * cos(beta)));
-
-  alpha *= 180 * 64 / G_PI;
-  delta *= 180 * 64 / G_PI;
-
-  gdk_draw_arc (window, color, 0, CENTER - dist, CENTER - dist,
-		2*dist, 2*dist,	alpha, delta);
+                 dist,
+                 -alpha,
+                 -beta);
+    }
+
+  cairo_set_line_width (cr, 3.0);
+  cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6);
+  cairo_stroke_preserve (cr);
+
+  cairo_set_line_width (cr, 1.0);
+  cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.8);
+  cairo_stroke (cr);
 }
diff --git a/plug-ins/color-rotate/color-rotate-draw.h b/plug-ins/color-rotate/color-rotate-draw.h
index e1ce8dd..6c226ad 100644
--- a/plug-ins/color-rotate/color-rotate-draw.h
+++ b/plug-ins/color-rotate/color-rotate-draw.h
@@ -52,19 +52,10 @@
 #define EACH_OR_BOTH  0.3
 
 
-
-/* Global variables */
-
-extern GdkGC *xor_gc;
-
-
-void color_rotate_draw_little_circle (GdkWindow *window,
-                                      GdkGC     *color,
+void color_rotate_draw_little_circle (cairo_t   *cr,
                                       gfloat     hue,
                                       gfloat     satur);
-void color_rotate_draw_large_circle  (GdkWindow *window,
-                                      GdkGC     *color,
+void color_rotate_draw_large_circle  (cairo_t   *cr,
                                       gfloat     gray_sat);
-void color_rotate_draw_arrows        (GdkWindow *window,
-                                      GdkGC     *color,
+void color_rotate_draw_arrows        (cairo_t   *cr,
                                       RcmAngle  *angle);
diff --git a/plug-ins/color-rotate/color-rotate.h b/plug-ins/color-rotate/color-rotate.h
index a42f7d6..8a74b5b 100644
--- a/plug-ins/color-rotate/color-rotate.h
+++ b/plug-ins/color-rotate/color-rotate.h
@@ -90,7 +90,6 @@ typedef struct
   gfloat     *target;
   gint        mode;
   RcmAngle   *angle;
-  RcmOp       action_flag;
   gfloat      prev_clicked;
 } RcmCircle;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]