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>
|
||||
|
||||
* app/channel.[ch]
|
||||
|
|
|
@ -47,10 +47,9 @@ struct _EditQmaskOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
GtkWidget *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||
|
@ -65,6 +64,8 @@ static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gpointer client_data);
|
||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data);
|
||||
static void qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data);
|
||||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
|
@ -74,11 +75,22 @@ static void
|
|||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
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
|
||||
|
@ -260,9 +272,10 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
/* the new options structure */
|
||||
options = g_new (EditQmaskOptions, 1);
|
||||
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 */
|
||||
options->query_box =
|
||||
|
@ -301,19 +314,23 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
gtk_widget_show (label);
|
||||
|
||||
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));
|
||||
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_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||
&options->color);
|
||||
options->color_panel);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* 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);
|
||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
||||
gtk_widget_show (options->color_panel);
|
||||
|
||||
gtk_widget_show (table);
|
||||
gtk_widget_show (vbox);
|
||||
|
@ -327,24 +344,25 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditQmaskOptions *options;
|
||||
Channel *channel;
|
||||
GimpRGB color;
|
||||
|
||||
options = (EditQmaskOptions *) client_data;
|
||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
if (options->gimage && channel)
|
||||
{
|
||||
if (gimp_rgba_distance (&channel->color,
|
||||
&options->color_panel->color) > 0.0001)
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||
&color);
|
||||
|
||||
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||
{
|
||||
channel_set_color (channel, &options->color_panel->color);
|
||||
channel->color = color;
|
||||
channel_update (channel);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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);
|
||||
g_free (options);
|
||||
|
|
|
@ -47,10 +47,9 @@ struct _EditQmaskOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
GtkWidget *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||
|
@ -65,6 +64,8 @@ static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gpointer client_data);
|
||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data);
|
||||
static void qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data);
|
||||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
|
@ -74,11 +75,22 @@ static void
|
|||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
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
|
||||
|
@ -260,9 +272,10 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
/* the new options structure */
|
||||
options = g_new (EditQmaskOptions, 1);
|
||||
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 */
|
||||
options->query_box =
|
||||
|
@ -301,19 +314,23 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
gtk_widget_show (label);
|
||||
|
||||
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));
|
||||
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_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||
&options->color);
|
||||
options->color_panel);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* 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);
|
||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
||||
gtk_widget_show (options->color_panel);
|
||||
|
||||
gtk_widget_show (table);
|
||||
gtk_widget_show (vbox);
|
||||
|
@ -327,24 +344,25 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditQmaskOptions *options;
|
||||
Channel *channel;
|
||||
GimpRGB color;
|
||||
|
||||
options = (EditQmaskOptions *) client_data;
|
||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
if (options->gimage && channel)
|
||||
{
|
||||
if (gimp_rgba_distance (&channel->color,
|
||||
&options->color_panel->color) > 0.0001)
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||
&color);
|
||||
|
||||
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||
{
|
||||
channel_set_color (channel, &options->color_panel->color);
|
||||
channel->color = color;
|
||||
channel_update (channel);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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);
|
||||
g_free (options);
|
||||
|
|
|
@ -204,6 +204,8 @@ static void channel_widget_channel_flush (GtkWidget *widget,
|
|||
|
||||
static void channels_dialog_opacity_update (GtkAdjustment *adjustment,
|
||||
gpointer data);
|
||||
static void channels_dialog_color_changed (GimpColorButton *button,
|
||||
gpointer data);
|
||||
|
||||
/* assorted query dialogs */
|
||||
static void channels_dialog_new_channel_query (GimpImage *gimage);
|
||||
|
@ -2463,11 +2465,22 @@ static void
|
|||
channels_dialog_opacity_update (GtkAdjustment *adjustment,
|
||||
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 *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
GtkWidget *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
static gchar *channel_name = NULL;
|
||||
|
@ -2506,16 +2518,14 @@ new_channel_query_ok_callback (GtkWidget *widget,
|
|||
|
||||
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,
|
||||
channel_name,
|
||||
&options->color_panel->color);
|
||||
&channel_color);
|
||||
|
||||
drawable_fill (GIMP_DRAWABLE (new_channel), TRANSPARENT_FILL);
|
||||
|
||||
channel_color = options->color_panel->color;
|
||||
|
||||
gimp_image_add_channel (gimage, new_channel, -1);
|
||||
gdisplays_flush ();
|
||||
}
|
||||
|
@ -2537,9 +2547,8 @@ channels_dialog_new_channel_query (GimpImage* gimage)
|
|||
/* the new options structure */
|
||||
options = g_new (NewChannelOptions, 1);
|
||||
options->gimage = gimage;
|
||||
options->color = channel_color;
|
||||
options->color_panel = color_panel_new (&channel_color,
|
||||
FALSE,
|
||||
options->color_panel = gimp_color_panel_new (&channel_color,
|
||||
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||
48, 64);
|
||||
|
||||
/* The dialog */
|
||||
|
@ -2599,20 +2608,23 @@ channels_dialog_new_channel_query (GimpImage* gimage)
|
|||
gtk_widget_show (label);
|
||||
|
||||
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));
|
||||
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_range_set_update_policy (GTK_RANGE (opacity_scale), GTK_UPDATE_DELAYED);
|
||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
|
||||
&options->color);
|
||||
options->color_panel);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* 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);
|
||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
||||
gtk_widget_show (options->color_panel);
|
||||
|
||||
gtk_widget_show (table);
|
||||
gtk_widget_show (vbox);
|
||||
|
@ -2630,11 +2642,10 @@ struct _EditChannelOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
GtkWidget *color_panel;
|
||||
|
||||
ChannelWidget *channel_widget;
|
||||
GimpImage *gimage;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -2643,6 +2654,7 @@ edit_channel_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditChannelOptions *options;
|
||||
Channel *channel;
|
||||
GimpRGB color;
|
||||
|
||||
options = (EditChannelOptions *) data;
|
||||
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),
|
||||
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,
|
||||
&channel->color) > 0.0001)
|
||||
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||
{
|
||||
channel->color = options->color_panel->color;
|
||||
|
||||
channel->color = color;
|
||||
drawable_update (GIMP_DRAWABLE (channel), 0, 0,
|
||||
GIMP_DRAWABLE (channel)->width,
|
||||
GIMP_DRAWABLE (channel)->height);
|
||||
|
@ -2687,12 +2698,11 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
|
|||
options = g_new (EditChannelOptions, 1);
|
||||
options->channel_widget = channel_widget;
|
||||
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,
|
||||
FALSE,
|
||||
options->color_panel = gimp_color_panel_new (&channel_color,
|
||||
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||
48, 64);
|
||||
|
||||
/* The dialog */
|
||||
|
@ -2753,19 +2763,22 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
|
|||
gtk_widget_show (label);
|
||||
|
||||
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));
|
||||
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_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
|
||||
&options->color);
|
||||
options->color_panel);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* 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);
|
||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
||||
gtk_widget_show (options->color_panel);
|
||||
|
||||
gtk_widget_show (table);
|
||||
gtk_widget_show (vbox);
|
||||
|
|
|
@ -25,305 +25,188 @@
|
|||
#include "appenv.h"
|
||||
#include "color_panel.h"
|
||||
#include "color_notebook.h"
|
||||
#include "colormaps.h"
|
||||
#include "gimpdnd.h"
|
||||
|
||||
|
||||
#define EVENT_MASK GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK
|
||||
|
||||
typedef struct _ColorPanelPrivate ColorPanelPrivate;
|
||||
|
||||
struct _ColorPanelPrivate
|
||||
struct _GimpColorPanel
|
||||
{
|
||||
GtkWidget *drawing_area;
|
||||
GdkGC *gc;
|
||||
|
||||
gboolean show_alpha;
|
||||
gboolean button_down;
|
||||
GimpColorButton parent;
|
||||
|
||||
ColorNotebook *color_notebook;
|
||||
gboolean color_notebook_active;
|
||||
};
|
||||
|
||||
/* local function prototypes */
|
||||
static void color_panel_free (ColorPanel *color_panel);
|
||||
static void color_panel_draw (ColorPanel *color_panel);
|
||||
static gint color_panel_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static void color_panel_select_callback (GimpRGB *color,
|
||||
static void gimp_color_panel_class_init (GimpColorPanelClass *klass);
|
||||
static void gimp_color_panel_init (GimpColorPanel *panel);
|
||||
static void gimp_color_panel_destroy (GtkObject *object);
|
||||
static void gimp_color_panel_color_changed (GimpColorButton *button);
|
||||
static void gimp_color_panel_clicked (GtkButton *button);
|
||||
|
||||
static void gimp_color_panel_select_callback (GimpRGB *color,
|
||||
ColorNotebookState state,
|
||||
gpointer data);
|
||||
|
||||
static void color_panel_drag_color (GtkWidget *widget,
|
||||
GimpRGB *color,
|
||||
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;
|
||||
|
||||
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
|
||||
};
|
||||
static guint n_color_panel_targets = (sizeof (color_panel_target_table) /
|
||||
sizeof (color_panel_target_table[0]));
|
||||
|
||||
/* public functions */
|
||||
panel_type = gtk_type_unique (GIMP_TYPE_COLOR_BUTTON, &panel_info);
|
||||
}
|
||||
|
||||
ColorPanel *
|
||||
color_panel_new (GimpRGB *color,
|
||||
gboolean show_alpha,
|
||||
return panel_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_panel_class_init (GimpColorPanelClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
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)
|
||||
{
|
||||
ColorPanel *color_panel;
|
||||
ColorPanelPrivate *private;
|
||||
GimpColorPanel *panel;
|
||||
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
private = g_new0 (ColorPanelPrivate, 1);
|
||||
private->color_notebook = NULL;
|
||||
private->color_notebook_active = FALSE;
|
||||
private->gc = NULL;
|
||||
private->show_alpha = show_alpha;
|
||||
private->button_down = FALSE;
|
||||
panel = gtk_type_new (gimp_color_panel_get_type ());
|
||||
|
||||
color_panel = g_new (ColorPanel, 1);
|
||||
color_panel->private_part = private;
|
||||
gimp_color_button_set_type (GIMP_COLOR_BUTTON (panel), type);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (panel), color);
|
||||
gtk_widget_set_usize (GTK_WIDGET (panel), width, height);
|
||||
|
||||
color_panel->color = *color;
|
||||
|
||||
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
|
||||
color_panel_free (ColorPanel *color_panel)
|
||||
{
|
||||
ColorPanelPrivate *private;
|
||||
|
||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
||||
|
||||
/* make sure we hide and free color_notebook */
|
||||
if (private->color_notebook)
|
||||
{
|
||||
color_notebook_hide (private->color_notebook);
|
||||
color_notebook_free (private->color_notebook);
|
||||
}
|
||||
|
||||
if (private->gc)
|
||||
gdk_gc_destroy (private->gc);
|
||||
|
||||
g_free (color_panel->private_part);
|
||||
g_free (color_panel);
|
||||
return GTK_WIDGET (panel);
|
||||
}
|
||||
|
||||
static void
|
||||
color_panel_draw (ColorPanel *color_panel)
|
||||
gimp_color_panel_color_changed (GimpColorButton *button)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
ColorPanelPrivate *private;
|
||||
GdkColor fg;
|
||||
guchar r, g, b;
|
||||
GimpColorPanel *panel;
|
||||
GimpRGB color;
|
||||
|
||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
||||
widget = private->drawing_area;
|
||||
panel = GIMP_COLOR_PANEL (button);
|
||||
|
||||
gimp_rgb_get_uchar (&color_panel->color, &r, &g, &b);
|
||||
|
||||
fg.pixel = get_color (r, g, b);
|
||||
|
||||
gdk_gc_set_foreground (private->gc, &fg);
|
||||
gdk_draw_rectangle (widget->window, private->gc, 1, 0, 0,
|
||||
widget->allocation.width, widget->allocation.height);
|
||||
if (panel->color_notebook_active)
|
||||
{
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &color);
|
||||
color_notebook_set_color (panel->color_notebook, &color);
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
color_panel_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
static void
|
||||
gimp_color_panel_clicked (GtkButton *button)
|
||||
{
|
||||
GdkEventButton *bevent;
|
||||
ColorPanel *color_panel;
|
||||
ColorPanelPrivate *private;
|
||||
GimpColorPanel *panel;
|
||||
GimpRGB color;
|
||||
|
||||
color_panel = (ColorPanel *) data;
|
||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
||||
panel = GIMP_COLOR_PANEL (button);
|
||||
|
||||
switch (event->type)
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &color);
|
||||
|
||||
if (! panel->color_notebook)
|
||||
{
|
||||
case GDK_EXPOSE:
|
||||
if (!private->gc)
|
||||
private->gc = gdk_gc_new (widget->window);
|
||||
|
||||
color_panel_draw (color_panel);
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button == 1)
|
||||
private->button_down = TRUE;
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_RELEASE:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button == 1 &&
|
||||
private->button_down)
|
||||
{
|
||||
if (! private->color_notebook)
|
||||
{
|
||||
private->color_notebook =
|
||||
color_notebook_new (&color_panel->color,
|
||||
color_panel_select_callback,
|
||||
color_panel,
|
||||
panel->color_notebook =
|
||||
color_notebook_new (&color,
|
||||
gimp_color_panel_select_callback,
|
||||
panel,
|
||||
FALSE,
|
||||
private->show_alpha);
|
||||
private->color_notebook_active = TRUE;
|
||||
gimp_color_button_has_alpha (GIMP_COLOR_BUTTON (button)));
|
||||
panel->color_notebook_active = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! private->color_notebook_active)
|
||||
if (! panel->color_notebook_active)
|
||||
{
|
||||
color_notebook_show (private->color_notebook);
|
||||
private->color_notebook_active = TRUE;
|
||||
color_notebook_show (panel->color_notebook);
|
||||
panel->color_notebook_active = TRUE;
|
||||
}
|
||||
color_notebook_set_color (private->color_notebook,
|
||||
&color_panel->color);
|
||||
color_notebook_set_color (panel->color_notebook, &color);
|
||||
}
|
||||
private->button_down = FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_LEAVE_NOTIFY:
|
||||
private->button_down = FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
color_panel_select_callback (GimpRGB *color,
|
||||
gimp_color_panel_select_callback (GimpRGB *color,
|
||||
ColorNotebookState state,
|
||||
gpointer data)
|
||||
{
|
||||
ColorPanel *color_panel;
|
||||
ColorPanelPrivate *private;
|
||||
GimpColorPanel *panel;
|
||||
|
||||
color_panel = (ColorPanel *) data;
|
||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
||||
panel = GIMP_COLOR_PANEL (data);
|
||||
|
||||
if (private->color_notebook)
|
||||
if (panel->color_notebook)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case COLOR_NOTEBOOK_UPDATE:
|
||||
break;
|
||||
case COLOR_NOTEBOOK_OK:
|
||||
color_panel->color = *color;
|
||||
|
||||
color_panel_draw (color_panel);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (panel), color);
|
||||
/* Fallthrough */
|
||||
case COLOR_NOTEBOOK_CANCEL:
|
||||
color_notebook_hide (private->color_notebook);
|
||||
private->color_notebook_active = FALSE;
|
||||
color_notebook_hide (panel->color_notebook);
|
||||
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__
|
||||
|
||||
|
||||
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 */
|
||||
GtkWidget *color_panel_widget;
|
||||
|
||||
/* The actual color */
|
||||
GimpRGB color;
|
||||
|
||||
/* Don't touch this :) */
|
||||
gpointer private_part;
|
||||
GimpColorButtonClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
ColorPanel * color_panel_new (GimpRGB *color,
|
||||
gboolean show_alpha,
|
||||
GtkType gimp_color_panel_get_type (void);
|
||||
GtkWidget * gimp_color_panel_new (const GimpRGB *color,
|
||||
GimpColorAreaType type,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
void color_panel_set_color (ColorPanel *color_panel,
|
||||
GimpRGB *color);
|
||||
|
||||
|
||||
#endif /* __COLOR_PANEL_H__ */
|
||||
|
|
|
@ -22,8 +22,9 @@
|
|||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "libgimp/gimpcolorarea.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "color_panel.h"
|
||||
#include "color_picker.h"
|
||||
#include "draw_core.h"
|
||||
#include "drawable.h"
|
||||
|
@ -88,7 +89,7 @@ gint col_value[5] = { 0, 0, 0, 0, 0 };
|
|||
static gint update_type;
|
||||
static GimpImageType sample_type;
|
||||
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 green_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)
|
||||
{
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *frame;
|
||||
GimpRGB color;
|
||||
|
||||
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);
|
||||
|
||||
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_drawable_has_alpha (tool->drawable),
|
||||
48, 64);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), color_panel->color_panel_widget,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (color_panel->color_panel_widget);
|
||||
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0);
|
||||
color_area = gimp_color_area_new (&color,
|
||||
gimp_drawable_has_alpha (tool->drawable) ? GIMP_COLOR_AREA_LARGE_CHECKS : GIMP_COLOR_AREA_FLAT, 0);
|
||||
gtk_widget_set_usize (GTK_WIDGET (color_area), 48, 64);
|
||||
gtk_container_add (GTK_CONTAINER (frame), color_area);
|
||||
gtk_widget_show (color_area);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
/* create the action area */
|
||||
gimp_dialog_create_action_area
|
||||
|
@ -643,8 +648,8 @@ color_picker_info_update (Tool *tool,
|
|||
{
|
||||
if (!valid)
|
||||
{
|
||||
if (GTK_WIDGET_IS_SENSITIVE (color_panel->color_panel_widget))
|
||||
gtk_widget_set_sensitive (color_panel->color_panel_widget, FALSE);
|
||||
if (GTK_WIDGET_IS_SENSITIVE (color_area))
|
||||
gtk_widget_set_sensitive (color_area, FALSE);
|
||||
|
||||
g_snprintf (red_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 a = 0;
|
||||
|
||||
if (! GTK_WIDGET_IS_SENSITIVE (color_panel->color_panel_widget))
|
||||
gtk_widget_set_sensitive (color_panel->color_panel_widget, TRUE);
|
||||
if (! GTK_WIDGET_IS_SENSITIVE (color_area))
|
||||
gtk_widget_set_sensitive (color_area, TRUE);
|
||||
|
||||
switch (sample_type)
|
||||
{
|
||||
|
@ -730,7 +735,7 @@ color_picker_info_update (Tool *tool,
|
|||
|
||||
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);
|
||||
|
@ -792,7 +797,7 @@ tools_free_color_picker (Tool *tool)
|
|||
info_dialog_free (color_picker_info);
|
||||
color_picker_info = NULL;
|
||||
|
||||
color_panel = NULL;
|
||||
color_area = NULL;
|
||||
}
|
||||
|
||||
g_free (cp_tool);
|
||||
|
|
|
@ -47,10 +47,9 @@ struct _EditQmaskOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
GtkWidget *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||
|
@ -65,6 +64,8 @@ static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gpointer client_data);
|
||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data);
|
||||
static void qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data);
|
||||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
|
@ -74,11 +75,22 @@ static void
|
|||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
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
|
||||
|
@ -260,9 +272,10 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
/* the new options structure */
|
||||
options = g_new (EditQmaskOptions, 1);
|
||||
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 */
|
||||
options->query_box =
|
||||
|
@ -301,19 +314,23 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
gtk_widget_show (label);
|
||||
|
||||
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));
|
||||
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_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||
&options->color);
|
||||
options->color_panel);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* 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);
|
||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
||||
gtk_widget_show (options->color_panel);
|
||||
|
||||
gtk_widget_show (table);
|
||||
gtk_widget_show (vbox);
|
||||
|
@ -327,24 +344,25 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditQmaskOptions *options;
|
||||
Channel *channel;
|
||||
GimpRGB color;
|
||||
|
||||
options = (EditQmaskOptions *) client_data;
|
||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
if (options->gimage && channel)
|
||||
{
|
||||
if (gimp_rgba_distance (&channel->color,
|
||||
&options->color_panel->color) > 0.0001)
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||
&color);
|
||||
|
||||
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||
{
|
||||
channel_set_color (channel, &options->color_panel->color);
|
||||
channel->color = color;
|
||||
channel_update (channel);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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);
|
||||
g_free (options);
|
||||
|
|
|
@ -47,10 +47,9 @@ struct _EditQmaskOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
GtkWidget *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||
|
@ -65,6 +64,8 @@ static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gpointer client_data);
|
||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data);
|
||||
static void qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data);
|
||||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
|
@ -74,11 +75,22 @@ static void
|
|||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
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
|
||||
|
@ -260,9 +272,10 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
/* the new options structure */
|
||||
options = g_new (EditQmaskOptions, 1);
|
||||
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 */
|
||||
options->query_box =
|
||||
|
@ -301,19 +314,23 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
gtk_widget_show (label);
|
||||
|
||||
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));
|
||||
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_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||
&options->color);
|
||||
options->color_panel);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* 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);
|
||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
||||
gtk_widget_show (options->color_panel);
|
||||
|
||||
gtk_widget_show (table);
|
||||
gtk_widget_show (vbox);
|
||||
|
@ -327,24 +344,25 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditQmaskOptions *options;
|
||||
Channel *channel;
|
||||
GimpRGB color;
|
||||
|
||||
options = (EditQmaskOptions *) client_data;
|
||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
if (options->gimage && channel)
|
||||
{
|
||||
if (gimp_rgba_distance (&channel->color,
|
||||
&options->color_panel->color) > 0.0001)
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||
&color);
|
||||
|
||||
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||
{
|
||||
channel_set_color (channel, &options->color_panel->color);
|
||||
channel->color = color;
|
||||
channel_update (channel);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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);
|
||||
g_free (options);
|
||||
|
|
|
@ -47,10 +47,9 @@ struct _EditQmaskOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
GtkWidget *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||
|
@ -65,6 +64,8 @@ static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gpointer client_data);
|
||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data);
|
||||
static void qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data);
|
||||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
|
@ -74,11 +75,22 @@ static void
|
|||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
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
|
||||
|
@ -260,9 +272,10 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
/* the new options structure */
|
||||
options = g_new (EditQmaskOptions, 1);
|
||||
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 */
|
||||
options->query_box =
|
||||
|
@ -301,19 +314,23 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
gtk_widget_show (label);
|
||||
|
||||
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));
|
||||
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_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||
&options->color);
|
||||
options->color_panel);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* 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);
|
||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
||||
gtk_widget_show (options->color_panel);
|
||||
|
||||
gtk_widget_show (table);
|
||||
gtk_widget_show (vbox);
|
||||
|
@ -327,24 +344,25 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditQmaskOptions *options;
|
||||
Channel *channel;
|
||||
GimpRGB color;
|
||||
|
||||
options = (EditQmaskOptions *) client_data;
|
||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
if (options->gimage && channel)
|
||||
{
|
||||
if (gimp_rgba_distance (&channel->color,
|
||||
&options->color_panel->color) > 0.0001)
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||
&color);
|
||||
|
||||
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||
{
|
||||
channel_set_color (channel, &options->color_panel->color);
|
||||
channel->color = color;
|
||||
channel_update (channel);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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);
|
||||
g_free (options);
|
||||
|
|
|
@ -204,6 +204,8 @@ static void channel_widget_channel_flush (GtkWidget *widget,
|
|||
|
||||
static void channels_dialog_opacity_update (GtkAdjustment *adjustment,
|
||||
gpointer data);
|
||||
static void channels_dialog_color_changed (GimpColorButton *button,
|
||||
gpointer data);
|
||||
|
||||
/* assorted query dialogs */
|
||||
static void channels_dialog_new_channel_query (GimpImage *gimage);
|
||||
|
@ -2463,11 +2465,22 @@ static void
|
|||
channels_dialog_opacity_update (GtkAdjustment *adjustment,
|
||||
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 *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
GtkWidget *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
static gchar *channel_name = NULL;
|
||||
|
@ -2506,16 +2518,14 @@ new_channel_query_ok_callback (GtkWidget *widget,
|
|||
|
||||
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,
|
||||
channel_name,
|
||||
&options->color_panel->color);
|
||||
&channel_color);
|
||||
|
||||
drawable_fill (GIMP_DRAWABLE (new_channel), TRANSPARENT_FILL);
|
||||
|
||||
channel_color = options->color_panel->color;
|
||||
|
||||
gimp_image_add_channel (gimage, new_channel, -1);
|
||||
gdisplays_flush ();
|
||||
}
|
||||
|
@ -2537,9 +2547,8 @@ channels_dialog_new_channel_query (GimpImage* gimage)
|
|||
/* the new options structure */
|
||||
options = g_new (NewChannelOptions, 1);
|
||||
options->gimage = gimage;
|
||||
options->color = channel_color;
|
||||
options->color_panel = color_panel_new (&channel_color,
|
||||
FALSE,
|
||||
options->color_panel = gimp_color_panel_new (&channel_color,
|
||||
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||
48, 64);
|
||||
|
||||
/* The dialog */
|
||||
|
@ -2599,20 +2608,23 @@ channels_dialog_new_channel_query (GimpImage* gimage)
|
|||
gtk_widget_show (label);
|
||||
|
||||
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));
|
||||
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_range_set_update_policy (GTK_RANGE (opacity_scale), GTK_UPDATE_DELAYED);
|
||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
|
||||
&options->color);
|
||||
options->color_panel);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* 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);
|
||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
||||
gtk_widget_show (options->color_panel);
|
||||
|
||||
gtk_widget_show (table);
|
||||
gtk_widget_show (vbox);
|
||||
|
@ -2630,11 +2642,10 @@ struct _EditChannelOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
GtkWidget *color_panel;
|
||||
|
||||
ChannelWidget *channel_widget;
|
||||
GimpImage *gimage;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -2643,6 +2654,7 @@ edit_channel_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditChannelOptions *options;
|
||||
Channel *channel;
|
||||
GimpRGB color;
|
||||
|
||||
options = (EditChannelOptions *) data;
|
||||
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),
|
||||
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,
|
||||
&channel->color) > 0.0001)
|
||||
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||
{
|
||||
channel->color = options->color_panel->color;
|
||||
|
||||
channel->color = color;
|
||||
drawable_update (GIMP_DRAWABLE (channel), 0, 0,
|
||||
GIMP_DRAWABLE (channel)->width,
|
||||
GIMP_DRAWABLE (channel)->height);
|
||||
|
@ -2687,12 +2698,11 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
|
|||
options = g_new (EditChannelOptions, 1);
|
||||
options->channel_widget = channel_widget;
|
||||
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,
|
||||
FALSE,
|
||||
options->color_panel = gimp_color_panel_new (&channel_color,
|
||||
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||
48, 64);
|
||||
|
||||
/* The dialog */
|
||||
|
@ -2753,19 +2763,22 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
|
|||
gtk_widget_show (label);
|
||||
|
||||
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));
|
||||
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_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
|
||||
&options->color);
|
||||
options->color_panel);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* 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);
|
||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
||||
gtk_widget_show (options->color_panel);
|
||||
|
||||
gtk_widget_show (table);
|
||||
gtk_widget_show (vbox);
|
||||
|
|
|
@ -47,10 +47,9 @@ struct _EditQmaskOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
GtkWidget *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||
|
@ -65,6 +64,8 @@ static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gpointer client_data);
|
||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data);
|
||||
static void qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data);
|
||||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
|
@ -74,11 +75,22 @@ static void
|
|||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
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
|
||||
|
@ -260,9 +272,10 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
/* the new options structure */
|
||||
options = g_new (EditQmaskOptions, 1);
|
||||
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 */
|
||||
options->query_box =
|
||||
|
@ -301,19 +314,23 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
gtk_widget_show (label);
|
||||
|
||||
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));
|
||||
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_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||
&options->color);
|
||||
options->color_panel);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* 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);
|
||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
||||
gtk_widget_show (options->color_panel);
|
||||
|
||||
gtk_widget_show (table);
|
||||
gtk_widget_show (vbox);
|
||||
|
@ -327,24 +344,25 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditQmaskOptions *options;
|
||||
Channel *channel;
|
||||
GimpRGB color;
|
||||
|
||||
options = (EditQmaskOptions *) client_data;
|
||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
if (options->gimage && channel)
|
||||
{
|
||||
if (gimp_rgba_distance (&channel->color,
|
||||
&options->color_panel->color) > 0.0001)
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||
&color);
|
||||
|
||||
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||
{
|
||||
channel_set_color (channel, &options->color_panel->color);
|
||||
channel->color = color;
|
||||
channel_update (channel);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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);
|
||||
g_free (options);
|
||||
|
|
52
app/qmask.c
52
app/qmask.c
|
@ -47,10 +47,9 @@ struct _EditQmaskOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
GtkWidget *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||
|
@ -65,6 +64,8 @@ static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gpointer client_data);
|
||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data);
|
||||
static void qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data);
|
||||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
|
@ -74,11 +75,22 @@ static void
|
|||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
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
|
||||
|
@ -260,9 +272,10 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
/* the new options structure */
|
||||
options = g_new (EditQmaskOptions, 1);
|
||||
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 */
|
||||
options->query_box =
|
||||
|
@ -301,19 +314,23 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
gtk_widget_show (label);
|
||||
|
||||
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));
|
||||
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_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||
&options->color);
|
||||
options->color_panel);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* 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);
|
||||
gtk_widget_show (options->color_panel->color_panel_widget);
|
||||
gtk_widget_show (options->color_panel);
|
||||
|
||||
gtk_widget_show (table);
|
||||
gtk_widget_show (vbox);
|
||||
|
@ -327,24 +344,25 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditQmaskOptions *options;
|
||||
Channel *channel;
|
||||
GimpRGB color;
|
||||
|
||||
options = (EditQmaskOptions *) client_data;
|
||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
if (options->gimage && channel)
|
||||
{
|
||||
if (gimp_rgba_distance (&channel->color,
|
||||
&options->color_panel->color) > 0.0001)
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||
&color);
|
||||
|
||||
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||
{
|
||||
channel_set_color (channel, &options->color_panel->color);
|
||||
channel->color = color;
|
||||
channel_update (channel);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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);
|
||||
g_free (options);
|
||||
|
|
|
@ -22,8 +22,9 @@
|
|||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "libgimp/gimpcolorarea.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "color_panel.h"
|
||||
#include "color_picker.h"
|
||||
#include "draw_core.h"
|
||||
#include "drawable.h"
|
||||
|
@ -88,7 +89,7 @@ gint col_value[5] = { 0, 0, 0, 0, 0 };
|
|||
static gint update_type;
|
||||
static GimpImageType sample_type;
|
||||
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 green_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)
|
||||
{
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *frame;
|
||||
GimpRGB color;
|
||||
|
||||
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);
|
||||
|
||||
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_drawable_has_alpha (tool->drawable),
|
||||
48, 64);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), color_panel->color_panel_widget,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (color_panel->color_panel_widget);
|
||||
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0);
|
||||
color_area = gimp_color_area_new (&color,
|
||||
gimp_drawable_has_alpha (tool->drawable) ? GIMP_COLOR_AREA_LARGE_CHECKS : GIMP_COLOR_AREA_FLAT, 0);
|
||||
gtk_widget_set_usize (GTK_WIDGET (color_area), 48, 64);
|
||||
gtk_container_add (GTK_CONTAINER (frame), color_area);
|
||||
gtk_widget_show (color_area);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
/* create the action area */
|
||||
gimp_dialog_create_action_area
|
||||
|
@ -643,8 +648,8 @@ color_picker_info_update (Tool *tool,
|
|||
{
|
||||
if (!valid)
|
||||
{
|
||||
if (GTK_WIDGET_IS_SENSITIVE (color_panel->color_panel_widget))
|
||||
gtk_widget_set_sensitive (color_panel->color_panel_widget, FALSE);
|
||||
if (GTK_WIDGET_IS_SENSITIVE (color_area))
|
||||
gtk_widget_set_sensitive (color_area, FALSE);
|
||||
|
||||
g_snprintf (red_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 a = 0;
|
||||
|
||||
if (! GTK_WIDGET_IS_SENSITIVE (color_panel->color_panel_widget))
|
||||
gtk_widget_set_sensitive (color_panel->color_panel_widget, TRUE);
|
||||
if (! GTK_WIDGET_IS_SENSITIVE (color_area))
|
||||
gtk_widget_set_sensitive (color_area, TRUE);
|
||||
|
||||
switch (sample_type)
|
||||
{
|
||||
|
@ -730,7 +735,7 @@ color_picker_info_update (Tool *tool,
|
|||
|
||||
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);
|
||||
|
@ -792,7 +797,7 @@ tools_free_color_picker (Tool *tool)
|
|||
info_dialog_free (color_picker_info);
|
||||
color_picker_info = NULL;
|
||||
|
||||
color_panel = NULL;
|
||||
color_area = NULL;
|
||||
}
|
||||
|
||||
g_free (cp_tool);
|
||||
|
|
|
@ -25,305 +25,188 @@
|
|||
#include "appenv.h"
|
||||
#include "color_panel.h"
|
||||
#include "color_notebook.h"
|
||||
#include "colormaps.h"
|
||||
#include "gimpdnd.h"
|
||||
|
||||
|
||||
#define EVENT_MASK GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK
|
||||
|
||||
typedef struct _ColorPanelPrivate ColorPanelPrivate;
|
||||
|
||||
struct _ColorPanelPrivate
|
||||
struct _GimpColorPanel
|
||||
{
|
||||
GtkWidget *drawing_area;
|
||||
GdkGC *gc;
|
||||
|
||||
gboolean show_alpha;
|
||||
gboolean button_down;
|
||||
GimpColorButton parent;
|
||||
|
||||
ColorNotebook *color_notebook;
|
||||
gboolean color_notebook_active;
|
||||
};
|
||||
|
||||
/* local function prototypes */
|
||||
static void color_panel_free (ColorPanel *color_panel);
|
||||
static void color_panel_draw (ColorPanel *color_panel);
|
||||
static gint color_panel_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static void color_panel_select_callback (GimpRGB *color,
|
||||
static void gimp_color_panel_class_init (GimpColorPanelClass *klass);
|
||||
static void gimp_color_panel_init (GimpColorPanel *panel);
|
||||
static void gimp_color_panel_destroy (GtkObject *object);
|
||||
static void gimp_color_panel_color_changed (GimpColorButton *button);
|
||||
static void gimp_color_panel_clicked (GtkButton *button);
|
||||
|
||||
static void gimp_color_panel_select_callback (GimpRGB *color,
|
||||
ColorNotebookState state,
|
||||
gpointer data);
|
||||
|
||||
static void color_panel_drag_color (GtkWidget *widget,
|
||||
GimpRGB *color,
|
||||
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;
|
||||
|
||||
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
|
||||
};
|
||||
static guint n_color_panel_targets = (sizeof (color_panel_target_table) /
|
||||
sizeof (color_panel_target_table[0]));
|
||||
|
||||
/* public functions */
|
||||
panel_type = gtk_type_unique (GIMP_TYPE_COLOR_BUTTON, &panel_info);
|
||||
}
|
||||
|
||||
ColorPanel *
|
||||
color_panel_new (GimpRGB *color,
|
||||
gboolean show_alpha,
|
||||
return panel_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_panel_class_init (GimpColorPanelClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
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)
|
||||
{
|
||||
ColorPanel *color_panel;
|
||||
ColorPanelPrivate *private;
|
||||
GimpColorPanel *panel;
|
||||
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
private = g_new0 (ColorPanelPrivate, 1);
|
||||
private->color_notebook = NULL;
|
||||
private->color_notebook_active = FALSE;
|
||||
private->gc = NULL;
|
||||
private->show_alpha = show_alpha;
|
||||
private->button_down = FALSE;
|
||||
panel = gtk_type_new (gimp_color_panel_get_type ());
|
||||
|
||||
color_panel = g_new (ColorPanel, 1);
|
||||
color_panel->private_part = private;
|
||||
gimp_color_button_set_type (GIMP_COLOR_BUTTON (panel), type);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (panel), color);
|
||||
gtk_widget_set_usize (GTK_WIDGET (panel), width, height);
|
||||
|
||||
color_panel->color = *color;
|
||||
|
||||
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
|
||||
color_panel_free (ColorPanel *color_panel)
|
||||
{
|
||||
ColorPanelPrivate *private;
|
||||
|
||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
||||
|
||||
/* make sure we hide and free color_notebook */
|
||||
if (private->color_notebook)
|
||||
{
|
||||
color_notebook_hide (private->color_notebook);
|
||||
color_notebook_free (private->color_notebook);
|
||||
}
|
||||
|
||||
if (private->gc)
|
||||
gdk_gc_destroy (private->gc);
|
||||
|
||||
g_free (color_panel->private_part);
|
||||
g_free (color_panel);
|
||||
return GTK_WIDGET (panel);
|
||||
}
|
||||
|
||||
static void
|
||||
color_panel_draw (ColorPanel *color_panel)
|
||||
gimp_color_panel_color_changed (GimpColorButton *button)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
ColorPanelPrivate *private;
|
||||
GdkColor fg;
|
||||
guchar r, g, b;
|
||||
GimpColorPanel *panel;
|
||||
GimpRGB color;
|
||||
|
||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
||||
widget = private->drawing_area;
|
||||
panel = GIMP_COLOR_PANEL (button);
|
||||
|
||||
gimp_rgb_get_uchar (&color_panel->color, &r, &g, &b);
|
||||
|
||||
fg.pixel = get_color (r, g, b);
|
||||
|
||||
gdk_gc_set_foreground (private->gc, &fg);
|
||||
gdk_draw_rectangle (widget->window, private->gc, 1, 0, 0,
|
||||
widget->allocation.width, widget->allocation.height);
|
||||
if (panel->color_notebook_active)
|
||||
{
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &color);
|
||||
color_notebook_set_color (panel->color_notebook, &color);
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
color_panel_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
static void
|
||||
gimp_color_panel_clicked (GtkButton *button)
|
||||
{
|
||||
GdkEventButton *bevent;
|
||||
ColorPanel *color_panel;
|
||||
ColorPanelPrivate *private;
|
||||
GimpColorPanel *panel;
|
||||
GimpRGB color;
|
||||
|
||||
color_panel = (ColorPanel *) data;
|
||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
||||
panel = GIMP_COLOR_PANEL (button);
|
||||
|
||||
switch (event->type)
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &color);
|
||||
|
||||
if (! panel->color_notebook)
|
||||
{
|
||||
case GDK_EXPOSE:
|
||||
if (!private->gc)
|
||||
private->gc = gdk_gc_new (widget->window);
|
||||
|
||||
color_panel_draw (color_panel);
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button == 1)
|
||||
private->button_down = TRUE;
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_RELEASE:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button == 1 &&
|
||||
private->button_down)
|
||||
{
|
||||
if (! private->color_notebook)
|
||||
{
|
||||
private->color_notebook =
|
||||
color_notebook_new (&color_panel->color,
|
||||
color_panel_select_callback,
|
||||
color_panel,
|
||||
panel->color_notebook =
|
||||
color_notebook_new (&color,
|
||||
gimp_color_panel_select_callback,
|
||||
panel,
|
||||
FALSE,
|
||||
private->show_alpha);
|
||||
private->color_notebook_active = TRUE;
|
||||
gimp_color_button_has_alpha (GIMP_COLOR_BUTTON (button)));
|
||||
panel->color_notebook_active = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! private->color_notebook_active)
|
||||
if (! panel->color_notebook_active)
|
||||
{
|
||||
color_notebook_show (private->color_notebook);
|
||||
private->color_notebook_active = TRUE;
|
||||
color_notebook_show (panel->color_notebook);
|
||||
panel->color_notebook_active = TRUE;
|
||||
}
|
||||
color_notebook_set_color (private->color_notebook,
|
||||
&color_panel->color);
|
||||
color_notebook_set_color (panel->color_notebook, &color);
|
||||
}
|
||||
private->button_down = FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_LEAVE_NOTIFY:
|
||||
private->button_down = FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
color_panel_select_callback (GimpRGB *color,
|
||||
gimp_color_panel_select_callback (GimpRGB *color,
|
||||
ColorNotebookState state,
|
||||
gpointer data)
|
||||
{
|
||||
ColorPanel *color_panel;
|
||||
ColorPanelPrivate *private;
|
||||
GimpColorPanel *panel;
|
||||
|
||||
color_panel = (ColorPanel *) data;
|
||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
||||
panel = GIMP_COLOR_PANEL (data);
|
||||
|
||||
if (private->color_notebook)
|
||||
if (panel->color_notebook)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case COLOR_NOTEBOOK_UPDATE:
|
||||
break;
|
||||
case COLOR_NOTEBOOK_OK:
|
||||
color_panel->color = *color;
|
||||
|
||||
color_panel_draw (color_panel);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (panel), color);
|
||||
/* Fallthrough */
|
||||
case COLOR_NOTEBOOK_CANCEL:
|
||||
color_notebook_hide (private->color_notebook);
|
||||
private->color_notebook_active = FALSE;
|
||||
color_notebook_hide (panel->color_notebook);
|
||||
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__
|
||||
|
||||
|
||||
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 */
|
||||
GtkWidget *color_panel_widget;
|
||||
|
||||
/* The actual color */
|
||||
GimpRGB color;
|
||||
|
||||
/* Don't touch this :) */
|
||||
gpointer private_part;
|
||||
GimpColorButtonClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
ColorPanel * color_panel_new (GimpRGB *color,
|
||||
gboolean show_alpha,
|
||||
GtkType gimp_color_panel_get_type (void);
|
||||
GtkWidget * gimp_color_panel_new (const GimpRGB *color,
|
||||
GimpColorAreaType type,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
void color_panel_set_color (ColorPanel *color_panel,
|
||||
GimpRGB *color);
|
||||
|
||||
|
||||
#endif /* __COLOR_PANEL_H__ */
|
||||
|
|
|
@ -43,7 +43,7 @@ struct _GimpColorArea
|
|||
{
|
||||
GtkPreview preview;
|
||||
|
||||
gboolean alpha;
|
||||
GimpColorAreaType type;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
|
@ -57,7 +57,7 @@ static guint gimp_color_area_signals[LAST_SIGNAL] = { 0 };
|
|||
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_destroy (GtkObject *object);
|
||||
static void gimp_color_area_update (GimpColorArea *gca);
|
||||
|
@ -105,13 +105,13 @@ gimp_color_area_get_type (void)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_color_area_class_init (GimpColorAreaClass *class)
|
||||
gimp_color_area_class_init (GimpColorAreaClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
|
||||
object_class = (GtkObjectClass*) class;
|
||||
widget_class = (GtkWidgetClass*) class;
|
||||
object_class = (GtkObjectClass*) klass;
|
||||
widget_class = (GtkWidgetClass*) klass;
|
||||
|
||||
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,
|
||||
LAST_SIGNAL);
|
||||
|
||||
class->color_changed = NULL;
|
||||
klass->color_changed = NULL;
|
||||
|
||||
object_class->destroy = gimp_color_area_destroy;
|
||||
|
||||
|
@ -141,7 +141,20 @@ gimp_color_area_class_init (GimpColorAreaClass *class)
|
|||
static void
|
||||
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
|
||||
|
@ -172,8 +185,8 @@ gimp_color_area_destroy (GtkObject *object)
|
|||
* Returns: Pointer to the new #GimpColorArea widget.
|
||||
**/
|
||||
GtkWidget *
|
||||
gimp_color_area_new (GimpRGB *color,
|
||||
gboolean alpha,
|
||||
gimp_color_area_new (const GimpRGB *color,
|
||||
GimpColorAreaType type,
|
||||
GdkModifierType drag_mask)
|
||||
{
|
||||
GimpColorArea *gca;
|
||||
|
@ -183,19 +196,7 @@ gimp_color_area_new (GimpRGB *color,
|
|||
gca = gtk_type_new (gimp_color_area_get_type ());
|
||||
|
||||
gca->color = *color;
|
||||
gca->alpha = alpha;
|
||||
|
||||
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);
|
||||
gca->type = type;
|
||||
|
||||
gtk_drag_dest_set (GTK_WIDGET (gca),
|
||||
GTK_DEST_DEFAULT_HIGHLIGHT |
|
||||
|
@ -224,7 +225,7 @@ gimp_color_area_new (GimpRGB *color,
|
|||
**/
|
||||
void
|
||||
gimp_color_area_set_color (GimpColorArea *gca,
|
||||
GimpRGB *color)
|
||||
const GimpRGB *color)
|
||||
{
|
||||
g_return_if_fail (gca != NULL);
|
||||
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 (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
|
||||
gimp_color_area_update (GimpColorArea *gca)
|
||||
{
|
||||
gint window_width, window_height;
|
||||
guint x, y;
|
||||
guint width, height;
|
||||
guint x, y;
|
||||
guint check_size = 0;
|
||||
guchar light[3];
|
||||
guchar dark[3];
|
||||
guchar opaque[3];
|
||||
|
@ -289,13 +302,28 @@ gimp_color_area_update (GimpColorArea *gca)
|
|||
width = window_width;
|
||||
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);
|
||||
|
||||
opaque[0] = gca->color.r * 255.999;
|
||||
opaque[1] = gca->color.g * 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 +
|
||||
(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;
|
||||
|
||||
if (((x / GIMP_CHECK_SIZE_SM) ^ (y / GIMP_CHECK_SIZE_SM)) & 1)
|
||||
if (((x / check_size) ^ (y / check_size)) & 1)
|
||||
{
|
||||
if ((gint) frac)
|
||||
{
|
||||
|
@ -407,7 +435,7 @@ gimp_color_area_drag_begin (GtkWidget *widget,
|
|||
|
||||
color_area =
|
||||
gimp_color_area_new (&color,
|
||||
gimp_color_area_has_alpha (GIMP_COLOR_AREA (widget)),
|
||||
GIMP_COLOR_AREA (widget)->type,
|
||||
0);
|
||||
|
||||
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[2] = gca->color.b * 0xffff;
|
||||
|
||||
if (gca->alpha)
|
||||
vals[3] = gca->color.a * 0xffff;
|
||||
else
|
||||
if (gca->type == GIMP_COLOR_AREA_FLAT)
|
||||
vals[3] = 0xffff;
|
||||
else
|
||||
vals[3] = gca->color.a * 0xffff;
|
||||
|
||||
gtk_selection_data_set (selection_data,
|
||||
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))
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GIMP_COLOR_AREA_FLAT = 0,
|
||||
GIMP_COLOR_AREA_SMALL_CHECKS,
|
||||
GIMP_COLOR_AREA_LARGE_CHECKS
|
||||
} GimpColorAreaType;
|
||||
|
||||
typedef struct _GimpColorAreaClass GimpColorAreaClass;
|
||||
|
||||
struct _GimpColorAreaClass
|
||||
|
@ -55,14 +62,16 @@ struct _GimpColorAreaClass
|
|||
|
||||
|
||||
GtkType gimp_color_area_get_type (void);
|
||||
GtkWidget * gimp_color_area_new (GimpRGB *color,
|
||||
gboolean alpha,
|
||||
GtkWidget * gimp_color_area_new (const GimpRGB *color,
|
||||
GimpColorAreaType type,
|
||||
GdkModifierType drag_mask);
|
||||
void gimp_color_area_set_color (GimpColorArea *gca,
|
||||
GimpRGB *color);
|
||||
const GimpRGB *color);
|
||||
void gimp_color_area_get_color (GimpColorArea *gca,
|
||||
GimpRGB *color); /* returns */
|
||||
GimpRGB *color);
|
||||
gboolean gimp_color_area_has_alpha (GimpColorArea *gca);
|
||||
void gimp_color_area_set_type (GimpColorArea *gca,
|
||||
GimpColorAreaType type);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -34,19 +34,11 @@
|
|||
|
||||
#include "libgimp-intl.h"
|
||||
|
||||
struct _GimpColorButton
|
||||
{
|
||||
GtkButton button;
|
||||
|
||||
gchar *title;
|
||||
|
||||
GtkWidget *color_area;
|
||||
GtkWidget *dialog;
|
||||
GtkItemFactory *item_factory;
|
||||
};
|
||||
|
||||
|
||||
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);
|
||||
|
||||
static void gimp_color_button_clicked (GtkButton *button);
|
||||
static void gimp_color_button_state_changed (GtkWidget *widget,
|
||||
GtkStateType previous_state);
|
||||
|
@ -89,7 +81,7 @@ enum
|
|||
|
||||
static guint gimp_color_button_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static GtkWidgetClass *parent_class = NULL;
|
||||
static GtkPreviewClass *parent_class = NULL;
|
||||
|
||||
|
||||
static void
|
||||
|
@ -113,15 +105,15 @@ gimp_color_button_destroy (GtkObject *object)
|
|||
|
||||
|
||||
static void
|
||||
gimp_color_button_class_init (GimpColorButtonClass *class)
|
||||
gimp_color_button_class_init (GimpColorButtonClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkButtonClass *button_class;
|
||||
|
||||
object_class = (GtkObjectClass*) class;
|
||||
widget_class = (GtkWidgetClass*) class;
|
||||
button_class = (GtkButtonClass*) class;
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
widget_class = (GtkWidgetClass *) klass;
|
||||
button_class = (GtkButtonClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (gtk_widget_get_type ());
|
||||
|
||||
|
@ -138,20 +130,40 @@ gimp_color_button_class_init (GimpColorButtonClass *class)
|
|||
gtk_object_class_add_signals (object_class, gimp_color_button_signals,
|
||||
LAST_SIGNAL);
|
||||
|
||||
class->color_changed = NULL;
|
||||
klass->color_changed = NULL;
|
||||
|
||||
object_class->destroy = gimp_color_button_destroy;
|
||||
widget_class->state_changed = gimp_color_button_state_changed;
|
||||
button_class->clicked = gimp_color_button_clicked;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_color_button_init (GimpColorButton *gcb)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gcb->title = NULL;
|
||||
gcb->color_area = 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
|
||||
|
@ -185,7 +197,7 @@ gimp_color_button_get_type (void)
|
|||
* @width: Width of the colorpreview in pixels.
|
||||
* @height: Height of the colorpreview in pixels.
|
||||
* @color: A pointer to a #GimpRGB color.
|
||||
* @alpha: TRUE if the button should show alpha.
|
||||
* @type:
|
||||
*
|
||||
* Creates a new #GimpColorButton widget.
|
||||
*
|
||||
|
@ -201,8 +213,8 @@ GtkWidget *
|
|||
gimp_color_button_new (const gchar *title,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpRGB *color,
|
||||
gboolean alpha)
|
||||
const GimpRGB *color,
|
||||
GimpColorAreaType type)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
|
||||
|
@ -212,25 +224,8 @@ gimp_color_button_new (const gchar *title,
|
|||
|
||||
gcb->title = g_strdup (title);
|
||||
|
||||
gcb->color_area = gimp_color_area_new (color, alpha, GDK_BUTTON2_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->color_area), "color_changed",
|
||||
gimp_color_button_color_changed,
|
||||
gcb);
|
||||
|
||||
gimp_color_area_set_type (GIMP_COLOR_AREA (gcb->color_area), type);
|
||||
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);
|
||||
}
|
||||
|
@ -243,7 +238,7 @@ gimp_color_button_new (const gchar *title,
|
|||
**/
|
||||
void
|
||||
gimp_color_button_set_color (GimpColorButton *gcb,
|
||||
GimpRGB *color)
|
||||
const GimpRGB *color)
|
||||
{
|
||||
g_return_if_fail (gcb != NULL);
|
||||
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 (color != NULL);
|
||||
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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
|
||||
gimp_color_button_state_changed (GtkWidget *widget,
|
||||
GtkStateType previous_state)
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
#ifndef __GIMP_COLOR_BUTTON_H__
|
||||
#define __GIMP_COLOR_BUTTON_H__
|
||||
|
||||
#include "libgimp/gimpcolorarea.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#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_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_BUTTON))
|
||||
|
||||
|
||||
typedef struct _GimpColorButtonClass GimpColorButtonClass;
|
||||
|
||||
struct _GimpColorButton
|
||||
{
|
||||
GtkButton button;
|
||||
|
||||
gchar *title;
|
||||
|
||||
GtkWidget *color_area;
|
||||
GtkWidget *dialog;
|
||||
GtkItemFactory *item_factory;
|
||||
};
|
||||
|
||||
struct _GimpColorButtonClass
|
||||
{
|
||||
GtkButtonClass parent_class;
|
||||
|
@ -54,13 +69,15 @@ GtkType gimp_color_button_get_type (void);
|
|||
GtkWidget * gimp_color_button_new (const gchar *title,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpRGB *color,
|
||||
gboolean alpha);
|
||||
const GimpRGB *color,
|
||||
GimpColorAreaType alpha);
|
||||
void gimp_color_button_set_color (GimpColorButton *gcb,
|
||||
GimpRGB *color);
|
||||
const GimpRGB *color);
|
||||
void gimp_color_button_get_color (GimpColorButton *gcb,
|
||||
GimpRGB *color);/* returns */
|
||||
GimpRGB *color);
|
||||
gboolean gimp_color_button_has_alpha (GimpColorButton *gcb);
|
||||
void gimp_color_button_set_type (GimpColorButton *gcb,
|
||||
GimpColorAreaType alpha);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -43,7 +43,7 @@ struct _GimpColorArea
|
|||
{
|
||||
GtkPreview preview;
|
||||
|
||||
gboolean alpha;
|
||||
GimpColorAreaType type;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
|
@ -57,7 +57,7 @@ static guint gimp_color_area_signals[LAST_SIGNAL] = { 0 };
|
|||
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_destroy (GtkObject *object);
|
||||
static void gimp_color_area_update (GimpColorArea *gca);
|
||||
|
@ -105,13 +105,13 @@ gimp_color_area_get_type (void)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_color_area_class_init (GimpColorAreaClass *class)
|
||||
gimp_color_area_class_init (GimpColorAreaClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
|
||||
object_class = (GtkObjectClass*) class;
|
||||
widget_class = (GtkWidgetClass*) class;
|
||||
object_class = (GtkObjectClass*) klass;
|
||||
widget_class = (GtkWidgetClass*) klass;
|
||||
|
||||
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,
|
||||
LAST_SIGNAL);
|
||||
|
||||
class->color_changed = NULL;
|
||||
klass->color_changed = NULL;
|
||||
|
||||
object_class->destroy = gimp_color_area_destroy;
|
||||
|
||||
|
@ -141,7 +141,20 @@ gimp_color_area_class_init (GimpColorAreaClass *class)
|
|||
static void
|
||||
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
|
||||
|
@ -172,8 +185,8 @@ gimp_color_area_destroy (GtkObject *object)
|
|||
* Returns: Pointer to the new #GimpColorArea widget.
|
||||
**/
|
||||
GtkWidget *
|
||||
gimp_color_area_new (GimpRGB *color,
|
||||
gboolean alpha,
|
||||
gimp_color_area_new (const GimpRGB *color,
|
||||
GimpColorAreaType type,
|
||||
GdkModifierType drag_mask)
|
||||
{
|
||||
GimpColorArea *gca;
|
||||
|
@ -183,19 +196,7 @@ gimp_color_area_new (GimpRGB *color,
|
|||
gca = gtk_type_new (gimp_color_area_get_type ());
|
||||
|
||||
gca->color = *color;
|
||||
gca->alpha = alpha;
|
||||
|
||||
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);
|
||||
gca->type = type;
|
||||
|
||||
gtk_drag_dest_set (GTK_WIDGET (gca),
|
||||
GTK_DEST_DEFAULT_HIGHLIGHT |
|
||||
|
@ -224,7 +225,7 @@ gimp_color_area_new (GimpRGB *color,
|
|||
**/
|
||||
void
|
||||
gimp_color_area_set_color (GimpColorArea *gca,
|
||||
GimpRGB *color)
|
||||
const GimpRGB *color)
|
||||
{
|
||||
g_return_if_fail (gca != NULL);
|
||||
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 (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
|
||||
gimp_color_area_update (GimpColorArea *gca)
|
||||
{
|
||||
gint window_width, window_height;
|
||||
guint x, y;
|
||||
guint width, height;
|
||||
guint x, y;
|
||||
guint check_size = 0;
|
||||
guchar light[3];
|
||||
guchar dark[3];
|
||||
guchar opaque[3];
|
||||
|
@ -289,13 +302,28 @@ gimp_color_area_update (GimpColorArea *gca)
|
|||
width = window_width;
|
||||
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);
|
||||
|
||||
opaque[0] = gca->color.r * 255.999;
|
||||
opaque[1] = gca->color.g * 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 +
|
||||
(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;
|
||||
|
||||
if (((x / GIMP_CHECK_SIZE_SM) ^ (y / GIMP_CHECK_SIZE_SM)) & 1)
|
||||
if (((x / check_size) ^ (y / check_size)) & 1)
|
||||
{
|
||||
if ((gint) frac)
|
||||
{
|
||||
|
@ -407,7 +435,7 @@ gimp_color_area_drag_begin (GtkWidget *widget,
|
|||
|
||||
color_area =
|
||||
gimp_color_area_new (&color,
|
||||
gimp_color_area_has_alpha (GIMP_COLOR_AREA (widget)),
|
||||
GIMP_COLOR_AREA (widget)->type,
|
||||
0);
|
||||
|
||||
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[2] = gca->color.b * 0xffff;
|
||||
|
||||
if (gca->alpha)
|
||||
vals[3] = gca->color.a * 0xffff;
|
||||
else
|
||||
if (gca->type == GIMP_COLOR_AREA_FLAT)
|
||||
vals[3] = 0xffff;
|
||||
else
|
||||
vals[3] = gca->color.a * 0xffff;
|
||||
|
||||
gtk_selection_data_set (selection_data,
|
||||
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))
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GIMP_COLOR_AREA_FLAT = 0,
|
||||
GIMP_COLOR_AREA_SMALL_CHECKS,
|
||||
GIMP_COLOR_AREA_LARGE_CHECKS
|
||||
} GimpColorAreaType;
|
||||
|
||||
typedef struct _GimpColorAreaClass GimpColorAreaClass;
|
||||
|
||||
struct _GimpColorAreaClass
|
||||
|
@ -55,14 +62,16 @@ struct _GimpColorAreaClass
|
|||
|
||||
|
||||
GtkType gimp_color_area_get_type (void);
|
||||
GtkWidget * gimp_color_area_new (GimpRGB *color,
|
||||
gboolean alpha,
|
||||
GtkWidget * gimp_color_area_new (const GimpRGB *color,
|
||||
GimpColorAreaType type,
|
||||
GdkModifierType drag_mask);
|
||||
void gimp_color_area_set_color (GimpColorArea *gca,
|
||||
GimpRGB *color);
|
||||
const GimpRGB *color);
|
||||
void gimp_color_area_get_color (GimpColorArea *gca,
|
||||
GimpRGB *color); /* returns */
|
||||
GimpRGB *color);
|
||||
gboolean gimp_color_area_has_alpha (GimpColorArea *gca);
|
||||
void gimp_color_area_set_type (GimpColorArea *gca,
|
||||
GimpColorAreaType type);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -34,19 +34,11 @@
|
|||
|
||||
#include "libgimp-intl.h"
|
||||
|
||||
struct _GimpColorButton
|
||||
{
|
||||
GtkButton button;
|
||||
|
||||
gchar *title;
|
||||
|
||||
GtkWidget *color_area;
|
||||
GtkWidget *dialog;
|
||||
GtkItemFactory *item_factory;
|
||||
};
|
||||
|
||||
|
||||
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);
|
||||
|
||||
static void gimp_color_button_clicked (GtkButton *button);
|
||||
static void gimp_color_button_state_changed (GtkWidget *widget,
|
||||
GtkStateType previous_state);
|
||||
|
@ -89,7 +81,7 @@ enum
|
|||
|
||||
static guint gimp_color_button_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static GtkWidgetClass *parent_class = NULL;
|
||||
static GtkPreviewClass *parent_class = NULL;
|
||||
|
||||
|
||||
static void
|
||||
|
@ -113,15 +105,15 @@ gimp_color_button_destroy (GtkObject *object)
|
|||
|
||||
|
||||
static void
|
||||
gimp_color_button_class_init (GimpColorButtonClass *class)
|
||||
gimp_color_button_class_init (GimpColorButtonClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkButtonClass *button_class;
|
||||
|
||||
object_class = (GtkObjectClass*) class;
|
||||
widget_class = (GtkWidgetClass*) class;
|
||||
button_class = (GtkButtonClass*) class;
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
widget_class = (GtkWidgetClass *) klass;
|
||||
button_class = (GtkButtonClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (gtk_widget_get_type ());
|
||||
|
||||
|
@ -138,20 +130,40 @@ gimp_color_button_class_init (GimpColorButtonClass *class)
|
|||
gtk_object_class_add_signals (object_class, gimp_color_button_signals,
|
||||
LAST_SIGNAL);
|
||||
|
||||
class->color_changed = NULL;
|
||||
klass->color_changed = NULL;
|
||||
|
||||
object_class->destroy = gimp_color_button_destroy;
|
||||
widget_class->state_changed = gimp_color_button_state_changed;
|
||||
button_class->clicked = gimp_color_button_clicked;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_color_button_init (GimpColorButton *gcb)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gcb->title = NULL;
|
||||
gcb->color_area = 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
|
||||
|
@ -185,7 +197,7 @@ gimp_color_button_get_type (void)
|
|||
* @width: Width of the colorpreview in pixels.
|
||||
* @height: Height of the colorpreview in pixels.
|
||||
* @color: A pointer to a #GimpRGB color.
|
||||
* @alpha: TRUE if the button should show alpha.
|
||||
* @type:
|
||||
*
|
||||
* Creates a new #GimpColorButton widget.
|
||||
*
|
||||
|
@ -201,8 +213,8 @@ GtkWidget *
|
|||
gimp_color_button_new (const gchar *title,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpRGB *color,
|
||||
gboolean alpha)
|
||||
const GimpRGB *color,
|
||||
GimpColorAreaType type)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
|
||||
|
@ -212,25 +224,8 @@ gimp_color_button_new (const gchar *title,
|
|||
|
||||
gcb->title = g_strdup (title);
|
||||
|
||||
gcb->color_area = gimp_color_area_new (color, alpha, GDK_BUTTON2_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->color_area), "color_changed",
|
||||
gimp_color_button_color_changed,
|
||||
gcb);
|
||||
|
||||
gimp_color_area_set_type (GIMP_COLOR_AREA (gcb->color_area), type);
|
||||
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);
|
||||
}
|
||||
|
@ -243,7 +238,7 @@ gimp_color_button_new (const gchar *title,
|
|||
**/
|
||||
void
|
||||
gimp_color_button_set_color (GimpColorButton *gcb,
|
||||
GimpRGB *color)
|
||||
const GimpRGB *color)
|
||||
{
|
||||
g_return_if_fail (gcb != NULL);
|
||||
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 (color != NULL);
|
||||
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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
|
||||
gimp_color_button_state_changed (GtkWidget *widget,
|
||||
GtkStateType previous_state)
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
#ifndef __GIMP_COLOR_BUTTON_H__
|
||||
#define __GIMP_COLOR_BUTTON_H__
|
||||
|
||||
#include "libgimp/gimpcolorarea.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#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_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_BUTTON))
|
||||
|
||||
|
||||
typedef struct _GimpColorButtonClass GimpColorButtonClass;
|
||||
|
||||
struct _GimpColorButton
|
||||
{
|
||||
GtkButton button;
|
||||
|
||||
gchar *title;
|
||||
|
||||
GtkWidget *color_area;
|
||||
GtkWidget *dialog;
|
||||
GtkItemFactory *item_factory;
|
||||
};
|
||||
|
||||
struct _GimpColorButtonClass
|
||||
{
|
||||
GtkButtonClass parent_class;
|
||||
|
@ -54,13 +69,15 @@ GtkType gimp_color_button_get_type (void);
|
|||
GtkWidget * gimp_color_button_new (const gchar *title,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpRGB *color,
|
||||
gboolean alpha);
|
||||
const GimpRGB *color,
|
||||
GimpColorAreaType alpha);
|
||||
void gimp_color_button_set_color (GimpColorButton *gcb,
|
||||
GimpRGB *color);
|
||||
const GimpRGB *color);
|
||||
void gimp_color_button_get_color (GimpColorButton *gcb,
|
||||
GimpRGB *color);/* returns */
|
||||
GimpRGB *color);
|
||||
gboolean gimp_color_button_has_alpha (GimpColorButton *gcb);
|
||||
void gimp_color_button_set_type (GimpColorButton *gcb,
|
||||
GimpColorAreaType alpha);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -589,7 +589,8 @@ create_light_page (void)
|
|||
|
||||
colorbutton = gimp_color_button_new (_("Select Lightsource Color"),
|
||||
64, 16,
|
||||
&mapvals.lightsource.color, FALSE);
|
||||
&mapvals.lightsource.color,
|
||||
GIMP_COLOR_AREA_FLAT);
|
||||
gtk_signal_connect (GTK_OBJECT (colorbutton), "color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||
&mapvals.lightsource.color);
|
||||
|
|
|
@ -732,7 +732,8 @@ create_light_page (void)
|
|||
|
||||
colorbutton = gimp_color_button_new (_("Select Lightsource Color"),
|
||||
64, 16,
|
||||
&mapvals.lightsource.color, FALSE);
|
||||
&mapvals.lightsource.color,
|
||||
GIMP_COLOR_AREA_FLAT);
|
||||
gtk_signal_connect (GTK_OBJECT (colorbutton), "color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||
&mapvals.lightsource.color);
|
||||
|
|
|
@ -342,7 +342,8 @@ colorify_dialog (GimpRGB *color)
|
|||
|
||||
custum_color_button = gimp_color_button_new (_("Colorify Custom Color"),
|
||||
COLOR_SIZE, COLOR_SIZE,
|
||||
color, FALSE);
|
||||
color,
|
||||
GIMP_COLOR_AREA_FLAT);
|
||||
gtk_signal_connect (GTK_OBJECT (custum_color_button), "color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||
color);
|
||||
|
@ -354,7 +355,8 @@ colorify_dialog (GimpRGB *color)
|
|||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
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);
|
||||
gtk_widget_set_usize (GTK_WIDGET (color_area), COLOR_SIZE, COLOR_SIZE);
|
||||
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"),
|
||||
PRV_WIDTH, PRV_HEIGHT,
|
||||
&pvals.color, FALSE);
|
||||
&pvals.color,
|
||||
GIMP_COLOR_AREA_FLAT);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||
&pvals.color);
|
||||
|
|
|
@ -362,7 +362,9 @@ exchange_dialog (void)
|
|||
gtk_widget_show (preview);
|
||||
|
||||
/* 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_FUNC (gimp_color_button_get_color),
|
||||
&xargs.threshold);
|
||||
|
@ -390,7 +392,7 @@ exchange_dialog (void)
|
|||
_("Color Exchange: From Color"),
|
||||
SCALE_WIDTH / 2, 16,
|
||||
framenumber ? &xargs.to : &xargs.from,
|
||||
FALSE);
|
||||
GIMP_COLOR_AREA_FLAT);
|
||||
gtk_signal_connect (GTK_OBJECT (colorbutton), "color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||
framenumber ? &xargs.to : &xargs.from);
|
||||
|
|
|
@ -1245,7 +1245,8 @@ film_dialog (gint32 image_ID)
|
|||
/* Film color */
|
||||
button = gimp_color_button_new (_("Select Film Color"),
|
||||
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_FUNC (gimp_color_button_get_color),
|
||||
&filmvals.film_color);
|
||||
|
@ -1293,7 +1294,8 @@ film_dialog (gint32 image_ID)
|
|||
/* Numbering color */
|
||||
button = gimp_color_button_new (_("Select Number Color"),
|
||||
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_FUNC (gimp_color_button_get_color),
|
||||
&filmvals.number_color);
|
||||
|
|
|
@ -910,7 +910,8 @@ dialog (gint32 image_ID,
|
|||
/* attach color selectors */
|
||||
hcolor_button = gimp_color_button_new (_("Horizontal Color"),
|
||||
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_FUNC (gimp_color_button_get_color),
|
||||
&grid_cfg.hcolor);
|
||||
|
@ -925,7 +926,8 @@ dialog (gint32 image_ID,
|
|||
|
||||
vcolor_button = gimp_color_button_new (_("Vertical Color"),
|
||||
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_FUNC (gimp_color_button_get_color),
|
||||
&grid_cfg.vcolor);
|
||||
|
@ -940,7 +942,8 @@ dialog (gint32 image_ID,
|
|||
|
||||
button = gimp_color_button_new (_("Intersection Color"),
|
||||
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_FUNC (gimp_color_button_get_color),
|
||||
&grid_cfg.icolor);
|
||||
|
|
|
@ -653,7 +653,8 @@ add_color_button (gint csel_index,
|
|||
|
||||
button = gimp_color_button_new (gettext (csel_title[csel_index]),
|
||||
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_FUNC (gimp_color_button_get_color),
|
||||
&plvals.colors[csel_index]);
|
||||
|
|
|
@ -511,7 +511,7 @@ nova_dialog (GimpDrawable *drawable)
|
|||
|
||||
button = gimp_color_button_new (_("SuperNova Color Picker"),
|
||||
SCALE_WIDTH - 8, 16,
|
||||
&pvals.color, FALSE);
|
||||
&pvals.color, GIMP_COLOR_AREA_FLAT);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||
&pvals.color);
|
||||
|
|
|
@ -396,7 +396,9 @@ open_dialog (void)
|
|||
|
||||
color_button = gimp_color_button_new (_("Background Color"), 100, 16,
|
||||
&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_FUNC (gimp_color_button_get_color),
|
||||
&p.params.background_color);
|
||||
|
|
|
@ -1893,7 +1893,8 @@ sinus_dialog (void)
|
|||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
|
||||
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_FUNC (gimp_color_button_get_color),
|
||||
&svals.col1);
|
||||
|
@ -1901,7 +1902,8 @@ sinus_dialog (void)
|
|||
gtk_widget_show (push_col1);
|
||||
|
||||
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_FUNC (gimp_color_button_get_color),
|
||||
&svals.col2);
|
||||
|
|
|
@ -327,8 +327,9 @@ create_main_window (GdtMainWindow **main_window,
|
|||
(gdouble) (((guint)data->color) >> 8) / 255.0,
|
||||
(gdouble) ((guint)data->color) / 255.0);
|
||||
color_button = gimp_color_button_new (_("GDynText: Select Color"),
|
||||
COLOR_PREVIEW_WIDTH, COLOR_PREVIEW_HEIGHT,
|
||||
&color, FALSE);
|
||||
COLOR_PREVIEW_WIDTH,
|
||||
COLOR_PREVIEW_HEIGHT,
|
||||
&color, GIMP_COLOR_AREA_FLAT);
|
||||
gtk_signal_connect (GTK_OBJECT (color_button), "color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||
&color);
|
||||
|
|
|
@ -2017,7 +2017,7 @@ color_map_create (gchar *name,
|
|||
|
||||
color_map->orig_preview =
|
||||
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_widget_set_usize (color_map->orig_preview,
|
||||
COLOR_SAMPLE_SIZE, COLOR_SAMPLE_SIZE);
|
||||
|
@ -2031,7 +2031,8 @@ color_map_create (gchar *name,
|
|||
color_map->button = gimp_color_button_new (name,
|
||||
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,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (color_map->button);
|
||||
|
|
|
@ -1302,7 +1302,8 @@ script_fu_interface (SFScript *script)
|
|||
sf_interface->args_widgets[i] =
|
||||
gimp_color_button_new (_("Script-Fu Color Selection"),
|
||||
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]),
|
||||
"color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||
|
|
|
@ -1302,7 +1302,8 @@ script_fu_interface (SFScript *script)
|
|||
sf_interface->args_widgets[i] =
|
||||
gimp_color_button_new (_("Script-Fu Color Selection"),
|
||||
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]),
|
||||
"color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||
|
|
Loading…
Reference in New Issue