made the indentation consistent.

1999-09-30  Michael Natterer  <mitch@gimp.org>

	* app/gradient.c: made the indentation consistent.
This commit is contained in:
Michael Natterer 1999-09-30 10:50:36 +00:00 committed by Michael Natterer
parent 762a4cb35b
commit 6afe31ff6a
5 changed files with 700 additions and 644 deletions

View File

@ -1,3 +1,7 @@
1999-09-30 Michael Natterer <mitch@gimp.org>
* app/gradient.c: made the indentation consistent.
Wed Sep 29 22:48:01 BST 1999 Adam D. Moss <adam@gimp.org> Wed Sep 29 22:48:01 BST 1999 Adam D. Moss <adam@gimp.org>
* app/gimpbrushpipe.c: very minor fix. * app/gimpbrushpipe.c: very minor fix.

View File

@ -474,8 +474,6 @@ static const gchar *coloring_types[] =
/***** Public functions *****/ /***** Public functions *****/
/*****/
void void
gradients_init (int no_data) gradients_init (int no_data)
{ {
@ -510,8 +508,11 @@ gradients_free (void)
/*****/ /*****/
void void
grad_get_color_at (double pos, grad_get_color_at (double pos,
double *r, double *g, double *b, double *a) double *r,
double *g,
double *b,
double *a)
{ {
double factor = 0.0; double factor = 0.0;
grad_segment_t *seg; grad_segment_t *seg;
@ -642,8 +643,6 @@ grad_get_color_at (double pos,
/***** The main gradient editor dialog *****/ /***** The main gradient editor dialog *****/
/*****/
void void
grad_create_gradient_editor_init (gint need_show) grad_create_gradient_editor_init (gint need_show)
{ {
@ -984,7 +983,10 @@ grad_create_gradient_editor_init (gint need_show)
/***** Gradient editor functions *****/ /***** Gradient editor functions *****/
static void static void
ed_fetch_foreground (double *fg_r, double *fg_g, double *fg_b, double *fg_a) ed_fetch_foreground (double *fg_r,
double *fg_g,
double *fg_b,
double *fg_a)
{ {
guchar r, g, b; guchar r, g, b;
@ -1094,209 +1096,222 @@ ed_set_list_of_gradients (GdkGC *gc,
/*****/ /*****/
static void static void
fill_clist_prev(gradient_t *grad, guchar *buf, gint width, gint height, double left, double right) fill_clist_prev (gradient_t *grad,
guchar *buf,
gint width,
gint height,
double left,
double right)
{ {
guchar *p0, *p1,*even,*odd; guchar *p0, *p1,*even,*odd;
int x, y; int x, y;
double dx, cur_x; double dx, cur_x;
double r, g, b, a; double r, g, b, a;
double c0, c1; double c0, c1;
gradient_t *oldgrad = curr_gradient; gradient_t *oldgrad = curr_gradient;
curr_gradient = grad; curr_gradient = grad;
dx = (right - left) / (width - 1); dx = (right - left) / (width - 1);
cur_x = left; cur_x = left;
p0 = even = g_malloc(width*3); p0 = even = g_malloc (width * 3);
p1 = odd = g_malloc(width*3); p1 = odd = g_malloc (width * 3);
/* Create lines to fill the image */ /* Create lines to fill the image */
for (x = 0; x < width; x++) { for (x = 0; x < width; x++)
grad_get_color_at(cur_x, &r, &g, &b, &a); {
grad_get_color_at (cur_x, &r, &g, &b, &a);
if ((x / GRAD_CHECK_SIZE_SM) & 1) { if ((x / GRAD_CHECK_SIZE_SM) & 1)
c0 = GRAD_CHECK_LIGHT; {
c1 = GRAD_CHECK_DARK; c0 = GRAD_CHECK_LIGHT;
} else { c1 = GRAD_CHECK_DARK;
c0 = GRAD_CHECK_DARK; }
c1 = GRAD_CHECK_LIGHT; else
} /* else */ {
c0 = GRAD_CHECK_DARK;
c1 = GRAD_CHECK_LIGHT;
}
*p0++ = (c0 + (r - c0) * a) * 255.0; *p0++ = (c0 + (r - c0) * a) * 255.0;
*p0++ = (c0 + (g - c0) * a) * 255.0; *p0++ = (c0 + (g - c0) * a) * 255.0;
*p0++ = (c0 + (b - c0) * a) * 255.0; *p0++ = (c0 + (b - c0) * a) * 255.0;
*p1++ = (c1 + (r - c1) * a) * 255.0; *p1++ = (c1 + (r - c1) * a) * 255.0;
*p1++ = (c1 + (g - c1) * a) * 255.0; *p1++ = (c1 + (g - c1) * a) * 255.0;
*p1++ = (c1 + (b - c1) * a) * 255.0; *p1++ = (c1 + (b - c1) * a) * 255.0;
cur_x += dx; cur_x += dx;
} /* for */ }
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
{ {
if ((y / GRAD_CHECK_SIZE_SM) & 1) if ((y / GRAD_CHECK_SIZE_SM) & 1)
{ {
memcpy(buf+(width*y*3),odd,width*3); memcpy (buf+(width*y*3),odd,width*3);
} }
else else
{ {
memcpy(buf+(width*y*3),even,width*3); memcpy (buf+(width*y*3),even,width*3);
} }
} }
g_free(even); g_free (even);
g_free(odd); g_free (odd);
curr_gradient = oldgrad; curr_gradient = oldgrad;
} }
/*****/ /*****/
static void static void
draw_small_preview(GdkGC *gc, GtkWidget * clist,gradient_t *grad,int pos) draw_small_preview (GdkGC *gc,
GtkWidget *clist,
gradient_t *grad,
int pos)
{ {
char rgb_buf[48*16*3]; char rgb_buf[48*16*3];
fill_clist_prev(grad,rgb_buf,48,16,0.0,1.0); fill_clist_prev (grad, rgb_buf, 48, 16, 0.0, 1.0);
gdk_draw_rgb_image (grad->pixmap, gdk_draw_rgb_image (grad->pixmap,
gc, gc,
0, 0,
0, 0,
48, 48,
16, 16,
GDK_RGB_DITHER_NORMAL, GDK_RGB_DITHER_NORMAL,
rgb_buf, rgb_buf,
48*3); 48*3);
gdk_gc_set_foreground(gc, &black); gdk_gc_set_foreground (gc, &black);
gdk_draw_rectangle(grad->pixmap, gc, FALSE, 0, 0, 47, 15); gdk_draw_rectangle (grad->pixmap, gc, FALSE, 0, 0, 47, 15);
gtk_clist_set_text(GTK_CLIST(clist),pos,1,grad->name); gtk_clist_set_text (GTK_CLIST (clist), pos, 1, grad->name);
} }
/*****/ /*****/
void void
ed_insert_in_gradients_listbox(GdkGC * gc, ed_insert_in_gradients_listbox (GdkGC *gc,
GtkWidget * clist, GtkWidget *clist,
gradient_t *grad, gradient_t *grad,
int pos, int pos,
int select) int select)
{ {
char *string[2]; char *string[2];
string[0] = NULL; string[0] = NULL;
string[1] = grad->name; string[1] = grad->name;
gtk_clist_insert(GTK_CLIST(clist), pos,string); gtk_clist_insert (GTK_CLIST (clist), pos,string);
if(grad->pixmap == NULL) if(grad->pixmap == NULL)
grad->pixmap = gdk_pixmap_new(g_editor->shell->window, grad->pixmap =
48, 16, gtk_widget_get_visual(g_editor->shell)->depth); gdk_pixmap_new (g_editor->shell->window,
48, 16, gtk_widget_get_visual (g_editor->shell)->depth);
draw_small_preview(gc,clist,grad,pos); draw_small_preview (gc, clist, grad, pos);
gtk_clist_set_pixmap(GTK_CLIST(clist), pos, 0, grad->pixmap, NULL); gtk_clist_set_pixmap (GTK_CLIST (clist), pos, 0, grad->pixmap, NULL);
if (select) if (select)
{ {
gtk_clist_select_row(GTK_CLIST(clist),pos,-1); gtk_clist_select_row (GTK_CLIST (clist), pos, -1);
gtk_clist_moveto(GTK_CLIST(clist),pos,0,0.5,0.0); gtk_clist_moveto (GTK_CLIST (clist), pos, 0, 0.5, 0.0);
} }
} /* ed_insert_in_gradients_listbox */
}
/*****/ /*****/
static void static void
ed_list_item_update(GtkWidget *widget, ed_list_item_update (GtkWidget *widget,
gint row, gint row,
gint column, gint column,
GdkEventButton *event, GdkEventButton *event,
gpointer data) gpointer data)
{ {
/* Update current gradient */ /* Update current gradient */
GSList* tmp = g_slist_nth(gradients_list,row); GSList* tmp = g_slist_nth (gradients_list,row);
curr_gradient = (gradient_t *)(tmp->data); curr_gradient = (gradient_t *)(tmp->data);
ed_update_editor(GRAD_UPDATE_PREVIEW | GRAD_RESET_CONTROL);
} /* ed_list_item_update */
ed_update_editor (GRAD_UPDATE_PREVIEW | GRAD_RESET_CONTROL);
}
/*****/ /*****/
static void static void
ed_initialize_saved_colors(void) ed_initialize_saved_colors (void)
{ {
int i; int i;
for (i = 0; i < (GRAD_NUM_COLORS + 3); i++) { for (i = 0; i < (GRAD_NUM_COLORS + 3); i++)
g_editor->left_load_color_boxes[i] = NULL; {
g_editor->left_load_labels[i] = NULL; g_editor->left_load_color_boxes[i] = NULL;
g_editor->left_load_labels[i] = NULL;
g_editor->right_load_color_boxes[i] = NULL; g_editor->right_load_color_boxes[i] = NULL;
g_editor->right_load_labels[i] = NULL; g_editor->right_load_labels[i] = NULL;
} /* for */ }
for (i = 0; i < GRAD_NUM_COLORS; i++) { for (i = 0; i < GRAD_NUM_COLORS; i++)
g_editor->left_save_color_boxes[i] = NULL; {
g_editor->left_save_labels[i] = NULL; g_editor->left_save_color_boxes[i] = NULL;
g_editor->left_save_labels[i] = NULL;
g_editor->right_save_color_boxes[i] = NULL; g_editor->right_save_color_boxes[i] = NULL;
g_editor->right_save_labels[i] = NULL; g_editor->right_save_labels[i] = NULL;
} /* for */ }
g_editor->saved_colors[0].r = 0.0; /* Black */ g_editor->saved_colors[0].r = 0.0; /* Black */
g_editor->saved_colors[0].g = 0.0; g_editor->saved_colors[0].g = 0.0;
g_editor->saved_colors[0].b = 0.0; g_editor->saved_colors[0].b = 0.0;
g_editor->saved_colors[0].a = 1.0; g_editor->saved_colors[0].a = 1.0;
g_editor->saved_colors[1].r = 0.5; /* 50% Gray */ g_editor->saved_colors[1].r = 0.5; /* 50% Gray */
g_editor->saved_colors[1].g = 0.5; g_editor->saved_colors[1].g = 0.5;
g_editor->saved_colors[1].b = 0.5; g_editor->saved_colors[1].b = 0.5;
g_editor->saved_colors[1].a = 1.0; g_editor->saved_colors[1].a = 1.0;
g_editor->saved_colors[2].r = 1.0; /* White */ g_editor->saved_colors[2].r = 1.0; /* White */
g_editor->saved_colors[2].g = 1.0; g_editor->saved_colors[2].g = 1.0;
g_editor->saved_colors[2].b = 1.0; g_editor->saved_colors[2].b = 1.0;
g_editor->saved_colors[2].a = 1.0; g_editor->saved_colors[2].a = 1.0;
g_editor->saved_colors[3].r = 0.0; /* Clear */ g_editor->saved_colors[3].r = 0.0; /* Clear */
g_editor->saved_colors[3].g = 0.0; g_editor->saved_colors[3].g = 0.0;
g_editor->saved_colors[3].b = 0.0; g_editor->saved_colors[3].b = 0.0;
g_editor->saved_colors[3].a = 0.0; g_editor->saved_colors[3].a = 0.0;
g_editor->saved_colors[4].r = 1.0; /* Red */ g_editor->saved_colors[4].r = 1.0; /* Red */
g_editor->saved_colors[4].g = 0.0; g_editor->saved_colors[4].g = 0.0;
g_editor->saved_colors[4].b = 0.0; g_editor->saved_colors[4].b = 0.0;
g_editor->saved_colors[4].a = 1.0; g_editor->saved_colors[4].a = 1.0;
g_editor->saved_colors[5].r = 1.0; /* Yellow */ g_editor->saved_colors[5].r = 1.0; /* Yellow */
g_editor->saved_colors[5].g = 1.0; g_editor->saved_colors[5].g = 1.0;
g_editor->saved_colors[5].b = 0.0; g_editor->saved_colors[5].b = 0.0;
g_editor->saved_colors[5].a = 1.0; g_editor->saved_colors[5].a = 1.0;
g_editor->saved_colors[6].r = 0.0; /* Green */ g_editor->saved_colors[6].r = 0.0; /* Green */
g_editor->saved_colors[6].g = 1.0; g_editor->saved_colors[6].g = 1.0;
g_editor->saved_colors[6].b = 0.0; g_editor->saved_colors[6].b = 0.0;
g_editor->saved_colors[6].a = 1.0; g_editor->saved_colors[6].a = 1.0;
g_editor->saved_colors[7].r = 0.0; /* Cyan */ g_editor->saved_colors[7].r = 0.0; /* Cyan */
g_editor->saved_colors[7].g = 1.0; g_editor->saved_colors[7].g = 1.0;
g_editor->saved_colors[7].b = 1.0; g_editor->saved_colors[7].b = 1.0;
g_editor->saved_colors[7].a = 1.0; g_editor->saved_colors[7].a = 1.0;
g_editor->saved_colors[8].r = 0.0; /* Blue */ g_editor->saved_colors[8].r = 0.0; /* Blue */
g_editor->saved_colors[8].g = 0.0; g_editor->saved_colors[8].g = 0.0;
g_editor->saved_colors[8].b = 1.0; g_editor->saved_colors[8].b = 1.0;
g_editor->saved_colors[8].a = 1.0; g_editor->saved_colors[8].a = 1.0;
g_editor->saved_colors[9].r = 1.0; /* Magenta */ g_editor->saved_colors[9].r = 1.0; /* Magenta */
g_editor->saved_colors[9].g = 0.0; g_editor->saved_colors[9].g = 0.0;
g_editor->saved_colors[9].b = 1.0; g_editor->saved_colors[9].b = 1.0;
g_editor->saved_colors[9].a = 1.0; g_editor->saved_colors[9].a = 1.0;
} /* ed_initialize_saved_colors */ }
/***** Main gradient editor dialog callbacks *****/ /***** Main gradient editor dialog callbacks *****/
@ -1805,8 +1820,8 @@ ed_scrollbar_update (GtkAdjustment *adjustment,
} }
static void static void
ed_zoom_all_callback(GtkWidget *widget, ed_zoom_all_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GtkAdjustment *adjustment; GtkAdjustment *adjustment;
@ -1848,8 +1863,8 @@ ed_zoom_out_callback (GtkWidget *widget,
else if ((value + page_size) > 1.0) else if ((value + page_size) > 1.0)
value = 1.0 - page_size; value = 1.0 - page_size;
adjustment->value = value; adjustment->value = value;
adjustment->page_size = page_size; adjustment->page_size = page_size;
adjustment->step_increment = page_size * GRAD_SCROLLBAR_STEP_SIZE; adjustment->step_increment = page_size * GRAD_SCROLLBAR_STEP_SIZE;
adjustment->page_increment = page_size * GRAD_SCROLLBAR_PAGE_SIZE; adjustment->page_increment = page_size * GRAD_SCROLLBAR_PAGE_SIZE;
@ -3338,7 +3353,7 @@ cpopup_create_main_menu (void)
static void static void
cpopup_do_popup (void) cpopup_do_popup (void)
{ {
cpopup_adjust_menus(); cpopup_adjust_menus ();
gtk_menu_popup (GTK_MENU (g_editor->control_main_popup), gtk_menu_popup (GTK_MENU (g_editor->control_main_popup),
NULL, NULL, NULL, NULL, 3, 0); NULL, NULL, NULL, NULL, 3, 0);
} }
@ -4052,8 +4067,6 @@ cpopup_set_color_selection_color (GtkColorSelection *cs,
gtk_color_selection_set_color (cs, color); gtk_color_selection_set_color (cs, color);
} }
/*****/
static void static void
cpopup_get_color_selection_color (GtkColorSelection *cs, cpopup_get_color_selection_color (GtkColorSelection *cs,
double *r, double *r,

View File

@ -474,8 +474,6 @@ static const gchar *coloring_types[] =
/***** Public functions *****/ /***** Public functions *****/
/*****/
void void
gradients_init (int no_data) gradients_init (int no_data)
{ {
@ -510,8 +508,11 @@ gradients_free (void)
/*****/ /*****/
void void
grad_get_color_at (double pos, grad_get_color_at (double pos,
double *r, double *g, double *b, double *a) double *r,
double *g,
double *b,
double *a)
{ {
double factor = 0.0; double factor = 0.0;
grad_segment_t *seg; grad_segment_t *seg;
@ -642,8 +643,6 @@ grad_get_color_at (double pos,
/***** The main gradient editor dialog *****/ /***** The main gradient editor dialog *****/
/*****/
void void
grad_create_gradient_editor_init (gint need_show) grad_create_gradient_editor_init (gint need_show)
{ {
@ -984,7 +983,10 @@ grad_create_gradient_editor_init (gint need_show)
/***** Gradient editor functions *****/ /***** Gradient editor functions *****/
static void static void
ed_fetch_foreground (double *fg_r, double *fg_g, double *fg_b, double *fg_a) ed_fetch_foreground (double *fg_r,
double *fg_g,
double *fg_b,
double *fg_a)
{ {
guchar r, g, b; guchar r, g, b;
@ -1094,209 +1096,222 @@ ed_set_list_of_gradients (GdkGC *gc,
/*****/ /*****/
static void static void
fill_clist_prev(gradient_t *grad, guchar *buf, gint width, gint height, double left, double right) fill_clist_prev (gradient_t *grad,
guchar *buf,
gint width,
gint height,
double left,
double right)
{ {
guchar *p0, *p1,*even,*odd; guchar *p0, *p1,*even,*odd;
int x, y; int x, y;
double dx, cur_x; double dx, cur_x;
double r, g, b, a; double r, g, b, a;
double c0, c1; double c0, c1;
gradient_t *oldgrad = curr_gradient; gradient_t *oldgrad = curr_gradient;
curr_gradient = grad; curr_gradient = grad;
dx = (right - left) / (width - 1); dx = (right - left) / (width - 1);
cur_x = left; cur_x = left;
p0 = even = g_malloc(width*3); p0 = even = g_malloc (width * 3);
p1 = odd = g_malloc(width*3); p1 = odd = g_malloc (width * 3);
/* Create lines to fill the image */ /* Create lines to fill the image */
for (x = 0; x < width; x++) { for (x = 0; x < width; x++)
grad_get_color_at(cur_x, &r, &g, &b, &a); {
grad_get_color_at (cur_x, &r, &g, &b, &a);
if ((x / GRAD_CHECK_SIZE_SM) & 1) { if ((x / GRAD_CHECK_SIZE_SM) & 1)
c0 = GRAD_CHECK_LIGHT; {
c1 = GRAD_CHECK_DARK; c0 = GRAD_CHECK_LIGHT;
} else { c1 = GRAD_CHECK_DARK;
c0 = GRAD_CHECK_DARK; }
c1 = GRAD_CHECK_LIGHT; else
} /* else */ {
c0 = GRAD_CHECK_DARK;
c1 = GRAD_CHECK_LIGHT;
}
*p0++ = (c0 + (r - c0) * a) * 255.0; *p0++ = (c0 + (r - c0) * a) * 255.0;
*p0++ = (c0 + (g - c0) * a) * 255.0; *p0++ = (c0 + (g - c0) * a) * 255.0;
*p0++ = (c0 + (b - c0) * a) * 255.0; *p0++ = (c0 + (b - c0) * a) * 255.0;
*p1++ = (c1 + (r - c1) * a) * 255.0; *p1++ = (c1 + (r - c1) * a) * 255.0;
*p1++ = (c1 + (g - c1) * a) * 255.0; *p1++ = (c1 + (g - c1) * a) * 255.0;
*p1++ = (c1 + (b - c1) * a) * 255.0; *p1++ = (c1 + (b - c1) * a) * 255.0;
cur_x += dx; cur_x += dx;
} /* for */ }
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
{ {
if ((y / GRAD_CHECK_SIZE_SM) & 1) if ((y / GRAD_CHECK_SIZE_SM) & 1)
{ {
memcpy(buf+(width*y*3),odd,width*3); memcpy (buf+(width*y*3),odd,width*3);
} }
else else
{ {
memcpy(buf+(width*y*3),even,width*3); memcpy (buf+(width*y*3),even,width*3);
} }
} }
g_free(even); g_free (even);
g_free(odd); g_free (odd);
curr_gradient = oldgrad; curr_gradient = oldgrad;
} }
/*****/ /*****/
static void static void
draw_small_preview(GdkGC *gc, GtkWidget * clist,gradient_t *grad,int pos) draw_small_preview (GdkGC *gc,
GtkWidget *clist,
gradient_t *grad,
int pos)
{ {
char rgb_buf[48*16*3]; char rgb_buf[48*16*3];
fill_clist_prev(grad,rgb_buf,48,16,0.0,1.0); fill_clist_prev (grad, rgb_buf, 48, 16, 0.0, 1.0);
gdk_draw_rgb_image (grad->pixmap, gdk_draw_rgb_image (grad->pixmap,
gc, gc,
0, 0,
0, 0,
48, 48,
16, 16,
GDK_RGB_DITHER_NORMAL, GDK_RGB_DITHER_NORMAL,
rgb_buf, rgb_buf,
48*3); 48*3);
gdk_gc_set_foreground(gc, &black); gdk_gc_set_foreground (gc, &black);
gdk_draw_rectangle(grad->pixmap, gc, FALSE, 0, 0, 47, 15); gdk_draw_rectangle (grad->pixmap, gc, FALSE, 0, 0, 47, 15);
gtk_clist_set_text(GTK_CLIST(clist),pos,1,grad->name); gtk_clist_set_text (GTK_CLIST (clist), pos, 1, grad->name);
} }
/*****/ /*****/
void void
ed_insert_in_gradients_listbox(GdkGC * gc, ed_insert_in_gradients_listbox (GdkGC *gc,
GtkWidget * clist, GtkWidget *clist,
gradient_t *grad, gradient_t *grad,
int pos, int pos,
int select) int select)
{ {
char *string[2]; char *string[2];
string[0] = NULL; string[0] = NULL;
string[1] = grad->name; string[1] = grad->name;
gtk_clist_insert(GTK_CLIST(clist), pos,string); gtk_clist_insert (GTK_CLIST (clist), pos,string);
if(grad->pixmap == NULL) if(grad->pixmap == NULL)
grad->pixmap = gdk_pixmap_new(g_editor->shell->window, grad->pixmap =
48, 16, gtk_widget_get_visual(g_editor->shell)->depth); gdk_pixmap_new (g_editor->shell->window,
48, 16, gtk_widget_get_visual (g_editor->shell)->depth);
draw_small_preview(gc,clist,grad,pos); draw_small_preview (gc, clist, grad, pos);
gtk_clist_set_pixmap(GTK_CLIST(clist), pos, 0, grad->pixmap, NULL); gtk_clist_set_pixmap (GTK_CLIST (clist), pos, 0, grad->pixmap, NULL);
if (select) if (select)
{ {
gtk_clist_select_row(GTK_CLIST(clist),pos,-1); gtk_clist_select_row (GTK_CLIST (clist), pos, -1);
gtk_clist_moveto(GTK_CLIST(clist),pos,0,0.5,0.0); gtk_clist_moveto (GTK_CLIST (clist), pos, 0, 0.5, 0.0);
} }
} /* ed_insert_in_gradients_listbox */
}
/*****/ /*****/
static void static void
ed_list_item_update(GtkWidget *widget, ed_list_item_update (GtkWidget *widget,
gint row, gint row,
gint column, gint column,
GdkEventButton *event, GdkEventButton *event,
gpointer data) gpointer data)
{ {
/* Update current gradient */ /* Update current gradient */
GSList* tmp = g_slist_nth(gradients_list,row); GSList* tmp = g_slist_nth (gradients_list,row);
curr_gradient = (gradient_t *)(tmp->data); curr_gradient = (gradient_t *)(tmp->data);
ed_update_editor(GRAD_UPDATE_PREVIEW | GRAD_RESET_CONTROL);
} /* ed_list_item_update */
ed_update_editor (GRAD_UPDATE_PREVIEW | GRAD_RESET_CONTROL);
}
/*****/ /*****/
static void static void
ed_initialize_saved_colors(void) ed_initialize_saved_colors (void)
{ {
int i; int i;
for (i = 0; i < (GRAD_NUM_COLORS + 3); i++) { for (i = 0; i < (GRAD_NUM_COLORS + 3); i++)
g_editor->left_load_color_boxes[i] = NULL; {
g_editor->left_load_labels[i] = NULL; g_editor->left_load_color_boxes[i] = NULL;
g_editor->left_load_labels[i] = NULL;
g_editor->right_load_color_boxes[i] = NULL; g_editor->right_load_color_boxes[i] = NULL;
g_editor->right_load_labels[i] = NULL; g_editor->right_load_labels[i] = NULL;
} /* for */ }
for (i = 0; i < GRAD_NUM_COLORS; i++) { for (i = 0; i < GRAD_NUM_COLORS; i++)
g_editor->left_save_color_boxes[i] = NULL; {
g_editor->left_save_labels[i] = NULL; g_editor->left_save_color_boxes[i] = NULL;
g_editor->left_save_labels[i] = NULL;
g_editor->right_save_color_boxes[i] = NULL; g_editor->right_save_color_boxes[i] = NULL;
g_editor->right_save_labels[i] = NULL; g_editor->right_save_labels[i] = NULL;
} /* for */ }
g_editor->saved_colors[0].r = 0.0; /* Black */ g_editor->saved_colors[0].r = 0.0; /* Black */
g_editor->saved_colors[0].g = 0.0; g_editor->saved_colors[0].g = 0.0;
g_editor->saved_colors[0].b = 0.0; g_editor->saved_colors[0].b = 0.0;
g_editor->saved_colors[0].a = 1.0; g_editor->saved_colors[0].a = 1.0;
g_editor->saved_colors[1].r = 0.5; /* 50% Gray */ g_editor->saved_colors[1].r = 0.5; /* 50% Gray */
g_editor->saved_colors[1].g = 0.5; g_editor->saved_colors[1].g = 0.5;
g_editor->saved_colors[1].b = 0.5; g_editor->saved_colors[1].b = 0.5;
g_editor->saved_colors[1].a = 1.0; g_editor->saved_colors[1].a = 1.0;
g_editor->saved_colors[2].r = 1.0; /* White */ g_editor->saved_colors[2].r = 1.0; /* White */
g_editor->saved_colors[2].g = 1.0; g_editor->saved_colors[2].g = 1.0;
g_editor->saved_colors[2].b = 1.0; g_editor->saved_colors[2].b = 1.0;
g_editor->saved_colors[2].a = 1.0; g_editor->saved_colors[2].a = 1.0;
g_editor->saved_colors[3].r = 0.0; /* Clear */ g_editor->saved_colors[3].r = 0.0; /* Clear */
g_editor->saved_colors[3].g = 0.0; g_editor->saved_colors[3].g = 0.0;
g_editor->saved_colors[3].b = 0.0; g_editor->saved_colors[3].b = 0.0;
g_editor->saved_colors[3].a = 0.0; g_editor->saved_colors[3].a = 0.0;
g_editor->saved_colors[4].r = 1.0; /* Red */ g_editor->saved_colors[4].r = 1.0; /* Red */
g_editor->saved_colors[4].g = 0.0; g_editor->saved_colors[4].g = 0.0;
g_editor->saved_colors[4].b = 0.0; g_editor->saved_colors[4].b = 0.0;
g_editor->saved_colors[4].a = 1.0; g_editor->saved_colors[4].a = 1.0;
g_editor->saved_colors[5].r = 1.0; /* Yellow */ g_editor->saved_colors[5].r = 1.0; /* Yellow */
g_editor->saved_colors[5].g = 1.0; g_editor->saved_colors[5].g = 1.0;
g_editor->saved_colors[5].b = 0.0; g_editor->saved_colors[5].b = 0.0;
g_editor->saved_colors[5].a = 1.0; g_editor->saved_colors[5].a = 1.0;
g_editor->saved_colors[6].r = 0.0; /* Green */ g_editor->saved_colors[6].r = 0.0; /* Green */
g_editor->saved_colors[6].g = 1.0; g_editor->saved_colors[6].g = 1.0;
g_editor->saved_colors[6].b = 0.0; g_editor->saved_colors[6].b = 0.0;
g_editor->saved_colors[6].a = 1.0; g_editor->saved_colors[6].a = 1.0;
g_editor->saved_colors[7].r = 0.0; /* Cyan */ g_editor->saved_colors[7].r = 0.0; /* Cyan */
g_editor->saved_colors[7].g = 1.0; g_editor->saved_colors[7].g = 1.0;
g_editor->saved_colors[7].b = 1.0; g_editor->saved_colors[7].b = 1.0;
g_editor->saved_colors[7].a = 1.0; g_editor->saved_colors[7].a = 1.0;
g_editor->saved_colors[8].r = 0.0; /* Blue */ g_editor->saved_colors[8].r = 0.0; /* Blue */
g_editor->saved_colors[8].g = 0.0; g_editor->saved_colors[8].g = 0.0;
g_editor->saved_colors[8].b = 1.0; g_editor->saved_colors[8].b = 1.0;
g_editor->saved_colors[8].a = 1.0; g_editor->saved_colors[8].a = 1.0;
g_editor->saved_colors[9].r = 1.0; /* Magenta */ g_editor->saved_colors[9].r = 1.0; /* Magenta */
g_editor->saved_colors[9].g = 0.0; g_editor->saved_colors[9].g = 0.0;
g_editor->saved_colors[9].b = 1.0; g_editor->saved_colors[9].b = 1.0;
g_editor->saved_colors[9].a = 1.0; g_editor->saved_colors[9].a = 1.0;
} /* ed_initialize_saved_colors */ }
/***** Main gradient editor dialog callbacks *****/ /***** Main gradient editor dialog callbacks *****/
@ -1805,8 +1820,8 @@ ed_scrollbar_update (GtkAdjustment *adjustment,
} }
static void static void
ed_zoom_all_callback(GtkWidget *widget, ed_zoom_all_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GtkAdjustment *adjustment; GtkAdjustment *adjustment;
@ -1848,8 +1863,8 @@ ed_zoom_out_callback (GtkWidget *widget,
else if ((value + page_size) > 1.0) else if ((value + page_size) > 1.0)
value = 1.0 - page_size; value = 1.0 - page_size;
adjustment->value = value; adjustment->value = value;
adjustment->page_size = page_size; adjustment->page_size = page_size;
adjustment->step_increment = page_size * GRAD_SCROLLBAR_STEP_SIZE; adjustment->step_increment = page_size * GRAD_SCROLLBAR_STEP_SIZE;
adjustment->page_increment = page_size * GRAD_SCROLLBAR_PAGE_SIZE; adjustment->page_increment = page_size * GRAD_SCROLLBAR_PAGE_SIZE;
@ -3338,7 +3353,7 @@ cpopup_create_main_menu (void)
static void static void
cpopup_do_popup (void) cpopup_do_popup (void)
{ {
cpopup_adjust_menus(); cpopup_adjust_menus ();
gtk_menu_popup (GTK_MENU (g_editor->control_main_popup), gtk_menu_popup (GTK_MENU (g_editor->control_main_popup),
NULL, NULL, NULL, NULL, 3, 0); NULL, NULL, NULL, NULL, 3, 0);
} }
@ -4052,8 +4067,6 @@ cpopup_set_color_selection_color (GtkColorSelection *cs,
gtk_color_selection_set_color (cs, color); gtk_color_selection_set_color (cs, color);
} }
/*****/
static void static void
cpopup_get_color_selection_color (GtkColorSelection *cs, cpopup_get_color_selection_color (GtkColorSelection *cs,
double *r, double *r,

View File

@ -474,8 +474,6 @@ static const gchar *coloring_types[] =
/***** Public functions *****/ /***** Public functions *****/
/*****/
void void
gradients_init (int no_data) gradients_init (int no_data)
{ {
@ -510,8 +508,11 @@ gradients_free (void)
/*****/ /*****/
void void
grad_get_color_at (double pos, grad_get_color_at (double pos,
double *r, double *g, double *b, double *a) double *r,
double *g,
double *b,
double *a)
{ {
double factor = 0.0; double factor = 0.0;
grad_segment_t *seg; grad_segment_t *seg;
@ -642,8 +643,6 @@ grad_get_color_at (double pos,
/***** The main gradient editor dialog *****/ /***** The main gradient editor dialog *****/
/*****/
void void
grad_create_gradient_editor_init (gint need_show) grad_create_gradient_editor_init (gint need_show)
{ {
@ -984,7 +983,10 @@ grad_create_gradient_editor_init (gint need_show)
/***** Gradient editor functions *****/ /***** Gradient editor functions *****/
static void static void
ed_fetch_foreground (double *fg_r, double *fg_g, double *fg_b, double *fg_a) ed_fetch_foreground (double *fg_r,
double *fg_g,
double *fg_b,
double *fg_a)
{ {
guchar r, g, b; guchar r, g, b;
@ -1094,209 +1096,222 @@ ed_set_list_of_gradients (GdkGC *gc,
/*****/ /*****/
static void static void
fill_clist_prev(gradient_t *grad, guchar *buf, gint width, gint height, double left, double right) fill_clist_prev (gradient_t *grad,
guchar *buf,
gint width,
gint height,
double left,
double right)
{ {
guchar *p0, *p1,*even,*odd; guchar *p0, *p1,*even,*odd;
int x, y; int x, y;
double dx, cur_x; double dx, cur_x;
double r, g, b, a; double r, g, b, a;
double c0, c1; double c0, c1;
gradient_t *oldgrad = curr_gradient; gradient_t *oldgrad = curr_gradient;
curr_gradient = grad; curr_gradient = grad;
dx = (right - left) / (width - 1); dx = (right - left) / (width - 1);
cur_x = left; cur_x = left;
p0 = even = g_malloc(width*3); p0 = even = g_malloc (width * 3);
p1 = odd = g_malloc(width*3); p1 = odd = g_malloc (width * 3);
/* Create lines to fill the image */ /* Create lines to fill the image */
for (x = 0; x < width; x++) { for (x = 0; x < width; x++)
grad_get_color_at(cur_x, &r, &g, &b, &a); {
grad_get_color_at (cur_x, &r, &g, &b, &a);
if ((x / GRAD_CHECK_SIZE_SM) & 1) { if ((x / GRAD_CHECK_SIZE_SM) & 1)
c0 = GRAD_CHECK_LIGHT; {
c1 = GRAD_CHECK_DARK; c0 = GRAD_CHECK_LIGHT;
} else { c1 = GRAD_CHECK_DARK;
c0 = GRAD_CHECK_DARK; }
c1 = GRAD_CHECK_LIGHT; else
} /* else */ {
c0 = GRAD_CHECK_DARK;
c1 = GRAD_CHECK_LIGHT;
}
*p0++ = (c0 + (r - c0) * a) * 255.0; *p0++ = (c0 + (r - c0) * a) * 255.0;
*p0++ = (c0 + (g - c0) * a) * 255.0; *p0++ = (c0 + (g - c0) * a) * 255.0;
*p0++ = (c0 + (b - c0) * a) * 255.0; *p0++ = (c0 + (b - c0) * a) * 255.0;
*p1++ = (c1 + (r - c1) * a) * 255.0; *p1++ = (c1 + (r - c1) * a) * 255.0;
*p1++ = (c1 + (g - c1) * a) * 255.0; *p1++ = (c1 + (g - c1) * a) * 255.0;
*p1++ = (c1 + (b - c1) * a) * 255.0; *p1++ = (c1 + (b - c1) * a) * 255.0;
cur_x += dx; cur_x += dx;
} /* for */ }
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
{ {
if ((y / GRAD_CHECK_SIZE_SM) & 1) if ((y / GRAD_CHECK_SIZE_SM) & 1)
{ {
memcpy(buf+(width*y*3),odd,width*3); memcpy (buf+(width*y*3),odd,width*3);
} }
else else
{ {
memcpy(buf+(width*y*3),even,width*3); memcpy (buf+(width*y*3),even,width*3);
} }
} }
g_free(even); g_free (even);
g_free(odd); g_free (odd);
curr_gradient = oldgrad; curr_gradient = oldgrad;
} }
/*****/ /*****/
static void static void
draw_small_preview(GdkGC *gc, GtkWidget * clist,gradient_t *grad,int pos) draw_small_preview (GdkGC *gc,
GtkWidget *clist,
gradient_t *grad,
int pos)
{ {
char rgb_buf[48*16*3]; char rgb_buf[48*16*3];
fill_clist_prev(grad,rgb_buf,48,16,0.0,1.0); fill_clist_prev (grad, rgb_buf, 48, 16, 0.0, 1.0);
gdk_draw_rgb_image (grad->pixmap, gdk_draw_rgb_image (grad->pixmap,
gc, gc,
0, 0,
0, 0,
48, 48,
16, 16,
GDK_RGB_DITHER_NORMAL, GDK_RGB_DITHER_NORMAL,
rgb_buf, rgb_buf,
48*3); 48*3);
gdk_gc_set_foreground(gc, &black); gdk_gc_set_foreground (gc, &black);
gdk_draw_rectangle(grad->pixmap, gc, FALSE, 0, 0, 47, 15); gdk_draw_rectangle (grad->pixmap, gc, FALSE, 0, 0, 47, 15);
gtk_clist_set_text(GTK_CLIST(clist),pos,1,grad->name); gtk_clist_set_text (GTK_CLIST (clist), pos, 1, grad->name);
} }
/*****/ /*****/
void void
ed_insert_in_gradients_listbox(GdkGC * gc, ed_insert_in_gradients_listbox (GdkGC *gc,
GtkWidget * clist, GtkWidget *clist,
gradient_t *grad, gradient_t *grad,
int pos, int pos,
int select) int select)
{ {
char *string[2]; char *string[2];
string[0] = NULL; string[0] = NULL;
string[1] = grad->name; string[1] = grad->name;
gtk_clist_insert(GTK_CLIST(clist), pos,string); gtk_clist_insert (GTK_CLIST (clist), pos,string);
if(grad->pixmap == NULL) if(grad->pixmap == NULL)
grad->pixmap = gdk_pixmap_new(g_editor->shell->window, grad->pixmap =
48, 16, gtk_widget_get_visual(g_editor->shell)->depth); gdk_pixmap_new (g_editor->shell->window,
48, 16, gtk_widget_get_visual (g_editor->shell)->depth);
draw_small_preview(gc,clist,grad,pos); draw_small_preview (gc, clist, grad, pos);
gtk_clist_set_pixmap(GTK_CLIST(clist), pos, 0, grad->pixmap, NULL); gtk_clist_set_pixmap (GTK_CLIST (clist), pos, 0, grad->pixmap, NULL);
if (select) if (select)
{ {
gtk_clist_select_row(GTK_CLIST(clist),pos,-1); gtk_clist_select_row (GTK_CLIST (clist), pos, -1);
gtk_clist_moveto(GTK_CLIST(clist),pos,0,0.5,0.0); gtk_clist_moveto (GTK_CLIST (clist), pos, 0, 0.5, 0.0);
} }
} /* ed_insert_in_gradients_listbox */
}
/*****/ /*****/
static void static void
ed_list_item_update(GtkWidget *widget, ed_list_item_update (GtkWidget *widget,
gint row, gint row,
gint column, gint column,
GdkEventButton *event, GdkEventButton *event,
gpointer data) gpointer data)
{ {
/* Update current gradient */ /* Update current gradient */
GSList* tmp = g_slist_nth(gradients_list,row); GSList* tmp = g_slist_nth (gradients_list,row);
curr_gradient = (gradient_t *)(tmp->data); curr_gradient = (gradient_t *)(tmp->data);
ed_update_editor(GRAD_UPDATE_PREVIEW | GRAD_RESET_CONTROL);
} /* ed_list_item_update */
ed_update_editor (GRAD_UPDATE_PREVIEW | GRAD_RESET_CONTROL);
}
/*****/ /*****/
static void static void
ed_initialize_saved_colors(void) ed_initialize_saved_colors (void)
{ {
int i; int i;
for (i = 0; i < (GRAD_NUM_COLORS + 3); i++) { for (i = 0; i < (GRAD_NUM_COLORS + 3); i++)
g_editor->left_load_color_boxes[i] = NULL; {
g_editor->left_load_labels[i] = NULL; g_editor->left_load_color_boxes[i] = NULL;
g_editor->left_load_labels[i] = NULL;
g_editor->right_load_color_boxes[i] = NULL; g_editor->right_load_color_boxes[i] = NULL;
g_editor->right_load_labels[i] = NULL; g_editor->right_load_labels[i] = NULL;
} /* for */ }
for (i = 0; i < GRAD_NUM_COLORS; i++) { for (i = 0; i < GRAD_NUM_COLORS; i++)
g_editor->left_save_color_boxes[i] = NULL; {
g_editor->left_save_labels[i] = NULL; g_editor->left_save_color_boxes[i] = NULL;
g_editor->left_save_labels[i] = NULL;
g_editor->right_save_color_boxes[i] = NULL; g_editor->right_save_color_boxes[i] = NULL;
g_editor->right_save_labels[i] = NULL; g_editor->right_save_labels[i] = NULL;
} /* for */ }
g_editor->saved_colors[0].r = 0.0; /* Black */ g_editor->saved_colors[0].r = 0.0; /* Black */
g_editor->saved_colors[0].g = 0.0; g_editor->saved_colors[0].g = 0.0;
g_editor->saved_colors[0].b = 0.0; g_editor->saved_colors[0].b = 0.0;
g_editor->saved_colors[0].a = 1.0; g_editor->saved_colors[0].a = 1.0;
g_editor->saved_colors[1].r = 0.5; /* 50% Gray */ g_editor->saved_colors[1].r = 0.5; /* 50% Gray */
g_editor->saved_colors[1].g = 0.5; g_editor->saved_colors[1].g = 0.5;
g_editor->saved_colors[1].b = 0.5; g_editor->saved_colors[1].b = 0.5;
g_editor->saved_colors[1].a = 1.0; g_editor->saved_colors[1].a = 1.0;
g_editor->saved_colors[2].r = 1.0; /* White */ g_editor->saved_colors[2].r = 1.0; /* White */
g_editor->saved_colors[2].g = 1.0; g_editor->saved_colors[2].g = 1.0;
g_editor->saved_colors[2].b = 1.0; g_editor->saved_colors[2].b = 1.0;
g_editor->saved_colors[2].a = 1.0; g_editor->saved_colors[2].a = 1.0;
g_editor->saved_colors[3].r = 0.0; /* Clear */ g_editor->saved_colors[3].r = 0.0; /* Clear */
g_editor->saved_colors[3].g = 0.0; g_editor->saved_colors[3].g = 0.0;
g_editor->saved_colors[3].b = 0.0; g_editor->saved_colors[3].b = 0.0;
g_editor->saved_colors[3].a = 0.0; g_editor->saved_colors[3].a = 0.0;
g_editor->saved_colors[4].r = 1.0; /* Red */ g_editor->saved_colors[4].r = 1.0; /* Red */
g_editor->saved_colors[4].g = 0.0; g_editor->saved_colors[4].g = 0.0;
g_editor->saved_colors[4].b = 0.0; g_editor->saved_colors[4].b = 0.0;
g_editor->saved_colors[4].a = 1.0; g_editor->saved_colors[4].a = 1.0;
g_editor->saved_colors[5].r = 1.0; /* Yellow */ g_editor->saved_colors[5].r = 1.0; /* Yellow */
g_editor->saved_colors[5].g = 1.0; g_editor->saved_colors[5].g = 1.0;
g_editor->saved_colors[5].b = 0.0; g_editor->saved_colors[5].b = 0.0;
g_editor->saved_colors[5].a = 1.0; g_editor->saved_colors[5].a = 1.0;
g_editor->saved_colors[6].r = 0.0; /* Green */ g_editor->saved_colors[6].r = 0.0; /* Green */
g_editor->saved_colors[6].g = 1.0; g_editor->saved_colors[6].g = 1.0;
g_editor->saved_colors[6].b = 0.0; g_editor->saved_colors[6].b = 0.0;
g_editor->saved_colors[6].a = 1.0; g_editor->saved_colors[6].a = 1.0;
g_editor->saved_colors[7].r = 0.0; /* Cyan */ g_editor->saved_colors[7].r = 0.0; /* Cyan */
g_editor->saved_colors[7].g = 1.0; g_editor->saved_colors[7].g = 1.0;
g_editor->saved_colors[7].b = 1.0; g_editor->saved_colors[7].b = 1.0;
g_editor->saved_colors[7].a = 1.0; g_editor->saved_colors[7].a = 1.0;
g_editor->saved_colors[8].r = 0.0; /* Blue */ g_editor->saved_colors[8].r = 0.0; /* Blue */
g_editor->saved_colors[8].g = 0.0; g_editor->saved_colors[8].g = 0.0;
g_editor->saved_colors[8].b = 1.0; g_editor->saved_colors[8].b = 1.0;
g_editor->saved_colors[8].a = 1.0; g_editor->saved_colors[8].a = 1.0;
g_editor->saved_colors[9].r = 1.0; /* Magenta */ g_editor->saved_colors[9].r = 1.0; /* Magenta */
g_editor->saved_colors[9].g = 0.0; g_editor->saved_colors[9].g = 0.0;
g_editor->saved_colors[9].b = 1.0; g_editor->saved_colors[9].b = 1.0;
g_editor->saved_colors[9].a = 1.0; g_editor->saved_colors[9].a = 1.0;
} /* ed_initialize_saved_colors */ }
/***** Main gradient editor dialog callbacks *****/ /***** Main gradient editor dialog callbacks *****/
@ -1805,8 +1820,8 @@ ed_scrollbar_update (GtkAdjustment *adjustment,
} }
static void static void
ed_zoom_all_callback(GtkWidget *widget, ed_zoom_all_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GtkAdjustment *adjustment; GtkAdjustment *adjustment;
@ -1848,8 +1863,8 @@ ed_zoom_out_callback (GtkWidget *widget,
else if ((value + page_size) > 1.0) else if ((value + page_size) > 1.0)
value = 1.0 - page_size; value = 1.0 - page_size;
adjustment->value = value; adjustment->value = value;
adjustment->page_size = page_size; adjustment->page_size = page_size;
adjustment->step_increment = page_size * GRAD_SCROLLBAR_STEP_SIZE; adjustment->step_increment = page_size * GRAD_SCROLLBAR_STEP_SIZE;
adjustment->page_increment = page_size * GRAD_SCROLLBAR_PAGE_SIZE; adjustment->page_increment = page_size * GRAD_SCROLLBAR_PAGE_SIZE;
@ -3338,7 +3353,7 @@ cpopup_create_main_menu (void)
static void static void
cpopup_do_popup (void) cpopup_do_popup (void)
{ {
cpopup_adjust_menus(); cpopup_adjust_menus ();
gtk_menu_popup (GTK_MENU (g_editor->control_main_popup), gtk_menu_popup (GTK_MENU (g_editor->control_main_popup),
NULL, NULL, NULL, NULL, 3, 0); NULL, NULL, NULL, NULL, 3, 0);
} }
@ -4052,8 +4067,6 @@ cpopup_set_color_selection_color (GtkColorSelection *cs,
gtk_color_selection_set_color (cs, color); gtk_color_selection_set_color (cs, color);
} }
/*****/
static void static void
cpopup_get_color_selection_color (GtkColorSelection *cs, cpopup_get_color_selection_color (GtkColorSelection *cs,
double *r, double *r,

View File

@ -474,8 +474,6 @@ static const gchar *coloring_types[] =
/***** Public functions *****/ /***** Public functions *****/
/*****/
void void
gradients_init (int no_data) gradients_init (int no_data)
{ {
@ -510,8 +508,11 @@ gradients_free (void)
/*****/ /*****/
void void
grad_get_color_at (double pos, grad_get_color_at (double pos,
double *r, double *g, double *b, double *a) double *r,
double *g,
double *b,
double *a)
{ {
double factor = 0.0; double factor = 0.0;
grad_segment_t *seg; grad_segment_t *seg;
@ -642,8 +643,6 @@ grad_get_color_at (double pos,
/***** The main gradient editor dialog *****/ /***** The main gradient editor dialog *****/
/*****/
void void
grad_create_gradient_editor_init (gint need_show) grad_create_gradient_editor_init (gint need_show)
{ {
@ -984,7 +983,10 @@ grad_create_gradient_editor_init (gint need_show)
/***** Gradient editor functions *****/ /***** Gradient editor functions *****/
static void static void
ed_fetch_foreground (double *fg_r, double *fg_g, double *fg_b, double *fg_a) ed_fetch_foreground (double *fg_r,
double *fg_g,
double *fg_b,
double *fg_a)
{ {
guchar r, g, b; guchar r, g, b;
@ -1094,209 +1096,222 @@ ed_set_list_of_gradients (GdkGC *gc,
/*****/ /*****/
static void static void
fill_clist_prev(gradient_t *grad, guchar *buf, gint width, gint height, double left, double right) fill_clist_prev (gradient_t *grad,
guchar *buf,
gint width,
gint height,
double left,
double right)
{ {
guchar *p0, *p1,*even,*odd; guchar *p0, *p1,*even,*odd;
int x, y; int x, y;
double dx, cur_x; double dx, cur_x;
double r, g, b, a; double r, g, b, a;
double c0, c1; double c0, c1;
gradient_t *oldgrad = curr_gradient; gradient_t *oldgrad = curr_gradient;
curr_gradient = grad; curr_gradient = grad;
dx = (right - left) / (width - 1); dx = (right - left) / (width - 1);
cur_x = left; cur_x = left;
p0 = even = g_malloc(width*3); p0 = even = g_malloc (width * 3);
p1 = odd = g_malloc(width*3); p1 = odd = g_malloc (width * 3);
/* Create lines to fill the image */ /* Create lines to fill the image */
for (x = 0; x < width; x++) { for (x = 0; x < width; x++)
grad_get_color_at(cur_x, &r, &g, &b, &a); {
grad_get_color_at (cur_x, &r, &g, &b, &a);
if ((x / GRAD_CHECK_SIZE_SM) & 1) { if ((x / GRAD_CHECK_SIZE_SM) & 1)
c0 = GRAD_CHECK_LIGHT; {
c1 = GRAD_CHECK_DARK; c0 = GRAD_CHECK_LIGHT;
} else { c1 = GRAD_CHECK_DARK;
c0 = GRAD_CHECK_DARK; }
c1 = GRAD_CHECK_LIGHT; else
} /* else */ {
c0 = GRAD_CHECK_DARK;
c1 = GRAD_CHECK_LIGHT;
}
*p0++ = (c0 + (r - c0) * a) * 255.0; *p0++ = (c0 + (r - c0) * a) * 255.0;
*p0++ = (c0 + (g - c0) * a) * 255.0; *p0++ = (c0 + (g - c0) * a) * 255.0;
*p0++ = (c0 + (b - c0) * a) * 255.0; *p0++ = (c0 + (b - c0) * a) * 255.0;
*p1++ = (c1 + (r - c1) * a) * 255.0; *p1++ = (c1 + (r - c1) * a) * 255.0;
*p1++ = (c1 + (g - c1) * a) * 255.0; *p1++ = (c1 + (g - c1) * a) * 255.0;
*p1++ = (c1 + (b - c1) * a) * 255.0; *p1++ = (c1 + (b - c1) * a) * 255.0;
cur_x += dx; cur_x += dx;
} /* for */ }
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
{ {
if ((y / GRAD_CHECK_SIZE_SM) & 1) if ((y / GRAD_CHECK_SIZE_SM) & 1)
{ {
memcpy(buf+(width*y*3),odd,width*3); memcpy (buf+(width*y*3),odd,width*3);
} }
else else
{ {
memcpy(buf+(width*y*3),even,width*3); memcpy (buf+(width*y*3),even,width*3);
} }
} }
g_free(even); g_free (even);
g_free(odd); g_free (odd);
curr_gradient = oldgrad; curr_gradient = oldgrad;
} }
/*****/ /*****/
static void static void
draw_small_preview(GdkGC *gc, GtkWidget * clist,gradient_t *grad,int pos) draw_small_preview (GdkGC *gc,
GtkWidget *clist,
gradient_t *grad,
int pos)
{ {
char rgb_buf[48*16*3]; char rgb_buf[48*16*3];
fill_clist_prev(grad,rgb_buf,48,16,0.0,1.0); fill_clist_prev (grad, rgb_buf, 48, 16, 0.0, 1.0);
gdk_draw_rgb_image (grad->pixmap, gdk_draw_rgb_image (grad->pixmap,
gc, gc,
0, 0,
0, 0,
48, 48,
16, 16,
GDK_RGB_DITHER_NORMAL, GDK_RGB_DITHER_NORMAL,
rgb_buf, rgb_buf,
48*3); 48*3);
gdk_gc_set_foreground(gc, &black); gdk_gc_set_foreground (gc, &black);
gdk_draw_rectangle(grad->pixmap, gc, FALSE, 0, 0, 47, 15); gdk_draw_rectangle (grad->pixmap, gc, FALSE, 0, 0, 47, 15);
gtk_clist_set_text(GTK_CLIST(clist),pos,1,grad->name); gtk_clist_set_text (GTK_CLIST (clist), pos, 1, grad->name);
} }
/*****/ /*****/
void void
ed_insert_in_gradients_listbox(GdkGC * gc, ed_insert_in_gradients_listbox (GdkGC *gc,
GtkWidget * clist, GtkWidget *clist,
gradient_t *grad, gradient_t *grad,
int pos, int pos,
int select) int select)
{ {
char *string[2]; char *string[2];
string[0] = NULL; string[0] = NULL;
string[1] = grad->name; string[1] = grad->name;
gtk_clist_insert(GTK_CLIST(clist), pos,string); gtk_clist_insert (GTK_CLIST (clist), pos,string);
if(grad->pixmap == NULL) if(grad->pixmap == NULL)
grad->pixmap = gdk_pixmap_new(g_editor->shell->window, grad->pixmap =
48, 16, gtk_widget_get_visual(g_editor->shell)->depth); gdk_pixmap_new (g_editor->shell->window,
48, 16, gtk_widget_get_visual (g_editor->shell)->depth);
draw_small_preview(gc,clist,grad,pos); draw_small_preview (gc, clist, grad, pos);
gtk_clist_set_pixmap(GTK_CLIST(clist), pos, 0, grad->pixmap, NULL); gtk_clist_set_pixmap (GTK_CLIST (clist), pos, 0, grad->pixmap, NULL);
if (select) if (select)
{ {
gtk_clist_select_row(GTK_CLIST(clist),pos,-1); gtk_clist_select_row (GTK_CLIST (clist), pos, -1);
gtk_clist_moveto(GTK_CLIST(clist),pos,0,0.5,0.0); gtk_clist_moveto (GTK_CLIST (clist), pos, 0, 0.5, 0.0);
} }
} /* ed_insert_in_gradients_listbox */
}
/*****/ /*****/
static void static void
ed_list_item_update(GtkWidget *widget, ed_list_item_update (GtkWidget *widget,
gint row, gint row,
gint column, gint column,
GdkEventButton *event, GdkEventButton *event,
gpointer data) gpointer data)
{ {
/* Update current gradient */ /* Update current gradient */
GSList* tmp = g_slist_nth(gradients_list,row); GSList* tmp = g_slist_nth (gradients_list,row);
curr_gradient = (gradient_t *)(tmp->data); curr_gradient = (gradient_t *)(tmp->data);
ed_update_editor(GRAD_UPDATE_PREVIEW | GRAD_RESET_CONTROL);
} /* ed_list_item_update */
ed_update_editor (GRAD_UPDATE_PREVIEW | GRAD_RESET_CONTROL);
}
/*****/ /*****/
static void static void
ed_initialize_saved_colors(void) ed_initialize_saved_colors (void)
{ {
int i; int i;
for (i = 0; i < (GRAD_NUM_COLORS + 3); i++) { for (i = 0; i < (GRAD_NUM_COLORS + 3); i++)
g_editor->left_load_color_boxes[i] = NULL; {
g_editor->left_load_labels[i] = NULL; g_editor->left_load_color_boxes[i] = NULL;
g_editor->left_load_labels[i] = NULL;
g_editor->right_load_color_boxes[i] = NULL; g_editor->right_load_color_boxes[i] = NULL;
g_editor->right_load_labels[i] = NULL; g_editor->right_load_labels[i] = NULL;
} /* for */ }
for (i = 0; i < GRAD_NUM_COLORS; i++) { for (i = 0; i < GRAD_NUM_COLORS; i++)
g_editor->left_save_color_boxes[i] = NULL; {
g_editor->left_save_labels[i] = NULL; g_editor->left_save_color_boxes[i] = NULL;
g_editor->left_save_labels[i] = NULL;
g_editor->right_save_color_boxes[i] = NULL; g_editor->right_save_color_boxes[i] = NULL;
g_editor->right_save_labels[i] = NULL; g_editor->right_save_labels[i] = NULL;
} /* for */ }
g_editor->saved_colors[0].r = 0.0; /* Black */ g_editor->saved_colors[0].r = 0.0; /* Black */
g_editor->saved_colors[0].g = 0.0; g_editor->saved_colors[0].g = 0.0;
g_editor->saved_colors[0].b = 0.0; g_editor->saved_colors[0].b = 0.0;
g_editor->saved_colors[0].a = 1.0; g_editor->saved_colors[0].a = 1.0;
g_editor->saved_colors[1].r = 0.5; /* 50% Gray */ g_editor->saved_colors[1].r = 0.5; /* 50% Gray */
g_editor->saved_colors[1].g = 0.5; g_editor->saved_colors[1].g = 0.5;
g_editor->saved_colors[1].b = 0.5; g_editor->saved_colors[1].b = 0.5;
g_editor->saved_colors[1].a = 1.0; g_editor->saved_colors[1].a = 1.0;
g_editor->saved_colors[2].r = 1.0; /* White */ g_editor->saved_colors[2].r = 1.0; /* White */
g_editor->saved_colors[2].g = 1.0; g_editor->saved_colors[2].g = 1.0;
g_editor->saved_colors[2].b = 1.0; g_editor->saved_colors[2].b = 1.0;
g_editor->saved_colors[2].a = 1.0; g_editor->saved_colors[2].a = 1.0;
g_editor->saved_colors[3].r = 0.0; /* Clear */ g_editor->saved_colors[3].r = 0.0; /* Clear */
g_editor->saved_colors[3].g = 0.0; g_editor->saved_colors[3].g = 0.0;
g_editor->saved_colors[3].b = 0.0; g_editor->saved_colors[3].b = 0.0;
g_editor->saved_colors[3].a = 0.0; g_editor->saved_colors[3].a = 0.0;
g_editor->saved_colors[4].r = 1.0; /* Red */ g_editor->saved_colors[4].r = 1.0; /* Red */
g_editor->saved_colors[4].g = 0.0; g_editor->saved_colors[4].g = 0.0;
g_editor->saved_colors[4].b = 0.0; g_editor->saved_colors[4].b = 0.0;
g_editor->saved_colors[4].a = 1.0; g_editor->saved_colors[4].a = 1.0;
g_editor->saved_colors[5].r = 1.0; /* Yellow */ g_editor->saved_colors[5].r = 1.0; /* Yellow */
g_editor->saved_colors[5].g = 1.0; g_editor->saved_colors[5].g = 1.0;
g_editor->saved_colors[5].b = 0.0; g_editor->saved_colors[5].b = 0.0;
g_editor->saved_colors[5].a = 1.0; g_editor->saved_colors[5].a = 1.0;
g_editor->saved_colors[6].r = 0.0; /* Green */ g_editor->saved_colors[6].r = 0.0; /* Green */
g_editor->saved_colors[6].g = 1.0; g_editor->saved_colors[6].g = 1.0;
g_editor->saved_colors[6].b = 0.0; g_editor->saved_colors[6].b = 0.0;
g_editor->saved_colors[6].a = 1.0; g_editor->saved_colors[6].a = 1.0;
g_editor->saved_colors[7].r = 0.0; /* Cyan */ g_editor->saved_colors[7].r = 0.0; /* Cyan */
g_editor->saved_colors[7].g = 1.0; g_editor->saved_colors[7].g = 1.0;
g_editor->saved_colors[7].b = 1.0; g_editor->saved_colors[7].b = 1.0;
g_editor->saved_colors[7].a = 1.0; g_editor->saved_colors[7].a = 1.0;
g_editor->saved_colors[8].r = 0.0; /* Blue */ g_editor->saved_colors[8].r = 0.0; /* Blue */
g_editor->saved_colors[8].g = 0.0; g_editor->saved_colors[8].g = 0.0;
g_editor->saved_colors[8].b = 1.0; g_editor->saved_colors[8].b = 1.0;
g_editor->saved_colors[8].a = 1.0; g_editor->saved_colors[8].a = 1.0;
g_editor->saved_colors[9].r = 1.0; /* Magenta */ g_editor->saved_colors[9].r = 1.0; /* Magenta */
g_editor->saved_colors[9].g = 0.0; g_editor->saved_colors[9].g = 0.0;
g_editor->saved_colors[9].b = 1.0; g_editor->saved_colors[9].b = 1.0;
g_editor->saved_colors[9].a = 1.0; g_editor->saved_colors[9].a = 1.0;
} /* ed_initialize_saved_colors */ }
/***** Main gradient editor dialog callbacks *****/ /***** Main gradient editor dialog callbacks *****/
@ -1805,8 +1820,8 @@ ed_scrollbar_update (GtkAdjustment *adjustment,
} }
static void static void
ed_zoom_all_callback(GtkWidget *widget, ed_zoom_all_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GtkAdjustment *adjustment; GtkAdjustment *adjustment;
@ -1848,8 +1863,8 @@ ed_zoom_out_callback (GtkWidget *widget,
else if ((value + page_size) > 1.0) else if ((value + page_size) > 1.0)
value = 1.0 - page_size; value = 1.0 - page_size;
adjustment->value = value; adjustment->value = value;
adjustment->page_size = page_size; adjustment->page_size = page_size;
adjustment->step_increment = page_size * GRAD_SCROLLBAR_STEP_SIZE; adjustment->step_increment = page_size * GRAD_SCROLLBAR_STEP_SIZE;
adjustment->page_increment = page_size * GRAD_SCROLLBAR_PAGE_SIZE; adjustment->page_increment = page_size * GRAD_SCROLLBAR_PAGE_SIZE;
@ -3338,7 +3353,7 @@ cpopup_create_main_menu (void)
static void static void
cpopup_do_popup (void) cpopup_do_popup (void)
{ {
cpopup_adjust_menus(); cpopup_adjust_menus ();
gtk_menu_popup (GTK_MENU (g_editor->control_main_popup), gtk_menu_popup (GTK_MENU (g_editor->control_main_popup),
NULL, NULL, NULL, NULL, 3, 0); NULL, NULL, NULL, NULL, 3, 0);
} }
@ -4052,8 +4067,6 @@ cpopup_set_color_selection_color (GtkColorSelection *cs,
gtk_color_selection_set_color (cs, color); gtk_color_selection_set_color (cs, color);
} }
/*****/
static void static void
cpopup_get_color_selection_color (GtkColorSelection *cs, cpopup_get_color_selection_color (GtkColorSelection *cs,
double *r, double *r,