Commit ab014f8b authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/by_color_select.c app/channels_dialog.c app/color_area.c

2001-01-07  Michael Natterer  <mitch@gimp.org>

	* app/by_color_select.c
	* app/channels_dialog.c
	* app/color_area.c
	* app/color_notebook.[ch]
	* app/color_panel.[ch]
	* app/color_picker.c
	* app/color_select.c
	* app/colormap_dialog.i.c
	* app/devices.c
	* app/disp_callbacks.[ch]
	* app/gimpdnd.[ch]
	* app/palette.c
	* app/qmask.c

	* libgimp/gimpcolorselector.h

	* modules/colorsel_gtk.c
	* modules/colorsel_triangle.c
	* modules/colorsel_water.c: made the color_notebook, the color_area
	and DND speak in terms of RGBA instead of GRB. The alpha value is
	not used yet, only the API changed. Everything should work exactly
	as before.
parent da07ba7c
2001-01-07 Michael Natterer <mitch@gimp.org>
* app/by_color_select.c
* app/channels_dialog.c
* app/color_area.c
* app/color_notebook.[ch]
* app/color_panel.[ch]
* app/color_picker.c
* app/color_select.c
* app/colormap_dialog.i.c
* app/devices.c
* app/disp_callbacks.[ch]
* app/gimpdnd.[ch]
* app/palette.c
* app/qmask.c
* libgimp/gimpcolorselector.h
* modules/colorsel_gtk.c
* modules/colorsel_triangle.c
* modules/colorsel_water.c: made the color_notebook, the color_area
and DND speak in terms of RGBA instead of GRB. The alpha value is
not used yet, only the API changed. Everything should work exactly
as before.
2001-01-07 Michael Natterer <mitch@gimp.org>
* TODO.xml: add "Cleanup GIMP's color selectors".
......
......@@ -255,9 +255,7 @@ edit_qmask_channel_query (GDisplay * gdisp)
GtkWidget *label;
GtkWidget *opacity_scale;
GtkObject *opacity_scale_data;
gint i;
guchar channel_color[3] = { 0, 0, 0 };
guchar r, g, b, a;
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
/* the new options structure */
......@@ -265,10 +263,12 @@ edit_qmask_channel_query (GDisplay * gdisp)
options->gimage = gdisp->gimage;
options->opacity = (gdouble) options->gimage->qmask_opacity;
for (i = 0; i < 3; i++)
channel_color[i] = options->gimage->qmask_color[i];
r = options->gimage->qmask_color[0];
g = options->gimage->qmask_color[1];
b = options->gimage->qmask_color[2];
a = 255;
options->color_panel = color_panel_new (channel_color, 48, 64);
options->color_panel = color_panel_new (r, g, b, a, FALSE, 48, 64);
/* The dialog */
options->query_box =
......
......@@ -255,9 +255,7 @@ edit_qmask_channel_query (GDisplay * gdisp)
GtkWidget *label;
GtkWidget *opacity_scale;
GtkObject *opacity_scale_data;
gint i;
guchar channel_color[3] = { 0, 0, 0 };
guchar r, g, b, a;
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
/* the new options structure */
......@@ -265,10 +263,12 @@ edit_qmask_channel_query (GDisplay * gdisp)
options->gimage = gdisp->gimage;
options->opacity = (gdouble) options->gimage->qmask_opacity;
for (i = 0; i < 3; i++)
channel_color[i] = options->gimage->qmask_color[i];
r = options->gimage->qmask_color[0];
g = options->gimage->qmask_color[1];
b = options->gimage->qmask_color[2];
a = 255;
options->color_panel = color_panel_new (channel_color, 48, 64);
options->color_panel = color_panel_new (r, g, b, a, FALSE, 48, 64);
/* The dialog */
options->query_box =
......
......@@ -102,6 +102,7 @@ static void by_color_select_color_drop (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
guchar a,
gpointer data);
/* by_color select action functions */
......@@ -1232,6 +1233,7 @@ by_color_select_color_drop (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
guchar a,
gpointer data)
{
......
......@@ -185,6 +185,7 @@ static void channel_widget_drop_color (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
guchar a,
gpointer data);
static void channel_widget_draw_drop_indicator (ChannelWidget *cw,
GimpDropType drop_type);
......@@ -1757,10 +1758,11 @@ channel_widget_drop_color (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
guchar a,
gpointer data)
{
ChannelWidget *channel_widget = (ChannelWidget *) data;
Channel *channel = channel_widget->channel;
Channel *channel = channel_widget->channel;
if (r != channel->col[0] ||
g != channel->col[1] ||
......@@ -1782,7 +1784,7 @@ channel_widget_draw_drop_indicator (ChannelWidget *channel_widget,
GimpDropType drop_type)
{
static GdkGC *gc = NULL;
gint y = 0;
gint y = 0;
if (!gc)
{
......@@ -1868,14 +1870,14 @@ channel_widget_button_events (GtkWidget *widget,
ChannelWidget *channel_widget;
GtkWidget *event_widget;
GdkEventButton *bevent;
gint return_val;
gint visible;
gint width, height;
gint return_val;
gint visible;
gint width, height;
static gboolean button_down = FALSE;
static gboolean button_down = FALSE;
static GtkWidget *click_widget = NULL;
static gint old_state;
static gint exclusive;
static gint old_state;
static gint exclusive;
channel_widget =
(ChannelWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
......@@ -1896,7 +1898,6 @@ channel_widget_button_events (GtkWidget *widget,
break;
}
switch (event->type)
{
case GDK_EXPOSE:
......@@ -1973,7 +1974,7 @@ channel_widget_button_events (GtkWidget *widget,
/* the user moved the cursor out of the widget before
releasing the button -> cancel the button_press */
button_down = FALSE;
if (widget == channel_widget->eye_widget)
{
if (exclusive)
......@@ -2009,7 +2010,7 @@ channel_widget_preview_events (GtkWidget *widget,
ChannelWidget *channel_widget;
GdkEventExpose *eevent;
GdkEventButton *bevent;
gboolean valid;
gboolean valid;
valid = FALSE;
......@@ -2082,8 +2083,8 @@ static void
channel_widget_preview_redraw (ChannelWidget *channel_widget)
{
TempBuf *preview_buf;
gint width, height;
gint channel;
gint width, height;
gint channel;
/* allocate the channel widget pixmap */
if (! channel_widget->channel_pixmap)
......@@ -2180,15 +2181,15 @@ channel_widget_preview_redraw (ChannelWidget *channel_widget)
static void
channel_widget_no_preview_redraw (ChannelWidget *channel_widget)
{
GdkPixmap *pixmap;
GdkPixmap **pixmap_normal;
GdkPixmap **pixmap_selected;
GdkPixmap **pixmap_insensitive;
GdkColor *color;
GtkWidget *widget;
GtkStateType state;
gchar *bits;
gint width, height;
GdkPixmap *pixmap;
GdkPixmap **pixmap_normal;
GdkPixmap **pixmap_selected;
GdkPixmap **pixmap_insensitive;
GdkColor *color;
GtkWidget *widget;
GtkStateType state;
gchar *bits;
gint width, height;
state = channel_widget->list_item->state;
......@@ -2249,10 +2250,10 @@ channel_widget_no_preview_redraw (ChannelWidget *channel_widget)
static void
channel_widget_eye_redraw (ChannelWidget *channel_widget)
{
GdkPixmap *pixmap;
GdkColor *color;
GtkStateType state;
gboolean visible;
GdkPixmap *pixmap;
GdkColor *color;
GtkStateType state;
gboolean visible;
state = channel_widget->list_item->state;
......@@ -2480,16 +2481,16 @@ struct _NewChannelOptions
};
static gchar *channel_name = NULL;
static guchar channel_color[3] = { 0, 0, 0 };
static guchar channel_color[4] = { 0, 0, 0, 0 };
static void
new_channel_query_ok_callback (GtkWidget *widget,
gpointer data)
{
NewChannelOptions *options;
Channel *new_channel;
GimpImage *gimage;
gint i;
Channel *new_channel;
GimpImage *gimage;
gint i;
options = (NewChannelOptions *) data;
......@@ -2530,7 +2531,12 @@ channels_dialog_new_channel_query (GimpImage* gimage)
options = g_new (NewChannelOptions, 1);
options->gimage = gimage;
options->opacity = 50.0;
options->color_panel = color_panel_new (channel_color, 48, 64);
options->color_panel = color_panel_new (channel_color[0],
channel_color[1],
channel_color[2],
channel_color[3],
FALSE,
48, 64);
/* The dialog */
options->query_box =
......@@ -2633,9 +2639,9 @@ edit_channel_query_ok_callback (GtkWidget *widget,
{
EditChannelOptions *options;
Channel *channel;
gint opacity;
gint update = FALSE;
gint i;
gint opacity;
gint update = FALSE;
gint i;
options = (EditChannelOptions *) data;
channel = options->channel_widget->channel;
......@@ -2654,6 +2660,7 @@ edit_channel_query_ok_callback (GtkWidget *widget,
channel->opacity = opacity;
update = TRUE;
}
for (i = 0; i < 3; i++)
if (options->color_panel->color[i] != channel->col[i])
{
......@@ -2683,17 +2690,23 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
GtkWidget *label;
GtkWidget *opacity_scale;
GtkObject *opacity_scale_data;
gint i;
gint i;
/* the new options structure */
options = g_new (EditChannelOptions, 1);
options->channel_widget = channel_widget;
options->gimage = channel_widget->gimage;
options->opacity = (gdouble) channel_widget->channel->opacity / 2.55;
for (i = 0; i < 3; i++)
channel_color[i] = channel_widget->channel->col[i];
options->color_panel = color_panel_new (channel_color, 48, 64);
options->color_panel = color_panel_new (channel_color[0],
channel_color[1],
channel_color[2],
channel_color[3],
FALSE,
48, 64);
/* The dialog */
options->query_box =
......
......@@ -51,16 +51,19 @@ static void color_area_drop_color (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
guchar a,
gpointer data);
static void color_area_drag_color (GtkWidget *widget,
guchar *r,
guchar *g,
guchar *b,
guchar *a,
gpointer data);
static void color_area_color_changed (GimpContext *context,
gint r,
gint g,
gint b,
gint a,
gpointer data);
/* Global variables */
......@@ -277,6 +280,7 @@ static void
color_area_select_callback (gint r,
gint g,
gint b,
gint a,
ColorNotebookState state,
void *client_data)
{
......@@ -330,8 +334,9 @@ color_area_edit (void)
if (! color_notebook)
{
color_notebook = color_notebook_new (r, g, b, color_area_select_callback,
NULL, TRUE);
color_notebook = color_notebook_new (r, g, b, 255,
color_area_select_callback,
NULL, TRUE, FALSE);
color_notebook_active = TRUE;
}
else
......@@ -344,7 +349,7 @@ color_area_edit (void)
else
gdk_window_raise (color_notebook->shell->window);
color_notebook_set_color (color_notebook, r, g, b, TRUE);
color_notebook_set_color (color_notebook, r, g, b, 255, TRUE);
}
}
......@@ -534,8 +539,11 @@ color_area_drag_color (GtkWidget *widget,
guchar *r,
guchar *g,
guchar *b,
guchar *a,
gpointer data)
{
*a = 255;
if (active_color == FOREGROUND)
gimp_context_get_foreground (gimp_context_get_user (), r, g, b);
else
......@@ -547,12 +555,13 @@ color_area_drop_color (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
guchar a,
gpointer data)
{
if (color_notebook_active &&
active_color == edit_color)
{
color_notebook_set_color (color_notebook, r, g, b, TRUE);
color_notebook_set_color (color_notebook, r, g, b, 255, TRUE);
}
else
{
......@@ -568,6 +577,7 @@ color_area_color_changed (GimpContext *context,
gint r,
gint g,
gint b,
gint a,
gpointer data)
{
color_area_draw ();
......
......@@ -46,7 +46,7 @@ struct _ColorSelectorInfo
{
char *name; /* label used in notebook tab */
char *help_page;
GimpColorSelectorMethods m;
GimpColorSelectorMethods methods;
int refs; /* number of instances around */
gboolean active;
void (*death_callback) (void *data);
......@@ -71,7 +71,8 @@ static void color_notebook_cancel_callback (GtkWidget *widget,
static void color_notebook_update_callback (gpointer data,
gint red,
gint green,
gint blue);
gint blue,
gint alpha);
static void color_notebook_page_switch (GtkWidget *widget,
GtkNotebookPage *page,
guint page_num);
......@@ -88,6 +89,7 @@ enum
RED,
GREEN,
BLUE,
ALPHA,
NUM_COLORS
};
......@@ -96,13 +98,15 @@ ColorNotebook *
color_notebook_new (gint red,
gint green,
gint blue,
gint alpha,
ColorNotebookCallback callback,
gpointer client_data,
gboolean wants_updates)
gboolean wants_updates,
gboolean show_alpha)
{
ColorNotebook *cnp;
GtkWidget *label;
ColorSelectorInfo *info;
ColorNotebook *cnp;
GtkWidget *label;
ColorSelectorInfo *info;
ColorSelectorInstance *csel;
g_return_val_if_fail (selector_info != NULL, NULL);
......@@ -118,6 +122,7 @@ color_notebook_new (gint red,
cnp->values[RED] = cnp->orig_values[RED] = red & 0xff;
cnp->values[GREEN] = cnp->orig_values[GREEN] = green & 0xff;
cnp->values[BLUE] = cnp->orig_values[BLUE] = blue & 0xff;
cnp->values[ALPHA] = cnp->orig_values[ALPHA] = alpha & 0xff;
cnp->shell =
gimp_dialog_new (_("Color Selection"), "color_selection",
......@@ -158,9 +163,10 @@ color_notebook_new (gint red,
csel->color_notebook = cnp;
csel->info = info;
info->refs++;
csel->frame = info->m.new (red, green, blue,
color_notebook_update_callback, csel,
&csel->selector_data);
csel->frame = info->methods.new (red, green, blue, alpha,
show_alpha,
color_notebook_update_callback, csel,
&csel->selector_data);
gtk_object_set_data (GTK_OBJECT (csel->frame), "gimp_color_notebook",
csel);
......@@ -201,7 +207,8 @@ color_notebook_new (gint red,
{
gtk_object_set_user_data (GTK_OBJECT (cnp->notebook), cnp);
gtk_signal_connect (GTK_OBJECT (cnp->notebook), "switch_page",
(GtkSignalFunc)color_notebook_page_switch, NULL);
GTK_SIGNAL_FUNC (color_notebook_page_switch),
NULL);
}
return cnp;
......@@ -236,7 +243,7 @@ color_notebook_free (ColorNotebook *cnp)
{
next = csel->next;
csel->info->m.free (csel->selector_data);
csel->info->methods.free (csel->selector_data);
csel->info->refs--;
if (csel->info->refs == 0 && !csel->info->active)
......@@ -254,24 +261,30 @@ color_notebook_set_color (ColorNotebook *cnp,
gint red,
gint green,
gint blue,
gint alpha,
gboolean set_current)
{
ColorSelectorInstance *csel;
g_return_if_fail (cnp != NULL);
cnp->orig_values[RED] = red;
cnp->orig_values[GREEN] = green;
cnp->orig_values[BLUE] = blue;
cnp->orig_values[ALPHA] = alpha;
if (set_current)
{
cnp->values[RED] = red;
cnp->values[GREEN] = green;
cnp->values[BLUE] = blue;
cnp->values[ALPHA] = alpha;
}
csel = cnp->cur_page;
csel->info->m.setcolor (csel->selector_data, red, green, blue, set_current);
csel->info->methods.setcolor (csel->selector_data,
red, green, blue, alpha,
set_current);
}
/* Called by a colour selector on user selection of a colour */
......@@ -279,10 +292,11 @@ static void
color_notebook_update_callback (gpointer data,
gint red,
gint green,
gint blue)
gint blue,
gint alpha)
{
ColorSelectorInstance *csel;
ColorNotebook *cnp;
ColorNotebook *cnp;
g_return_if_fail (data != NULL);
......@@ -292,12 +306,14 @@ color_notebook_update_callback (gpointer data,
cnp->values[RED] = red;
cnp->values[GREEN] = green;
cnp->values[BLUE] = blue;
cnp->values[ALPHA] = alpha;
if (cnp->wants_updates && cnp->callback)
{
(* cnp->callback) (cnp->values[RED],
cnp->values[GREEN],
cnp->values[BLUE],
cnp->values[ALPHA],
COLOR_NOTEBOOK_UPDATE,
cnp->client_data);
}
......@@ -315,6 +331,7 @@ color_notebook_ok_callback (GtkWidget *widget,
(* cnp->callback) (cnp->values[RED],
cnp->values[GREEN],
cnp->values[BLUE],
cnp->values[ALPHA],
COLOR_NOTEBOOK_OK,
cnp->client_data);
}
......@@ -331,6 +348,7 @@ color_notebook_cancel_callback (GtkWidget *widget,
(* cnp->callback) (cnp->orig_values[RED],
cnp->orig_values[GREEN],
cnp->orig_values[BLUE],
cnp->orig_values[ALPHA],
COLOR_NOTEBOOK_CANCEL,
cnp->client_data);
}
......@@ -340,7 +358,7 @@ color_notebook_page_switch (GtkWidget *widget,
GtkNotebookPage *page,
guint page_num)
{
ColorNotebook *cnp;
ColorNotebook *cnp;
ColorSelectorInstance *csel;
cnp = gtk_object_get_user_data (GTK_OBJECT (widget));
......@@ -349,18 +367,19 @@ color_notebook_page_switch (GtkWidget *widget,
g_return_if_fail (cnp != NULL && csel != NULL);
cnp->cur_page = csel;
csel->info->m.setcolor (csel->selector_data,
cnp->values[RED],
cnp->values[GREEN],
cnp->values[BLUE],
TRUE);
csel->info->methods.setcolor (csel->selector_data,
cnp->values[RED],
cnp->values[GREEN],
cnp->values[BLUE],
cnp->values[ALPHA],
TRUE);
}
static void
color_notebook_help_func (const gchar *data)
{
ColorNotebook *cnp;
gchar *help_path;
gchar *help_path;
cnp = (ColorNotebook *) data;
......@@ -393,13 +412,14 @@ gimp_color_selector_register (const gchar *name,
info = g_new (ColorSelectorInfo, 1);
info->name = g_strdup (name);
info->name = g_strdup (name);
info->help_page = g_strdup (help_page);
info->m = *methods;
info->refs = 0;
info->active = TRUE;
info->methods = *methods;
info->refs = 0;
info->active = TRUE;
info->next = selector_info;
info->next = selector_info;
selector_info = info;
return info;
......
......@@ -30,6 +30,7 @@ typedef enum
typedef void (* ColorNotebookCallback) (gint red,
gint green,
gint blue,
gint alpha,
ColorNotebookState state,
gpointer data);
......@@ -42,8 +43,8 @@ struct _ColorNotebook
GtkWidget *shell;
GtkWidget *notebook;
gint values[3];
gint orig_values[3];
gint values[4];