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

This commit is contained in:
Michael Natterer 2010-09-09 21:50:55 +02:00
parent d9932ff159
commit a0d3d8d763
5 changed files with 135 additions and 277 deletions

View File

@ -83,15 +83,10 @@ void
rcm_360_degrees (GtkWidget *button, rcm_360_degrees (GtkWidget *button,
RcmCircle *circle) RcmCircle *circle)
{ {
GtkStyle *style = gtk_widget_get_style (circle->preview);
circle->action_flag = DO_NOTHING;
gtk_widget_queue_draw (circle->preview); gtk_widget_queue_draw (circle->preview);
circle->angle->beta = circle->angle->alpha-circle->angle->cw_ccw * 0.001; 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); rcm_render_preview (Current.Bna->after);
} }
@ -116,18 +111,10 @@ void
rcm_a_to_b (GtkWidget *button, rcm_a_to_b (GtkWidget *button,
RcmCircle *circle) RcmCircle *circle)
{ {
GtkStyle *style = gtk_widget_get_style (circle->preview);
circle->action_flag = DO_NOTHING;
gtk_widget_queue_draw (circle->preview); gtk_widget_queue_draw (circle->preview);
SWAP (circle->angle->alpha, circle->angle->beta); 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); rcm_render_preview (Current.Bna->after);
} }
@ -181,10 +168,6 @@ rcm_switch_to_degrees (GtkWidget *button,
rcm_spinbutton_to_degrees (Current.Gray->hue_entry, rcm_spinbutton_to_degrees (Current.Gray->hue_entry,
Current.Gray->hue, Current.Gray->hue,
Current.Gray->hue_units_label); 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, rcm_spinbutton_to_radians (Current.Gray->hue_entry,
Current.Gray->hue, Current.Gray->hue,
Current.Gray->hue_units_label); 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, rcm_spinbutton_to_radians_over_PI (Current.Gray->hue_entry,
Current.Gray->hue, Current.Gray->hue,
Current.Gray->hue_units_label); 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, GdkEventExpose *event,
RcmCircle *circle) RcmCircle *circle)
{ {
if (circle->action_flag == VIRGIN) cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
{
GtkStyle *style = gtk_widget_get_style (widget);
color_rotate_draw_arrows (gtk_widget_get_window (widget), cairo_translate (cr, 0.5, 0.5);
style->black_gc,
circle->angle); color_rotate_draw_arrows (cr, circle->angle);
}
cairo_destroy (cr);
return TRUE; return TRUE;
} }
@ -384,7 +358,6 @@ rcm_button_press_event (GtkWidget *widget,
alpha = &circle->angle->alpha; alpha = &circle->angle->alpha;
beta = &circle->angle->beta; beta = &circle->angle->beta;
circle->action_flag = DRAG_START;
clicked_angle = angle_mod_2PI (arctg (CENTER - event->y, event->x - CENTER)); clicked_angle = angle_mod_2PI (arctg (CENTER - event->y, event->x - CENTER));
circle->prev_clicked = clicked_angle; circle->prev_clicked = clicked_angle;
@ -397,13 +370,8 @@ rcm_button_press_event (GtkWidget *widget,
if (*(circle->target) != clicked_angle) if (*(circle->target) != clicked_angle)
{ {
GtkStyle *style = gtk_widget_get_style (widget);
*(circle->target) = clicked_angle; *(circle->target) = clicked_angle;
gtk_widget_queue_draw (circle->preview); 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), gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->alpha_entry),
circle->angle->alpha * circle->angle->alpha *
@ -428,18 +396,6 @@ rcm_release_event (GtkWidget *widget,
GdkEventButton *event, GdkEventButton *event,
RcmCircle *circle) 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); rcm_render_preview (Current.Bna->after);
return TRUE; return TRUE;
@ -450,20 +406,15 @@ rcm_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event, GdkEventMotion *event,
RcmCircle *circle) RcmCircle *circle)
{ {
gfloat clicked_angle, delta; gfloat clicked_angle, delta;
gfloat *alpha, *beta; gfloat *alpha, *beta;
gint cw_ccw; gint cw_ccw;
GdkGCValues values;
alpha = &(circle->angle->alpha); alpha = &(circle->angle->alpha);
beta = &(circle->angle->beta); beta = &(circle->angle->beta);
cw_ccw = circle->angle->cw_ccw; cw_ccw = circle->angle->cw_ccw;
delta = angle_mod_2PI (cw_ccw * (*beta - *alpha)); 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)); 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 (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) if (circle->mode == EACH)
{ {
*(circle->target)=clicked_angle; *(circle->target) = clicked_angle;
} }
else else
{ {
circle->angle->alpha=angle_mod_2PI(circle->angle->alpha + delta); circle->angle->alpha = angle_mod_2PI (circle->angle->alpha + delta);
circle->angle->beta =angle_mod_2PI(circle->angle->beta + 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); 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), gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->alpha_entry),
circle->angle->alpha * circle->angle->alpha *
@ -523,19 +461,14 @@ rcm_gray_expose_event (GtkWidget *widget,
GdkEventExpose *event, GdkEventExpose *event,
RcmGray *circle) RcmGray *circle)
{ {
if (circle->action_flag == VIRGIN) cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
{
GtkStyle *style = gtk_widget_get_style (widget);
GdkWindow *window = gtk_widget_get_window (widget);
color_rotate_draw_little_circle (window, cairo_translate (cr, 0.5, 0.5);
style->black_gc,
circle->hue, circle->satur);
color_rotate_draw_large_circle (window, color_rotate_draw_little_circle (cr, circle->hue, circle->satur);
style->black_gc, color_rotate_draw_large_circle (cr, circle->gray_sat);
circle->gray_sat);
} cairo_destroy (cr);
return TRUE; return TRUE;
} }
@ -545,27 +478,18 @@ rcm_gray_button_press_event (GtkWidget *widget,
GdkEventButton *event, GdkEventButton *event,
RcmGray *circle) RcmGray *circle)
{ {
GtkStyle *style = gtk_widget_get_style (widget); gint x, y;
int x, y;
x = event->x - GRAY_CENTER - LITTLE_RADIUS; x = event->x - GRAY_CENTER - LITTLE_RADIUS;
y = GRAY_CENTER - event->y + LITTLE_RADIUS; y = GRAY_CENTER - event->y + LITTLE_RADIUS;
circle->action_flag = DRAG_START; circle->hue = angle_mod_2PI(arctg(y, x));
circle->hue = angle_mod_2PI(arctg(y, x)); circle->satur = sqrt (SQR (x) + SQR (y)) / GRAY_RADIUS;
circle->satur = sqrt (SQR (x) + SQR (y)) / GRAY_RADIUS;
if (circle->satur > 1.0) if (circle->satur > 1.0)
circle->satur = 1; circle->satur = 1;
gtk_widget_queue_draw (circle->preview); 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), gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->hue_entry),
circle->hue * rcm_units_factor (Current.Units)); circle->hue * rcm_units_factor (Current.Units));
@ -584,18 +508,6 @@ rcm_gray_release_event (GtkWidget *widget,
GdkEventButton *event, GdkEventButton *event,
RcmGray *circle) 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); rcm_render_preview (Current.Bna->after);
return TRUE; return TRUE;
@ -606,30 +518,9 @@ rcm_gray_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event, GdkEventMotion *event,
RcmGray *circle) RcmGray *circle)
{ {
gint x, y; gint x, y;
GdkGCValues values;
values.function = GDK_INVERT; gtk_widget_queue_draw (circle->preview);
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);
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 */
}
x = event->x - GRAY_CENTER - LITTLE_RADIUS; x = event->x - GRAY_CENTER - LITTLE_RADIUS;
y = GRAY_CENTER - event->y + 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) if (circle->satur > 1.0)
circle->satur = 1; 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), gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->hue_entry),
circle->hue * rcm_units_factor(Current.Units)); circle->hue * rcm_units_factor(Current.Units));
@ -664,20 +552,11 @@ void
rcm_set_alpha (GtkWidget *entry, rcm_set_alpha (GtkWidget *entry,
RcmCircle *circle) 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)) / circle->angle->alpha = (gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry)) /
rcm_units_factor (Current.Units)); rcm_units_factor (Current.Units));
gtk_widget_queue_draw (circle->preview); 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); rcm_render_preview (Current.Bna->after);
} }
@ -685,20 +564,11 @@ void
rcm_set_beta (GtkWidget *entry, rcm_set_beta (GtkWidget *entry,
RcmCircle *circle) 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)) / circle->angle->beta = (gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry)) /
rcm_units_factor(Current.Units)); rcm_units_factor(Current.Units));
gtk_widget_queue_draw (circle->preview); 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); rcm_render_preview (Current.Bna->after);
} }
@ -706,24 +576,11 @@ void
rcm_set_hue (GtkWidget *entry, rcm_set_hue (GtkWidget *entry,
RcmGray *circle) 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)) / circle->hue = (gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry)) /
rcm_units_factor(Current.Units)); rcm_units_factor(Current.Units));
gtk_widget_queue_draw (circle->preview); 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); rcm_render_preview (Current.Bna->after);
} }
@ -731,23 +588,10 @@ void
rcm_set_satur (GtkWidget *entry, rcm_set_satur (GtkWidget *entry,
RcmGray *circle) 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)); circle->satur = gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry));
gtk_widget_queue_draw (circle->preview); 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); rcm_render_preview (Current.Bna->after);
} }
@ -755,15 +599,9 @@ void
rcm_set_gray_sat (GtkWidget *entry, rcm_set_gray_sat (GtkWidget *entry,
RcmGray *circle) RcmGray *circle)
{ {
GtkStyle *style = gtk_widget_get_style (circle->preview);
circle->gray_sat = gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry)); circle->gray_sat = gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry));
gtk_widget_queue_draw (circle->preview); 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); rcm_render_preview (Current.Bna->after);
} }

View File

@ -200,7 +200,6 @@ rcm_create_one_circle (gint height,
st = g_new (RcmCircle, 1); st = g_new (RcmCircle, 1);
st->action_flag = VIRGIN;
st->angle = g_new (RcmAngle, 1); st->angle = g_new (RcmAngle, 1);
st->angle->alpha = INITIAL_ALPHA; st->angle->alpha = INITIAL_ALPHA;
st->angle->beta = INITIAL_BETA; st->angle->beta = INITIAL_BETA;
@ -407,9 +406,8 @@ rcm_create_gray (void)
GtkAdjustment *adj; GtkAdjustment *adj;
Current.Gray = st = g_new (RcmGray, 1); Current.Gray = st = g_new (RcmGray, 1);
st->hue = 0; st->hue = 0;
st->satur = 0; st->satur = 0;
st->action_flag = VIRGIN;
top_vbox = gtk_vbox_new (FALSE, 12); top_vbox = gtk_vbox_new (FALSE, 12);
gtk_container_set_border_width (GTK_CONTAINER (top_vbox), 12); gtk_container_set_border_width (GTK_CONTAINER (top_vbox), 12);

View File

@ -46,55 +46,59 @@
#include "color-rotate-draw.h" #include "color-rotate-draw.h"
/* Global variables */
GdkGC *xor_gc;
/* Drawing routines */ /* Drawing routines */
void void
color_rotate_draw_little_circle (GdkWindow *window, color_rotate_draw_little_circle (cairo_t *cr,
GdkGC *color, gfloat hue,
gfloat hue, gfloat satur)
gfloat satur)
{ {
gint x,y; gint x, y;
x = GRAY_CENTER + GRAY_RADIUS * satur * cos(hue); x = GRAY_CENTER + GRAY_RADIUS * satur * cos(hue);
y = GRAY_CENTER - GRAY_RADIUS * satur * sin(hue); y = GRAY_CENTER - GRAY_RADIUS * satur * sin(hue);
gdk_draw_arc (window, color, 0, x-LITTLE_RADIUS, y-LITTLE_RADIUS, cairo_new_sub_path (cr);
2*LITTLE_RADIUS, 2*LITTLE_RADIUS, 0, 360*64); 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 void
color_rotate_draw_large_circle (GdkWindow *window, color_rotate_draw_large_circle (cairo_t *cr,
GdkGC *color, gfloat gray_sat)
gfloat gray_sat)
{ {
gint x, y; gint x, y;
x = GRAY_CENTER; x = GRAY_CENTER;
y = GRAY_CENTER; y = GRAY_CENTER;
gdk_draw_arc (window, color, 0, cairo_new_sub_path (cr);
ROUND (x - GRAY_RADIUS * gray_sat), cairo_arc (cr, x, y, GRAY_RADIUS * gray_sat, 0, 2 * G_PI);
ROUND (y - GRAY_RADIUS * gray_sat),
ROUND (2 * GRAY_RADIUS * gray_sat), cairo_set_line_width (cr, 3.0);
ROUND (2 * GRAY_RADIUS * gray_sat), cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6);
0, 360 * 64); 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 REL 0.8
#define DEL .1 #define DEL 0.1
#define TICK 10 #define TICK 10
void void
color_rotate_draw_arrows (GdkWindow *window, color_rotate_draw_arrows (cairo_t *cr,
GdkGC *color, RcmAngle *angle)
RcmAngle *angle)
{ {
gint dist; gint dist;
gfloat alpha, beta, cw_ccw, delta; gfloat alpha, beta, cw_ccw, delta;
@ -102,58 +106,86 @@ color_rotate_draw_arrows (GdkWindow *window,
alpha = angle->alpha; alpha = angle->alpha;
beta = angle->beta; beta = angle->beta;
cw_ccw = angle->cw_ccw; cw_ccw = angle->cw_ccw;
delta = angle_mod_2PI(beta - alpha); delta = angle_mod_2PI (beta - alpha);
if (cw_ccw == -1) if (cw_ccw == -1)
delta = delta - TP; delta = delta - TP;
gdk_draw_line (window,color, 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,
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,
CENTER, CENTER,
ROUND (CENTER + RADIUS * cos(alpha)), dist,
ROUND (CENTER - RADIUS * sin(alpha))); -alpha,
-beta);
}
gdk_draw_line( window,color, cairo_set_line_width (cr, 3.0);
CENTER + RADIUS * cos(alpha), cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6);
CENTER - RADIUS * sin(alpha), cairo_stroke_preserve (cr);
ROUND (CENTER + RADIUS * REL * cos(alpha - DEL)),
ROUND (CENTER - RADIUS * REL * sin(alpha - DEL)));
gdk_draw_line (window,color, cairo_set_line_width (cr, 1.0);
CENTER + RADIUS * cos(alpha), cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.8);
CENTER - RADIUS * sin(alpha), cairo_stroke (cr);
ROUND (CENTER + RADIUS * REL * cos(alpha + DEL)),
ROUND (CENTER - RADIUS * REL * sin(alpha + DEL)));
gdk_draw_line (window,color,
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);
} }

View File

@ -52,19 +52,10 @@
#define EACH_OR_BOTH 0.3 #define EACH_OR_BOTH 0.3
void color_rotate_draw_little_circle (cairo_t *cr,
/* Global variables */
extern GdkGC *xor_gc;
void color_rotate_draw_little_circle (GdkWindow *window,
GdkGC *color,
gfloat hue, gfloat hue,
gfloat satur); gfloat satur);
void color_rotate_draw_large_circle (GdkWindow *window, void color_rotate_draw_large_circle (cairo_t *cr,
GdkGC *color,
gfloat gray_sat); gfloat gray_sat);
void color_rotate_draw_arrows (GdkWindow *window, void color_rotate_draw_arrows (cairo_t *cr,
GdkGC *color,
RcmAngle *angle); RcmAngle *angle);

View File

@ -90,7 +90,6 @@ typedef struct
gfloat *target; gfloat *target;
gint mode; gint mode;
RcmAngle *angle; RcmAngle *angle;
RcmOp action_flag;
gfloat prev_clicked; gfloat prev_clicked;
} RcmCircle; } RcmCircle;