mirror of https://github.com/GNOME/gimp.git
rewritten as proper widget derived from GimpColorButton
2001-01-15 Sven Neumann <sven@gimp.org> * app/color_panel.[ch]: rewritten as proper widget derived from GimpColorButton * app/channels_dialog.c * app/color_picker.c * app/qmask.c: use new GimpColorPanel widget * libgimp/gimpcolorarea.[ch] * libgimp/gimpcolorbutton.[ch]: some changes needed to derive from GimpColorButton * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.c * plug-ins/script-fu/script-fu-scripts.c: follow API changes of GimpColorButton and GimpColorArea
This commit is contained in:
parent
d822839089
commit
943847677c
29
ChangeLog
29
ChangeLog
|
@ -1,3 +1,32 @@
|
||||||
|
2001-01-15 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* app/color_panel.[ch]: rewritten as proper widget derived from
|
||||||
|
GimpColorButton
|
||||||
|
|
||||||
|
* app/channels_dialog.c
|
||||||
|
* app/color_picker.c
|
||||||
|
* app/qmask.c: use new GimpColorPanel widget
|
||||||
|
|
||||||
|
* libgimp/gimpcolorarea.[ch]
|
||||||
|
* libgimp/gimpcolorbutton.[ch]: some changes needed to derive from
|
||||||
|
GimpColorButton
|
||||||
|
|
||||||
|
* plug-ins/Lighting/lighting_ui.c
|
||||||
|
* plug-ins/MapObject/mapobject_ui.c
|
||||||
|
* plug-ins/common/colorify.c
|
||||||
|
* plug-ins/common/colortoalpha.c
|
||||||
|
* plug-ins/common/exchange.c
|
||||||
|
* plug-ins/common/film.c
|
||||||
|
* plug-ins/common/grid.c
|
||||||
|
* plug-ins/common/mapcolor.c
|
||||||
|
* plug-ins/common/nova.c
|
||||||
|
* plug-ins/common/papertile.c
|
||||||
|
* plug-ins/common/sinus.c
|
||||||
|
* plug-ins/gdyntext/gdyntext_ui.c
|
||||||
|
* plug-ins/ifscompose/ifscompose.c
|
||||||
|
* plug-ins/script-fu/script-fu-scripts.c: follow API changes of
|
||||||
|
GimpColorButton and GimpColorArea
|
||||||
|
|
||||||
2001-01-15 Michael Natterer <mitch@gimp.org>
|
2001-01-15 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* app/channel.[ch]
|
* app/channel.[ch]
|
||||||
|
|
|
@ -47,10 +47,9 @@ struct _EditQmaskOptions
|
||||||
{
|
{
|
||||||
GtkWidget *query_box;
|
GtkWidget *query_box;
|
||||||
GtkWidget *name_entry;
|
GtkWidget *name_entry;
|
||||||
ColorPanel *color_panel;
|
GtkWidget *color_panel;
|
||||||
|
|
||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
GimpRGB color;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||||
|
@ -58,15 +57,17 @@ typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||||
/* Global variables */
|
/* Global variables */
|
||||||
/* Static variables */
|
/* Static variables */
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
static void edit_qmask_channel_query (GDisplay *gdisp);
|
static void edit_qmask_channel_query (GDisplay *gdisp);
|
||||||
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||||
gpointer client_data);
|
gpointer client_data);
|
||||||
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
||||||
gpointer client_data);
|
gpointer client_data);
|
||||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
static void qmask_removed_callback (GtkObject *qmask,
|
static void qmask_color_changed (GimpColorButton *button,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
static void qmask_removed_callback (GtkObject *qmask,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
/* Actual code */
|
/* Actual code */
|
||||||
|
|
||||||
|
@ -74,11 +75,22 @@ static void
|
||||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpRGB *color;
|
GimpRGB color;
|
||||||
|
|
||||||
color = (GimpRGB *) data;
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||||
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
}
|
||||||
|
|
||||||
color->a = adjustment->value / 100.0;
|
static void
|
||||||
|
qmask_color_changed (GimpColorButton *button,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
|
gimp_color_button_get_color (button, &color);
|
||||||
|
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -260,9 +272,10 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
||||||
/* the new options structure */
|
/* the new options structure */
|
||||||
options = g_new (EditQmaskOptions, 1);
|
options = g_new (EditQmaskOptions, 1);
|
||||||
options->gimage = gdisp->gimage;
|
options->gimage = gdisp->gimage;
|
||||||
options->color = options->gimage->qmask_color;
|
|
||||||
|
|
||||||
options->color_panel = color_panel_new (&options->color, FALSE, 48, 64);
|
options->color_panel = gimp_color_panel_new (&options->gimage->qmask_color,
|
||||||
|
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||||
|
48, 64);
|
||||||
|
|
||||||
/* The dialog */
|
/* The dialog */
|
||||||
options->query_box =
|
options->query_box =
|
||||||
|
@ -301,19 +314,23 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
||||||
gtk_widget_show (label);
|
gtk_widget_show (label);
|
||||||
|
|
||||||
opacity_scale_data =
|
opacity_scale_data =
|
||||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
gtk_adjustment_new (options->gimage->qmask_color.a * 100.0,
|
||||||
|
0.0, 100.0, 1.0, 1.0, 0.0);
|
||||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||||
&options->color);
|
options->color_panel);
|
||||||
gtk_widget_show (opacity_scale);
|
gtk_widget_show (opacity_scale);
|
||||||
|
|
||||||
/* The color panel */
|
/* The color panel */
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel->color_panel_widget,
|
gtk_signal_connect (GTK_OBJECT (options->color_panel), "color_changed",
|
||||||
|
qmask_color_changed,
|
||||||
|
opacity_scale_data);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
|
||||||
TRUE, TRUE, 0);
|
TRUE, TRUE, 0);
|
||||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
gtk_widget_show (options->color_panel);
|
||||||
|
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
@ -327,24 +344,25 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||||
{
|
{
|
||||||
EditQmaskOptions *options;
|
EditQmaskOptions *options;
|
||||||
Channel *channel;
|
Channel *channel;
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
options = (EditQmaskOptions *) client_data;
|
options = (EditQmaskOptions *) client_data;
|
||||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||||
|
|
||||||
options->color_panel->color.a = options->color.a;
|
|
||||||
|
|
||||||
if (options->gimage && channel)
|
if (options->gimage && channel)
|
||||||
{
|
{
|
||||||
if (gimp_rgba_distance (&channel->color,
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||||
&options->color_panel->color) > 0.0001)
|
&color);
|
||||||
|
|
||||||
|
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||||
{
|
{
|
||||||
channel_set_color (channel, &options->color_panel->color);
|
channel->color = color;
|
||||||
channel_update (channel);
|
channel_update (channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update the qmask color no matter what */
|
/* update the qmask color no matter what */
|
||||||
options->gimage->qmask_color = options->color_panel->color;
|
options->gimage->qmask_color = color;
|
||||||
|
|
||||||
gtk_widget_destroy (options->query_box);
|
gtk_widget_destroy (options->query_box);
|
||||||
g_free (options);
|
g_free (options);
|
||||||
|
|
|
@ -47,10 +47,9 @@ struct _EditQmaskOptions
|
||||||
{
|
{
|
||||||
GtkWidget *query_box;
|
GtkWidget *query_box;
|
||||||
GtkWidget *name_entry;
|
GtkWidget *name_entry;
|
||||||
ColorPanel *color_panel;
|
GtkWidget *color_panel;
|
||||||
|
|
||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
GimpRGB color;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||||
|
@ -58,15 +57,17 @@ typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||||
/* Global variables */
|
/* Global variables */
|
||||||
/* Static variables */
|
/* Static variables */
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
static void edit_qmask_channel_query (GDisplay *gdisp);
|
static void edit_qmask_channel_query (GDisplay *gdisp);
|
||||||
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||||
gpointer client_data);
|
gpointer client_data);
|
||||||
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
||||||
gpointer client_data);
|
gpointer client_data);
|
||||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
static void qmask_removed_callback (GtkObject *qmask,
|
static void qmask_color_changed (GimpColorButton *button,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
static void qmask_removed_callback (GtkObject *qmask,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
/* Actual code */
|
/* Actual code */
|
||||||
|
|
||||||
|
@ -74,11 +75,22 @@ static void
|
||||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpRGB *color;
|
GimpRGB color;
|
||||||
|
|
||||||
color = (GimpRGB *) data;
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||||
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
}
|
||||||
|
|
||||||
color->a = adjustment->value / 100.0;
|
static void
|
||||||
|
qmask_color_changed (GimpColorButton *button,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
|
gimp_color_button_get_color (button, &color);
|
||||||
|
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -260,9 +272,10 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
||||||
/* the new options structure */
|
/* the new options structure */
|
||||||
options = g_new (EditQmaskOptions, 1);
|
options = g_new (EditQmaskOptions, 1);
|
||||||
options->gimage = gdisp->gimage;
|
options->gimage = gdisp->gimage;
|
||||||
options->color = options->gimage->qmask_color;
|
|
||||||
|
|
||||||
options->color_panel = color_panel_new (&options->color, FALSE, 48, 64);
|
options->color_panel = gimp_color_panel_new (&options->gimage->qmask_color,
|
||||||
|
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||||
|
48, 64);
|
||||||
|
|
||||||
/* The dialog */
|
/* The dialog */
|
||||||
options->query_box =
|
options->query_box =
|
||||||
|
@ -301,19 +314,23 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
||||||
gtk_widget_show (label);
|
gtk_widget_show (label);
|
||||||
|
|
||||||
opacity_scale_data =
|
opacity_scale_data =
|
||||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
gtk_adjustment_new (options->gimage->qmask_color.a * 100.0,
|
||||||
|
0.0, 100.0, 1.0, 1.0, 0.0);
|
||||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||||
&options->color);
|
options->color_panel);
|
||||||
gtk_widget_show (opacity_scale);
|
gtk_widget_show (opacity_scale);
|
||||||
|
|
||||||
/* The color panel */
|
/* The color panel */
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel->color_panel_widget,
|
gtk_signal_connect (GTK_OBJECT (options->color_panel), "color_changed",
|
||||||
|
qmask_color_changed,
|
||||||
|
opacity_scale_data);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
|
||||||
TRUE, TRUE, 0);
|
TRUE, TRUE, 0);
|
||||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
gtk_widget_show (options->color_panel);
|
||||||
|
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
@ -327,24 +344,25 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||||
{
|
{
|
||||||
EditQmaskOptions *options;
|
EditQmaskOptions *options;
|
||||||
Channel *channel;
|
Channel *channel;
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
options = (EditQmaskOptions *) client_data;
|
options = (EditQmaskOptions *) client_data;
|
||||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||||
|
|
||||||
options->color_panel->color.a = options->color.a;
|
|
||||||
|
|
||||||
if (options->gimage && channel)
|
if (options->gimage && channel)
|
||||||
{
|
{
|
||||||
if (gimp_rgba_distance (&channel->color,
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||||
&options->color_panel->color) > 0.0001)
|
&color);
|
||||||
|
|
||||||
|
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||||
{
|
{
|
||||||
channel_set_color (channel, &options->color_panel->color);
|
channel->color = color;
|
||||||
channel_update (channel);
|
channel_update (channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update the qmask color no matter what */
|
/* update the qmask color no matter what */
|
||||||
options->gimage->qmask_color = options->color_panel->color;
|
options->gimage->qmask_color = color;
|
||||||
|
|
||||||
gtk_widget_destroy (options->query_box);
|
gtk_widget_destroy (options->query_box);
|
||||||
g_free (options);
|
g_free (options);
|
||||||
|
|
|
@ -202,8 +202,10 @@ static void channel_widget_exclusive_visible (ChannelWidget *cw);
|
||||||
static void channel_widget_channel_flush (GtkWidget *widget,
|
static void channel_widget_channel_flush (GtkWidget *widget,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
|
||||||
static void channels_dialog_opacity_update (GtkAdjustment *adjustment,
|
static void channels_dialog_opacity_update (GtkAdjustment *adjustment,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
static void channels_dialog_color_changed (GimpColorButton *button,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
/* assorted query dialogs */
|
/* assorted query dialogs */
|
||||||
static void channels_dialog_new_channel_query (GimpImage *gimage);
|
static void channels_dialog_new_channel_query (GimpImage *gimage);
|
||||||
|
@ -2463,11 +2465,22 @@ static void
|
||||||
channels_dialog_opacity_update (GtkAdjustment *adjustment,
|
channels_dialog_opacity_update (GtkAdjustment *adjustment,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpRGB *color;
|
GimpRGB color;
|
||||||
|
|
||||||
color = (GimpRGB *) data;
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||||
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
}
|
||||||
|
|
||||||
color->a = adjustment->value / 100.0;
|
static void
|
||||||
|
channels_dialog_color_changed (GimpColorButton *button,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
|
gimp_color_button_get_color (button, &color);
|
||||||
|
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************/
|
/**********************************/
|
||||||
|
@ -2480,10 +2493,9 @@ struct _NewChannelOptions
|
||||||
{
|
{
|
||||||
GtkWidget *query_box;
|
GtkWidget *query_box;
|
||||||
GtkWidget *name_entry;
|
GtkWidget *name_entry;
|
||||||
ColorPanel *color_panel;
|
GtkWidget *color_panel;
|
||||||
|
|
||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
GimpRGB color;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static gchar *channel_name = NULL;
|
static gchar *channel_name = NULL;
|
||||||
|
@ -2506,16 +2518,14 @@ new_channel_query_ok_callback (GtkWidget *widget,
|
||||||
|
|
||||||
if ((gimage = options->gimage))
|
if ((gimage = options->gimage))
|
||||||
{
|
{
|
||||||
options->color_panel->color.a = options->color.a;
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||||
|
&channel_color);
|
||||||
new_channel = channel_new (gimage, gimage->width, gimage->height,
|
new_channel = channel_new (gimage, gimage->width, gimage->height,
|
||||||
channel_name,
|
channel_name,
|
||||||
&options->color_panel->color);
|
&channel_color);
|
||||||
|
|
||||||
drawable_fill (GIMP_DRAWABLE (new_channel), TRANSPARENT_FILL);
|
drawable_fill (GIMP_DRAWABLE (new_channel), TRANSPARENT_FILL);
|
||||||
|
|
||||||
channel_color = options->color_panel->color;
|
|
||||||
|
|
||||||
gimp_image_add_channel (gimage, new_channel, -1);
|
gimp_image_add_channel (gimage, new_channel, -1);
|
||||||
gdisplays_flush ();
|
gdisplays_flush ();
|
||||||
}
|
}
|
||||||
|
@ -2537,11 +2547,10 @@ channels_dialog_new_channel_query (GimpImage* gimage)
|
||||||
/* the new options structure */
|
/* the new options structure */
|
||||||
options = g_new (NewChannelOptions, 1);
|
options = g_new (NewChannelOptions, 1);
|
||||||
options->gimage = gimage;
|
options->gimage = gimage;
|
||||||
options->color = channel_color;
|
options->color_panel = gimp_color_panel_new (&channel_color,
|
||||||
options->color_panel = color_panel_new (&channel_color,
|
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||||
FALSE,
|
48, 64);
|
||||||
48, 64);
|
|
||||||
|
|
||||||
/* The dialog */
|
/* The dialog */
|
||||||
options->query_box =
|
options->query_box =
|
||||||
gimp_dialog_new (_("New Channel Options"), "new_channel_options",
|
gimp_dialog_new (_("New Channel Options"), "new_channel_options",
|
||||||
|
@ -2599,20 +2608,23 @@ channels_dialog_new_channel_query (GimpImage* gimage)
|
||||||
gtk_widget_show (label);
|
gtk_widget_show (label);
|
||||||
|
|
||||||
opacity_scale_data =
|
opacity_scale_data =
|
||||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
gtk_adjustment_new (channel_color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||||
gtk_range_set_update_policy (GTK_RANGE (opacity_scale), GTK_UPDATE_DELAYED);
|
gtk_range_set_update_policy (GTK_RANGE (opacity_scale), GTK_UPDATE_DELAYED);
|
||||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||||
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
|
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
|
||||||
&options->color);
|
options->color_panel);
|
||||||
gtk_widget_show (opacity_scale);
|
gtk_widget_show (opacity_scale);
|
||||||
|
|
||||||
/* The color panel */
|
/* The color panel */
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel->color_panel_widget,
|
gtk_signal_connect (GTK_OBJECT (options->color_panel), "color_changed",
|
||||||
|
channels_dialog_color_changed,
|
||||||
|
opacity_scale_data);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
|
||||||
TRUE, TRUE, 0);
|
TRUE, TRUE, 0);
|
||||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
gtk_widget_show (options->color_panel);
|
||||||
|
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
@ -2630,11 +2642,10 @@ struct _EditChannelOptions
|
||||||
{
|
{
|
||||||
GtkWidget *query_box;
|
GtkWidget *query_box;
|
||||||
GtkWidget *name_entry;
|
GtkWidget *name_entry;
|
||||||
ColorPanel *color_panel;
|
GtkWidget *color_panel;
|
||||||
|
|
||||||
ChannelWidget *channel_widget;
|
ChannelWidget *channel_widget;
|
||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
GimpRGB color;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2643,6 +2654,7 @@ edit_channel_query_ok_callback (GtkWidget *widget,
|
||||||
{
|
{
|
||||||
EditChannelOptions *options;
|
EditChannelOptions *options;
|
||||||
Channel *channel;
|
Channel *channel;
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
options = (EditChannelOptions *) data;
|
options = (EditChannelOptions *) data;
|
||||||
channel = options->channel_widget->channel;
|
channel = options->channel_widget->channel;
|
||||||
|
@ -2655,13 +2667,12 @@ edit_channel_query_ok_callback (GtkWidget *widget,
|
||||||
gtk_label_set_text (GTK_LABEL (options->channel_widget->label),
|
gtk_label_set_text (GTK_LABEL (options->channel_widget->label),
|
||||||
gimp_object_get_name (GIMP_OBJECT (channel)));
|
gimp_object_get_name (GIMP_OBJECT (channel)));
|
||||||
|
|
||||||
options->color_panel->color.a = options->color.a;
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||||
|
&color);
|
||||||
|
|
||||||
if (gimp_rgba_distance (&options->color_panel->color,
|
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||||
&channel->color) > 0.0001)
|
|
||||||
{
|
{
|
||||||
channel->color = options->color_panel->color;
|
channel->color = color;
|
||||||
|
|
||||||
drawable_update (GIMP_DRAWABLE (channel), 0, 0,
|
drawable_update (GIMP_DRAWABLE (channel), 0, 0,
|
||||||
GIMP_DRAWABLE (channel)->width,
|
GIMP_DRAWABLE (channel)->width,
|
||||||
GIMP_DRAWABLE (channel)->height);
|
GIMP_DRAWABLE (channel)->height);
|
||||||
|
@ -2687,13 +2698,12 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
|
||||||
options = g_new (EditChannelOptions, 1);
|
options = g_new (EditChannelOptions, 1);
|
||||||
options->channel_widget = channel_widget;
|
options->channel_widget = channel_widget;
|
||||||
options->gimage = channel_widget->gimage;
|
options->gimage = channel_widget->gimage;
|
||||||
options->color = channel_widget->channel->color;
|
|
||||||
|
|
||||||
channel_color = options->color;
|
channel_color = channel_widget->channel->color;
|
||||||
|
|
||||||
options->color_panel = color_panel_new (&channel_color,
|
options->color_panel = gimp_color_panel_new (&channel_color,
|
||||||
FALSE,
|
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||||
48, 64);
|
48, 64);
|
||||||
|
|
||||||
/* The dialog */
|
/* The dialog */
|
||||||
options->query_box =
|
options->query_box =
|
||||||
|
@ -2753,19 +2763,22 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
|
||||||
gtk_widget_show (label);
|
gtk_widget_show (label);
|
||||||
|
|
||||||
opacity_scale_data =
|
opacity_scale_data =
|
||||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
gtk_adjustment_new (channel_color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||||
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
|
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
|
||||||
&options->color);
|
options->color_panel);
|
||||||
gtk_widget_show (opacity_scale);
|
gtk_widget_show (opacity_scale);
|
||||||
|
|
||||||
/* The color panel */
|
/* The color panel */
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel->color_panel_widget,
|
gtk_signal_connect (GTK_OBJECT (options->color_panel), "color_changed",
|
||||||
|
channels_dialog_color_changed,
|
||||||
|
opacity_scale_data);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
|
||||||
TRUE, TRUE, 0);
|
TRUE, TRUE, 0);
|
||||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
gtk_widget_show (options->color_panel);
|
||||||
|
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
|
|
@ -25,305 +25,188 @@
|
||||||
#include "appenv.h"
|
#include "appenv.h"
|
||||||
#include "color_panel.h"
|
#include "color_panel.h"
|
||||||
#include "color_notebook.h"
|
#include "color_notebook.h"
|
||||||
#include "colormaps.h"
|
|
||||||
#include "gimpdnd.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define EVENT_MASK GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | \
|
struct _GimpColorPanel
|
||||||
GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | \
|
|
||||||
GDK_LEAVE_NOTIFY_MASK
|
|
||||||
|
|
||||||
typedef struct _ColorPanelPrivate ColorPanelPrivate;
|
|
||||||
|
|
||||||
struct _ColorPanelPrivate
|
|
||||||
{
|
{
|
||||||
GtkWidget *drawing_area;
|
GimpColorButton parent;
|
||||||
GdkGC *gc;
|
|
||||||
|
|
||||||
gboolean show_alpha;
|
ColorNotebook *color_notebook;
|
||||||
gboolean button_down;
|
gboolean color_notebook_active;
|
||||||
|
|
||||||
ColorNotebook *color_notebook;
|
|
||||||
gboolean color_notebook_active;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void color_panel_free (ColorPanel *color_panel);
|
static void gimp_color_panel_class_init (GimpColorPanelClass *klass);
|
||||||
static void color_panel_draw (ColorPanel *color_panel);
|
static void gimp_color_panel_init (GimpColorPanel *panel);
|
||||||
static gint color_panel_events (GtkWidget *widget,
|
static void gimp_color_panel_destroy (GtkObject *object);
|
||||||
GdkEvent *event,
|
static void gimp_color_panel_color_changed (GimpColorButton *button);
|
||||||
gpointer data);
|
static void gimp_color_panel_clicked (GtkButton *button);
|
||||||
static void color_panel_select_callback (GimpRGB *color,
|
|
||||||
ColorNotebookState state,
|
|
||||||
gpointer data);
|
|
||||||
|
|
||||||
static void color_panel_drag_color (GtkWidget *widget,
|
static void gimp_color_panel_select_callback (GimpRGB *color,
|
||||||
GimpRGB *color,
|
ColorNotebookState state,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
static void color_panel_drop_color (GtkWidget *widget,
|
|
||||||
GimpRGB *color,
|
|
||||||
gpointer data);
|
|
||||||
|
|
||||||
/* dnd stuff */
|
|
||||||
static GtkTargetEntry color_panel_target_table[] =
|
static GimpColorButtonClass *parent_class = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
GtkType
|
||||||
|
gimp_color_panel_get_type (void)
|
||||||
{
|
{
|
||||||
GIMP_TARGET_COLOR
|
static guint panel_type = 0;
|
||||||
};
|
|
||||||
static guint n_color_panel_targets = (sizeof (color_panel_target_table) /
|
|
||||||
sizeof (color_panel_target_table[0]));
|
|
||||||
|
|
||||||
/* public functions */
|
if (!panel_type)
|
||||||
|
{
|
||||||
|
GtkTypeInfo panel_info =
|
||||||
|
{
|
||||||
|
"GimpColorPanel",
|
||||||
|
sizeof (GimpColorPanel),
|
||||||
|
sizeof (GimpColorPanelClass),
|
||||||
|
(GtkClassInitFunc) gimp_color_panel_class_init,
|
||||||
|
(GtkObjectInitFunc) gimp_color_panel_init,
|
||||||
|
/* reserved_1 */ NULL,
|
||||||
|
/* reserved_2 */ NULL,
|
||||||
|
(GtkClassInitFunc) NULL
|
||||||
|
};
|
||||||
|
|
||||||
ColorPanel *
|
panel_type = gtk_type_unique (GIMP_TYPE_COLOR_BUTTON, &panel_info);
|
||||||
color_panel_new (GimpRGB *color,
|
}
|
||||||
gboolean show_alpha,
|
|
||||||
gint width,
|
return panel_type;
|
||||||
gint height)
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_color_panel_class_init (GimpColorPanelClass *klass)
|
||||||
{
|
{
|
||||||
ColorPanel *color_panel;
|
GtkObjectClass *object_class;
|
||||||
ColorPanelPrivate *private;
|
GtkButtonClass *button_class;
|
||||||
|
GimpColorButtonClass *color_button_class;
|
||||||
|
|
||||||
|
object_class = (GtkObjectClass *) klass;
|
||||||
|
button_class = (GtkButtonClass *) klass;
|
||||||
|
color_button_class = (GimpColorButtonClass *) klass;
|
||||||
|
|
||||||
|
parent_class = gtk_type_class (gimp_color_button_get_type ());
|
||||||
|
|
||||||
|
object_class->destroy = gimp_color_panel_destroy;
|
||||||
|
color_button_class->color_changed = gimp_color_panel_color_changed;
|
||||||
|
button_class->clicked = gimp_color_panel_clicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_color_panel_init (GimpColorPanel *panel)
|
||||||
|
{
|
||||||
|
panel->color_notebook = NULL;
|
||||||
|
panel->color_notebook_active = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_color_panel_destroy (GtkObject *object)
|
||||||
|
{
|
||||||
|
GimpColorPanel *panel;
|
||||||
|
|
||||||
|
g_return_if_fail (object != NULL);
|
||||||
|
g_return_if_fail (GIMP_IS_COLOR_PANEL (object));
|
||||||
|
|
||||||
|
panel = GIMP_COLOR_PANEL (object);
|
||||||
|
|
||||||
|
/* make sure we hide and free color_notebook */
|
||||||
|
if (panel->color_notebook)
|
||||||
|
{
|
||||||
|
color_notebook_hide (panel->color_notebook);
|
||||||
|
color_notebook_free (panel->color_notebook);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||||
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
gimp_color_panel_new (const GimpRGB *color,
|
||||||
|
GimpColorAreaType type,
|
||||||
|
gint width,
|
||||||
|
gint height)
|
||||||
|
{
|
||||||
|
GimpColorPanel *panel;
|
||||||
|
|
||||||
g_return_val_if_fail (color != NULL, NULL);
|
g_return_val_if_fail (color != NULL, NULL);
|
||||||
|
|
||||||
private = g_new0 (ColorPanelPrivate, 1);
|
panel = gtk_type_new (gimp_color_panel_get_type ());
|
||||||
private->color_notebook = NULL;
|
|
||||||
private->color_notebook_active = FALSE;
|
|
||||||
private->gc = NULL;
|
|
||||||
private->show_alpha = show_alpha;
|
|
||||||
private->button_down = FALSE;
|
|
||||||
|
|
||||||
color_panel = g_new (ColorPanel, 1);
|
gimp_color_button_set_type (GIMP_COLOR_BUTTON (panel), type);
|
||||||
color_panel->private_part = private;
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (panel), color);
|
||||||
|
gtk_widget_set_usize (GTK_WIDGET (panel), width, height);
|
||||||
color_panel->color = *color;
|
|
||||||
|
return GTK_WIDGET (panel);
|
||||||
color_panel->color_panel_widget = gtk_frame_new (NULL);
|
|
||||||
gtk_frame_set_shadow_type (GTK_FRAME (color_panel->color_panel_widget),
|
|
||||||
GTK_SHADOW_IN);
|
|
||||||
|
|
||||||
/* drawing area */
|
|
||||||
private->drawing_area = gtk_drawing_area_new ();
|
|
||||||
gtk_drawing_area_size (GTK_DRAWING_AREA (private->drawing_area),
|
|
||||||
width, height);
|
|
||||||
gtk_widget_set_events (private->drawing_area, EVENT_MASK);
|
|
||||||
gtk_signal_connect (GTK_OBJECT (private->drawing_area), "event",
|
|
||||||
GTK_SIGNAL_FUNC (color_panel_events),
|
|
||||||
color_panel);
|
|
||||||
gtk_container_add (GTK_CONTAINER (color_panel->color_panel_widget),
|
|
||||||
private->drawing_area);
|
|
||||||
gtk_widget_show (private->drawing_area);
|
|
||||||
|
|
||||||
/* dnd stuff */
|
|
||||||
gtk_drag_source_set (private->drawing_area,
|
|
||||||
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
|
|
||||||
color_panel_target_table, n_color_panel_targets,
|
|
||||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
|
||||||
gimp_dnd_color_source_set (private->drawing_area,
|
|
||||||
color_panel_drag_color, color_panel);
|
|
||||||
|
|
||||||
gtk_drag_dest_set (private->drawing_area,
|
|
||||||
GTK_DEST_DEFAULT_HIGHLIGHT |
|
|
||||||
GTK_DEST_DEFAULT_MOTION |
|
|
||||||
GTK_DEST_DEFAULT_DROP,
|
|
||||||
color_panel_target_table, n_color_panel_targets,
|
|
||||||
GDK_ACTION_COPY);
|
|
||||||
gimp_dnd_color_dest_set (private->drawing_area,
|
|
||||||
color_panel_drop_color, color_panel);
|
|
||||||
|
|
||||||
gtk_signal_connect_object (GTK_OBJECT (color_panel->color_panel_widget),
|
|
||||||
"destroy",
|
|
||||||
GTK_SIGNAL_FUNC (color_panel_free),
|
|
||||||
(GtkObject *) color_panel);
|
|
||||||
|
|
||||||
return color_panel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
color_panel_set_color (ColorPanel *color_panel,
|
|
||||||
GimpRGB *color)
|
|
||||||
{
|
|
||||||
ColorPanelPrivate *private = color_panel->private_part;
|
|
||||||
|
|
||||||
g_return_if_fail (color_panel != NULL);
|
|
||||||
g_return_if_fail (color != NULL);
|
|
||||||
|
|
||||||
color_panel->color = *color;
|
|
||||||
|
|
||||||
if (private->color_notebook_active)
|
|
||||||
color_notebook_set_color (private->color_notebook, color);
|
|
||||||
|
|
||||||
if (private->gc)
|
|
||||||
color_panel_draw (color_panel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* private functions */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
color_panel_free (ColorPanel *color_panel)
|
gimp_color_panel_color_changed (GimpColorButton *button)
|
||||||
{
|
{
|
||||||
ColorPanelPrivate *private;
|
GimpColorPanel *panel;
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
panel = GIMP_COLOR_PANEL (button);
|
||||||
|
|
||||||
/* make sure we hide and free color_notebook */
|
if (panel->color_notebook_active)
|
||||||
if (private->color_notebook)
|
|
||||||
{
|
{
|
||||||
color_notebook_hide (private->color_notebook);
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &color);
|
||||||
color_notebook_free (private->color_notebook);
|
color_notebook_set_color (panel->color_notebook, &color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (private->gc)
|
|
||||||
gdk_gc_destroy (private->gc);
|
|
||||||
|
|
||||||
g_free (color_panel->private_part);
|
|
||||||
g_free (color_panel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
color_panel_draw (ColorPanel *color_panel)
|
gimp_color_panel_clicked (GtkButton *button)
|
||||||
{
|
{
|
||||||
GtkWidget *widget;
|
GimpColorPanel *panel;
|
||||||
ColorPanelPrivate *private;
|
GimpRGB color;
|
||||||
GdkColor fg;
|
|
||||||
guchar r, g, b;
|
|
||||||
|
|
||||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
panel = GIMP_COLOR_PANEL (button);
|
||||||
widget = private->drawing_area;
|
|
||||||
|
|
||||||
gimp_rgb_get_uchar (&color_panel->color, &r, &g, &b);
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &color);
|
||||||
|
|
||||||
fg.pixel = get_color (r, g, b);
|
if (! panel->color_notebook)
|
||||||
|
|
||||||
gdk_gc_set_foreground (private->gc, &fg);
|
|
||||||
gdk_draw_rectangle (widget->window, private->gc, 1, 0, 0,
|
|
||||||
widget->allocation.width, widget->allocation.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gint
|
|
||||||
color_panel_events (GtkWidget *widget,
|
|
||||||
GdkEvent *event,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
GdkEventButton *bevent;
|
|
||||||
ColorPanel *color_panel;
|
|
||||||
ColorPanelPrivate *private;
|
|
||||||
|
|
||||||
color_panel = (ColorPanel *) data;
|
|
||||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
|
||||||
|
|
||||||
switch (event->type)
|
|
||||||
{
|
{
|
||||||
case GDK_EXPOSE:
|
panel->color_notebook =
|
||||||
if (!private->gc)
|
color_notebook_new (&color,
|
||||||
private->gc = gdk_gc_new (widget->window);
|
gimp_color_panel_select_callback,
|
||||||
|
panel,
|
||||||
color_panel_draw (color_panel);
|
FALSE,
|
||||||
break;
|
gimp_color_button_has_alpha (GIMP_COLOR_BUTTON (button)));
|
||||||
|
panel->color_notebook_active = TRUE;
|
||||||
case GDK_BUTTON_PRESS:
|
}
|
||||||
bevent = (GdkEventButton *) event;
|
else
|
||||||
|
{
|
||||||
if (bevent->button == 1)
|
if (! panel->color_notebook_active)
|
||||||
private->button_down = TRUE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GDK_BUTTON_RELEASE:
|
|
||||||
bevent = (GdkEventButton *) event;
|
|
||||||
|
|
||||||
if (bevent->button == 1 &&
|
|
||||||
private->button_down)
|
|
||||||
{
|
{
|
||||||
if (! private->color_notebook)
|
color_notebook_show (panel->color_notebook);
|
||||||
{
|
panel->color_notebook_active = TRUE;
|
||||||
private->color_notebook =
|
|
||||||
color_notebook_new (&color_panel->color,
|
|
||||||
color_panel_select_callback,
|
|
||||||
color_panel,
|
|
||||||
FALSE,
|
|
||||||
private->show_alpha);
|
|
||||||
private->color_notebook_active = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (! private->color_notebook_active)
|
|
||||||
{
|
|
||||||
color_notebook_show (private->color_notebook);
|
|
||||||
private->color_notebook_active = TRUE;
|
|
||||||
}
|
|
||||||
color_notebook_set_color (private->color_notebook,
|
|
||||||
&color_panel->color);
|
|
||||||
}
|
|
||||||
private->button_down = FALSE;
|
|
||||||
}
|
}
|
||||||
break;
|
color_notebook_set_color (panel->color_notebook, &color);
|
||||||
|
|
||||||
case GDK_LEAVE_NOTIFY:
|
|
||||||
private->button_down = FALSE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
color_panel_select_callback (GimpRGB *color,
|
gimp_color_panel_select_callback (GimpRGB *color,
|
||||||
ColorNotebookState state,
|
ColorNotebookState state,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
ColorPanel *color_panel;
|
GimpColorPanel *panel;
|
||||||
ColorPanelPrivate *private;
|
|
||||||
|
|
||||||
color_panel = (ColorPanel *) data;
|
panel = GIMP_COLOR_PANEL (data);
|
||||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
|
||||||
|
|
||||||
if (private->color_notebook)
|
if (panel->color_notebook)
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case COLOR_NOTEBOOK_UPDATE:
|
case COLOR_NOTEBOOK_UPDATE:
|
||||||
break;
|
break;
|
||||||
case COLOR_NOTEBOOK_OK:
|
case COLOR_NOTEBOOK_OK:
|
||||||
color_panel->color = *color;
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (panel), color);
|
||||||
|
|
||||||
color_panel_draw (color_panel);
|
|
||||||
/* Fallthrough */
|
/* Fallthrough */
|
||||||
case COLOR_NOTEBOOK_CANCEL:
|
case COLOR_NOTEBOOK_CANCEL:
|
||||||
color_notebook_hide (private->color_notebook);
|
color_notebook_hide (panel->color_notebook);
|
||||||
private->color_notebook_active = FALSE;
|
panel->color_notebook_active = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
color_panel_drag_color (GtkWidget *widget,
|
|
||||||
GimpRGB *color,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
ColorPanel *color_panel;
|
|
||||||
|
|
||||||
color_panel = (ColorPanel *) data;
|
|
||||||
|
|
||||||
*color = color_panel->color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
color_panel_drop_color (GtkWidget *widget,
|
|
||||||
GimpRGB *color,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
ColorPanel *color_panel;
|
|
||||||
ColorPanelPrivate *private;
|
|
||||||
|
|
||||||
color_panel = (ColorPanel *) data;
|
|
||||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
|
||||||
|
|
||||||
color_panel->color = *color;
|
|
||||||
|
|
||||||
if (private->color_notebook_active)
|
|
||||||
color_notebook_set_color (private->color_notebook, color);
|
|
||||||
|
|
||||||
color_panel_draw (color_panel);
|
|
||||||
}
|
|
||||||
|
|
|
@ -20,28 +20,28 @@
|
||||||
#define __COLOR_PANEL_H__
|
#define __COLOR_PANEL_H__
|
||||||
|
|
||||||
|
|
||||||
typedef struct _ColorPanel ColorPanel;
|
#include "libgimp/gimpcolorbutton.h"
|
||||||
|
|
||||||
struct _ColorPanel
|
|
||||||
|
#define GIMP_TYPE_COLOR_PANEL (gimp_color_panel_get_type ())
|
||||||
|
#define GIMP_COLOR_PANEL(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_COLOR_PANEL, GimpColorPanel))
|
||||||
|
#define GIMP_COLOR_PANEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_PANEL, GimpColorPanelClass))
|
||||||
|
#define GIMP_IS_COLOR_PANEL(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_COLOR_PANEL))
|
||||||
|
#define GIMP_IS_COLOR_PANEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_PANEL))
|
||||||
|
|
||||||
|
typedef struct _GimpColorPanel GimpColorPanel;
|
||||||
|
typedef struct _GimpColorPanelClass GimpColorPanelClass;
|
||||||
|
|
||||||
|
struct _GimpColorPanelClass
|
||||||
{
|
{
|
||||||
/* The calling procedure is respondible for showing this widget */
|
GimpColorButtonClass parent_class;
|
||||||
GtkWidget *color_panel_widget;
|
|
||||||
|
|
||||||
/* The actual color */
|
|
||||||
GimpRGB color;
|
|
||||||
|
|
||||||
/* Don't touch this :) */
|
|
||||||
gpointer private_part;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GtkType gimp_color_panel_get_type (void);
|
||||||
ColorPanel * color_panel_new (GimpRGB *color,
|
GtkWidget * gimp_color_panel_new (const GimpRGB *color,
|
||||||
gboolean show_alpha,
|
GimpColorAreaType type,
|
||||||
gint width,
|
gint width,
|
||||||
gint height);
|
gint height);
|
||||||
|
|
||||||
void color_panel_set_color (ColorPanel *color_panel,
|
|
||||||
GimpRGB *color);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __COLOR_PANEL_H__ */
|
#endif /* __COLOR_PANEL_H__ */
|
||||||
|
|
|
@ -22,8 +22,9 @@
|
||||||
|
|
||||||
#include "apptypes.h"
|
#include "apptypes.h"
|
||||||
|
|
||||||
|
#include "libgimp/gimpcolorarea.h"
|
||||||
|
|
||||||
#include "appenv.h"
|
#include "appenv.h"
|
||||||
#include "color_panel.h"
|
|
||||||
#include "color_picker.h"
|
#include "color_picker.h"
|
||||||
#include "draw_core.h"
|
#include "draw_core.h"
|
||||||
#include "drawable.h"
|
#include "drawable.h"
|
||||||
|
@ -88,7 +89,7 @@ gint col_value[5] = { 0, 0, 0, 0, 0 };
|
||||||
static gint update_type;
|
static gint update_type;
|
||||||
static GimpImageType sample_type;
|
static GimpImageType sample_type;
|
||||||
static InfoDialog *color_picker_info = NULL;
|
static InfoDialog *color_picker_info = NULL;
|
||||||
static ColorPanel *color_panel = NULL;
|
static GtkWidget *color_area = NULL;
|
||||||
static gchar red_buf [MAX_INFO_BUF];
|
static gchar red_buf [MAX_INFO_BUF];
|
||||||
static gchar green_buf [MAX_INFO_BUF];
|
static gchar green_buf [MAX_INFO_BUF];
|
||||||
static gchar blue_buf [MAX_INFO_BUF];
|
static gchar blue_buf [MAX_INFO_BUF];
|
||||||
|
@ -263,6 +264,7 @@ color_picker_button_press (Tool *tool,
|
||||||
if (! color_picker_info)
|
if (! color_picker_info)
|
||||||
{
|
{
|
||||||
GtkWidget *hbox;
|
GtkWidget *hbox;
|
||||||
|
GtkWidget *frame;
|
||||||
GimpRGB color;
|
GimpRGB color;
|
||||||
|
|
||||||
color_picker_info = info_dialog_new (_("Color Picker"),
|
color_picker_info = info_dialog_new (_("Color Picker"),
|
||||||
|
@ -305,14 +307,17 @@ color_picker_button_press (Tool *tool,
|
||||||
|
|
||||||
gtk_widget_reparent (color_picker_info->info_table, hbox);
|
gtk_widget_reparent (color_picker_info->info_table, hbox);
|
||||||
|
|
||||||
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0);
|
frame = gtk_frame_new (NULL);
|
||||||
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
|
||||||
|
|
||||||
color_panel = color_panel_new (&color,
|
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0);
|
||||||
gimp_drawable_has_alpha (tool->drawable),
|
color_area = gimp_color_area_new (&color,
|
||||||
48, 64);
|
gimp_drawable_has_alpha (tool->drawable) ? GIMP_COLOR_AREA_LARGE_CHECKS : GIMP_COLOR_AREA_FLAT, 0);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), color_panel->color_panel_widget,
|
gtk_widget_set_usize (GTK_WIDGET (color_area), 48, 64);
|
||||||
FALSE, FALSE, 0);
|
gtk_container_add (GTK_CONTAINER (frame), color_area);
|
||||||
gtk_widget_show (color_panel->color_panel_widget);
|
gtk_widget_show (color_area);
|
||||||
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
/* create the action area */
|
/* create the action area */
|
||||||
gimp_dialog_create_action_area
|
gimp_dialog_create_action_area
|
||||||
|
@ -643,8 +648,8 @@ color_picker_info_update (Tool *tool,
|
||||||
{
|
{
|
||||||
if (!valid)
|
if (!valid)
|
||||||
{
|
{
|
||||||
if (GTK_WIDGET_IS_SENSITIVE (color_panel->color_panel_widget))
|
if (GTK_WIDGET_IS_SENSITIVE (color_area))
|
||||||
gtk_widget_set_sensitive (color_panel->color_panel_widget, FALSE);
|
gtk_widget_set_sensitive (color_area, FALSE);
|
||||||
|
|
||||||
g_snprintf (red_buf, MAX_INFO_BUF, _("N/A"));
|
g_snprintf (red_buf, MAX_INFO_BUF, _("N/A"));
|
||||||
g_snprintf (green_buf, MAX_INFO_BUF, _("N/A"));
|
g_snprintf (green_buf, MAX_INFO_BUF, _("N/A"));
|
||||||
|
@ -662,8 +667,8 @@ color_picker_info_update (Tool *tool,
|
||||||
guchar b = 0;
|
guchar b = 0;
|
||||||
guchar a = 0;
|
guchar a = 0;
|
||||||
|
|
||||||
if (! GTK_WIDGET_IS_SENSITIVE (color_panel->color_panel_widget))
|
if (! GTK_WIDGET_IS_SENSITIVE (color_area))
|
||||||
gtk_widget_set_sensitive (color_panel->color_panel_widget, TRUE);
|
gtk_widget_set_sensitive (color_area, TRUE);
|
||||||
|
|
||||||
switch (sample_type)
|
switch (sample_type)
|
||||||
{
|
{
|
||||||
|
@ -730,7 +735,7 @@ color_picker_info_update (Tool *tool,
|
||||||
|
|
||||||
gimp_rgba_set_uchar (&color, r, g, b, a);
|
gimp_rgba_set_uchar (&color, r, g, b, a);
|
||||||
|
|
||||||
color_panel_set_color (color_panel, &color);
|
gimp_color_area_set_color (GIMP_COLOR_AREA (color_area), &color);
|
||||||
}
|
}
|
||||||
|
|
||||||
info_dialog_update (color_picker_info);
|
info_dialog_update (color_picker_info);
|
||||||
|
@ -792,7 +797,7 @@ tools_free_color_picker (Tool *tool)
|
||||||
info_dialog_free (color_picker_info);
|
info_dialog_free (color_picker_info);
|
||||||
color_picker_info = NULL;
|
color_picker_info = NULL;
|
||||||
|
|
||||||
color_panel = NULL;
|
color_area = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (cp_tool);
|
g_free (cp_tool);
|
||||||
|
|
|
@ -47,10 +47,9 @@ struct _EditQmaskOptions
|
||||||
{
|
{
|
||||||
GtkWidget *query_box;
|
GtkWidget *query_box;
|
||||||
GtkWidget *name_entry;
|
GtkWidget *name_entry;
|
||||||
ColorPanel *color_panel;
|
GtkWidget *color_panel;
|
||||||
|
|
||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
GimpRGB color;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||||
|
@ -58,15 +57,17 @@ typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||||
/* Global variables */
|
/* Global variables */
|
||||||
/* Static variables */
|
/* Static variables */
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
static void edit_qmask_channel_query (GDisplay *gdisp);
|
static void edit_qmask_channel_query (GDisplay *gdisp);
|
||||||
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||||
gpointer client_data);
|
gpointer client_data);
|
||||||
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
||||||
gpointer client_data);
|
gpointer client_data);
|
||||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
static void qmask_removed_callback (GtkObject *qmask,
|
static void qmask_color_changed (GimpColorButton *button,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
static void qmask_removed_callback (GtkObject *qmask,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
/* Actual code */
|
/* Actual code */
|
||||||
|
|
||||||
|
@ -74,11 +75,22 @@ static void
|
||||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpRGB *color;
|
GimpRGB color;
|
||||||
|
|
||||||
color = (GimpRGB *) data;
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||||
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
}
|
||||||
|
|
||||||
color->a = adjustment->value / 100.0;
|
static void
|
||||||
|
qmask_color_changed (GimpColorButton *button,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
|
gimp_color_button_get_color (button, &color);
|
||||||
|
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -260,9 +272,10 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
||||||
/* the new options structure */
|
/* the new options structure */
|
||||||
options = g_new (EditQmaskOptions, 1);
|
options = g_new (EditQmaskOptions, 1);
|
||||||
options->gimage = gdisp->gimage;
|
options->gimage = gdisp->gimage;
|
||||||
options->color = options->gimage->qmask_color;
|
|
||||||
|
|
||||||
options->color_panel = color_panel_new (&options->color, FALSE, 48, 64);
|
options->color_panel = gimp_color_panel_new (&options->gimage->qmask_color,
|
||||||
|
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||||
|
48, 64);
|
||||||
|
|
||||||
/* The dialog */
|
/* The dialog */
|
||||||
options->query_box =
|
options->query_box =
|
||||||
|
@ -301,19 +314,23 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
||||||
gtk_widget_show (label);
|
gtk_widget_show (label);
|
||||||
|
|
||||||
opacity_scale_data =
|
opacity_scale_data =
|
||||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
gtk_adjustment_new (options->gimage->qmask_color.a * 100.0,
|
||||||
|
0.0, 100.0, 1.0, 1.0, 0.0);
|
||||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||||
&options->color);
|
options->color_panel);
|
||||||
gtk_widget_show (opacity_scale);
|
gtk_widget_show (opacity_scale);
|
||||||
|
|
||||||
/* The color panel */
|
/* The color panel */
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel->color_panel_widget,
|
gtk_signal_connect (GTK_OBJECT (options->color_panel), "color_changed",
|
||||||
|
qmask_color_changed,
|
||||||
|
opacity_scale_data);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
|
||||||
TRUE, TRUE, 0);
|
TRUE, TRUE, 0);
|
||||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
gtk_widget_show (options->color_panel);
|
||||||
|
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
@ -327,24 +344,25 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||||
{
|
{
|
||||||
EditQmaskOptions *options;
|
EditQmaskOptions *options;
|
||||||
Channel *channel;
|
Channel *channel;
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
options = (EditQmaskOptions *) client_data;
|
options = (EditQmaskOptions *) client_data;
|
||||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||||
|
|
||||||
options->color_panel->color.a = options->color.a;
|
|
||||||
|
|
||||||
if (options->gimage && channel)
|
if (options->gimage && channel)
|
||||||
{
|
{
|
||||||
if (gimp_rgba_distance (&channel->color,
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||||
&options->color_panel->color) > 0.0001)
|
&color);
|
||||||
|
|
||||||
|
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||||
{
|
{
|
||||||
channel_set_color (channel, &options->color_panel->color);
|
channel->color = color;
|
||||||
channel_update (channel);
|
channel_update (channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update the qmask color no matter what */
|
/* update the qmask color no matter what */
|
||||||
options->gimage->qmask_color = options->color_panel->color;
|
options->gimage->qmask_color = color;
|
||||||
|
|
||||||
gtk_widget_destroy (options->query_box);
|
gtk_widget_destroy (options->query_box);
|
||||||
g_free (options);
|
g_free (options);
|
||||||
|
|
|
@ -47,10 +47,9 @@ struct _EditQmaskOptions
|
||||||
{
|
{
|
||||||
GtkWidget *query_box;
|
GtkWidget *query_box;
|
||||||
GtkWidget *name_entry;
|
GtkWidget *name_entry;
|
||||||
ColorPanel *color_panel;
|
GtkWidget *color_panel;
|
||||||
|
|
||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
GimpRGB color;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||||
|
@ -58,15 +57,17 @@ typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||||
/* Global variables */
|
/* Global variables */
|
||||||
/* Static variables */
|
/* Static variables */
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
static void edit_qmask_channel_query (GDisplay *gdisp);
|
static void edit_qmask_channel_query (GDisplay *gdisp);
|
||||||
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||||
gpointer client_data);
|
gpointer client_data);
|
||||||
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
||||||
gpointer client_data);
|
gpointer client_data);
|
||||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
static void qmask_removed_callback (GtkObject *qmask,
|
static void qmask_color_changed (GimpColorButton *button,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
static void qmask_removed_callback (GtkObject *qmask,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
/* Actual code */
|
/* Actual code */
|
||||||
|
|
||||||
|
@ -74,11 +75,22 @@ static void
|
||||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpRGB *color;
|
GimpRGB color;
|
||||||
|
|
||||||
color = (GimpRGB *) data;
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||||
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
}
|
||||||
|
|
||||||
color->a = adjustment->value / 100.0;
|
static void
|
||||||
|
qmask_color_changed (GimpColorButton *button,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
|
gimp_color_button_get_color (button, &color);
|
||||||
|
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -260,9 +272,10 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
||||||
/* the new options structure */
|
/* the new options structure */
|
||||||
options = g_new (EditQmaskOptions, 1);
|
options = g_new (EditQmaskOptions, 1);
|
||||||
options->gimage = gdisp->gimage;
|
options->gimage = gdisp->gimage;
|
||||||
options->color = options->gimage->qmask_color;
|
|
||||||
|
|
||||||
options->color_panel = color_panel_new (&options->color, FALSE, 48, 64);
|
options->color_panel = gimp_color_panel_new (&options->gimage->qmask_color,
|
||||||
|
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||||
|
48, 64);
|
||||||
|
|
||||||
/* The dialog */
|
/* The dialog */
|
||||||
options->query_box =
|
options->query_box =
|
||||||
|
@ -301,19 +314,23 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
||||||
gtk_widget_show (label);
|
gtk_widget_show (label);
|
||||||
|
|
||||||
opacity_scale_data =
|
opacity_scale_data =
|
||||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
gtk_adjustment_new (options->gimage->qmask_color.a * 100.0,
|
||||||
|
0.0, 100.0, 1.0, 1.0, 0.0);
|
||||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||||
&options->color);
|
options->color_panel);
|
||||||
gtk_widget_show (opacity_scale);
|
gtk_widget_show (opacity_scale);
|
||||||
|
|
||||||
/* The color panel */
|
/* The color panel */
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel->color_panel_widget,
|
gtk_signal_connect (GTK_OBJECT (options->color_panel), "color_changed",
|
||||||
|
qmask_color_changed,
|
||||||
|
opacity_scale_data);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
|
||||||
TRUE, TRUE, 0);
|
TRUE, TRUE, 0);
|
||||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
gtk_widget_show (options->color_panel);
|
||||||
|
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
@ -327,24 +344,25 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||||
{
|
{
|
||||||
EditQmaskOptions *options;
|
EditQmaskOptions *options;
|
||||||
Channel *channel;
|
Channel *channel;
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
options = (EditQmaskOptions *) client_data;
|
options = (EditQmaskOptions *) client_data;
|
||||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||||
|
|
||||||
options->color_panel->color.a = options->color.a;
|
|
||||||
|
|
||||||
if (options->gimage && channel)
|
if (options->gimage && channel)
|
||||||
{
|
{
|
||||||
if (gimp_rgba_distance (&channel->color,
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||||
&options->color_panel->color) > 0.0001)
|
&color);
|
||||||
|
|
||||||
|
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||||
{
|
{
|
||||||
channel_set_color (channel, &options->color_panel->color);
|
channel->color = color;
|
||||||
channel_update (channel);
|
channel_update (channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update the qmask color no matter what */
|
/* update the qmask color no matter what */
|
||||||
options->gimage->qmask_color = options->color_panel->color;
|
options->gimage->qmask_color = color;
|
||||||
|
|
||||||
gtk_widget_destroy (options->query_box);
|
gtk_widget_destroy (options->query_box);
|
||||||
g_free (options);
|
g_free (options);
|
||||||
|
|
|
@ -47,10 +47,9 @@ struct _EditQmaskOptions
|
||||||
{
|
{
|
||||||
GtkWidget *query_box;
|
GtkWidget *query_box;
|
||||||
GtkWidget *name_entry;
|
GtkWidget *name_entry;
|
||||||
ColorPanel *color_panel;
|
GtkWidget *color_panel;
|
||||||
|
|
||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
GimpRGB color;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||||
|
@ -58,15 +57,17 @@ typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||||
/* Global variables */
|
/* Global variables */
|
||||||
/* Static variables */
|
/* Static variables */
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
static void edit_qmask_channel_query (GDisplay *gdisp);
|
static void edit_qmask_channel_query (GDisplay *gdisp);
|
||||||
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||||
gpointer client_data);
|
gpointer client_data);
|
||||||
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
||||||
gpointer client_data);
|
gpointer client_data);
|
||||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
static void qmask_removed_callback (GtkObject *qmask,
|
static void qmask_color_changed (GimpColorButton *button,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
static void qmask_removed_callback (GtkObject *qmask,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
/* Actual code */
|
/* Actual code */
|
||||||
|
|
||||||
|
@ -74,11 +75,22 @@ static void
|
||||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpRGB *color;
|
GimpRGB color;
|
||||||
|
|
||||||
color = (GimpRGB *) data;
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||||
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
}
|
||||||
|
|
||||||
color->a = adjustment->value / 100.0;
|
static void
|
||||||
|
qmask_color_changed (GimpColorButton *button,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
|
gimp_color_button_get_color (button, &color);
|
||||||
|
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -260,9 +272,10 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
||||||
/* the new options structure */
|
/* the new options structure */
|
||||||
options = g_new (EditQmaskOptions, 1);
|
options = g_new (EditQmaskOptions, 1);
|
||||||
options->gimage = gdisp->gimage;
|
options->gimage = gdisp->gimage;
|
||||||
options->color = options->gimage->qmask_color;
|
|
||||||
|
|
||||||
options->color_panel = color_panel_new (&options->color, FALSE, 48, 64);
|
options->color_panel = gimp_color_panel_new (&options->gimage->qmask_color,
|
||||||
|
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||||
|
48, 64);
|
||||||
|
|
||||||
/* The dialog */
|
/* The dialog */
|
||||||
options->query_box =
|
options->query_box =
|
||||||
|
@ -301,19 +314,23 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
||||||
gtk_widget_show (label);
|
gtk_widget_show (label);
|
||||||
|
|
||||||
opacity_scale_data =
|
opacity_scale_data =
|
||||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
gtk_adjustment_new (options->gimage->qmask_color.a * 100.0,
|
||||||
|
0.0, 100.0, 1.0, 1.0, 0.0);
|
||||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||||
&options->color);
|
options->color_panel);
|
||||||
gtk_widget_show (opacity_scale);
|
gtk_widget_show (opacity_scale);
|
||||||
|
|
||||||
/* The color panel */
|
/* The color panel */
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel->color_panel_widget,
|
gtk_signal_connect (GTK_OBJECT (options->color_panel), "color_changed",
|
||||||
|
qmask_color_changed,
|
||||||
|
opacity_scale_data);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
|
||||||
TRUE, TRUE, 0);
|
TRUE, TRUE, 0);
|
||||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
gtk_widget_show (options->color_panel);
|
||||||
|
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
@ -327,24 +344,25 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||||
{
|
{
|
||||||
EditQmaskOptions *options;
|
EditQmaskOptions *options;
|
||||||
Channel *channel;
|
Channel *channel;
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
options = (EditQmaskOptions *) client_data;
|
options = (EditQmaskOptions *) client_data;
|
||||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||||
|
|
||||||
options->color_panel->color.a = options->color.a;
|
|
||||||
|
|
||||||
if (options->gimage && channel)
|
if (options->gimage && channel)
|
||||||
{
|
{
|
||||||
if (gimp_rgba_distance (&channel->color,
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||||
&options->color_panel->color) > 0.0001)
|
&color);
|
||||||
|
|
||||||
|
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||||
{
|
{
|
||||||
channel_set_color (channel, &options->color_panel->color);
|
channel->color = color;
|
||||||
channel_update (channel);
|
channel_update (channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update the qmask color no matter what */
|
/* update the qmask color no matter what */
|
||||||
options->gimage->qmask_color = options->color_panel->color;
|
options->gimage->qmask_color = color;
|
||||||
|
|
||||||
gtk_widget_destroy (options->query_box);
|
gtk_widget_destroy (options->query_box);
|
||||||
g_free (options);
|
g_free (options);
|
||||||
|
|
|
@ -202,8 +202,10 @@ static void channel_widget_exclusive_visible (ChannelWidget *cw);
|
||||||
static void channel_widget_channel_flush (GtkWidget *widget,
|
static void channel_widget_channel_flush (GtkWidget *widget,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
|
||||||
static void channels_dialog_opacity_update (GtkAdjustment *adjustment,
|
static void channels_dialog_opacity_update (GtkAdjustment *adjustment,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
static void channels_dialog_color_changed (GimpColorButton *button,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
/* assorted query dialogs */
|
/* assorted query dialogs */
|
||||||
static void channels_dialog_new_channel_query (GimpImage *gimage);
|
static void channels_dialog_new_channel_query (GimpImage *gimage);
|
||||||
|
@ -2463,11 +2465,22 @@ static void
|
||||||
channels_dialog_opacity_update (GtkAdjustment *adjustment,
|
channels_dialog_opacity_update (GtkAdjustment *adjustment,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpRGB *color;
|
GimpRGB color;
|
||||||
|
|
||||||
color = (GimpRGB *) data;
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||||
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
}
|
||||||
|
|
||||||
color->a = adjustment->value / 100.0;
|
static void
|
||||||
|
channels_dialog_color_changed (GimpColorButton *button,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
|
gimp_color_button_get_color (button, &color);
|
||||||
|
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************/
|
/**********************************/
|
||||||
|
@ -2480,10 +2493,9 @@ struct _NewChannelOptions
|
||||||
{
|
{
|
||||||
GtkWidget *query_box;
|
GtkWidget *query_box;
|
||||||
GtkWidget *name_entry;
|
GtkWidget *name_entry;
|
||||||
ColorPanel *color_panel;
|
GtkWidget *color_panel;
|
||||||
|
|
||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
GimpRGB color;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static gchar *channel_name = NULL;
|
static gchar *channel_name = NULL;
|
||||||
|
@ -2506,16 +2518,14 @@ new_channel_query_ok_callback (GtkWidget *widget,
|
||||||
|
|
||||||
if ((gimage = options->gimage))
|
if ((gimage = options->gimage))
|
||||||
{
|
{
|
||||||
options->color_panel->color.a = options->color.a;
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||||
|
&channel_color);
|
||||||
new_channel = channel_new (gimage, gimage->width, gimage->height,
|
new_channel = channel_new (gimage, gimage->width, gimage->height,
|
||||||
channel_name,
|
channel_name,
|
||||||
&options->color_panel->color);
|
&channel_color);
|
||||||
|
|
||||||
drawable_fill (GIMP_DRAWABLE (new_channel), TRANSPARENT_FILL);
|
drawable_fill (GIMP_DRAWABLE (new_channel), TRANSPARENT_FILL);
|
||||||
|
|
||||||
channel_color = options->color_panel->color;
|
|
||||||
|
|
||||||
gimp_image_add_channel (gimage, new_channel, -1);
|
gimp_image_add_channel (gimage, new_channel, -1);
|
||||||
gdisplays_flush ();
|
gdisplays_flush ();
|
||||||
}
|
}
|
||||||
|
@ -2537,11 +2547,10 @@ channels_dialog_new_channel_query (GimpImage* gimage)
|
||||||
/* the new options structure */
|
/* the new options structure */
|
||||||
options = g_new (NewChannelOptions, 1);
|
options = g_new (NewChannelOptions, 1);
|
||||||
options->gimage = gimage;
|
options->gimage = gimage;
|
||||||
options->color = channel_color;
|
options->color_panel = gimp_color_panel_new (&channel_color,
|
||||||
options->color_panel = color_panel_new (&channel_color,
|
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||||
FALSE,
|
48, 64);
|
||||||
48, 64);
|
|
||||||
|
|
||||||
/* The dialog */
|
/* The dialog */
|
||||||
options->query_box =
|
options->query_box =
|
||||||
gimp_dialog_new (_("New Channel Options"), "new_channel_options",
|
gimp_dialog_new (_("New Channel Options"), "new_channel_options",
|
||||||
|
@ -2599,20 +2608,23 @@ channels_dialog_new_channel_query (GimpImage* gimage)
|
||||||
gtk_widget_show (label);
|
gtk_widget_show (label);
|
||||||
|
|
||||||
opacity_scale_data =
|
opacity_scale_data =
|
||||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
gtk_adjustment_new (channel_color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||||
gtk_range_set_update_policy (GTK_RANGE (opacity_scale), GTK_UPDATE_DELAYED);
|
gtk_range_set_update_policy (GTK_RANGE (opacity_scale), GTK_UPDATE_DELAYED);
|
||||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||||
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
|
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
|
||||||
&options->color);
|
options->color_panel);
|
||||||
gtk_widget_show (opacity_scale);
|
gtk_widget_show (opacity_scale);
|
||||||
|
|
||||||
/* The color panel */
|
/* The color panel */
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel->color_panel_widget,
|
gtk_signal_connect (GTK_OBJECT (options->color_panel), "color_changed",
|
||||||
|
channels_dialog_color_changed,
|
||||||
|
opacity_scale_data);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
|
||||||
TRUE, TRUE, 0);
|
TRUE, TRUE, 0);
|
||||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
gtk_widget_show (options->color_panel);
|
||||||
|
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
@ -2630,11 +2642,10 @@ struct _EditChannelOptions
|
||||||
{
|
{
|
||||||
GtkWidget *query_box;
|
GtkWidget *query_box;
|
||||||
GtkWidget *name_entry;
|
GtkWidget *name_entry;
|
||||||
ColorPanel *color_panel;
|
GtkWidget *color_panel;
|
||||||
|
|
||||||
ChannelWidget *channel_widget;
|
ChannelWidget *channel_widget;
|
||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
GimpRGB color;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2643,6 +2654,7 @@ edit_channel_query_ok_callback (GtkWidget *widget,
|
||||||
{
|
{
|
||||||
EditChannelOptions *options;
|
EditChannelOptions *options;
|
||||||
Channel *channel;
|
Channel *channel;
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
options = (EditChannelOptions *) data;
|
options = (EditChannelOptions *) data;
|
||||||
channel = options->channel_widget->channel;
|
channel = options->channel_widget->channel;
|
||||||
|
@ -2655,13 +2667,12 @@ edit_channel_query_ok_callback (GtkWidget *widget,
|
||||||
gtk_label_set_text (GTK_LABEL (options->channel_widget->label),
|
gtk_label_set_text (GTK_LABEL (options->channel_widget->label),
|
||||||
gimp_object_get_name (GIMP_OBJECT (channel)));
|
gimp_object_get_name (GIMP_OBJECT (channel)));
|
||||||
|
|
||||||
options->color_panel->color.a = options->color.a;
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||||
|
&color);
|
||||||
|
|
||||||
if (gimp_rgba_distance (&options->color_panel->color,
|
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||||
&channel->color) > 0.0001)
|
|
||||||
{
|
{
|
||||||
channel->color = options->color_panel->color;
|
channel->color = color;
|
||||||
|
|
||||||
drawable_update (GIMP_DRAWABLE (channel), 0, 0,
|
drawable_update (GIMP_DRAWABLE (channel), 0, 0,
|
||||||
GIMP_DRAWABLE (channel)->width,
|
GIMP_DRAWABLE (channel)->width,
|
||||||
GIMP_DRAWABLE (channel)->height);
|
GIMP_DRAWABLE (channel)->height);
|
||||||
|
@ -2687,13 +2698,12 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
|
||||||
options = g_new (EditChannelOptions, 1);
|
options = g_new (EditChannelOptions, 1);
|
||||||
options->channel_widget = channel_widget;
|
options->channel_widget = channel_widget;
|
||||||
options->gimage = channel_widget->gimage;
|
options->gimage = channel_widget->gimage;
|
||||||
options->color = channel_widget->channel->color;
|
|
||||||
|
|
||||||
channel_color = options->color;
|
channel_color = channel_widget->channel->color;
|
||||||
|
|
||||||
options->color_panel = color_panel_new (&channel_color,
|
options->color_panel = gimp_color_panel_new (&channel_color,
|
||||||
FALSE,
|
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||||
48, 64);
|
48, 64);
|
||||||
|
|
||||||
/* The dialog */
|
/* The dialog */
|
||||||
options->query_box =
|
options->query_box =
|
||||||
|
@ -2753,19 +2763,22 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
|
||||||
gtk_widget_show (label);
|
gtk_widget_show (label);
|
||||||
|
|
||||||
opacity_scale_data =
|
opacity_scale_data =
|
||||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
gtk_adjustment_new (channel_color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||||
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
|
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
|
||||||
&options->color);
|
options->color_panel);
|
||||||
gtk_widget_show (opacity_scale);
|
gtk_widget_show (opacity_scale);
|
||||||
|
|
||||||
/* The color panel */
|
/* The color panel */
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel->color_panel_widget,
|
gtk_signal_connect (GTK_OBJECT (options->color_panel), "color_changed",
|
||||||
|
channels_dialog_color_changed,
|
||||||
|
opacity_scale_data);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
|
||||||
TRUE, TRUE, 0);
|
TRUE, TRUE, 0);
|
||||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
gtk_widget_show (options->color_panel);
|
||||||
|
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
|
|
@ -47,10 +47,9 @@ struct _EditQmaskOptions
|
||||||
{
|
{
|
||||||
GtkWidget *query_box;
|
GtkWidget *query_box;
|
||||||
GtkWidget *name_entry;
|
GtkWidget *name_entry;
|
||||||
ColorPanel *color_panel;
|
GtkWidget *color_panel;
|
||||||
|
|
||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
GimpRGB color;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||||
|
@ -58,15 +57,17 @@ typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||||
/* Global variables */
|
/* Global variables */
|
||||||
/* Static variables */
|
/* Static variables */
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
static void edit_qmask_channel_query (GDisplay *gdisp);
|
static void edit_qmask_channel_query (GDisplay *gdisp);
|
||||||
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||||
gpointer client_data);
|
gpointer client_data);
|
||||||
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
||||||
gpointer client_data);
|
gpointer client_data);
|
||||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
static void qmask_removed_callback (GtkObject *qmask,
|
static void qmask_color_changed (GimpColorButton *button,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
static void qmask_removed_callback (GtkObject *qmask,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
/* Actual code */
|
/* Actual code */
|
||||||
|
|
||||||
|
@ -74,11 +75,22 @@ static void
|
||||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpRGB *color;
|
GimpRGB color;
|
||||||
|
|
||||||
color = (GimpRGB *) data;
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||||
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
}
|
||||||
|
|
||||||
color->a = adjustment->value / 100.0;
|
static void
|
||||||
|
qmask_color_changed (GimpColorButton *button,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
|
gimp_color_button_get_color (button, &color);
|
||||||
|
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -260,9 +272,10 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
||||||
/* the new options structure */
|
/* the new options structure */
|
||||||
options = g_new (EditQmaskOptions, 1);
|
options = g_new (EditQmaskOptions, 1);
|
||||||
options->gimage = gdisp->gimage;
|
options->gimage = gdisp->gimage;
|
||||||
options->color = options->gimage->qmask_color;
|
|
||||||
|
|
||||||
options->color_panel = color_panel_new (&options->color, FALSE, 48, 64);
|
options->color_panel = gimp_color_panel_new (&options->gimage->qmask_color,
|
||||||
|
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||||
|
48, 64);
|
||||||
|
|
||||||
/* The dialog */
|
/* The dialog */
|
||||||
options->query_box =
|
options->query_box =
|
||||||
|
@ -301,19 +314,23 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
||||||
gtk_widget_show (label);
|
gtk_widget_show (label);
|
||||||
|
|
||||||
opacity_scale_data =
|
opacity_scale_data =
|
||||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
gtk_adjustment_new (options->gimage->qmask_color.a * 100.0,
|
||||||
|
0.0, 100.0, 1.0, 1.0, 0.0);
|
||||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||||
&options->color);
|
options->color_panel);
|
||||||
gtk_widget_show (opacity_scale);
|
gtk_widget_show (opacity_scale);
|
||||||
|
|
||||||
/* The color panel */
|
/* The color panel */
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel->color_panel_widget,
|
gtk_signal_connect (GTK_OBJECT (options->color_panel), "color_changed",
|
||||||
|
qmask_color_changed,
|
||||||
|
opacity_scale_data);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
|
||||||
TRUE, TRUE, 0);
|
TRUE, TRUE, 0);
|
||||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
gtk_widget_show (options->color_panel);
|
||||||
|
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
@ -327,24 +344,25 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||||
{
|
{
|
||||||
EditQmaskOptions *options;
|
EditQmaskOptions *options;
|
||||||
Channel *channel;
|
Channel *channel;
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
options = (EditQmaskOptions *) client_data;
|
options = (EditQmaskOptions *) client_data;
|
||||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||||
|
|
||||||
options->color_panel->color.a = options->color.a;
|
|
||||||
|
|
||||||
if (options->gimage && channel)
|
if (options->gimage && channel)
|
||||||
{
|
{
|
||||||
if (gimp_rgba_distance (&channel->color,
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||||
&options->color_panel->color) > 0.0001)
|
&color);
|
||||||
|
|
||||||
|
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||||
{
|
{
|
||||||
channel_set_color (channel, &options->color_panel->color);
|
channel->color = color;
|
||||||
channel_update (channel);
|
channel_update (channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update the qmask color no matter what */
|
/* update the qmask color no matter what */
|
||||||
options->gimage->qmask_color = options->color_panel->color;
|
options->gimage->qmask_color = color;
|
||||||
|
|
||||||
gtk_widget_destroy (options->query_box);
|
gtk_widget_destroy (options->query_box);
|
||||||
g_free (options);
|
g_free (options);
|
||||||
|
|
70
app/qmask.c
70
app/qmask.c
|
@ -47,10 +47,9 @@ struct _EditQmaskOptions
|
||||||
{
|
{
|
||||||
GtkWidget *query_box;
|
GtkWidget *query_box;
|
||||||
GtkWidget *name_entry;
|
GtkWidget *name_entry;
|
||||||
ColorPanel *color_panel;
|
GtkWidget *color_panel;
|
||||||
|
|
||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
GimpRGB color;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||||
|
@ -58,15 +57,17 @@ typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||||
/* Global variables */
|
/* Global variables */
|
||||||
/* Static variables */
|
/* Static variables */
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
static void edit_qmask_channel_query (GDisplay *gdisp);
|
static void edit_qmask_channel_query (GDisplay *gdisp);
|
||||||
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||||
gpointer client_data);
|
gpointer client_data);
|
||||||
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
||||||
gpointer client_data);
|
gpointer client_data);
|
||||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
static void qmask_removed_callback (GtkObject *qmask,
|
static void qmask_color_changed (GimpColorButton *button,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
static void qmask_removed_callback (GtkObject *qmask,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
/* Actual code */
|
/* Actual code */
|
||||||
|
|
||||||
|
@ -74,11 +75,22 @@ static void
|
||||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpRGB *color;
|
GimpRGB color;
|
||||||
|
|
||||||
color = (GimpRGB *) data;
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||||
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||||
|
}
|
||||||
|
|
||||||
color->a = adjustment->value / 100.0;
|
static void
|
||||||
|
qmask_color_changed (GimpColorButton *button,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
|
gimp_color_button_get_color (button, &color);
|
||||||
|
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -260,9 +272,10 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
||||||
/* the new options structure */
|
/* the new options structure */
|
||||||
options = g_new (EditQmaskOptions, 1);
|
options = g_new (EditQmaskOptions, 1);
|
||||||
options->gimage = gdisp->gimage;
|
options->gimage = gdisp->gimage;
|
||||||
options->color = options->gimage->qmask_color;
|
|
||||||
|
|
||||||
options->color_panel = color_panel_new (&options->color, FALSE, 48, 64);
|
options->color_panel = gimp_color_panel_new (&options->gimage->qmask_color,
|
||||||
|
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||||
|
48, 64);
|
||||||
|
|
||||||
/* The dialog */
|
/* The dialog */
|
||||||
options->query_box =
|
options->query_box =
|
||||||
|
@ -301,19 +314,23 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
||||||
gtk_widget_show (label);
|
gtk_widget_show (label);
|
||||||
|
|
||||||
opacity_scale_data =
|
opacity_scale_data =
|
||||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
gtk_adjustment_new (options->gimage->qmask_color.a * 100.0,
|
||||||
|
0.0, 100.0, 1.0, 1.0, 0.0);
|
||||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||||
&options->color);
|
options->color_panel);
|
||||||
gtk_widget_show (opacity_scale);
|
gtk_widget_show (opacity_scale);
|
||||||
|
|
||||||
/* The color panel */
|
/* The color panel */
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel->color_panel_widget,
|
gtk_signal_connect (GTK_OBJECT (options->color_panel), "color_changed",
|
||||||
|
qmask_color_changed,
|
||||||
|
opacity_scale_data);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
|
||||||
TRUE, TRUE, 0);
|
TRUE, TRUE, 0);
|
||||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
gtk_widget_show (options->color_panel);
|
||||||
|
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
@ -327,24 +344,25 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||||
{
|
{
|
||||||
EditQmaskOptions *options;
|
EditQmaskOptions *options;
|
||||||
Channel *channel;
|
Channel *channel;
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
options = (EditQmaskOptions *) client_data;
|
options = (EditQmaskOptions *) client_data;
|
||||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||||
|
|
||||||
options->color_panel->color.a = options->color.a;
|
|
||||||
|
|
||||||
if (options->gimage && channel)
|
if (options->gimage && channel)
|
||||||
{
|
{
|
||||||
if (gimp_rgba_distance (&channel->color,
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||||
&options->color_panel->color) > 0.0001)
|
&color);
|
||||||
|
|
||||||
|
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||||
{
|
{
|
||||||
channel_set_color (channel, &options->color_panel->color);
|
channel->color = color;
|
||||||
channel_update (channel);
|
channel_update (channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update the qmask color no matter what */
|
/* update the qmask color no matter what */
|
||||||
options->gimage->qmask_color = options->color_panel->color;
|
options->gimage->qmask_color = color;
|
||||||
|
|
||||||
gtk_widget_destroy (options->query_box);
|
gtk_widget_destroy (options->query_box);
|
||||||
g_free (options);
|
g_free (options);
|
||||||
|
|
|
@ -22,8 +22,9 @@
|
||||||
|
|
||||||
#include "apptypes.h"
|
#include "apptypes.h"
|
||||||
|
|
||||||
|
#include "libgimp/gimpcolorarea.h"
|
||||||
|
|
||||||
#include "appenv.h"
|
#include "appenv.h"
|
||||||
#include "color_panel.h"
|
|
||||||
#include "color_picker.h"
|
#include "color_picker.h"
|
||||||
#include "draw_core.h"
|
#include "draw_core.h"
|
||||||
#include "drawable.h"
|
#include "drawable.h"
|
||||||
|
@ -88,7 +89,7 @@ gint col_value[5] = { 0, 0, 0, 0, 0 };
|
||||||
static gint update_type;
|
static gint update_type;
|
||||||
static GimpImageType sample_type;
|
static GimpImageType sample_type;
|
||||||
static InfoDialog *color_picker_info = NULL;
|
static InfoDialog *color_picker_info = NULL;
|
||||||
static ColorPanel *color_panel = NULL;
|
static GtkWidget *color_area = NULL;
|
||||||
static gchar red_buf [MAX_INFO_BUF];
|
static gchar red_buf [MAX_INFO_BUF];
|
||||||
static gchar green_buf [MAX_INFO_BUF];
|
static gchar green_buf [MAX_INFO_BUF];
|
||||||
static gchar blue_buf [MAX_INFO_BUF];
|
static gchar blue_buf [MAX_INFO_BUF];
|
||||||
|
@ -263,6 +264,7 @@ color_picker_button_press (Tool *tool,
|
||||||
if (! color_picker_info)
|
if (! color_picker_info)
|
||||||
{
|
{
|
||||||
GtkWidget *hbox;
|
GtkWidget *hbox;
|
||||||
|
GtkWidget *frame;
|
||||||
GimpRGB color;
|
GimpRGB color;
|
||||||
|
|
||||||
color_picker_info = info_dialog_new (_("Color Picker"),
|
color_picker_info = info_dialog_new (_("Color Picker"),
|
||||||
|
@ -305,14 +307,17 @@ color_picker_button_press (Tool *tool,
|
||||||
|
|
||||||
gtk_widget_reparent (color_picker_info->info_table, hbox);
|
gtk_widget_reparent (color_picker_info->info_table, hbox);
|
||||||
|
|
||||||
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0);
|
frame = gtk_frame_new (NULL);
|
||||||
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
|
||||||
|
|
||||||
color_panel = color_panel_new (&color,
|
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0);
|
||||||
gimp_drawable_has_alpha (tool->drawable),
|
color_area = gimp_color_area_new (&color,
|
||||||
48, 64);
|
gimp_drawable_has_alpha (tool->drawable) ? GIMP_COLOR_AREA_LARGE_CHECKS : GIMP_COLOR_AREA_FLAT, 0);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), color_panel->color_panel_widget,
|
gtk_widget_set_usize (GTK_WIDGET (color_area), 48, 64);
|
||||||
FALSE, FALSE, 0);
|
gtk_container_add (GTK_CONTAINER (frame), color_area);
|
||||||
gtk_widget_show (color_panel->color_panel_widget);
|
gtk_widget_show (color_area);
|
||||||
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
/* create the action area */
|
/* create the action area */
|
||||||
gimp_dialog_create_action_area
|
gimp_dialog_create_action_area
|
||||||
|
@ -643,8 +648,8 @@ color_picker_info_update (Tool *tool,
|
||||||
{
|
{
|
||||||
if (!valid)
|
if (!valid)
|
||||||
{
|
{
|
||||||
if (GTK_WIDGET_IS_SENSITIVE (color_panel->color_panel_widget))
|
if (GTK_WIDGET_IS_SENSITIVE (color_area))
|
||||||
gtk_widget_set_sensitive (color_panel->color_panel_widget, FALSE);
|
gtk_widget_set_sensitive (color_area, FALSE);
|
||||||
|
|
||||||
g_snprintf (red_buf, MAX_INFO_BUF, _("N/A"));
|
g_snprintf (red_buf, MAX_INFO_BUF, _("N/A"));
|
||||||
g_snprintf (green_buf, MAX_INFO_BUF, _("N/A"));
|
g_snprintf (green_buf, MAX_INFO_BUF, _("N/A"));
|
||||||
|
@ -662,8 +667,8 @@ color_picker_info_update (Tool *tool,
|
||||||
guchar b = 0;
|
guchar b = 0;
|
||||||
guchar a = 0;
|
guchar a = 0;
|
||||||
|
|
||||||
if (! GTK_WIDGET_IS_SENSITIVE (color_panel->color_panel_widget))
|
if (! GTK_WIDGET_IS_SENSITIVE (color_area))
|
||||||
gtk_widget_set_sensitive (color_panel->color_panel_widget, TRUE);
|
gtk_widget_set_sensitive (color_area, TRUE);
|
||||||
|
|
||||||
switch (sample_type)
|
switch (sample_type)
|
||||||
{
|
{
|
||||||
|
@ -730,7 +735,7 @@ color_picker_info_update (Tool *tool,
|
||||||
|
|
||||||
gimp_rgba_set_uchar (&color, r, g, b, a);
|
gimp_rgba_set_uchar (&color, r, g, b, a);
|
||||||
|
|
||||||
color_panel_set_color (color_panel, &color);
|
gimp_color_area_set_color (GIMP_COLOR_AREA (color_area), &color);
|
||||||
}
|
}
|
||||||
|
|
||||||
info_dialog_update (color_picker_info);
|
info_dialog_update (color_picker_info);
|
||||||
|
@ -792,7 +797,7 @@ tools_free_color_picker (Tool *tool)
|
||||||
info_dialog_free (color_picker_info);
|
info_dialog_free (color_picker_info);
|
||||||
color_picker_info = NULL;
|
color_picker_info = NULL;
|
||||||
|
|
||||||
color_panel = NULL;
|
color_area = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (cp_tool);
|
g_free (cp_tool);
|
||||||
|
|
|
@ -25,305 +25,188 @@
|
||||||
#include "appenv.h"
|
#include "appenv.h"
|
||||||
#include "color_panel.h"
|
#include "color_panel.h"
|
||||||
#include "color_notebook.h"
|
#include "color_notebook.h"
|
||||||
#include "colormaps.h"
|
|
||||||
#include "gimpdnd.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define EVENT_MASK GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | \
|
struct _GimpColorPanel
|
||||||
GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | \
|
|
||||||
GDK_LEAVE_NOTIFY_MASK
|
|
||||||
|
|
||||||
typedef struct _ColorPanelPrivate ColorPanelPrivate;
|
|
||||||
|
|
||||||
struct _ColorPanelPrivate
|
|
||||||
{
|
{
|
||||||
GtkWidget *drawing_area;
|
GimpColorButton parent;
|
||||||
GdkGC *gc;
|
|
||||||
|
|
||||||
gboolean show_alpha;
|
ColorNotebook *color_notebook;
|
||||||
gboolean button_down;
|
gboolean color_notebook_active;
|
||||||
|
|
||||||
ColorNotebook *color_notebook;
|
|
||||||
gboolean color_notebook_active;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void color_panel_free (ColorPanel *color_panel);
|
static void gimp_color_panel_class_init (GimpColorPanelClass *klass);
|
||||||
static void color_panel_draw (ColorPanel *color_panel);
|
static void gimp_color_panel_init (GimpColorPanel *panel);
|
||||||
static gint color_panel_events (GtkWidget *widget,
|
static void gimp_color_panel_destroy (GtkObject *object);
|
||||||
GdkEvent *event,
|
static void gimp_color_panel_color_changed (GimpColorButton *button);
|
||||||
gpointer data);
|
static void gimp_color_panel_clicked (GtkButton *button);
|
||||||
static void color_panel_select_callback (GimpRGB *color,
|
|
||||||
ColorNotebookState state,
|
|
||||||
gpointer data);
|
|
||||||
|
|
||||||
static void color_panel_drag_color (GtkWidget *widget,
|
static void gimp_color_panel_select_callback (GimpRGB *color,
|
||||||
GimpRGB *color,
|
ColorNotebookState state,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
static void color_panel_drop_color (GtkWidget *widget,
|
|
||||||
GimpRGB *color,
|
|
||||||
gpointer data);
|
|
||||||
|
|
||||||
/* dnd stuff */
|
|
||||||
static GtkTargetEntry color_panel_target_table[] =
|
static GimpColorButtonClass *parent_class = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
GtkType
|
||||||
|
gimp_color_panel_get_type (void)
|
||||||
{
|
{
|
||||||
GIMP_TARGET_COLOR
|
static guint panel_type = 0;
|
||||||
};
|
|
||||||
static guint n_color_panel_targets = (sizeof (color_panel_target_table) /
|
|
||||||
sizeof (color_panel_target_table[0]));
|
|
||||||
|
|
||||||
/* public functions */
|
if (!panel_type)
|
||||||
|
{
|
||||||
|
GtkTypeInfo panel_info =
|
||||||
|
{
|
||||||
|
"GimpColorPanel",
|
||||||
|
sizeof (GimpColorPanel),
|
||||||
|
sizeof (GimpColorPanelClass),
|
||||||
|
(GtkClassInitFunc) gimp_color_panel_class_init,
|
||||||
|
(GtkObjectInitFunc) gimp_color_panel_init,
|
||||||
|
/* reserved_1 */ NULL,
|
||||||
|
/* reserved_2 */ NULL,
|
||||||
|
(GtkClassInitFunc) NULL
|
||||||
|
};
|
||||||
|
|
||||||
ColorPanel *
|
panel_type = gtk_type_unique (GIMP_TYPE_COLOR_BUTTON, &panel_info);
|
||||||
color_panel_new (GimpRGB *color,
|
}
|
||||||
gboolean show_alpha,
|
|
||||||
gint width,
|
return panel_type;
|
||||||
gint height)
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_color_panel_class_init (GimpColorPanelClass *klass)
|
||||||
{
|
{
|
||||||
ColorPanel *color_panel;
|
GtkObjectClass *object_class;
|
||||||
ColorPanelPrivate *private;
|
GtkButtonClass *button_class;
|
||||||
|
GimpColorButtonClass *color_button_class;
|
||||||
|
|
||||||
|
object_class = (GtkObjectClass *) klass;
|
||||||
|
button_class = (GtkButtonClass *) klass;
|
||||||
|
color_button_class = (GimpColorButtonClass *) klass;
|
||||||
|
|
||||||
|
parent_class = gtk_type_class (gimp_color_button_get_type ());
|
||||||
|
|
||||||
|
object_class->destroy = gimp_color_panel_destroy;
|
||||||
|
color_button_class->color_changed = gimp_color_panel_color_changed;
|
||||||
|
button_class->clicked = gimp_color_panel_clicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_color_panel_init (GimpColorPanel *panel)
|
||||||
|
{
|
||||||
|
panel->color_notebook = NULL;
|
||||||
|
panel->color_notebook_active = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_color_panel_destroy (GtkObject *object)
|
||||||
|
{
|
||||||
|
GimpColorPanel *panel;
|
||||||
|
|
||||||
|
g_return_if_fail (object != NULL);
|
||||||
|
g_return_if_fail (GIMP_IS_COLOR_PANEL (object));
|
||||||
|
|
||||||
|
panel = GIMP_COLOR_PANEL (object);
|
||||||
|
|
||||||
|
/* make sure we hide and free color_notebook */
|
||||||
|
if (panel->color_notebook)
|
||||||
|
{
|
||||||
|
color_notebook_hide (panel->color_notebook);
|
||||||
|
color_notebook_free (panel->color_notebook);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||||
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
gimp_color_panel_new (const GimpRGB *color,
|
||||||
|
GimpColorAreaType type,
|
||||||
|
gint width,
|
||||||
|
gint height)
|
||||||
|
{
|
||||||
|
GimpColorPanel *panel;
|
||||||
|
|
||||||
g_return_val_if_fail (color != NULL, NULL);
|
g_return_val_if_fail (color != NULL, NULL);
|
||||||
|
|
||||||
private = g_new0 (ColorPanelPrivate, 1);
|
panel = gtk_type_new (gimp_color_panel_get_type ());
|
||||||
private->color_notebook = NULL;
|
|
||||||
private->color_notebook_active = FALSE;
|
|
||||||
private->gc = NULL;
|
|
||||||
private->show_alpha = show_alpha;
|
|
||||||
private->button_down = FALSE;
|
|
||||||
|
|
||||||
color_panel = g_new (ColorPanel, 1);
|
gimp_color_button_set_type (GIMP_COLOR_BUTTON (panel), type);
|
||||||
color_panel->private_part = private;
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (panel), color);
|
||||||
|
gtk_widget_set_usize (GTK_WIDGET (panel), width, height);
|
||||||
color_panel->color = *color;
|
|
||||||
|
return GTK_WIDGET (panel);
|
||||||
color_panel->color_panel_widget = gtk_frame_new (NULL);
|
|
||||||
gtk_frame_set_shadow_type (GTK_FRAME (color_panel->color_panel_widget),
|
|
||||||
GTK_SHADOW_IN);
|
|
||||||
|
|
||||||
/* drawing area */
|
|
||||||
private->drawing_area = gtk_drawing_area_new ();
|
|
||||||
gtk_drawing_area_size (GTK_DRAWING_AREA (private->drawing_area),
|
|
||||||
width, height);
|
|
||||||
gtk_widget_set_events (private->drawing_area, EVENT_MASK);
|
|
||||||
gtk_signal_connect (GTK_OBJECT (private->drawing_area), "event",
|
|
||||||
GTK_SIGNAL_FUNC (color_panel_events),
|
|
||||||
color_panel);
|
|
||||||
gtk_container_add (GTK_CONTAINER (color_panel->color_panel_widget),
|
|
||||||
private->drawing_area);
|
|
||||||
gtk_widget_show (private->drawing_area);
|
|
||||||
|
|
||||||
/* dnd stuff */
|
|
||||||
gtk_drag_source_set (private->drawing_area,
|
|
||||||
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
|
|
||||||
color_panel_target_table, n_color_panel_targets,
|
|
||||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
|
||||||
gimp_dnd_color_source_set (private->drawing_area,
|
|
||||||
color_panel_drag_color, color_panel);
|
|
||||||
|
|
||||||
gtk_drag_dest_set (private->drawing_area,
|
|
||||||
GTK_DEST_DEFAULT_HIGHLIGHT |
|
|
||||||
GTK_DEST_DEFAULT_MOTION |
|
|
||||||
GTK_DEST_DEFAULT_DROP,
|
|
||||||
color_panel_target_table, n_color_panel_targets,
|
|
||||||
GDK_ACTION_COPY);
|
|
||||||
gimp_dnd_color_dest_set (private->drawing_area,
|
|
||||||
color_panel_drop_color, color_panel);
|
|
||||||
|
|
||||||
gtk_signal_connect_object (GTK_OBJECT (color_panel->color_panel_widget),
|
|
||||||
"destroy",
|
|
||||||
GTK_SIGNAL_FUNC (color_panel_free),
|
|
||||||
(GtkObject *) color_panel);
|
|
||||||
|
|
||||||
return color_panel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
color_panel_set_color (ColorPanel *color_panel,
|
|
||||||
GimpRGB *color)
|
|
||||||
{
|
|
||||||
ColorPanelPrivate *private = color_panel->private_part;
|
|
||||||
|
|
||||||
g_return_if_fail (color_panel != NULL);
|
|
||||||
g_return_if_fail (color != NULL);
|
|
||||||
|
|
||||||
color_panel->color = *color;
|
|
||||||
|
|
||||||
if (private->color_notebook_active)
|
|
||||||
color_notebook_set_color (private->color_notebook, color);
|
|
||||||
|
|
||||||
if (private->gc)
|
|
||||||
color_panel_draw (color_panel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* private functions */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
color_panel_free (ColorPanel *color_panel)
|
gimp_color_panel_color_changed (GimpColorButton *button)
|
||||||
{
|
{
|
||||||
ColorPanelPrivate *private;
|
GimpColorPanel *panel;
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
panel = GIMP_COLOR_PANEL (button);
|
||||||
|
|
||||||
/* make sure we hide and free color_notebook */
|
if (panel->color_notebook_active)
|
||||||
if (private->color_notebook)
|
|
||||||
{
|
{
|
||||||
color_notebook_hide (private->color_notebook);
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &color);
|
||||||
color_notebook_free (private->color_notebook);
|
color_notebook_set_color (panel->color_notebook, &color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (private->gc)
|
|
||||||
gdk_gc_destroy (private->gc);
|
|
||||||
|
|
||||||
g_free (color_panel->private_part);
|
|
||||||
g_free (color_panel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
color_panel_draw (ColorPanel *color_panel)
|
gimp_color_panel_clicked (GtkButton *button)
|
||||||
{
|
{
|
||||||
GtkWidget *widget;
|
GimpColorPanel *panel;
|
||||||
ColorPanelPrivate *private;
|
GimpRGB color;
|
||||||
GdkColor fg;
|
|
||||||
guchar r, g, b;
|
|
||||||
|
|
||||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
panel = GIMP_COLOR_PANEL (button);
|
||||||
widget = private->drawing_area;
|
|
||||||
|
|
||||||
gimp_rgb_get_uchar (&color_panel->color, &r, &g, &b);
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &color);
|
||||||
|
|
||||||
fg.pixel = get_color (r, g, b);
|
if (! panel->color_notebook)
|
||||||
|
|
||||||
gdk_gc_set_foreground (private->gc, &fg);
|
|
||||||
gdk_draw_rectangle (widget->window, private->gc, 1, 0, 0,
|
|
||||||
widget->allocation.width, widget->allocation.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gint
|
|
||||||
color_panel_events (GtkWidget *widget,
|
|
||||||
GdkEvent *event,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
GdkEventButton *bevent;
|
|
||||||
ColorPanel *color_panel;
|
|
||||||
ColorPanelPrivate *private;
|
|
||||||
|
|
||||||
color_panel = (ColorPanel *) data;
|
|
||||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
|
||||||
|
|
||||||
switch (event->type)
|
|
||||||
{
|
{
|
||||||
case GDK_EXPOSE:
|
panel->color_notebook =
|
||||||
if (!private->gc)
|
color_notebook_new (&color,
|
||||||
private->gc = gdk_gc_new (widget->window);
|
gimp_color_panel_select_callback,
|
||||||
|
panel,
|
||||||
color_panel_draw (color_panel);
|
FALSE,
|
||||||
break;
|
gimp_color_button_has_alpha (GIMP_COLOR_BUTTON (button)));
|
||||||
|
panel->color_notebook_active = TRUE;
|
||||||
case GDK_BUTTON_PRESS:
|
}
|
||||||
bevent = (GdkEventButton *) event;
|
else
|
||||||
|
{
|
||||||
if (bevent->button == 1)
|
if (! panel->color_notebook_active)
|
||||||
private->button_down = TRUE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GDK_BUTTON_RELEASE:
|
|
||||||
bevent = (GdkEventButton *) event;
|
|
||||||
|
|
||||||
if (bevent->button == 1 &&
|
|
||||||
private->button_down)
|
|
||||||
{
|
{
|
||||||
if (! private->color_notebook)
|
color_notebook_show (panel->color_notebook);
|
||||||
{
|
panel->color_notebook_active = TRUE;
|
||||||
private->color_notebook =
|
|
||||||
color_notebook_new (&color_panel->color,
|
|
||||||
color_panel_select_callback,
|
|
||||||
color_panel,
|
|
||||||
FALSE,
|
|
||||||
private->show_alpha);
|
|
||||||
private->color_notebook_active = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (! private->color_notebook_active)
|
|
||||||
{
|
|
||||||
color_notebook_show (private->color_notebook);
|
|
||||||
private->color_notebook_active = TRUE;
|
|
||||||
}
|
|
||||||
color_notebook_set_color (private->color_notebook,
|
|
||||||
&color_panel->color);
|
|
||||||
}
|
|
||||||
private->button_down = FALSE;
|
|
||||||
}
|
}
|
||||||
break;
|
color_notebook_set_color (panel->color_notebook, &color);
|
||||||
|
|
||||||
case GDK_LEAVE_NOTIFY:
|
|
||||||
private->button_down = FALSE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
color_panel_select_callback (GimpRGB *color,
|
gimp_color_panel_select_callback (GimpRGB *color,
|
||||||
ColorNotebookState state,
|
ColorNotebookState state,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
ColorPanel *color_panel;
|
GimpColorPanel *panel;
|
||||||
ColorPanelPrivate *private;
|
|
||||||
|
|
||||||
color_panel = (ColorPanel *) data;
|
panel = GIMP_COLOR_PANEL (data);
|
||||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
|
||||||
|
|
||||||
if (private->color_notebook)
|
if (panel->color_notebook)
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case COLOR_NOTEBOOK_UPDATE:
|
case COLOR_NOTEBOOK_UPDATE:
|
||||||
break;
|
break;
|
||||||
case COLOR_NOTEBOOK_OK:
|
case COLOR_NOTEBOOK_OK:
|
||||||
color_panel->color = *color;
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (panel), color);
|
||||||
|
|
||||||
color_panel_draw (color_panel);
|
|
||||||
/* Fallthrough */
|
/* Fallthrough */
|
||||||
case COLOR_NOTEBOOK_CANCEL:
|
case COLOR_NOTEBOOK_CANCEL:
|
||||||
color_notebook_hide (private->color_notebook);
|
color_notebook_hide (panel->color_notebook);
|
||||||
private->color_notebook_active = FALSE;
|
panel->color_notebook_active = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
color_panel_drag_color (GtkWidget *widget,
|
|
||||||
GimpRGB *color,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
ColorPanel *color_panel;
|
|
||||||
|
|
||||||
color_panel = (ColorPanel *) data;
|
|
||||||
|
|
||||||
*color = color_panel->color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
color_panel_drop_color (GtkWidget *widget,
|
|
||||||
GimpRGB *color,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
ColorPanel *color_panel;
|
|
||||||
ColorPanelPrivate *private;
|
|
||||||
|
|
||||||
color_panel = (ColorPanel *) data;
|
|
||||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
|
||||||
|
|
||||||
color_panel->color = *color;
|
|
||||||
|
|
||||||
if (private->color_notebook_active)
|
|
||||||
color_notebook_set_color (private->color_notebook, color);
|
|
||||||
|
|
||||||
color_panel_draw (color_panel);
|
|
||||||
}
|
|
||||||
|
|
|
@ -20,28 +20,28 @@
|
||||||
#define __COLOR_PANEL_H__
|
#define __COLOR_PANEL_H__
|
||||||
|
|
||||||
|
|
||||||
typedef struct _ColorPanel ColorPanel;
|
#include "libgimp/gimpcolorbutton.h"
|
||||||
|
|
||||||
struct _ColorPanel
|
|
||||||
|
#define GIMP_TYPE_COLOR_PANEL (gimp_color_panel_get_type ())
|
||||||
|
#define GIMP_COLOR_PANEL(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_COLOR_PANEL, GimpColorPanel))
|
||||||
|
#define GIMP_COLOR_PANEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_PANEL, GimpColorPanelClass))
|
||||||
|
#define GIMP_IS_COLOR_PANEL(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_COLOR_PANEL))
|
||||||
|
#define GIMP_IS_COLOR_PANEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_PANEL))
|
||||||
|
|
||||||
|
typedef struct _GimpColorPanel GimpColorPanel;
|
||||||
|
typedef struct _GimpColorPanelClass GimpColorPanelClass;
|
||||||
|
|
||||||
|
struct _GimpColorPanelClass
|
||||||
{
|
{
|
||||||
/* The calling procedure is respondible for showing this widget */
|
GimpColorButtonClass parent_class;
|
||||||
GtkWidget *color_panel_widget;
|
|
||||||
|
|
||||||
/* The actual color */
|
|
||||||
GimpRGB color;
|
|
||||||
|
|
||||||
/* Don't touch this :) */
|
|
||||||
gpointer private_part;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GtkType gimp_color_panel_get_type (void);
|
||||||
ColorPanel * color_panel_new (GimpRGB *color,
|
GtkWidget * gimp_color_panel_new (const GimpRGB *color,
|
||||||
gboolean show_alpha,
|
GimpColorAreaType type,
|
||||||
gint width,
|
gint width,
|
||||||
gint height);
|
gint height);
|
||||||
|
|
||||||
void color_panel_set_color (ColorPanel *color_panel,
|
|
||||||
GimpRGB *color);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __COLOR_PANEL_H__ */
|
#endif /* __COLOR_PANEL_H__ */
|
||||||
|
|
|
@ -41,10 +41,10 @@ static const GtkTargetEntry targets[] = { { "application/x-color", 0 } };
|
||||||
|
|
||||||
struct _GimpColorArea
|
struct _GimpColorArea
|
||||||
{
|
{
|
||||||
GtkPreview preview;
|
GtkPreview preview;
|
||||||
|
|
||||||
gboolean alpha;
|
GimpColorAreaType type;
|
||||||
GimpRGB color;
|
GimpRGB color;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -57,7 +57,7 @@ static guint gimp_color_area_signals[LAST_SIGNAL] = { 0 };
|
||||||
static GtkWidgetClass *parent_class = NULL;
|
static GtkWidgetClass *parent_class = NULL;
|
||||||
|
|
||||||
|
|
||||||
static void gimp_color_area_class_init (GimpColorAreaClass *class);
|
static void gimp_color_area_class_init (GimpColorAreaClass *klass);
|
||||||
static void gimp_color_area_init (GimpColorArea *gca);
|
static void gimp_color_area_init (GimpColorArea *gca);
|
||||||
static void gimp_color_area_destroy (GtkObject *object);
|
static void gimp_color_area_destroy (GtkObject *object);
|
||||||
static void gimp_color_area_update (GimpColorArea *gca);
|
static void gimp_color_area_update (GimpColorArea *gca);
|
||||||
|
@ -105,13 +105,13 @@ gimp_color_area_get_type (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_area_class_init (GimpColorAreaClass *class)
|
gimp_color_area_class_init (GimpColorAreaClass *klass)
|
||||||
{
|
{
|
||||||
GtkObjectClass *object_class;
|
GtkObjectClass *object_class;
|
||||||
GtkWidgetClass *widget_class;
|
GtkWidgetClass *widget_class;
|
||||||
|
|
||||||
object_class = (GtkObjectClass*) class;
|
object_class = (GtkObjectClass*) klass;
|
||||||
widget_class = (GtkWidgetClass*) class;
|
widget_class = (GtkWidgetClass*) klass;
|
||||||
|
|
||||||
parent_class = gtk_type_class (gtk_preview_get_type ());
|
parent_class = gtk_type_class (gtk_preview_get_type ());
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ gimp_color_area_class_init (GimpColorAreaClass *class)
|
||||||
gtk_object_class_add_signals (object_class, gimp_color_area_signals,
|
gtk_object_class_add_signals (object_class, gimp_color_area_signals,
|
||||||
LAST_SIGNAL);
|
LAST_SIGNAL);
|
||||||
|
|
||||||
class->color_changed = NULL;
|
klass->color_changed = NULL;
|
||||||
|
|
||||||
object_class->destroy = gimp_color_area_destroy;
|
object_class->destroy = gimp_color_area_destroy;
|
||||||
|
|
||||||
|
@ -141,7 +141,20 @@ gimp_color_area_class_init (GimpColorAreaClass *class)
|
||||||
static void
|
static void
|
||||||
gimp_color_area_init (GimpColorArea *gca)
|
gimp_color_area_init (GimpColorArea *gca)
|
||||||
{
|
{
|
||||||
gca->alpha = FALSE;
|
gimp_rgba_set (&gca->color, 0.0, 0.0, 0.0, 1.0);
|
||||||
|
gca->type = GIMP_COLOR_AREA_FLAT;
|
||||||
|
|
||||||
|
GTK_PREVIEW (gca)->type = GTK_PREVIEW_COLOR;
|
||||||
|
GTK_PREVIEW (gca)->bpp = 3;
|
||||||
|
GTK_PREVIEW (gca)->dither = GDK_RGB_DITHER_NORMAL;
|
||||||
|
GTK_PREVIEW (gca)->expand = TRUE;
|
||||||
|
|
||||||
|
gtk_signal_connect_after (GTK_OBJECT (gca), "realize",
|
||||||
|
GTK_SIGNAL_FUNC (gimp_color_area_update),
|
||||||
|
NULL);
|
||||||
|
gtk_signal_connect (GTK_OBJECT (gca), "size_allocate",
|
||||||
|
GTK_SIGNAL_FUNC (gimp_color_area_update),
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -172,9 +185,9 @@ gimp_color_area_destroy (GtkObject *object)
|
||||||
* Returns: Pointer to the new #GimpColorArea widget.
|
* Returns: Pointer to the new #GimpColorArea widget.
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gimp_color_area_new (GimpRGB *color,
|
gimp_color_area_new (const GimpRGB *color,
|
||||||
gboolean alpha,
|
GimpColorAreaType type,
|
||||||
GdkModifierType drag_mask)
|
GdkModifierType drag_mask)
|
||||||
{
|
{
|
||||||
GimpColorArea *gca;
|
GimpColorArea *gca;
|
||||||
|
|
||||||
|
@ -183,20 +196,8 @@ gimp_color_area_new (GimpRGB *color,
|
||||||
gca = gtk_type_new (gimp_color_area_get_type ());
|
gca = gtk_type_new (gimp_color_area_get_type ());
|
||||||
|
|
||||||
gca->color = *color;
|
gca->color = *color;
|
||||||
gca->alpha = alpha;
|
gca->type = type;
|
||||||
|
|
||||||
GTK_PREVIEW (gca)->type = GTK_PREVIEW_COLOR;
|
|
||||||
GTK_PREVIEW (gca)->bpp = 3;
|
|
||||||
GTK_PREVIEW (gca)->dither = GDK_RGB_DITHER_NORMAL;
|
|
||||||
GTK_PREVIEW (gca)->expand = TRUE;
|
|
||||||
|
|
||||||
gtk_signal_connect_after (GTK_OBJECT (gca), "realize",
|
|
||||||
GTK_SIGNAL_FUNC (gimp_color_area_update),
|
|
||||||
NULL);
|
|
||||||
gtk_signal_connect (GTK_OBJECT (gca), "size_allocate",
|
|
||||||
GTK_SIGNAL_FUNC (gimp_color_area_update),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
gtk_drag_dest_set (GTK_WIDGET (gca),
|
gtk_drag_dest_set (GTK_WIDGET (gca),
|
||||||
GTK_DEST_DEFAULT_HIGHLIGHT |
|
GTK_DEST_DEFAULT_HIGHLIGHT |
|
||||||
GTK_DEST_DEFAULT_MOTION |
|
GTK_DEST_DEFAULT_MOTION |
|
||||||
|
@ -224,7 +225,7 @@ gimp_color_area_new (GimpRGB *color,
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gimp_color_area_set_color (GimpColorArea *gca,
|
gimp_color_area_set_color (GimpColorArea *gca,
|
||||||
GimpRGB *color)
|
const GimpRGB *color)
|
||||||
{
|
{
|
||||||
g_return_if_fail (gca != NULL);
|
g_return_if_fail (gca != NULL);
|
||||||
g_return_if_fail (GIMP_IS_COLOR_AREA (gca));
|
g_return_if_fail (GIMP_IS_COLOR_AREA (gca));
|
||||||
|
@ -258,15 +259,27 @@ gimp_color_area_has_alpha (GimpColorArea *gca)
|
||||||
g_return_val_if_fail (gca != NULL, FALSE);
|
g_return_val_if_fail (gca != NULL, FALSE);
|
||||||
g_return_val_if_fail (GIMP_IS_COLOR_AREA (gca), FALSE);
|
g_return_val_if_fail (GIMP_IS_COLOR_AREA (gca), FALSE);
|
||||||
|
|
||||||
return gca->alpha;
|
return gca->type != GIMP_COLOR_AREA_FLAT;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_color_area_set_type (GimpColorArea *gca,
|
||||||
|
GimpColorAreaType type)
|
||||||
|
{
|
||||||
|
g_return_if_fail (gca != NULL);
|
||||||
|
g_return_if_fail (GIMP_IS_COLOR_AREA (gca));
|
||||||
|
|
||||||
|
gca->type = type;
|
||||||
|
gimp_color_area_update (gca);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_area_update (GimpColorArea *gca)
|
gimp_color_area_update (GimpColorArea *gca)
|
||||||
{
|
{
|
||||||
gint window_width, window_height;
|
gint window_width, window_height;
|
||||||
guint x, y;
|
|
||||||
guint width, height;
|
guint width, height;
|
||||||
|
guint x, y;
|
||||||
|
guint check_size = 0;
|
||||||
guchar light[3];
|
guchar light[3];
|
||||||
guchar dark[3];
|
guchar dark[3];
|
||||||
guchar opaque[3];
|
guchar opaque[3];
|
||||||
|
@ -289,13 +302,28 @@ gimp_color_area_update (GimpColorArea *gca)
|
||||||
width = window_width;
|
width = window_width;
|
||||||
height = window_height;
|
height = window_height;
|
||||||
|
|
||||||
|
switch (gca->type)
|
||||||
|
{
|
||||||
|
case GIMP_COLOR_AREA_FLAT:
|
||||||
|
check_size = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GIMP_COLOR_AREA_SMALL_CHECKS:
|
||||||
|
check_size = GIMP_CHECK_SIZE_SM;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GIMP_COLOR_AREA_LARGE_CHECKS:
|
||||||
|
check_size = GIMP_CHECK_SIZE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
p = buf = g_new (guchar, width * 3);
|
p = buf = g_new (guchar, width * 3);
|
||||||
|
|
||||||
opaque[0] = gca->color.r * 255.999;
|
opaque[0] = gca->color.r * 255.999;
|
||||||
opaque[1] = gca->color.g * 255.999;
|
opaque[1] = gca->color.g * 255.999;
|
||||||
opaque[2] = gca->color.b * 255.999;
|
opaque[2] = gca->color.b * 255.999;
|
||||||
|
|
||||||
if (gca->alpha && gca->color.a < 1.0)
|
if (check_size && gca->color.a < 1.0)
|
||||||
{
|
{
|
||||||
light[0] = (GIMP_CHECK_LIGHT +
|
light[0] = (GIMP_CHECK_LIGHT +
|
||||||
(gca->color.r - GIMP_CHECK_LIGHT) * gca->color.a) * 255.999;
|
(gca->color.r - GIMP_CHECK_LIGHT) * gca->color.a) * 255.999;
|
||||||
|
@ -327,7 +355,7 @@ gimp_color_area_update (GimpColorArea *gca)
|
||||||
|
|
||||||
frac = (gdouble) (x * height) / (gdouble) width - y;
|
frac = (gdouble) (x * height) / (gdouble) width - y;
|
||||||
|
|
||||||
if (((x / GIMP_CHECK_SIZE_SM) ^ (y / GIMP_CHECK_SIZE_SM)) & 1)
|
if (((x / check_size) ^ (y / check_size)) & 1)
|
||||||
{
|
{
|
||||||
if ((gint) frac)
|
if ((gint) frac)
|
||||||
{
|
{
|
||||||
|
@ -407,7 +435,7 @@ gimp_color_area_drag_begin (GtkWidget *widget,
|
||||||
|
|
||||||
color_area =
|
color_area =
|
||||||
gimp_color_area_new (&color,
|
gimp_color_area_new (&color,
|
||||||
gimp_color_area_has_alpha (GIMP_COLOR_AREA (widget)),
|
GIMP_COLOR_AREA (widget)->type,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
gtk_widget_set_usize (color_area, DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
|
gtk_widget_set_usize (color_area, DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
|
||||||
|
@ -483,10 +511,10 @@ gimp_color_area_drag_data_get (GtkWidget *widget,
|
||||||
vals[1] = gca->color.g * 0xffff;
|
vals[1] = gca->color.g * 0xffff;
|
||||||
vals[2] = gca->color.b * 0xffff;
|
vals[2] = gca->color.b * 0xffff;
|
||||||
|
|
||||||
if (gca->alpha)
|
if (gca->type == GIMP_COLOR_AREA_FLAT)
|
||||||
vals[3] = gca->color.a * 0xffff;
|
|
||||||
else
|
|
||||||
vals[3] = 0xffff;
|
vals[3] = 0xffff;
|
||||||
|
else
|
||||||
|
vals[3] = gca->color.a * 0xffff;
|
||||||
|
|
||||||
gtk_selection_data_set (selection_data,
|
gtk_selection_data_set (selection_data,
|
||||||
gdk_atom_intern ("application/x-color", FALSE),
|
gdk_atom_intern ("application/x-color", FALSE),
|
||||||
|
|
|
@ -44,6 +44,13 @@ extern "C" {
|
||||||
#define GIMP_IS_COLOR_AREA_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_AREA))
|
#define GIMP_IS_COLOR_AREA_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_AREA))
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
GIMP_COLOR_AREA_FLAT = 0,
|
||||||
|
GIMP_COLOR_AREA_SMALL_CHECKS,
|
||||||
|
GIMP_COLOR_AREA_LARGE_CHECKS
|
||||||
|
} GimpColorAreaType;
|
||||||
|
|
||||||
typedef struct _GimpColorAreaClass GimpColorAreaClass;
|
typedef struct _GimpColorAreaClass GimpColorAreaClass;
|
||||||
|
|
||||||
struct _GimpColorAreaClass
|
struct _GimpColorAreaClass
|
||||||
|
@ -55,14 +62,16 @@ struct _GimpColorAreaClass
|
||||||
|
|
||||||
|
|
||||||
GtkType gimp_color_area_get_type (void);
|
GtkType gimp_color_area_get_type (void);
|
||||||
GtkWidget * gimp_color_area_new (GimpRGB *color,
|
GtkWidget * gimp_color_area_new (const GimpRGB *color,
|
||||||
gboolean alpha,
|
GimpColorAreaType type,
|
||||||
GdkModifierType drag_mask);
|
GdkModifierType drag_mask);
|
||||||
void gimp_color_area_set_color (GimpColorArea *gca,
|
void gimp_color_area_set_color (GimpColorArea *gca,
|
||||||
GimpRGB *color);
|
const GimpRGB *color);
|
||||||
void gimp_color_area_get_color (GimpColorArea *gca,
|
void gimp_color_area_get_color (GimpColorArea *gca,
|
||||||
GimpRGB *color); /* returns */
|
GimpRGB *color);
|
||||||
gboolean gimp_color_area_has_alpha (GimpColorArea *gca);
|
gboolean gimp_color_area_has_alpha (GimpColorArea *gca);
|
||||||
|
void gimp_color_area_set_type (GimpColorArea *gca,
|
||||||
|
GimpColorAreaType type);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -34,19 +34,11 @@
|
||||||
|
|
||||||
#include "libgimp-intl.h"
|
#include "libgimp-intl.h"
|
||||||
|
|
||||||
struct _GimpColorButton
|
|
||||||
{
|
|
||||||
GtkButton button;
|
|
||||||
|
|
||||||
gchar *title;
|
static void gimp_color_button_class_init (GimpColorButtonClass *klass);
|
||||||
|
static void gimp_color_button_init (GimpColorButton *gcb);
|
||||||
|
static void gimp_color_button_destroy (GtkObject *object);
|
||||||
|
|
||||||
GtkWidget *color_area;
|
|
||||||
GtkWidget *dialog;
|
|
||||||
GtkItemFactory *item_factory;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static void gimp_color_button_destroy (GtkObject *object);
|
|
||||||
static void gimp_color_button_clicked (GtkButton *button);
|
static void gimp_color_button_clicked (GtkButton *button);
|
||||||
static void gimp_color_button_state_changed (GtkWidget *widget,
|
static void gimp_color_button_state_changed (GtkWidget *widget,
|
||||||
GtkStateType previous_state);
|
GtkStateType previous_state);
|
||||||
|
@ -89,7 +81,7 @@ enum
|
||||||
|
|
||||||
static guint gimp_color_button_signals[LAST_SIGNAL] = { 0 };
|
static guint gimp_color_button_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
static GtkWidgetClass *parent_class = NULL;
|
static GtkPreviewClass *parent_class = NULL;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -113,16 +105,16 @@ gimp_color_button_destroy (GtkObject *object)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_button_class_init (GimpColorButtonClass *class)
|
gimp_color_button_class_init (GimpColorButtonClass *klass)
|
||||||
{
|
{
|
||||||
GtkObjectClass *object_class;
|
GtkObjectClass *object_class;
|
||||||
GtkWidgetClass *widget_class;
|
GtkWidgetClass *widget_class;
|
||||||
GtkButtonClass *button_class;
|
GtkButtonClass *button_class;
|
||||||
|
|
||||||
object_class = (GtkObjectClass*) class;
|
object_class = (GtkObjectClass *) klass;
|
||||||
widget_class = (GtkWidgetClass*) class;
|
widget_class = (GtkWidgetClass *) klass;
|
||||||
button_class = (GtkButtonClass*) class;
|
button_class = (GtkButtonClass *) klass;
|
||||||
|
|
||||||
parent_class = gtk_type_class (gtk_widget_get_type ());
|
parent_class = gtk_type_class (gtk_widget_get_type ());
|
||||||
|
|
||||||
gimp_color_button_signals[COLOR_CHANGED] =
|
gimp_color_button_signals[COLOR_CHANGED] =
|
||||||
|
@ -138,20 +130,40 @@ gimp_color_button_class_init (GimpColorButtonClass *class)
|
||||||
gtk_object_class_add_signals (object_class, gimp_color_button_signals,
|
gtk_object_class_add_signals (object_class, gimp_color_button_signals,
|
||||||
LAST_SIGNAL);
|
LAST_SIGNAL);
|
||||||
|
|
||||||
class->color_changed = NULL;
|
klass->color_changed = NULL;
|
||||||
|
|
||||||
object_class->destroy = gimp_color_button_destroy;
|
object_class->destroy = gimp_color_button_destroy;
|
||||||
widget_class->state_changed = gimp_color_button_state_changed;
|
widget_class->state_changed = gimp_color_button_state_changed;
|
||||||
button_class->clicked = gimp_color_button_clicked;
|
button_class->clicked = gimp_color_button_clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_button_init (GimpColorButton *gcb)
|
gimp_color_button_init (GimpColorButton *gcb)
|
||||||
{
|
{
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
gcb->title = NULL;
|
gcb->title = NULL;
|
||||||
gcb->color_area = NULL;
|
|
||||||
gcb->dialog = NULL;
|
gcb->dialog = NULL;
|
||||||
|
|
||||||
|
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
|
||||||
|
gcb->color_area = gimp_color_area_new (&color, FALSE, GDK_BUTTON2_MASK);
|
||||||
|
gtk_signal_connect (GTK_OBJECT (gcb->color_area), "color_changed",
|
||||||
|
gimp_color_button_color_changed,
|
||||||
|
gcb);
|
||||||
|
|
||||||
|
gtk_container_add (GTK_CONTAINER (gcb), gcb->color_area);
|
||||||
|
gtk_widget_show (gcb->color_area);
|
||||||
|
|
||||||
|
/* right-click opens a popup */
|
||||||
|
gcb->item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<popup>", NULL);
|
||||||
|
gtk_item_factory_set_translate_func (gcb->item_factory,
|
||||||
|
gimp_color_button_menu_translate,
|
||||||
|
NULL, NULL);
|
||||||
|
gtk_item_factory_create_items (gcb->item_factory,
|
||||||
|
nmenu_items, menu_items, gcb);
|
||||||
|
gtk_signal_connect (GTK_OBJECT (gcb), "button_press_event",
|
||||||
|
GTK_SIGNAL_FUNC (gimp_color_button_menu_popup),
|
||||||
|
gcb);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkType
|
GtkType
|
||||||
|
@ -185,7 +197,7 @@ gimp_color_button_get_type (void)
|
||||||
* @width: Width of the colorpreview in pixels.
|
* @width: Width of the colorpreview in pixels.
|
||||||
* @height: Height of the colorpreview in pixels.
|
* @height: Height of the colorpreview in pixels.
|
||||||
* @color: A pointer to a #GimpRGB color.
|
* @color: A pointer to a #GimpRGB color.
|
||||||
* @alpha: TRUE if the button should show alpha.
|
* @type:
|
||||||
*
|
*
|
||||||
* Creates a new #GimpColorButton widget.
|
* Creates a new #GimpColorButton widget.
|
||||||
*
|
*
|
||||||
|
@ -198,11 +210,11 @@ gimp_color_button_get_type (void)
|
||||||
* Returns: Pointer to the new #GimpColorButton widget.
|
* Returns: Pointer to the new #GimpColorButton widget.
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gimp_color_button_new (const gchar *title,
|
gimp_color_button_new (const gchar *title,
|
||||||
gint width,
|
gint width,
|
||||||
gint height,
|
gint height,
|
||||||
GimpRGB *color,
|
const GimpRGB *color,
|
||||||
gboolean alpha)
|
GimpColorAreaType type)
|
||||||
{
|
{
|
||||||
GimpColorButton *gcb;
|
GimpColorButton *gcb;
|
||||||
|
|
||||||
|
@ -212,25 +224,8 @@ gimp_color_button_new (const gchar *title,
|
||||||
|
|
||||||
gcb->title = g_strdup (title);
|
gcb->title = g_strdup (title);
|
||||||
|
|
||||||
gcb->color_area = gimp_color_area_new (color, alpha, GDK_BUTTON2_MASK);
|
gimp_color_area_set_type (GIMP_COLOR_AREA (gcb->color_area), type);
|
||||||
gtk_signal_connect (GTK_OBJECT (gcb->color_area), "color_changed",
|
|
||||||
gimp_color_button_color_changed,
|
|
||||||
gcb);
|
|
||||||
|
|
||||||
gtk_widget_set_usize (GTK_WIDGET (gcb->color_area), width, height);
|
gtk_widget_set_usize (GTK_WIDGET (gcb->color_area), width, height);
|
||||||
gtk_container_add (GTK_CONTAINER (gcb), gcb->color_area);
|
|
||||||
gtk_widget_show (gcb->color_area);
|
|
||||||
|
|
||||||
/* right-click opens a popup */
|
|
||||||
gcb->item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<popup>", NULL);
|
|
||||||
gtk_item_factory_set_translate_func (gcb->item_factory,
|
|
||||||
gimp_color_button_menu_translate,
|
|
||||||
NULL, NULL);
|
|
||||||
gtk_item_factory_create_items (gcb->item_factory,
|
|
||||||
nmenu_items, menu_items, gcb);
|
|
||||||
gtk_signal_connect (GTK_OBJECT (gcb), "button_press_event",
|
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_menu_popup),
|
|
||||||
gcb);
|
|
||||||
|
|
||||||
return GTK_WIDGET (gcb);
|
return GTK_WIDGET (gcb);
|
||||||
}
|
}
|
||||||
|
@ -243,7 +238,7 @@ gimp_color_button_new (const gchar *title,
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gimp_color_button_set_color (GimpColorButton *gcb,
|
gimp_color_button_set_color (GimpColorButton *gcb,
|
||||||
GimpRGB *color)
|
const GimpRGB *color)
|
||||||
{
|
{
|
||||||
g_return_if_fail (gcb != NULL);
|
g_return_if_fail (gcb != NULL);
|
||||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb));
|
g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb));
|
||||||
|
@ -265,6 +260,8 @@ gimp_color_button_get_color (GimpColorButton *gcb,
|
||||||
g_return_if_fail (gcb != NULL);
|
g_return_if_fail (gcb != NULL);
|
||||||
g_return_if_fail (color != NULL);
|
g_return_if_fail (color != NULL);
|
||||||
|
|
||||||
|
g_return_if_fail (color != NULL);
|
||||||
|
|
||||||
gimp_color_area_get_color (GIMP_COLOR_AREA (gcb->color_area), color);
|
gimp_color_area_get_color (GIMP_COLOR_AREA (gcb->color_area), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,6 +278,15 @@ gimp_color_button_has_alpha (GimpColorButton *gcb)
|
||||||
return gimp_color_area_has_alpha (GIMP_COLOR_AREA (gcb->color_area));
|
return gimp_color_area_has_alpha (GIMP_COLOR_AREA (gcb->color_area));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_color_button_set_type (GimpColorButton *gcb,
|
||||||
|
GimpColorAreaType type)
|
||||||
|
{
|
||||||
|
g_return_if_fail (gcb != NULL);
|
||||||
|
|
||||||
|
gimp_color_area_set_type (GIMP_COLOR_AREA (gcb->color_area), type);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_button_state_changed (GtkWidget *widget,
|
gimp_color_button_state_changed (GtkWidget *widget,
|
||||||
GtkStateType previous_state)
|
GtkStateType previous_state)
|
||||||
|
|
|
@ -29,6 +29,9 @@
|
||||||
#ifndef __GIMP_COLOR_BUTTON_H__
|
#ifndef __GIMP_COLOR_BUTTON_H__
|
||||||
#define __GIMP_COLOR_BUTTON_H__
|
#define __GIMP_COLOR_BUTTON_H__
|
||||||
|
|
||||||
|
#include "libgimp/gimpcolorarea.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
@ -40,8 +43,20 @@ extern "C" {
|
||||||
#define GIMP_IS_COLOR_BUTTON(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_COLOR_BUTTON))
|
#define GIMP_IS_COLOR_BUTTON(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_COLOR_BUTTON))
|
||||||
#define GIMP_IS_COLOR_BUTTON_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_BUTTON))
|
#define GIMP_IS_COLOR_BUTTON_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_BUTTON))
|
||||||
|
|
||||||
|
|
||||||
typedef struct _GimpColorButtonClass GimpColorButtonClass;
|
typedef struct _GimpColorButtonClass GimpColorButtonClass;
|
||||||
|
|
||||||
|
struct _GimpColorButton
|
||||||
|
{
|
||||||
|
GtkButton button;
|
||||||
|
|
||||||
|
gchar *title;
|
||||||
|
|
||||||
|
GtkWidget *color_area;
|
||||||
|
GtkWidget *dialog;
|
||||||
|
GtkItemFactory *item_factory;
|
||||||
|
};
|
||||||
|
|
||||||
struct _GimpColorButtonClass
|
struct _GimpColorButtonClass
|
||||||
{
|
{
|
||||||
GtkButtonClass parent_class;
|
GtkButtonClass parent_class;
|
||||||
|
@ -51,16 +66,18 @@ struct _GimpColorButtonClass
|
||||||
|
|
||||||
|
|
||||||
GtkType gimp_color_button_get_type (void);
|
GtkType gimp_color_button_get_type (void);
|
||||||
GtkWidget * gimp_color_button_new (const gchar *title,
|
GtkWidget * gimp_color_button_new (const gchar *title,
|
||||||
gint width,
|
gint width,
|
||||||
gint height,
|
gint height,
|
||||||
GimpRGB *color,
|
const GimpRGB *color,
|
||||||
gboolean alpha);
|
GimpColorAreaType alpha);
|
||||||
void gimp_color_button_set_color (GimpColorButton *gcb,
|
void gimp_color_button_set_color (GimpColorButton *gcb,
|
||||||
GimpRGB *color);
|
const GimpRGB *color);
|
||||||
void gimp_color_button_get_color (GimpColorButton *gcb,
|
void gimp_color_button_get_color (GimpColorButton *gcb,
|
||||||
GimpRGB *color);/* returns */
|
GimpRGB *color);
|
||||||
gboolean gimp_color_button_has_alpha (GimpColorButton *gcb);
|
gboolean gimp_color_button_has_alpha (GimpColorButton *gcb);
|
||||||
|
void gimp_color_button_set_type (GimpColorButton *gcb,
|
||||||
|
GimpColorAreaType alpha);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -41,10 +41,10 @@ static const GtkTargetEntry targets[] = { { "application/x-color", 0 } };
|
||||||
|
|
||||||
struct _GimpColorArea
|
struct _GimpColorArea
|
||||||
{
|
{
|
||||||
GtkPreview preview;
|
GtkPreview preview;
|
||||||
|
|
||||||
gboolean alpha;
|
GimpColorAreaType type;
|
||||||
GimpRGB color;
|
GimpRGB color;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -57,7 +57,7 @@ static guint gimp_color_area_signals[LAST_SIGNAL] = { 0 };
|
||||||
static GtkWidgetClass *parent_class = NULL;
|
static GtkWidgetClass *parent_class = NULL;
|
||||||
|
|
||||||
|
|
||||||
static void gimp_color_area_class_init (GimpColorAreaClass *class);
|
static void gimp_color_area_class_init (GimpColorAreaClass *klass);
|
||||||
static void gimp_color_area_init (GimpColorArea *gca);
|
static void gimp_color_area_init (GimpColorArea *gca);
|
||||||
static void gimp_color_area_destroy (GtkObject *object);
|
static void gimp_color_area_destroy (GtkObject *object);
|
||||||
static void gimp_color_area_update (GimpColorArea *gca);
|
static void gimp_color_area_update (GimpColorArea *gca);
|
||||||
|
@ -105,13 +105,13 @@ gimp_color_area_get_type (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_area_class_init (GimpColorAreaClass *class)
|
gimp_color_area_class_init (GimpColorAreaClass *klass)
|
||||||
{
|
{
|
||||||
GtkObjectClass *object_class;
|
GtkObjectClass *object_class;
|
||||||
GtkWidgetClass *widget_class;
|
GtkWidgetClass *widget_class;
|
||||||
|
|
||||||
object_class = (GtkObjectClass*) class;
|
object_class = (GtkObjectClass*) klass;
|
||||||
widget_class = (GtkWidgetClass*) class;
|
widget_class = (GtkWidgetClass*) klass;
|
||||||
|
|
||||||
parent_class = gtk_type_class (gtk_preview_get_type ());
|
parent_class = gtk_type_class (gtk_preview_get_type ());
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ gimp_color_area_class_init (GimpColorAreaClass *class)
|
||||||
gtk_object_class_add_signals (object_class, gimp_color_area_signals,
|
gtk_object_class_add_signals (object_class, gimp_color_area_signals,
|
||||||
LAST_SIGNAL);
|
LAST_SIGNAL);
|
||||||
|
|
||||||
class->color_changed = NULL;
|
klass->color_changed = NULL;
|
||||||
|
|
||||||
object_class->destroy = gimp_color_area_destroy;
|
object_class->destroy = gimp_color_area_destroy;
|
||||||
|
|
||||||
|
@ -141,7 +141,20 @@ gimp_color_area_class_init (GimpColorAreaClass *class)
|
||||||
static void
|
static void
|
||||||
gimp_color_area_init (GimpColorArea *gca)
|
gimp_color_area_init (GimpColorArea *gca)
|
||||||
{
|
{
|
||||||
gca->alpha = FALSE;
|
gimp_rgba_set (&gca->color, 0.0, 0.0, 0.0, 1.0);
|
||||||
|
gca->type = GIMP_COLOR_AREA_FLAT;
|
||||||
|
|
||||||
|
GTK_PREVIEW (gca)->type = GTK_PREVIEW_COLOR;
|
||||||
|
GTK_PREVIEW (gca)->bpp = 3;
|
||||||
|
GTK_PREVIEW (gca)->dither = GDK_RGB_DITHER_NORMAL;
|
||||||
|
GTK_PREVIEW (gca)->expand = TRUE;
|
||||||
|
|
||||||
|
gtk_signal_connect_after (GTK_OBJECT (gca), "realize",
|
||||||
|
GTK_SIGNAL_FUNC (gimp_color_area_update),
|
||||||
|
NULL);
|
||||||
|
gtk_signal_connect (GTK_OBJECT (gca), "size_allocate",
|
||||||
|
GTK_SIGNAL_FUNC (gimp_color_area_update),
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -172,9 +185,9 @@ gimp_color_area_destroy (GtkObject *object)
|
||||||
* Returns: Pointer to the new #GimpColorArea widget.
|
* Returns: Pointer to the new #GimpColorArea widget.
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gimp_color_area_new (GimpRGB *color,
|
gimp_color_area_new (const GimpRGB *color,
|
||||||
gboolean alpha,
|
GimpColorAreaType type,
|
||||||
GdkModifierType drag_mask)
|
GdkModifierType drag_mask)
|
||||||
{
|
{
|
||||||
GimpColorArea *gca;
|
GimpColorArea *gca;
|
||||||
|
|
||||||
|
@ -183,20 +196,8 @@ gimp_color_area_new (GimpRGB *color,
|
||||||
gca = gtk_type_new (gimp_color_area_get_type ());
|
gca = gtk_type_new (gimp_color_area_get_type ());
|
||||||
|
|
||||||
gca->color = *color;
|
gca->color = *color;
|
||||||
gca->alpha = alpha;
|
gca->type = type;
|
||||||
|
|
||||||
GTK_PREVIEW (gca)->type = GTK_PREVIEW_COLOR;
|
|
||||||
GTK_PREVIEW (gca)->bpp = 3;
|
|
||||||
GTK_PREVIEW (gca)->dither = GDK_RGB_DITHER_NORMAL;
|
|
||||||
GTK_PREVIEW (gca)->expand = TRUE;
|
|
||||||
|
|
||||||
gtk_signal_connect_after (GTK_OBJECT (gca), "realize",
|
|
||||||
GTK_SIGNAL_FUNC (gimp_color_area_update),
|
|
||||||
NULL);
|
|
||||||
gtk_signal_connect (GTK_OBJECT (gca), "size_allocate",
|
|
||||||
GTK_SIGNAL_FUNC (gimp_color_area_update),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
gtk_drag_dest_set (GTK_WIDGET (gca),
|
gtk_drag_dest_set (GTK_WIDGET (gca),
|
||||||
GTK_DEST_DEFAULT_HIGHLIGHT |
|
GTK_DEST_DEFAULT_HIGHLIGHT |
|
||||||
GTK_DEST_DEFAULT_MOTION |
|
GTK_DEST_DEFAULT_MOTION |
|
||||||
|
@ -224,7 +225,7 @@ gimp_color_area_new (GimpRGB *color,
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gimp_color_area_set_color (GimpColorArea *gca,
|
gimp_color_area_set_color (GimpColorArea *gca,
|
||||||
GimpRGB *color)
|
const GimpRGB *color)
|
||||||
{
|
{
|
||||||
g_return_if_fail (gca != NULL);
|
g_return_if_fail (gca != NULL);
|
||||||
g_return_if_fail (GIMP_IS_COLOR_AREA (gca));
|
g_return_if_fail (GIMP_IS_COLOR_AREA (gca));
|
||||||
|
@ -258,15 +259,27 @@ gimp_color_area_has_alpha (GimpColorArea *gca)
|
||||||
g_return_val_if_fail (gca != NULL, FALSE);
|
g_return_val_if_fail (gca != NULL, FALSE);
|
||||||
g_return_val_if_fail (GIMP_IS_COLOR_AREA (gca), FALSE);
|
g_return_val_if_fail (GIMP_IS_COLOR_AREA (gca), FALSE);
|
||||||
|
|
||||||
return gca->alpha;
|
return gca->type != GIMP_COLOR_AREA_FLAT;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_color_area_set_type (GimpColorArea *gca,
|
||||||
|
GimpColorAreaType type)
|
||||||
|
{
|
||||||
|
g_return_if_fail (gca != NULL);
|
||||||
|
g_return_if_fail (GIMP_IS_COLOR_AREA (gca));
|
||||||
|
|
||||||
|
gca->type = type;
|
||||||
|
gimp_color_area_update (gca);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_area_update (GimpColorArea *gca)
|
gimp_color_area_update (GimpColorArea *gca)
|
||||||
{
|
{
|
||||||
gint window_width, window_height;
|
gint window_width, window_height;
|
||||||
guint x, y;
|
|
||||||
guint width, height;
|
guint width, height;
|
||||||
|
guint x, y;
|
||||||
|
guint check_size = 0;
|
||||||
guchar light[3];
|
guchar light[3];
|
||||||
guchar dark[3];
|
guchar dark[3];
|
||||||
guchar opaque[3];
|
guchar opaque[3];
|
||||||
|
@ -289,13 +302,28 @@ gimp_color_area_update (GimpColorArea *gca)
|
||||||
width = window_width;
|
width = window_width;
|
||||||
height = window_height;
|
height = window_height;
|
||||||
|
|
||||||
|
switch (gca->type)
|
||||||
|
{
|
||||||
|
case GIMP_COLOR_AREA_FLAT:
|
||||||
|
check_size = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GIMP_COLOR_AREA_SMALL_CHECKS:
|
||||||
|
check_size = GIMP_CHECK_SIZE_SM;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GIMP_COLOR_AREA_LARGE_CHECKS:
|
||||||
|
check_size = GIMP_CHECK_SIZE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
p = buf = g_new (guchar, width * 3);
|
p = buf = g_new (guchar, width * 3);
|
||||||
|
|
||||||
opaque[0] = gca->color.r * 255.999;
|
opaque[0] = gca->color.r * 255.999;
|
||||||
opaque[1] = gca->color.g * 255.999;
|
opaque[1] = gca->color.g * 255.999;
|
||||||
opaque[2] = gca->color.b * 255.999;
|
opaque[2] = gca->color.b * 255.999;
|
||||||
|
|
||||||
if (gca->alpha && gca->color.a < 1.0)
|
if (check_size && gca->color.a < 1.0)
|
||||||
{
|
{
|
||||||
light[0] = (GIMP_CHECK_LIGHT +
|
light[0] = (GIMP_CHECK_LIGHT +
|
||||||
(gca->color.r - GIMP_CHECK_LIGHT) * gca->color.a) * 255.999;
|
(gca->color.r - GIMP_CHECK_LIGHT) * gca->color.a) * 255.999;
|
||||||
|
@ -327,7 +355,7 @@ gimp_color_area_update (GimpColorArea *gca)
|
||||||
|
|
||||||
frac = (gdouble) (x * height) / (gdouble) width - y;
|
frac = (gdouble) (x * height) / (gdouble) width - y;
|
||||||
|
|
||||||
if (((x / GIMP_CHECK_SIZE_SM) ^ (y / GIMP_CHECK_SIZE_SM)) & 1)
|
if (((x / check_size) ^ (y / check_size)) & 1)
|
||||||
{
|
{
|
||||||
if ((gint) frac)
|
if ((gint) frac)
|
||||||
{
|
{
|
||||||
|
@ -407,7 +435,7 @@ gimp_color_area_drag_begin (GtkWidget *widget,
|
||||||
|
|
||||||
color_area =
|
color_area =
|
||||||
gimp_color_area_new (&color,
|
gimp_color_area_new (&color,
|
||||||
gimp_color_area_has_alpha (GIMP_COLOR_AREA (widget)),
|
GIMP_COLOR_AREA (widget)->type,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
gtk_widget_set_usize (color_area, DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
|
gtk_widget_set_usize (color_area, DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
|
||||||
|
@ -483,10 +511,10 @@ gimp_color_area_drag_data_get (GtkWidget *widget,
|
||||||
vals[1] = gca->color.g * 0xffff;
|
vals[1] = gca->color.g * 0xffff;
|
||||||
vals[2] = gca->color.b * 0xffff;
|
vals[2] = gca->color.b * 0xffff;
|
||||||
|
|
||||||
if (gca->alpha)
|
if (gca->type == GIMP_COLOR_AREA_FLAT)
|
||||||
vals[3] = gca->color.a * 0xffff;
|
|
||||||
else
|
|
||||||
vals[3] = 0xffff;
|
vals[3] = 0xffff;
|
||||||
|
else
|
||||||
|
vals[3] = gca->color.a * 0xffff;
|
||||||
|
|
||||||
gtk_selection_data_set (selection_data,
|
gtk_selection_data_set (selection_data,
|
||||||
gdk_atom_intern ("application/x-color", FALSE),
|
gdk_atom_intern ("application/x-color", FALSE),
|
||||||
|
|
|
@ -44,6 +44,13 @@ extern "C" {
|
||||||
#define GIMP_IS_COLOR_AREA_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_AREA))
|
#define GIMP_IS_COLOR_AREA_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_AREA))
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
GIMP_COLOR_AREA_FLAT = 0,
|
||||||
|
GIMP_COLOR_AREA_SMALL_CHECKS,
|
||||||
|
GIMP_COLOR_AREA_LARGE_CHECKS
|
||||||
|
} GimpColorAreaType;
|
||||||
|
|
||||||
typedef struct _GimpColorAreaClass GimpColorAreaClass;
|
typedef struct _GimpColorAreaClass GimpColorAreaClass;
|
||||||
|
|
||||||
struct _GimpColorAreaClass
|
struct _GimpColorAreaClass
|
||||||
|
@ -55,14 +62,16 @@ struct _GimpColorAreaClass
|
||||||
|
|
||||||
|
|
||||||
GtkType gimp_color_area_get_type (void);
|
GtkType gimp_color_area_get_type (void);
|
||||||
GtkWidget * gimp_color_area_new (GimpRGB *color,
|
GtkWidget * gimp_color_area_new (const GimpRGB *color,
|
||||||
gboolean alpha,
|
GimpColorAreaType type,
|
||||||
GdkModifierType drag_mask);
|
GdkModifierType drag_mask);
|
||||||
void gimp_color_area_set_color (GimpColorArea *gca,
|
void gimp_color_area_set_color (GimpColorArea *gca,
|
||||||
GimpRGB *color);
|
const GimpRGB *color);
|
||||||
void gimp_color_area_get_color (GimpColorArea *gca,
|
void gimp_color_area_get_color (GimpColorArea *gca,
|
||||||
GimpRGB *color); /* returns */
|
GimpRGB *color);
|
||||||
gboolean gimp_color_area_has_alpha (GimpColorArea *gca);
|
gboolean gimp_color_area_has_alpha (GimpColorArea *gca);
|
||||||
|
void gimp_color_area_set_type (GimpColorArea *gca,
|
||||||
|
GimpColorAreaType type);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -34,19 +34,11 @@
|
||||||
|
|
||||||
#include "libgimp-intl.h"
|
#include "libgimp-intl.h"
|
||||||
|
|
||||||
struct _GimpColorButton
|
|
||||||
{
|
|
||||||
GtkButton button;
|
|
||||||
|
|
||||||
gchar *title;
|
static void gimp_color_button_class_init (GimpColorButtonClass *klass);
|
||||||
|
static void gimp_color_button_init (GimpColorButton *gcb);
|
||||||
|
static void gimp_color_button_destroy (GtkObject *object);
|
||||||
|
|
||||||
GtkWidget *color_area;
|
|
||||||
GtkWidget *dialog;
|
|
||||||
GtkItemFactory *item_factory;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static void gimp_color_button_destroy (GtkObject *object);
|
|
||||||
static void gimp_color_button_clicked (GtkButton *button);
|
static void gimp_color_button_clicked (GtkButton *button);
|
||||||
static void gimp_color_button_state_changed (GtkWidget *widget,
|
static void gimp_color_button_state_changed (GtkWidget *widget,
|
||||||
GtkStateType previous_state);
|
GtkStateType previous_state);
|
||||||
|
@ -89,7 +81,7 @@ enum
|
||||||
|
|
||||||
static guint gimp_color_button_signals[LAST_SIGNAL] = { 0 };
|
static guint gimp_color_button_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
static GtkWidgetClass *parent_class = NULL;
|
static GtkPreviewClass *parent_class = NULL;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -113,16 +105,16 @@ gimp_color_button_destroy (GtkObject *object)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_button_class_init (GimpColorButtonClass *class)
|
gimp_color_button_class_init (GimpColorButtonClass *klass)
|
||||||
{
|
{
|
||||||
GtkObjectClass *object_class;
|
GtkObjectClass *object_class;
|
||||||
GtkWidgetClass *widget_class;
|
GtkWidgetClass *widget_class;
|
||||||
GtkButtonClass *button_class;
|
GtkButtonClass *button_class;
|
||||||
|
|
||||||
object_class = (GtkObjectClass*) class;
|
object_class = (GtkObjectClass *) klass;
|
||||||
widget_class = (GtkWidgetClass*) class;
|
widget_class = (GtkWidgetClass *) klass;
|
||||||
button_class = (GtkButtonClass*) class;
|
button_class = (GtkButtonClass *) klass;
|
||||||
|
|
||||||
parent_class = gtk_type_class (gtk_widget_get_type ());
|
parent_class = gtk_type_class (gtk_widget_get_type ());
|
||||||
|
|
||||||
gimp_color_button_signals[COLOR_CHANGED] =
|
gimp_color_button_signals[COLOR_CHANGED] =
|
||||||
|
@ -138,20 +130,40 @@ gimp_color_button_class_init (GimpColorButtonClass *class)
|
||||||
gtk_object_class_add_signals (object_class, gimp_color_button_signals,
|
gtk_object_class_add_signals (object_class, gimp_color_button_signals,
|
||||||
LAST_SIGNAL);
|
LAST_SIGNAL);
|
||||||
|
|
||||||
class->color_changed = NULL;
|
klass->color_changed = NULL;
|
||||||
|
|
||||||
object_class->destroy = gimp_color_button_destroy;
|
object_class->destroy = gimp_color_button_destroy;
|
||||||
widget_class->state_changed = gimp_color_button_state_changed;
|
widget_class->state_changed = gimp_color_button_state_changed;
|
||||||
button_class->clicked = gimp_color_button_clicked;
|
button_class->clicked = gimp_color_button_clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_button_init (GimpColorButton *gcb)
|
gimp_color_button_init (GimpColorButton *gcb)
|
||||||
{
|
{
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
gcb->title = NULL;
|
gcb->title = NULL;
|
||||||
gcb->color_area = NULL;
|
|
||||||
gcb->dialog = NULL;
|
gcb->dialog = NULL;
|
||||||
|
|
||||||
|
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
|
||||||
|
gcb->color_area = gimp_color_area_new (&color, FALSE, GDK_BUTTON2_MASK);
|
||||||
|
gtk_signal_connect (GTK_OBJECT (gcb->color_area), "color_changed",
|
||||||
|
gimp_color_button_color_changed,
|
||||||
|
gcb);
|
||||||
|
|
||||||
|
gtk_container_add (GTK_CONTAINER (gcb), gcb->color_area);
|
||||||
|
gtk_widget_show (gcb->color_area);
|
||||||
|
|
||||||
|
/* right-click opens a popup */
|
||||||
|
gcb->item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<popup>", NULL);
|
||||||
|
gtk_item_factory_set_translate_func (gcb->item_factory,
|
||||||
|
gimp_color_button_menu_translate,
|
||||||
|
NULL, NULL);
|
||||||
|
gtk_item_factory_create_items (gcb->item_factory,
|
||||||
|
nmenu_items, menu_items, gcb);
|
||||||
|
gtk_signal_connect (GTK_OBJECT (gcb), "button_press_event",
|
||||||
|
GTK_SIGNAL_FUNC (gimp_color_button_menu_popup),
|
||||||
|
gcb);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkType
|
GtkType
|
||||||
|
@ -185,7 +197,7 @@ gimp_color_button_get_type (void)
|
||||||
* @width: Width of the colorpreview in pixels.
|
* @width: Width of the colorpreview in pixels.
|
||||||
* @height: Height of the colorpreview in pixels.
|
* @height: Height of the colorpreview in pixels.
|
||||||
* @color: A pointer to a #GimpRGB color.
|
* @color: A pointer to a #GimpRGB color.
|
||||||
* @alpha: TRUE if the button should show alpha.
|
* @type:
|
||||||
*
|
*
|
||||||
* Creates a new #GimpColorButton widget.
|
* Creates a new #GimpColorButton widget.
|
||||||
*
|
*
|
||||||
|
@ -198,11 +210,11 @@ gimp_color_button_get_type (void)
|
||||||
* Returns: Pointer to the new #GimpColorButton widget.
|
* Returns: Pointer to the new #GimpColorButton widget.
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gimp_color_button_new (const gchar *title,
|
gimp_color_button_new (const gchar *title,
|
||||||
gint width,
|
gint width,
|
||||||
gint height,
|
gint height,
|
||||||
GimpRGB *color,
|
const GimpRGB *color,
|
||||||
gboolean alpha)
|
GimpColorAreaType type)
|
||||||
{
|
{
|
||||||
GimpColorButton *gcb;
|
GimpColorButton *gcb;
|
||||||
|
|
||||||
|
@ -212,25 +224,8 @@ gimp_color_button_new (const gchar *title,
|
||||||
|
|
||||||
gcb->title = g_strdup (title);
|
gcb->title = g_strdup (title);
|
||||||
|
|
||||||
gcb->color_area = gimp_color_area_new (color, alpha, GDK_BUTTON2_MASK);
|
gimp_color_area_set_type (GIMP_COLOR_AREA (gcb->color_area), type);
|
||||||
gtk_signal_connect (GTK_OBJECT (gcb->color_area), "color_changed",
|
|
||||||
gimp_color_button_color_changed,
|
|
||||||
gcb);
|
|
||||||
|
|
||||||
gtk_widget_set_usize (GTK_WIDGET (gcb->color_area), width, height);
|
gtk_widget_set_usize (GTK_WIDGET (gcb->color_area), width, height);
|
||||||
gtk_container_add (GTK_CONTAINER (gcb), gcb->color_area);
|
|
||||||
gtk_widget_show (gcb->color_area);
|
|
||||||
|
|
||||||
/* right-click opens a popup */
|
|
||||||
gcb->item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<popup>", NULL);
|
|
||||||
gtk_item_factory_set_translate_func (gcb->item_factory,
|
|
||||||
gimp_color_button_menu_translate,
|
|
||||||
NULL, NULL);
|
|
||||||
gtk_item_factory_create_items (gcb->item_factory,
|
|
||||||
nmenu_items, menu_items, gcb);
|
|
||||||
gtk_signal_connect (GTK_OBJECT (gcb), "button_press_event",
|
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_menu_popup),
|
|
||||||
gcb);
|
|
||||||
|
|
||||||
return GTK_WIDGET (gcb);
|
return GTK_WIDGET (gcb);
|
||||||
}
|
}
|
||||||
|
@ -243,7 +238,7 @@ gimp_color_button_new (const gchar *title,
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gimp_color_button_set_color (GimpColorButton *gcb,
|
gimp_color_button_set_color (GimpColorButton *gcb,
|
||||||
GimpRGB *color)
|
const GimpRGB *color)
|
||||||
{
|
{
|
||||||
g_return_if_fail (gcb != NULL);
|
g_return_if_fail (gcb != NULL);
|
||||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb));
|
g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb));
|
||||||
|
@ -265,6 +260,8 @@ gimp_color_button_get_color (GimpColorButton *gcb,
|
||||||
g_return_if_fail (gcb != NULL);
|
g_return_if_fail (gcb != NULL);
|
||||||
g_return_if_fail (color != NULL);
|
g_return_if_fail (color != NULL);
|
||||||
|
|
||||||
|
g_return_if_fail (color != NULL);
|
||||||
|
|
||||||
gimp_color_area_get_color (GIMP_COLOR_AREA (gcb->color_area), color);
|
gimp_color_area_get_color (GIMP_COLOR_AREA (gcb->color_area), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,6 +278,15 @@ gimp_color_button_has_alpha (GimpColorButton *gcb)
|
||||||
return gimp_color_area_has_alpha (GIMP_COLOR_AREA (gcb->color_area));
|
return gimp_color_area_has_alpha (GIMP_COLOR_AREA (gcb->color_area));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_color_button_set_type (GimpColorButton *gcb,
|
||||||
|
GimpColorAreaType type)
|
||||||
|
{
|
||||||
|
g_return_if_fail (gcb != NULL);
|
||||||
|
|
||||||
|
gimp_color_area_set_type (GIMP_COLOR_AREA (gcb->color_area), type);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_button_state_changed (GtkWidget *widget,
|
gimp_color_button_state_changed (GtkWidget *widget,
|
||||||
GtkStateType previous_state)
|
GtkStateType previous_state)
|
||||||
|
|
|
@ -29,6 +29,9 @@
|
||||||
#ifndef __GIMP_COLOR_BUTTON_H__
|
#ifndef __GIMP_COLOR_BUTTON_H__
|
||||||
#define __GIMP_COLOR_BUTTON_H__
|
#define __GIMP_COLOR_BUTTON_H__
|
||||||
|
|
||||||
|
#include "libgimp/gimpcolorarea.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
@ -40,8 +43,20 @@ extern "C" {
|
||||||
#define GIMP_IS_COLOR_BUTTON(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_COLOR_BUTTON))
|
#define GIMP_IS_COLOR_BUTTON(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_COLOR_BUTTON))
|
||||||
#define GIMP_IS_COLOR_BUTTON_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_BUTTON))
|
#define GIMP_IS_COLOR_BUTTON_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_BUTTON))
|
||||||
|
|
||||||
|
|
||||||
typedef struct _GimpColorButtonClass GimpColorButtonClass;
|
typedef struct _GimpColorButtonClass GimpColorButtonClass;
|
||||||
|
|
||||||
|
struct _GimpColorButton
|
||||||
|
{
|
||||||
|
GtkButton button;
|
||||||
|
|
||||||
|
gchar *title;
|
||||||
|
|
||||||
|
GtkWidget *color_area;
|
||||||
|
GtkWidget *dialog;
|
||||||
|
GtkItemFactory *item_factory;
|
||||||
|
};
|
||||||
|
|
||||||
struct _GimpColorButtonClass
|
struct _GimpColorButtonClass
|
||||||
{
|
{
|
||||||
GtkButtonClass parent_class;
|
GtkButtonClass parent_class;
|
||||||
|
@ -51,16 +66,18 @@ struct _GimpColorButtonClass
|
||||||
|
|
||||||
|
|
||||||
GtkType gimp_color_button_get_type (void);
|
GtkType gimp_color_button_get_type (void);
|
||||||
GtkWidget * gimp_color_button_new (const gchar *title,
|
GtkWidget * gimp_color_button_new (const gchar *title,
|
||||||
gint width,
|
gint width,
|
||||||
gint height,
|
gint height,
|
||||||
GimpRGB *color,
|
const GimpRGB *color,
|
||||||
gboolean alpha);
|
GimpColorAreaType alpha);
|
||||||
void gimp_color_button_set_color (GimpColorButton *gcb,
|
void gimp_color_button_set_color (GimpColorButton *gcb,
|
||||||
GimpRGB *color);
|
const GimpRGB *color);
|
||||||
void gimp_color_button_get_color (GimpColorButton *gcb,
|
void gimp_color_button_get_color (GimpColorButton *gcb,
|
||||||
GimpRGB *color);/* returns */
|
GimpRGB *color);
|
||||||
gboolean gimp_color_button_has_alpha (GimpColorButton *gcb);
|
gboolean gimp_color_button_has_alpha (GimpColorButton *gcb);
|
||||||
|
void gimp_color_button_set_type (GimpColorButton *gcb,
|
||||||
|
GimpColorAreaType alpha);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -589,7 +589,8 @@ create_light_page (void)
|
||||||
|
|
||||||
colorbutton = gimp_color_button_new (_("Select Lightsource Color"),
|
colorbutton = gimp_color_button_new (_("Select Lightsource Color"),
|
||||||
64, 16,
|
64, 16,
|
||||||
&mapvals.lightsource.color, FALSE);
|
&mapvals.lightsource.color,
|
||||||
|
GIMP_COLOR_AREA_FLAT);
|
||||||
gtk_signal_connect (GTK_OBJECT (colorbutton), "color_changed",
|
gtk_signal_connect (GTK_OBJECT (colorbutton), "color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
&mapvals.lightsource.color);
|
&mapvals.lightsource.color);
|
||||||
|
|
|
@ -732,7 +732,8 @@ create_light_page (void)
|
||||||
|
|
||||||
colorbutton = gimp_color_button_new (_("Select Lightsource Color"),
|
colorbutton = gimp_color_button_new (_("Select Lightsource Color"),
|
||||||
64, 16,
|
64, 16,
|
||||||
&mapvals.lightsource.color, FALSE);
|
&mapvals.lightsource.color,
|
||||||
|
GIMP_COLOR_AREA_FLAT);
|
||||||
gtk_signal_connect (GTK_OBJECT (colorbutton), "color_changed",
|
gtk_signal_connect (GTK_OBJECT (colorbutton), "color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
&mapvals.lightsource.color);
|
&mapvals.lightsource.color);
|
||||||
|
|
|
@ -342,7 +342,8 @@ colorify_dialog (GimpRGB *color)
|
||||||
|
|
||||||
custum_color_button = gimp_color_button_new (_("Colorify Custom Color"),
|
custum_color_button = gimp_color_button_new (_("Colorify Custom Color"),
|
||||||
COLOR_SIZE, COLOR_SIZE,
|
COLOR_SIZE, COLOR_SIZE,
|
||||||
color, FALSE);
|
color,
|
||||||
|
GIMP_COLOR_AREA_FLAT);
|
||||||
gtk_signal_connect (GTK_OBJECT (custum_color_button), "color_changed",
|
gtk_signal_connect (GTK_OBJECT (custum_color_button), "color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
color);
|
color);
|
||||||
|
@ -354,7 +355,8 @@ colorify_dialog (GimpRGB *color)
|
||||||
for (i = 0; i < 7; i++)
|
for (i = 0; i < 7; i++)
|
||||||
{
|
{
|
||||||
button = gtk_button_new ();
|
button = gtk_button_new ();
|
||||||
color_area = gimp_color_area_new (&button_color[i], FALSE,
|
color_area = gimp_color_area_new (&button_color[i],
|
||||||
|
GIMP_COLOR_AREA_FLAT,
|
||||||
GDK_BUTTON2_MASK);
|
GDK_BUTTON2_MASK);
|
||||||
gtk_widget_set_usize (GTK_WIDGET (color_area), COLOR_SIZE, COLOR_SIZE);
|
gtk_widget_set_usize (GTK_WIDGET (color_area), COLOR_SIZE, COLOR_SIZE);
|
||||||
gtk_container_add (GTK_CONTAINER (button), color_area);
|
gtk_container_add (GTK_CONTAINER (button), color_area);
|
||||||
|
|
|
@ -440,7 +440,8 @@ colortoalpha_dialog (GimpDrawable *drawable)
|
||||||
|
|
||||||
button = gimp_color_button_new (_("Color to Alpha Color Picker"),
|
button = gimp_color_button_new (_("Color to Alpha Color Picker"),
|
||||||
PRV_WIDTH, PRV_HEIGHT,
|
PRV_WIDTH, PRV_HEIGHT,
|
||||||
&pvals.color, FALSE);
|
&pvals.color,
|
||||||
|
GIMP_COLOR_AREA_FLAT);
|
||||||
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
&pvals.color);
|
&pvals.color);
|
||||||
|
|
|
@ -362,7 +362,9 @@ exchange_dialog (void)
|
||||||
gtk_widget_show (preview);
|
gtk_widget_show (preview);
|
||||||
|
|
||||||
/* a hidden color_button to handle the threshold more easily */
|
/* a hidden color_button to handle the threshold more easily */
|
||||||
threshold = gimp_color_button_new (NULL, 1, 1, &xargs.threshold, FALSE);
|
threshold = gimp_color_button_new (NULL, 1, 1,
|
||||||
|
&xargs.threshold,
|
||||||
|
GIMP_COLOR_AREA_FLAT);
|
||||||
gtk_signal_connect (GTK_OBJECT (threshold), "color_changed",
|
gtk_signal_connect (GTK_OBJECT (threshold), "color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
&xargs.threshold);
|
&xargs.threshold);
|
||||||
|
@ -390,7 +392,7 @@ exchange_dialog (void)
|
||||||
_("Color Exchange: From Color"),
|
_("Color Exchange: From Color"),
|
||||||
SCALE_WIDTH / 2, 16,
|
SCALE_WIDTH / 2, 16,
|
||||||
framenumber ? &xargs.to : &xargs.from,
|
framenumber ? &xargs.to : &xargs.from,
|
||||||
FALSE);
|
GIMP_COLOR_AREA_FLAT);
|
||||||
gtk_signal_connect (GTK_OBJECT (colorbutton), "color_changed",
|
gtk_signal_connect (GTK_OBJECT (colorbutton), "color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
framenumber ? &xargs.to : &xargs.from);
|
framenumber ? &xargs.to : &xargs.from);
|
||||||
|
|
|
@ -1245,7 +1245,8 @@ film_dialog (gint32 image_ID)
|
||||||
/* Film color */
|
/* Film color */
|
||||||
button = gimp_color_button_new (_("Select Film Color"),
|
button = gimp_color_button_new (_("Select Film Color"),
|
||||||
COLOR_BUTTON_WIDTH, COLOR_BUTTON_HEIGHT,
|
COLOR_BUTTON_WIDTH, COLOR_BUTTON_HEIGHT,
|
||||||
&filmvals.film_color, FALSE);
|
&filmvals.film_color,
|
||||||
|
GIMP_COLOR_AREA_FLAT);
|
||||||
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
&filmvals.film_color);
|
&filmvals.film_color);
|
||||||
|
@ -1293,7 +1294,8 @@ film_dialog (gint32 image_ID)
|
||||||
/* Numbering color */
|
/* Numbering color */
|
||||||
button = gimp_color_button_new (_("Select Number Color"),
|
button = gimp_color_button_new (_("Select Number Color"),
|
||||||
COLOR_BUTTON_WIDTH, COLOR_BUTTON_HEIGHT,
|
COLOR_BUTTON_WIDTH, COLOR_BUTTON_HEIGHT,
|
||||||
&filmvals.number_color, FALSE);
|
&filmvals.number_color,
|
||||||
|
GIMP_COLOR_AREA_FLAT);
|
||||||
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
&filmvals.number_color);
|
&filmvals.number_color);
|
||||||
|
|
|
@ -910,7 +910,8 @@ dialog (gint32 image_ID,
|
||||||
/* attach color selectors */
|
/* attach color selectors */
|
||||||
hcolor_button = gimp_color_button_new (_("Horizontal Color"),
|
hcolor_button = gimp_color_button_new (_("Horizontal Color"),
|
||||||
COLOR_BUTTON_WIDTH, 16,
|
COLOR_BUTTON_WIDTH, 16,
|
||||||
&grid_cfg.hcolor, TRUE);
|
&grid_cfg.hcolor,
|
||||||
|
GIMP_COLOR_AREA_SMALL_CHECKS);
|
||||||
gtk_signal_connect (GTK_OBJECT (hcolor_button), "color_changed",
|
gtk_signal_connect (GTK_OBJECT (hcolor_button), "color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
&grid_cfg.hcolor);
|
&grid_cfg.hcolor);
|
||||||
|
@ -925,7 +926,8 @@ dialog (gint32 image_ID,
|
||||||
|
|
||||||
vcolor_button = gimp_color_button_new (_("Vertical Color"),
|
vcolor_button = gimp_color_button_new (_("Vertical Color"),
|
||||||
COLOR_BUTTON_WIDTH, 16,
|
COLOR_BUTTON_WIDTH, 16,
|
||||||
&grid_cfg.vcolor, TRUE);
|
&grid_cfg.vcolor,
|
||||||
|
GIMP_COLOR_AREA_SMALL_CHECKS);
|
||||||
gtk_signal_connect (GTK_OBJECT (vcolor_button), "color_changed",
|
gtk_signal_connect (GTK_OBJECT (vcolor_button), "color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
&grid_cfg.vcolor);
|
&grid_cfg.vcolor);
|
||||||
|
@ -940,7 +942,8 @@ dialog (gint32 image_ID,
|
||||||
|
|
||||||
button = gimp_color_button_new (_("Intersection Color"),
|
button = gimp_color_button_new (_("Intersection Color"),
|
||||||
COLOR_BUTTON_WIDTH, 16,
|
COLOR_BUTTON_WIDTH, 16,
|
||||||
&grid_cfg.icolor, TRUE);
|
&grid_cfg.icolor,
|
||||||
|
GIMP_COLOR_AREA_SMALL_CHECKS);
|
||||||
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
&grid_cfg.icolor);
|
&grid_cfg.icolor);
|
||||||
|
|
|
@ -653,7 +653,8 @@ add_color_button (gint csel_index,
|
||||||
|
|
||||||
button = gimp_color_button_new (gettext (csel_title[csel_index]),
|
button = gimp_color_button_new (gettext (csel_title[csel_index]),
|
||||||
PRV_WIDTH, PRV_HEIGHT,
|
PRV_WIDTH, PRV_HEIGHT,
|
||||||
&plvals.colors[csel_index], FALSE);
|
&plvals.colors[csel_index],
|
||||||
|
GIMP_COLOR_AREA_FLAT);
|
||||||
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
&plvals.colors[csel_index]);
|
&plvals.colors[csel_index]);
|
||||||
|
|
|
@ -511,7 +511,7 @@ nova_dialog (GimpDrawable *drawable)
|
||||||
|
|
||||||
button = gimp_color_button_new (_("SuperNova Color Picker"),
|
button = gimp_color_button_new (_("SuperNova Color Picker"),
|
||||||
SCALE_WIDTH - 8, 16,
|
SCALE_WIDTH - 8, 16,
|
||||||
&pvals.color, FALSE);
|
&pvals.color, GIMP_COLOR_AREA_FLAT);
|
||||||
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
&pvals.color);
|
&pvals.color);
|
||||||
|
|
|
@ -396,7 +396,9 @@ open_dialog (void)
|
||||||
|
|
||||||
color_button = gimp_color_button_new (_("Background Color"), 100, 16,
|
color_button = gimp_color_button_new (_("Background Color"), 100, 16,
|
||||||
&p.params.background_color,
|
&p.params.background_color,
|
||||||
p.drawable_has_alpha);
|
p.drawable_has_alpha ?
|
||||||
|
GIMP_COLOR_AREA_SMALL_CHECKS :
|
||||||
|
GIMP_COLOR_AREA_FLAT);
|
||||||
gtk_signal_connect (GTK_OBJECT (color_button), "color_changed",
|
gtk_signal_connect (GTK_OBJECT (color_button), "color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
&p.params.background_color);
|
&p.params.background_color);
|
||||||
|
|
|
@ -1893,7 +1893,8 @@ sinus_dialog (void)
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||||
|
|
||||||
push_col1 = gimp_color_button_new (_("First Color"), 32, 32,
|
push_col1 = gimp_color_button_new (_("First Color"), 32, 32,
|
||||||
&svals.col1, TRUE);
|
&svals.col1,
|
||||||
|
GIMP_COLOR_AREA_SMALL_CHECKS);
|
||||||
gtk_signal_connect (GTK_OBJECT (push_col1), "color_changed",
|
gtk_signal_connect (GTK_OBJECT (push_col1), "color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
&svals.col1);
|
&svals.col1);
|
||||||
|
@ -1901,7 +1902,8 @@ sinus_dialog (void)
|
||||||
gtk_widget_show (push_col1);
|
gtk_widget_show (push_col1);
|
||||||
|
|
||||||
push_col2 = gimp_color_button_new (_("Second Color"), 32, 32,
|
push_col2 = gimp_color_button_new (_("Second Color"), 32, 32,
|
||||||
&svals.col2, TRUE);
|
&svals.col2,
|
||||||
|
GIMP_COLOR_AREA_SMALL_CHECKS);
|
||||||
gtk_signal_connect (GTK_OBJECT (push_col2), "color_changed",
|
gtk_signal_connect (GTK_OBJECT (push_col2), "color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
&svals.col2);
|
&svals.col2);
|
||||||
|
|
|
@ -327,8 +327,9 @@ create_main_window (GdtMainWindow **main_window,
|
||||||
(gdouble) (((guint)data->color) >> 8) / 255.0,
|
(gdouble) (((guint)data->color) >> 8) / 255.0,
|
||||||
(gdouble) ((guint)data->color) / 255.0);
|
(gdouble) ((guint)data->color) / 255.0);
|
||||||
color_button = gimp_color_button_new (_("GDynText: Select Color"),
|
color_button = gimp_color_button_new (_("GDynText: Select Color"),
|
||||||
COLOR_PREVIEW_WIDTH, COLOR_PREVIEW_HEIGHT,
|
COLOR_PREVIEW_WIDTH,
|
||||||
&color, FALSE);
|
COLOR_PREVIEW_HEIGHT,
|
||||||
|
&color, GIMP_COLOR_AREA_FLAT);
|
||||||
gtk_signal_connect (GTK_OBJECT (color_button), "color_changed",
|
gtk_signal_connect (GTK_OBJECT (color_button), "color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
&color);
|
&color);
|
||||||
|
|
|
@ -2017,7 +2017,7 @@ color_map_create (gchar *name,
|
||||||
|
|
||||||
color_map->orig_preview =
|
color_map->orig_preview =
|
||||||
gimp_color_area_new (fixed_point ? data : orig_color,
|
gimp_color_area_new (fixed_point ? data : orig_color,
|
||||||
FALSE, 0);
|
GIMP_COLOR_AREA_FLAT, 0);
|
||||||
gtk_drag_dest_unset (color_map->orig_preview);
|
gtk_drag_dest_unset (color_map->orig_preview);
|
||||||
gtk_widget_set_usize (color_map->orig_preview,
|
gtk_widget_set_usize (color_map->orig_preview,
|
||||||
COLOR_SAMPLE_SIZE, COLOR_SAMPLE_SIZE);
|
COLOR_SAMPLE_SIZE, COLOR_SAMPLE_SIZE);
|
||||||
|
@ -2031,7 +2031,8 @@ color_map_create (gchar *name,
|
||||||
color_map->button = gimp_color_button_new (name,
|
color_map->button = gimp_color_button_new (name,
|
||||||
COLOR_SAMPLE_SIZE,
|
COLOR_SAMPLE_SIZE,
|
||||||
COLOR_SAMPLE_SIZE,
|
COLOR_SAMPLE_SIZE,
|
||||||
data, FALSE);
|
data,
|
||||||
|
GIMP_COLOR_AREA_FLAT);
|
||||||
gtk_box_pack_start (GTK_BOX (color_map->hbox), color_map->button,
|
gtk_box_pack_start (GTK_BOX (color_map->hbox), color_map->button,
|
||||||
FALSE, FALSE, 0);
|
FALSE, FALSE, 0);
|
||||||
gtk_widget_show (color_map->button);
|
gtk_widget_show (color_map->button);
|
||||||
|
|
|
@ -1302,7 +1302,8 @@ script_fu_interface (SFScript *script)
|
||||||
sf_interface->args_widgets[i] =
|
sf_interface->args_widgets[i] =
|
||||||
gimp_color_button_new (_("Script-Fu Color Selection"),
|
gimp_color_button_new (_("Script-Fu Color Selection"),
|
||||||
COLOR_SAMPLE_WIDTH, COLOR_SAMPLE_HEIGHT,
|
COLOR_SAMPLE_WIDTH, COLOR_SAMPLE_HEIGHT,
|
||||||
&script->arg_values[i].sfa_color, FALSE);
|
&script->arg_values[i].sfa_color,
|
||||||
|
GIMP_COLOR_AREA_FLAT);
|
||||||
gtk_signal_connect (GTK_OBJECT (sf_interface->args_widgets[i]),
|
gtk_signal_connect (GTK_OBJECT (sf_interface->args_widgets[i]),
|
||||||
"color_changed",
|
"color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
|
|
|
@ -1302,7 +1302,8 @@ script_fu_interface (SFScript *script)
|
||||||
sf_interface->args_widgets[i] =
|
sf_interface->args_widgets[i] =
|
||||||
gimp_color_button_new (_("Script-Fu Color Selection"),
|
gimp_color_button_new (_("Script-Fu Color Selection"),
|
||||||
COLOR_SAMPLE_WIDTH, COLOR_SAMPLE_HEIGHT,
|
COLOR_SAMPLE_WIDTH, COLOR_SAMPLE_HEIGHT,
|
||||||
&script->arg_values[i].sfa_color, FALSE);
|
&script->arg_values[i].sfa_color,
|
||||||
|
GIMP_COLOR_AREA_FLAT);
|
||||||
gtk_signal_connect (GTK_OBJECT (sf_interface->args_widgets[i]),
|
gtk_signal_connect (GTK_OBJECT (sf_interface->args_widgets[i]),
|
||||||
"color_changed",
|
"color_changed",
|
||||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||||
|
|
Loading…
Reference in New Issue