mirror of https://github.com/GNOME/gimp.git
finished new GimpColorArea widget which uses GimpRGB and handles DND and
2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * 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.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
This commit is contained in:
parent
a16b8d20e2
commit
45c4a41f4b
42
ChangeLog
42
ChangeLog
|
@ -1,3 +1,45 @@
|
|||
2001-01-10 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which
|
||||
uses GimpRGB and handles DND and alpha channel.
|
||||
|
||||
* libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the
|
||||
GimpColorButton has changed!
|
||||
|
||||
* libgimp/gimpwidgets.[ch]: added temporary function
|
||||
gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB.
|
||||
This function will go away.
|
||||
|
||||
* plug-ins/Lighting/lighting_main.h
|
||||
* plug-ins/Lighting/lighting_ui.c
|
||||
* plug-ins/MapObject/mapobject_main.h
|
||||
* 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.[ch]
|
||||
* plug-ins/ifscompose/ifscompose_storage.c
|
||||
* plug-ins/ifscompose/ifscompose_utils.c
|
||||
* plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and
|
||||
GimpColorButton. Started to introduce GimpRGB color type. This change
|
||||
might have broken some of these plug-ins. This is work in progress.
|
||||
|
||||
* libgimp/Makefile.am: added GimpColorArea and GimpColorButton to
|
||||
libgimpi.
|
||||
|
||||
* app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground()
|
||||
functions so the app can link against libgimp/gimpcolorbutton.o.
|
||||
These functions will go away.
|
||||
|
||||
* app/gimpdnd.c: use a GimpColorArea for DND
|
||||
|
||||
2001-01-10 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/gimpdrawable.[ch]: removed the "name" parameter and use
|
||||
|
|
|
@ -1076,6 +1076,14 @@ gimp_context_get_foreground (GimpContext *context,
|
|||
*b = context->foreground[2];
|
||||
}
|
||||
|
||||
void
|
||||
gimp_palette_get_foreground (guchar *r,
|
||||
guchar *g,
|
||||
guchar *b)
|
||||
{
|
||||
gimp_context_get_foreground (NULL, r, g, b);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_context_set_foreground (GimpContext *context,
|
||||
gint r,
|
||||
|
@ -1147,6 +1155,14 @@ gimp_context_get_background (GimpContext *context,
|
|||
*b = context->background[2];
|
||||
}
|
||||
|
||||
void
|
||||
gimp_palette_get_background (guchar *r,
|
||||
guchar *g,
|
||||
guchar *b)
|
||||
{
|
||||
gimp_context_get_background (NULL, r, g, b);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_context_set_background (GimpContext *context,
|
||||
gint r,
|
||||
|
|
|
@ -225,6 +225,10 @@ void gimp_context_get_foreground (GimpContext *context,
|
|||
guchar *r,
|
||||
guchar *g,
|
||||
guchar *b);
|
||||
/* FIXME: this let's the core link against gimp_color_button */
|
||||
void gimp_palette_get_foreground (guchar *r,
|
||||
guchar *g,
|
||||
guchar *b);
|
||||
void gimp_context_set_foreground (GimpContext *context,
|
||||
gint r,
|
||||
gint g,
|
||||
|
@ -236,6 +240,10 @@ void gimp_context_get_background (GimpContext *context,
|
|||
guchar *r,
|
||||
guchar *g,
|
||||
guchar *b);
|
||||
/* FIXME: this let's the core link against gimp_color_button */
|
||||
void gimp_palette_get_background (guchar *r,
|
||||
guchar *g,
|
||||
guchar *b);
|
||||
void gimp_context_set_background (GimpContext *context,
|
||||
gint r,
|
||||
gint g,
|
||||
|
|
|
@ -1076,6 +1076,14 @@ gimp_context_get_foreground (GimpContext *context,
|
|||
*b = context->foreground[2];
|
||||
}
|
||||
|
||||
void
|
||||
gimp_palette_get_foreground (guchar *r,
|
||||
guchar *g,
|
||||
guchar *b)
|
||||
{
|
||||
gimp_context_get_foreground (NULL, r, g, b);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_context_set_foreground (GimpContext *context,
|
||||
gint r,
|
||||
|
@ -1147,6 +1155,14 @@ gimp_context_get_background (GimpContext *context,
|
|||
*b = context->background[2];
|
||||
}
|
||||
|
||||
void
|
||||
gimp_palette_get_background (guchar *r,
|
||||
guchar *g,
|
||||
guchar *b)
|
||||
{
|
||||
gimp_context_get_background (NULL, r, g, b);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_context_set_background (GimpContext *context,
|
||||
gint r,
|
||||
|
|
|
@ -225,6 +225,10 @@ void gimp_context_get_foreground (GimpContext *context,
|
|||
guchar *r,
|
||||
guchar *g,
|
||||
guchar *b);
|
||||
/* FIXME: this let's the core link against gimp_color_button */
|
||||
void gimp_palette_get_foreground (guchar *r,
|
||||
guchar *g,
|
||||
guchar *b);
|
||||
void gimp_context_set_foreground (GimpContext *context,
|
||||
gint r,
|
||||
gint g,
|
||||
|
@ -236,6 +240,10 @@ void gimp_context_get_background (GimpContext *context,
|
|||
guchar *r,
|
||||
guchar *g,
|
||||
guchar *b);
|
||||
/* FIXME: this let's the core link against gimp_color_button */
|
||||
void gimp_palette_get_background (guchar *r,
|
||||
guchar *g,
|
||||
guchar *b);
|
||||
void gimp_context_set_background (GimpContext *context,
|
||||
gint r,
|
||||
gint g,
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "tools.h"
|
||||
|
||||
#include "libgimp/gimplimits.h"
|
||||
#include "libgimp/gimpcolorarea.h"
|
||||
|
||||
#define DRAG_PREVIEW_SIZE 32
|
||||
|
||||
|
@ -491,32 +492,23 @@ gimp_dnd_get_color_icon (GtkWidget *widget,
|
|||
GtkSignalFunc get_color_func,
|
||||
gpointer get_color_data)
|
||||
{
|
||||
GtkWidget *preview;
|
||||
GtkWidget *color_area;
|
||||
GimpRGB color;
|
||||
guchar r, g, b, a;
|
||||
guchar row[DRAG_PREVIEW_SIZE * 3];
|
||||
gint i;
|
||||
|
||||
(* (GimpDndDragColorFunc) get_color_func) (widget, &r, &g, &b, &a,
|
||||
get_color_data);
|
||||
|
||||
for (i = 0; i < DRAG_PREVIEW_SIZE; i++)
|
||||
{
|
||||
row[i * 3] = r;
|
||||
row[i * 3 + 1] = g;
|
||||
row[i * 3 + 2] = b;
|
||||
}
|
||||
gimp_rgba_set (&color,
|
||||
(gdouble) r / 255.0,
|
||||
(gdouble) g / 255.0,
|
||||
(gdouble) b / 255.0,
|
||||
(gdouble) a / 255.0);
|
||||
|
||||
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (preview),
|
||||
DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
|
||||
color_area = gimp_color_area_new (&color, TRUE, 0);
|
||||
gtk_widget_set_usize (color_area, DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
|
||||
|
||||
for (i = 0; i < DRAG_PREVIEW_SIZE; i++)
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (preview), row,
|
||||
0, i, DRAG_PREVIEW_SIZE);
|
||||
}
|
||||
|
||||
return preview;
|
||||
return color_area;
|
||||
}
|
||||
|
||||
static guchar *
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "tools.h"
|
||||
|
||||
#include "libgimp/gimplimits.h"
|
||||
#include "libgimp/gimpcolorarea.h"
|
||||
|
||||
#define DRAG_PREVIEW_SIZE 32
|
||||
|
||||
|
@ -491,32 +492,23 @@ gimp_dnd_get_color_icon (GtkWidget *widget,
|
|||
GtkSignalFunc get_color_func,
|
||||
gpointer get_color_data)
|
||||
{
|
||||
GtkWidget *preview;
|
||||
GtkWidget *color_area;
|
||||
GimpRGB color;
|
||||
guchar r, g, b, a;
|
||||
guchar row[DRAG_PREVIEW_SIZE * 3];
|
||||
gint i;
|
||||
|
||||
(* (GimpDndDragColorFunc) get_color_func) (widget, &r, &g, &b, &a,
|
||||
get_color_data);
|
||||
|
||||
for (i = 0; i < DRAG_PREVIEW_SIZE; i++)
|
||||
{
|
||||
row[i * 3] = r;
|
||||
row[i * 3 + 1] = g;
|
||||
row[i * 3 + 2] = b;
|
||||
}
|
||||
gimp_rgba_set (&color,
|
||||
(gdouble) r / 255.0,
|
||||
(gdouble) g / 255.0,
|
||||
(gdouble) b / 255.0,
|
||||
(gdouble) a / 255.0);
|
||||
|
||||
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (preview),
|
||||
DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
|
||||
color_area = gimp_color_area_new (&color, TRUE, 0);
|
||||
gtk_widget_set_usize (color_area, DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
|
||||
|
||||
for (i = 0; i < DRAG_PREVIEW_SIZE; i++)
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (preview), row,
|
||||
0, i, DRAG_PREVIEW_SIZE);
|
||||
}
|
||||
|
||||
return preview;
|
||||
return color_area;
|
||||
}
|
||||
|
||||
static guchar *
|
||||
|
|
|
@ -101,7 +101,10 @@ libgimpi_a_SOURCES = \
|
|||
gimpcolor.h \
|
||||
gimpchainbutton.c \
|
||||
gimpchainbutton.h \
|
||||
gimpcolorarea.c \
|
||||
gimpcolorarea.h \
|
||||
gimpcolorbutton.c \
|
||||
gimpcolorbutton.h \
|
||||
gimpcolorspace.c \
|
||||
gimpcolorspace.h \
|
||||
gimpdialog.c \
|
||||
|
|
|
@ -60,7 +60,7 @@ static GtkWidgetClass *parent_class = NULL;
|
|||
static void gimp_color_area_class_init (GimpColorAreaClass *class);
|
||||
static void gimp_color_area_init (GimpColorArea *gca);
|
||||
static void gimp_color_area_destroy (GtkObject *object);
|
||||
static void gimp_color_area_paint (GimpColorArea *gca);
|
||||
static void gimp_color_area_update (GimpColorArea *gca);
|
||||
|
||||
static void gimp_color_area_drag_begin (GtkWidget *widget,
|
||||
GdkDragContext *context);
|
||||
|
@ -121,16 +121,16 @@ gimp_color_area_class_init (GimpColorAreaClass *class)
|
|||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpColorAreaClass,
|
||||
color_changed),
|
||||
gtk_marshal_NONE__POINTER,
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE,
|
||||
1, GTK_TYPE_POINTER);
|
||||
0);
|
||||
|
||||
gtk_object_class_add_signals (object_class, gimp_color_area_signals,
|
||||
LAST_SIGNAL);
|
||||
|
||||
class->color_changed = NULL;
|
||||
|
||||
object_class->destroy = gimp_color_area_destroy;
|
||||
object_class->destroy = gimp_color_area_destroy;
|
||||
|
||||
widget_class->drag_begin = gimp_color_area_drag_begin;
|
||||
widget_class->drag_end = gimp_color_area_drag_end;
|
||||
|
@ -160,8 +160,9 @@ gimp_color_area_destroy (GtkObject *object)
|
|||
|
||||
/**
|
||||
* gimp_color_area_new:
|
||||
* @color: An array of guchar holding the color (RGB or RGBA)
|
||||
* @bpp: May be 3 for RGB or 4 for RGBA.
|
||||
* @color: A pointer to a #GimpRGB struct.
|
||||
* @alpha: If the color_area should show alpha.
|
||||
* @drag_mask: The event_mask that should trigger drags.
|
||||
*
|
||||
* Creates a new #GimpColorArea widget.
|
||||
*
|
||||
|
@ -171,8 +172,9 @@ 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 (GimpRGB *color,
|
||||
gboolean alpha,
|
||||
GdkModifierType drag_mask)
|
||||
{
|
||||
GimpColorArea *gca;
|
||||
|
||||
|
@ -181,15 +183,19 @@ 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), "size_allocate",
|
||||
GTK_SIGNAL_FUNC (gimp_color_area_paint),
|
||||
gtk_signal_connect_after (GTK_OBJECT (gca), "realize",
|
||||
GTK_SIGNAL_FUNC (gimp_color_area_update),
|
||||
NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (gca), "size_allocate",
|
||||
GTK_SIGNAL_FUNC (gimp_color_area_update),
|
||||
NULL);
|
||||
|
||||
gtk_drag_dest_set (GTK_WIDGET (gca),
|
||||
GTK_DEST_DEFAULT_HIGHLIGHT |
|
||||
|
@ -197,10 +203,15 @@ gimp_color_area_new (GimpRGB *color,
|
|||
GTK_DEST_DEFAULT_DROP,
|
||||
targets, 1,
|
||||
GDK_ACTION_COPY);
|
||||
gtk_drag_source_set (GTK_WIDGET (gca),
|
||||
GDK_BUTTON2_MASK,
|
||||
targets, 1,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
|
||||
/* do we need this ?? */
|
||||
drag_mask &= (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK);
|
||||
|
||||
if (drag_mask)
|
||||
gtk_drag_source_set (GTK_WIDGET (gca),
|
||||
drag_mask,
|
||||
targets, 1,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
|
||||
return GTK_WIDGET (gca);
|
||||
}
|
||||
|
@ -224,27 +235,47 @@ gimp_color_area_set_color (GimpColorArea *gca,
|
|||
{
|
||||
gca->color = *color;
|
||||
|
||||
gimp_color_area_paint (gca);
|
||||
gimp_color_area_update (gca);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (gca),
|
||||
gimp_color_area_signals[COLOR_CHANGED],
|
||||
&gca->color);
|
||||
gimp_color_area_signals[COLOR_CHANGED]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_area_paint (GimpColorArea *gca)
|
||||
void
|
||||
gimp_color_area_get_color (GimpColorArea *gca,
|
||||
GimpRGB *color)
|
||||
{
|
||||
gint x, y;
|
||||
gdouble c0, c1;
|
||||
g_return_if_fail (gca != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_AREA (gca));
|
||||
|
||||
*color = gca->color;
|
||||
}
|
||||
|
||||
gboolean
|
||||
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;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_area_update (GimpColorArea *gca)
|
||||
{
|
||||
guint x, y;
|
||||
guint width, height;
|
||||
guchar *p0, *p1;
|
||||
guchar *even, *odd;
|
||||
guchar light[3];
|
||||
guchar dark[3];
|
||||
guchar opaque[3];
|
||||
guchar *p;
|
||||
guchar *buf;
|
||||
|
||||
g_return_if_fail (gca != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_AREA (gca));
|
||||
|
||||
if (! GTK_WIDGET_DRAWABLE (GTK_WIDGET (gca)))
|
||||
if (! GTK_WIDGET_REALIZED (GTK_WIDGET (gca)))
|
||||
return;
|
||||
|
||||
gdk_window_get_size (GTK_WIDGET (gca)->window, &width, &height);
|
||||
|
@ -252,55 +283,72 @@ gimp_color_area_paint (GimpColorArea *gca)
|
|||
if (!width || !height)
|
||||
return;
|
||||
|
||||
p0 = even = g_new (guchar, width * 3);
|
||||
p1 = odd = g_new (guchar, width * 3);
|
||||
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)
|
||||
{
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
if ((x / GIMP_CHECK_SIZE_SM) & 1)
|
||||
{
|
||||
c0 = GIMP_CHECK_LIGHT;
|
||||
c1 = GIMP_CHECK_DARK;
|
||||
}
|
||||
else
|
||||
{
|
||||
c0 = GIMP_CHECK_DARK;
|
||||
c1 = GIMP_CHECK_LIGHT;
|
||||
}
|
||||
|
||||
*p0++ = (c0 + (gca->color.r - c0) * gca->color.a) * 255.999;
|
||||
*p1++ = (c1 + (gca->color.r - c1) * gca->color.a) * 255.999;
|
||||
*p0++ = (c0 + (gca->color.g - c0) * gca->color.a) * 255.999;
|
||||
*p1++ = (c1 + (gca->color.g - c1) * gca->color.a) * 255.999;
|
||||
*p0++ = (c0 + (gca->color.b - c0) * gca->color.a) * 255.999;
|
||||
*p1++ = (c1 + (gca->color.b - c1) * gca->color.a) * 255.999;
|
||||
}
|
||||
light[0] = (GIMP_CHECK_LIGHT +
|
||||
(gca->color.r - GIMP_CHECK_LIGHT) * gca->color.a) * 255.999;
|
||||
dark[0] = (GIMP_CHECK_DARK +
|
||||
(gca->color.r - GIMP_CHECK_DARK) * gca->color.a) * 255.999;
|
||||
light[1] = (GIMP_CHECK_LIGHT +
|
||||
(gca->color.g - GIMP_CHECK_LIGHT) * gca->color.a) * 255.999;
|
||||
dark[1] = (GIMP_CHECK_DARK +
|
||||
(gca->color.g - GIMP_CHECK_DARK) * gca->color.a) * 255.999;
|
||||
light[2] = (GIMP_CHECK_LIGHT +
|
||||
(gca->color.b - GIMP_CHECK_LIGHT) * gca->color.a) * 255.999;
|
||||
dark[2] = (GIMP_CHECK_DARK +
|
||||
(gca->color.b - GIMP_CHECK_DARK) * gca->color.a) * 255.999;
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
if ((y / GIMP_CHECK_SIZE_SM) & 1)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (gca), odd, 0, y, width);
|
||||
else
|
||||
gtk_preview_draw_row (GTK_PREVIEW (gca), even, 0, y, width);
|
||||
p = buf;
|
||||
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
if (x <= y)
|
||||
{
|
||||
*p++ = opaque[0];
|
||||
*p++ = opaque[1];
|
||||
*p++ = opaque[2];
|
||||
}
|
||||
else if (((x / GIMP_CHECK_SIZE_SM) ^ (y / GIMP_CHECK_SIZE_SM))
|
||||
& 1)
|
||||
{
|
||||
*p++ = light[0];
|
||||
*p++ = light[1];
|
||||
*p++ = light[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
*p++ = dark[0];
|
||||
*p++ = dark[1];
|
||||
*p++ = dark[2];
|
||||
}
|
||||
}
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW (gca), buf,
|
||||
0, height - y - 1, width);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
*p0++ = gca->color.r;
|
||||
*p0++ = gca->color.g;
|
||||
*p0++ = gca->color.b;
|
||||
*p++ = opaque[0];
|
||||
*p++ = opaque[1];
|
||||
*p++ = opaque[2];
|
||||
}
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (gca), even, 0, y, width);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (gca), buf, 0, y, width);
|
||||
}
|
||||
|
||||
g_free (even);
|
||||
g_free (odd);
|
||||
g_free (buf);
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (gca));
|
||||
}
|
||||
|
@ -309,28 +357,35 @@ static void
|
|||
gimp_color_area_drag_begin (GtkWidget *widget,
|
||||
GdkDragContext *context)
|
||||
{
|
||||
GimpColorArea *gca;
|
||||
GtkWidget *window;
|
||||
GdkColor bg;
|
||||
|
||||
gca = GIMP_COLOR_AREA (widget);
|
||||
GimpRGB color;
|
||||
GtkWidget *window;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *color_area;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
|
||||
gtk_widget_set_usize (window, DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
|
||||
gtk_widget_realize (window);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (window), frame);
|
||||
|
||||
gimp_color_area_get_color (GIMP_COLOR_AREA (widget), &color);
|
||||
|
||||
color_area =
|
||||
gimp_color_area_new (&color,
|
||||
gimp_color_area_has_alpha (GIMP_COLOR_AREA (widget)),
|
||||
0);
|
||||
|
||||
gtk_widget_set_usize (color_area, DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
|
||||
gtk_container_add (GTK_CONTAINER (frame), color_area);
|
||||
gtk_widget_show (color_area);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
gtk_object_set_data_full (GTK_OBJECT (widget),
|
||||
"gimp-color-area-drag-window",
|
||||
window,
|
||||
(GtkDestroyNotify) gtk_widget_destroy);
|
||||
|
||||
bg.red = gca->color.r * 0xffff;
|
||||
bg.green = gca->color.g * 0xffff;
|
||||
bg.blue = gca->color.b * 0xffff;
|
||||
|
||||
gdk_color_alloc (gtk_widget_get_colormap (window), &bg);
|
||||
gdk_window_set_background (window->window, &bg);
|
||||
|
||||
gtk_drag_set_icon_widget (context, window, DRAG_ICON_OFFSET, DRAG_ICON_OFFSET);
|
||||
}
|
||||
|
||||
|
@ -393,9 +448,14 @@ gimp_color_area_drag_data_get (GtkWidget *widget,
|
|||
vals[0] = gca->color.r * 0xffff;
|
||||
vals[1] = gca->color.g * 0xffff;
|
||||
vals[2] = gca->color.b * 0xffff;
|
||||
vals[3] = gca->color.a * 0xffff;
|
||||
|
||||
if (gca->alpha)
|
||||
vals[3] = gca->color.a * 0xffff;
|
||||
else
|
||||
vals[3] = 0xffff;
|
||||
|
||||
gtk_selection_data_set (selection_data,
|
||||
gdk_atom_intern ("application/x-color", FALSE),
|
||||
16, (guchar *)vals, 8);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,16 +50,19 @@ struct _GimpColorAreaClass
|
|||
{
|
||||
GtkPreviewClass parent_class;
|
||||
|
||||
void (* color_changed) (GimpColorArea *gca,
|
||||
GimpRGB *color);
|
||||
void (* color_changed) (GimpColorArea *gca);
|
||||
};
|
||||
|
||||
|
||||
GtkType gimp_color_area_get_type (void);
|
||||
GtkWidget * gimp_color_area_new (GimpRGB *color,
|
||||
gboolean alpha);
|
||||
void gimp_color_area_set_color (GimpColorArea *gca,
|
||||
GimpRGB *color);
|
||||
GtkWidget * gimp_color_area_new (GimpRGB *color,
|
||||
gboolean alpha,
|
||||
GdkModifierType drag_mask);
|
||||
void gimp_color_area_set_color (GimpColorArea *gca,
|
||||
GimpRGB *color);
|
||||
void gimp_color_area_get_color (GimpColorArea *gca,
|
||||
GimpRGB *color); /* returns */
|
||||
gboolean gimp_color_area_has_alpha (GimpColorArea *gca);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpcolorbutton.c
|
||||
* Copyright (C) 1999 Sven Neumann
|
||||
* Copyright (C) 1999-2001 Sven Neumann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -20,14 +20,6 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* TODO:
|
||||
*
|
||||
* handle bytes != 3|4 -- would we have to provide a special color
|
||||
* select dialog for that case? Another possibility
|
||||
* could be to hide or destroy all color-related
|
||||
* widgets in the gtk colorselector.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
@ -36,87 +28,49 @@
|
|||
|
||||
#include "gimpuitypes.h"
|
||||
|
||||
#include "gimpcolorarea.h"
|
||||
#include "gimpcolorbutton.h"
|
||||
#include "gimplimits.h"
|
||||
|
||||
#include "libgimp-intl.h"
|
||||
|
||||
|
||||
/* DND -- remove as soon as gimpdnd is in libgimp */
|
||||
#define DRAG_PREVIEW_SIZE 32
|
||||
#define DRAG_ICON_OFFSET -8
|
||||
|
||||
static void gimp_color_button_drag_begin (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data);
|
||||
static void gimp_color_button_drag_end (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data);
|
||||
static void gimp_color_button_drop_handle (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data);
|
||||
static void gimp_color_button_drag_handle (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data);
|
||||
|
||||
static const GtkTargetEntry targets[] = { { "application/x-color", 0 } };
|
||||
|
||||
|
||||
/* end of DND */
|
||||
|
||||
struct _GimpColorButton
|
||||
{
|
||||
GtkButton button;
|
||||
GtkButton button;
|
||||
|
||||
gboolean double_color;
|
||||
|
||||
gchar *title;
|
||||
gpointer color;
|
||||
gint bpp;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
gdouble *dcolor;
|
||||
GtkWidget *preview;
|
||||
|
||||
GtkWidget *color_area;
|
||||
GtkWidget *dialog;
|
||||
GtkItemFactory *item_factory;
|
||||
|
||||
guchar *even;
|
||||
guchar *odd;
|
||||
};
|
||||
|
||||
|
||||
static void gimp_color_button_destroy (GtkObject *object);
|
||||
static void gimp_color_button_clicked (GtkButton *button);
|
||||
static void gimp_color_button_paint (GimpColorButton *gcb);
|
||||
static void gimp_color_button_state_changed (GtkWidget *widget,
|
||||
GtkStateType previous_state);
|
||||
|
||||
static void gimp_color_button_dialog_ok (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_color_button_dialog_cancel (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_color_button_dialog_ok (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_color_button_dialog_cancel (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static void gimp_color_button_use_fg (gpointer callback_data,
|
||||
guint callback_action,
|
||||
GtkWidget *widget);
|
||||
static void gimp_color_button_use_bg (gpointer callback_data,
|
||||
guint callback_action,
|
||||
GtkWidget *widget);
|
||||
static void gimp_color_button_use_fg (gpointer callback_data,
|
||||
guint callback_action,
|
||||
GtkWidget *widget);
|
||||
static void gimp_color_button_use_bg (gpointer callback_data,
|
||||
guint callback_action,
|
||||
GtkWidget *widget);
|
||||
|
||||
static gint gimp_color_button_menu_popup (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static gchar* gimp_color_button_menu_translate (const gchar *path,
|
||||
gpointer func_data);
|
||||
static gint gimp_color_button_menu_popup (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static gchar * gimp_color_button_menu_translate (const gchar *path,
|
||||
gpointer func_data);
|
||||
|
||||
static void gimp_color_button_color_changed (GtkObject *object,
|
||||
gpointer data);
|
||||
|
||||
|
||||
static GtkItemFactoryEntry menu_items[] =
|
||||
|
@ -150,10 +104,9 @@ gimp_color_button_destroy (GtkObject *object)
|
|||
if (gcb->dialog)
|
||||
gtk_widget_destroy (gcb->dialog);
|
||||
|
||||
g_free (gcb->dcolor);
|
||||
g_free (gcb->even);
|
||||
g_free (gcb->odd);
|
||||
|
||||
if (gcb->color_area)
|
||||
gtk_widget_destroy (gcb->color_area);
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
@ -178,7 +131,9 @@ gimp_color_button_class_init (GimpColorButtonClass *class)
|
|||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpColorButtonClass,
|
||||
color_changed),
|
||||
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE,
|
||||
0);
|
||||
|
||||
gtk_object_class_add_signals (object_class, gimp_color_button_signals,
|
||||
LAST_SIGNAL);
|
||||
|
@ -194,18 +149,9 @@ gimp_color_button_class_init (GimpColorButtonClass *class)
|
|||
static void
|
||||
gimp_color_button_init (GimpColorButton *gcb)
|
||||
{
|
||||
gcb->double_color = FALSE;
|
||||
|
||||
gcb->title = NULL;
|
||||
gcb->bpp = 0;
|
||||
gcb->color = NULL;
|
||||
|
||||
gcb->dcolor = NULL;
|
||||
gcb->preview = NULL;
|
||||
gcb->color_area = NULL;
|
||||
gcb->dialog = NULL;
|
||||
|
||||
gcb->even = NULL;
|
||||
gcb->odd = NULL;
|
||||
}
|
||||
|
||||
GtkType
|
||||
|
@ -233,103 +179,13 @@ gimp_color_button_get_type (void)
|
|||
return gcb_type;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
_gimp_color_button_new (gboolean double_color,
|
||||
const gchar *title,
|
||||
gint width,
|
||||
gint height,
|
||||
gpointer color,
|
||||
gint bpp)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (width > 0 && height > 0, NULL);
|
||||
g_return_val_if_fail (bpp == 3 || bpp == 4, NULL);
|
||||
|
||||
gcb = gtk_type_new (gimp_color_button_get_type ());
|
||||
|
||||
gcb->double_color = double_color;
|
||||
|
||||
gcb->title = g_strdup (title);
|
||||
gcb->width = width;
|
||||
gcb->height = height;
|
||||
gcb->color = color;
|
||||
gcb->bpp = bpp;
|
||||
|
||||
gcb->dcolor = g_new (gdouble, 4);
|
||||
gcb->even = g_new (guchar, 3 * width);
|
||||
gcb->odd = g_new (guchar, 3 * width);
|
||||
|
||||
if (double_color)
|
||||
{
|
||||
for (i = 0; i < bpp; i++)
|
||||
gcb->dcolor[i] = ((gdouble *) color)[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < bpp; i++)
|
||||
gcb->dcolor[i] = (gdouble) ((guchar *) color)[i] / 255.0;
|
||||
}
|
||||
|
||||
if (bpp == 3)
|
||||
gcb->dcolor[3] = 1.0;
|
||||
|
||||
gcb->preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview), "destroy",
|
||||
gtk_widget_destroyed, &gcb->preview);
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (gcb->preview), width, height);
|
||||
gtk_container_add (GTK_CONTAINER (gcb), gcb->preview);
|
||||
gtk_widget_show (gcb->preview);
|
||||
gimp_color_button_paint (gcb);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* DND -- to be changed as soon as gimpdnd is in libgimp */
|
||||
gtk_drag_dest_set (gcb->preview,
|
||||
GTK_DEST_DEFAULT_HIGHLIGHT |
|
||||
GTK_DEST_DEFAULT_MOTION |
|
||||
GTK_DEST_DEFAULT_DROP,
|
||||
targets, 1,
|
||||
GDK_ACTION_COPY);
|
||||
gtk_drag_source_set (gcb->preview,
|
||||
GDK_BUTTON2_MASK,
|
||||
targets, 1,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview), "drag_begin",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_drag_begin),
|
||||
gcb);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview), "drag_end",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_drag_end),
|
||||
gcb);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview), "drag_data_get",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_drag_handle),
|
||||
gcb);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview), "drag_data_received",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_drop_handle),
|
||||
gcb);
|
||||
/* end of DND */
|
||||
|
||||
return GTK_WIDGET (gcb);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_button_new:
|
||||
* @title: String that will be used as title for the color_selector.
|
||||
* @width: Width of the colorpreview in pixels.
|
||||
* @height: Height of the colorpreview in pixels.
|
||||
* @color: An array of guchar holding the color (RGB or RGBA)
|
||||
* @bpp: May be 3 for RGB or 4 for RGBA.
|
||||
* @color: A pointer to a #GimpRGB color.
|
||||
* @alpha: TRUE if the button should show alpha.
|
||||
*
|
||||
* Creates a new #GimpColorButton widget.
|
||||
*
|
||||
|
@ -343,76 +199,86 @@ _gimp_color_button_new (gboolean double_color,
|
|||
**/
|
||||
GtkWidget *
|
||||
gimp_color_button_new (const gchar *title,
|
||||
gint width,
|
||||
gint height,
|
||||
guchar *color,
|
||||
gint bpp)
|
||||
guint width,
|
||||
guint height,
|
||||
GimpRGB *color,
|
||||
gboolean alpha)
|
||||
{
|
||||
return _gimp_color_button_new (FALSE, title, width, height,
|
||||
(gpointer) color, bpp);
|
||||
GimpColorButton *gcb;
|
||||
|
||||
g_return_val_if_fail (width > 0 && height > 0, NULL);
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
gcb = gtk_type_new (gimp_color_button_get_type ());
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_button_double_new:
|
||||
* @title: String that wil be used as title for the color_selector.
|
||||
* @width: Width of the colorpreview in pixels.
|
||||
* @height: Height of the colorpreview in pixels.
|
||||
* @color: An array of gdouble holding the color (RGB or RGBA)
|
||||
* @bpp: May be 3 for RGB or 4 for RGBA.
|
||||
*
|
||||
* Creates a new #GimpColorButton widget.
|
||||
*
|
||||
* This returns a button with a preview showing the color.
|
||||
* When the button is clicked a GtkColorSelectionDialog is opened.
|
||||
* If the user changes the color the new color is written into the
|
||||
* array that was used to pass the initial color and the "color_changed"
|
||||
* signal is emitted.
|
||||
*
|
||||
* Returns: Pointer to the new GimpColorButton widget.
|
||||
**/
|
||||
GtkWidget *
|
||||
gimp_color_button_double_new (const gchar *title,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble *color,
|
||||
gint bpp)
|
||||
{
|
||||
return _gimp_color_button_new (TRUE, title, width, height,
|
||||
(gpointer) color, bpp);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_button_update:
|
||||
* gimp_color_button_set_color:
|
||||
* @gcb: Pointer to a #GimpColorButton.
|
||||
* @color: Pointer to the new #GimpRGB color.
|
||||
*
|
||||
* Should be used after the color controlled by a #GimpColorButton
|
||||
* was changed. The color is then reread and the change is propagated
|
||||
* to the preview and the GtkColorSelectionDialog if one is open.
|
||||
**/
|
||||
void
|
||||
gimp_color_button_update (GimpColorButton *gcb)
|
||||
gimp_color_button_set_color (GimpColorButton *gcb,
|
||||
GimpRGB *color)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (gcb != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb));
|
||||
|
||||
if (gcb->double_color)
|
||||
{
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
gcb->dcolor[i] = ((gdouble *) gcb->color)[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
gcb->dcolor[i] = (gdouble) ((guchar *) gcb->color)[i] / 255.0;
|
||||
}
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
gimp_color_button_paint (gcb);
|
||||
gimp_color_area_set_color (GIMP_COLOR_AREA (gcb->color_area), color);
|
||||
}
|
||||
|
||||
if (gcb->dialog)
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel),
|
||||
gcb->dcolor);
|
||||
/**
|
||||
* gimp_color_button_get_color:
|
||||
* @gcb: Pointer to a #GimpColorButton.
|
||||
*
|
||||
**/
|
||||
void
|
||||
gimp_color_button_get_color (GimpColorButton *gcb,
|
||||
GimpRGB *color)
|
||||
{
|
||||
g_return_if_fail (gcb != NULL);
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
gimp_color_area_get_color (GIMP_COLOR_AREA (gcb->color_area), color);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_button_has_alpha:
|
||||
* @gcb: Pointer to a #GimpColorButton.
|
||||
*
|
||||
**/
|
||||
gboolean
|
||||
gimp_color_button_has_alpha (GimpColorButton *gcb)
|
||||
{
|
||||
g_return_val_if_fail (gcb != NULL, FALSE);
|
||||
|
||||
return gimp_color_area_has_alpha (GIMP_COLOR_AREA (gcb->color_area));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -464,155 +330,79 @@ static void
|
|||
gimp_color_button_clicked (GtkButton *button)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
GtkColorSelection *colorsel;
|
||||
GimpRGB color;
|
||||
gdouble dcolor[4];
|
||||
|
||||
g_return_if_fail (button != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
|
||||
|
||||
gcb = GIMP_COLOR_BUTTON (button);
|
||||
|
||||
gimp_color_button_get_color (gcb, &color);
|
||||
|
||||
dcolor[0] = color.r;
|
||||
dcolor[1] = color.g;
|
||||
dcolor[2] = color.b;
|
||||
dcolor[3] = color.a;
|
||||
|
||||
if (!gcb->dialog)
|
||||
{
|
||||
gcb->dialog = gtk_color_selection_dialog_new (gcb->title);
|
||||
colorsel = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel);
|
||||
gtk_color_selection_set_opacity (colorsel, (gcb->bpp == 4));
|
||||
gtk_color_selection_set_color (colorsel, gcb->dcolor);
|
||||
|
||||
gtk_color_selection_set_opacity (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), gimp_color_button_has_alpha (gcb));
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), dcolor);
|
||||
|
||||
gtk_widget_destroy (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->help_button);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (gcb->dialog), 2);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->dialog), "destroy",
|
||||
(GtkSignalFunc) gtk_widget_destroyed, &gcb->dialog);
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&gcb->dialog);
|
||||
gtk_signal_connect (GTK_OBJECT (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->ok_button),
|
||||
"clicked",
|
||||
(GtkSignalFunc) gimp_color_button_dialog_ok, gcb);
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_dialog_ok),
|
||||
gcb);
|
||||
gtk_signal_connect (GTK_OBJECT (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->cancel_button),
|
||||
"clicked",
|
||||
(GtkSignalFunc) gimp_color_button_dialog_cancel, gcb);
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_dialog_cancel),
|
||||
gcb);
|
||||
gtk_window_set_position (GTK_WINDOW (gcb->dialog), GTK_WIN_POS_MOUSE);
|
||||
}
|
||||
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel),
|
||||
gcb->dcolor);
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), dcolor);
|
||||
|
||||
gtk_widget_show (gcb->dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_paint (GimpColorButton *gcb)
|
||||
{
|
||||
gint x, y, i;
|
||||
gdouble c0, c1;
|
||||
guchar *p0, *p1;
|
||||
|
||||
g_return_if_fail (gcb != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb));
|
||||
|
||||
p0 = gcb->even;
|
||||
p1 = gcb->odd;
|
||||
|
||||
if (gcb->bpp == 3)
|
||||
{
|
||||
for (x = 0; x < gcb->width; x++)
|
||||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
*p0++ = gcb->dcolor[i] * 255.999;
|
||||
}
|
||||
for (y = 0; y < gcb->height; y++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->even,
|
||||
0, y, gcb->width);
|
||||
}
|
||||
else /* gcb->bpp == 4 */
|
||||
{
|
||||
for (x = 0; x < gcb->width; x++)
|
||||
{
|
||||
if ((x / GIMP_CHECK_SIZE_SM) & 1)
|
||||
{
|
||||
c0 = GIMP_CHECK_LIGHT;
|
||||
c1 = GIMP_CHECK_DARK;
|
||||
}
|
||||
else
|
||||
{
|
||||
c0 = GIMP_CHECK_DARK;
|
||||
c1 = GIMP_CHECK_LIGHT;
|
||||
}
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
*p0++ = (c0 + (gcb->dcolor[i] - c0) * gcb->dcolor[3]) * 255.999;
|
||||
*p1++ = (c1 + (gcb->dcolor[i] - c1) * gcb->dcolor[3]) * 255.999;
|
||||
}
|
||||
}
|
||||
for (y = 0; y < gcb->height; y++)
|
||||
{
|
||||
if ((y / GIMP_CHECK_SIZE_SM) & 1)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->odd,
|
||||
0, y, gcb->width);
|
||||
else
|
||||
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->even,
|
||||
0, y, gcb->width);
|
||||
}
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw (gcb->preview);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_dialog_ok (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
gboolean color_changed = FALSE;
|
||||
gint i;
|
||||
GimpRGB color;
|
||||
gdouble dcolor[4];
|
||||
|
||||
g_return_if_fail (data != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (data));
|
||||
|
||||
gcb = GIMP_COLOR_BUTTON (data);
|
||||
|
||||
gtk_color_selection_get_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), gcb->dcolor);
|
||||
gtk_color_selection_get_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), dcolor);
|
||||
|
||||
if (gcb->double_color)
|
||||
{
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
{
|
||||
if (gcb->dcolor[i] != ((gdouble *) gcb->color)[i])
|
||||
color_changed = TRUE;
|
||||
((gdouble *) gcb->color)[i] = gcb->dcolor[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
guchar new_color[4];
|
||||
gimp_rgba_set (&color, dcolor[0], dcolor[1], dcolor[2], dcolor[3]);
|
||||
gimp_color_button_set_color (gcb, &color);
|
||||
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
{
|
||||
new_color[i] = gcb->dcolor[i] * 255.999;
|
||||
if (new_color[i] != ((guchar *) gcb->color)[i])
|
||||
color_changed = TRUE;
|
||||
((guchar *) gcb->color)[i] = new_color[i];
|
||||
}
|
||||
}
|
||||
|
||||
gtk_widget_hide (gcb->dialog);
|
||||
|
||||
if (color_changed)
|
||||
{
|
||||
gimp_color_button_paint (gcb);
|
||||
gtk_signal_emit (GTK_OBJECT (gcb),
|
||||
gimp_color_button_signals[COLOR_CHANGED]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_dialog_cancel (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
|
||||
g_return_if_fail (data != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (data));
|
||||
|
||||
gcb = GIMP_COLOR_BUTTON (data);
|
||||
|
||||
gtk_widget_hide (gcb->dialog);
|
||||
gtk_widget_hide (GIMP_COLOR_BUTTON (data)->dialog);
|
||||
}
|
||||
|
||||
|
||||
|
@ -621,65 +411,66 @@ gimp_color_button_use_fg (gpointer callback_data,
|
|||
guint callback_action,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
guchar fg_color[3];
|
||||
gint i;
|
||||
GimpRGB color;
|
||||
guchar fg_color[3];
|
||||
|
||||
g_return_if_fail (callback_data != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data));
|
||||
|
||||
gcb = GIMP_COLOR_BUTTON (callback_data);
|
||||
gimp_palette_get_foreground (&fg_color[0], &fg_color[1], &fg_color[2]);
|
||||
|
||||
gimp_palette_get_foreground (fg_color, &fg_color[1], &fg_color[2]);
|
||||
|
||||
if (gcb->double_color)
|
||||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
((gdouble *) gcb->color)[i] = fg_color[i] / 255.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 3; i ++)
|
||||
((guchar *) gcb->color)[i] = fg_color[i];
|
||||
}
|
||||
|
||||
gimp_color_button_update (gcb);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (gcb),
|
||||
gimp_color_button_signals[COLOR_CHANGED]);
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (callback_data), &color);
|
||||
gimp_rgb_set (&color,
|
||||
fg_color[0] / 255.0,
|
||||
fg_color[1] / 255.0,
|
||||
fg_color[2] / 255.0);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (callback_data), &color);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_color_button_use_bg (gpointer callback_data,
|
||||
guint callback_action,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
guchar bg_color[3];
|
||||
gint i;
|
||||
GimpRGB color;
|
||||
guchar bg_color[3];
|
||||
|
||||
g_return_if_fail (callback_data != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data));
|
||||
|
||||
gcb = GIMP_COLOR_BUTTON (callback_data);
|
||||
gimp_palette_get_background (&bg_color[0], &bg_color[1], &bg_color[2]);
|
||||
|
||||
gimp_palette_get_background (bg_color, &bg_color[1], &bg_color[2]);
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (callback_data), &color);
|
||||
gimp_rgb_set (&color,
|
||||
bg_color[0] / 255.0,
|
||||
bg_color[1] / 255.0,
|
||||
bg_color[2] / 255.0);
|
||||
|
||||
if (gcb->double_color)
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (callback_data), &color);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_color_changed (GtkObject *object,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb = GIMP_COLOR_BUTTON (data);
|
||||
|
||||
if (gcb->dialog)
|
||||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
((gdouble *) gcb->color)[i] = bg_color[i] / 255.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 3; i ++)
|
||||
((guchar *) gcb->color)[i] = bg_color[i];
|
||||
GimpRGB color;
|
||||
gdouble dcolor[4];
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
|
||||
dcolor[0] = color.r;
|
||||
dcolor[1] = color.g;
|
||||
dcolor[2] = color.b;
|
||||
dcolor[3] = color.a;
|
||||
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), dcolor);
|
||||
}
|
||||
|
||||
gimp_color_button_update (gcb);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (gcb),
|
||||
gtk_signal_emit (GTK_OBJECT (gcb),
|
||||
gimp_color_button_signals[COLOR_CHANGED]);
|
||||
}
|
||||
|
||||
|
@ -689,126 +480,3 @@ gimp_color_button_menu_translate (const gchar *path,
|
|||
{
|
||||
return (gettext (path));
|
||||
}
|
||||
|
||||
/* DND -- remove as soon as gimpdnd is in libgimp */
|
||||
|
||||
static void
|
||||
gimp_color_button_drag_begin (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb = data;
|
||||
GtkWidget *window;
|
||||
GdkColor bg;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
|
||||
gtk_widget_set_usize (window, DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
|
||||
gtk_widget_realize (window);
|
||||
gtk_object_set_data_full (GTK_OBJECT (widget),
|
||||
"gimp-color-button-drag-window",
|
||||
window,
|
||||
(GtkDestroyNotify) gtk_widget_destroy);
|
||||
|
||||
bg.red = 0xffff * gcb->dcolor[0];
|
||||
bg.green = 0xffff * gcb->dcolor[1];
|
||||
bg.blue = 0xffff * gcb->dcolor[2];
|
||||
|
||||
gdk_color_alloc (gtk_widget_get_colormap (window), &bg);
|
||||
gdk_window_set_background (window->window, &bg);
|
||||
|
||||
gtk_drag_set_icon_widget (context, window, DRAG_ICON_OFFSET, DRAG_ICON_OFFSET);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_drag_end (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_object_set_data (GTK_OBJECT (widget),
|
||||
"gimp-color-button-drag-window", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_drop_handle (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb = data;
|
||||
guint16 *vals;
|
||||
gboolean color_changed = FALSE;
|
||||
gint i;
|
||||
|
||||
if (selection_data->length < 0)
|
||||
return;
|
||||
|
||||
if ((selection_data->format != 16) ||
|
||||
(selection_data->length != 8))
|
||||
{
|
||||
g_warning ("Received invalid color data\n");
|
||||
return;
|
||||
}
|
||||
|
||||
vals = (guint16 *)selection_data->data;
|
||||
|
||||
if (gcb->double_color)
|
||||
{
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
{
|
||||
gcb->dcolor[i] = (gdouble) vals[i] / 0xffff;
|
||||
if (gcb->dcolor[i] != ((gdouble *) gcb->color)[i])
|
||||
color_changed = TRUE;
|
||||
((gdouble *) gcb->color)[i] = gcb->dcolor[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
guchar new_color[4];
|
||||
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
{
|
||||
gcb->dcolor[i] = (gdouble) vals[i] / 0xffff;
|
||||
new_color[i] = gcb->dcolor[i] * 255.999;
|
||||
if (new_color[i] != ((guchar *) gcb->color)[i])
|
||||
color_changed = TRUE;
|
||||
((guchar *) gcb->color)[i] = new_color[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (color_changed)
|
||||
{
|
||||
gimp_color_button_paint (gcb);
|
||||
gtk_signal_emit (GTK_OBJECT (gcb),
|
||||
gimp_color_button_signals[COLOR_CHANGED]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_drag_handle (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb = data;
|
||||
guint16 vals[4];
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
vals[i] = gcb->dcolor[i] * 0xffff;
|
||||
|
||||
if (i == 3)
|
||||
vals[3] = 0xffff;
|
||||
|
||||
gtk_selection_data_set (selection_data,
|
||||
gdk_atom_intern ("application/x-color", FALSE),
|
||||
16, (guchar *)vals, 8);
|
||||
}
|
||||
|
||||
/* end of DND */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpcolorbutton.h
|
||||
* Copyright (C) 1999 Sven Neumann
|
||||
* Copyright (C) 1999-2001 Sven Neumann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -52,16 +52,15 @@ struct _GimpColorButtonClass
|
|||
|
||||
GtkType gimp_color_button_get_type (void);
|
||||
GtkWidget * gimp_color_button_new (const gchar *title,
|
||||
gint width,
|
||||
gint height,
|
||||
guchar *color,
|
||||
gint bpp);
|
||||
GtkWidget * gimp_color_button_double_new (const gchar *title,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble *color,
|
||||
gint bpp);
|
||||
void gimp_color_button_update (GimpColorButton *gcb);
|
||||
guint width,
|
||||
guint height,
|
||||
GimpRGB *color,
|
||||
gboolean alpha);
|
||||
void gimp_color_button_set_color (GimpColorButton *gcb,
|
||||
GimpRGB *color);
|
||||
void gimp_color_button_get_color (GimpColorButton *gcb,
|
||||
GimpRGB *color);/* returns */
|
||||
gboolean gimp_color_button_has_alpha (GimpColorButton *gcb);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include "gimptypes.h"
|
||||
#include "gimpuitypes.h"
|
||||
|
||||
#include "gimpcolorarea.h"
|
||||
#include "gimpcolorbutton.h"
|
||||
#include "gimpchainbutton.h"
|
||||
#include "gimphelpui.h"
|
||||
#include "gimppixmap.h"
|
||||
|
@ -1337,6 +1339,51 @@ gimp_unit_menu_update (GtkWidget *widget,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_update:
|
||||
* @widget: A pointer to a #GimpColorArea or #GimpColorButton.
|
||||
* @data: A pointer to an array of #guchar that will be set to the new color.
|
||||
*
|
||||
* This function will go away.
|
||||
**/
|
||||
void
|
||||
gimp_color_update_uchar (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB color;
|
||||
gboolean alpha;
|
||||
guchar *dest;
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_AREA (widget) ||
|
||||
GIMP_IS_COLOR_BUTTON (widget));
|
||||
|
||||
if (GIMP_IS_COLOR_AREA (widget))
|
||||
{
|
||||
gimp_color_area_get_color (GIMP_COLOR_AREA (widget), &color);
|
||||
alpha = gimp_color_area_has_alpha (GIMP_COLOR_AREA (widget));
|
||||
}
|
||||
else if (GIMP_IS_COLOR_BUTTON (widget))
|
||||
{
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (widget), &color);
|
||||
alpha = gimp_color_button_has_alpha (GIMP_COLOR_BUTTON (widget));
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
dest = (guchar *) data;
|
||||
|
||||
*dest++ = color.r * 255.999;
|
||||
*dest++ = color.g * 255.999;
|
||||
*dest++ = color.b * 255.999;
|
||||
|
||||
if (alpha)
|
||||
*dest++ = color.a * 255.999;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Helper Functions
|
||||
*/
|
||||
|
|
|
@ -227,6 +227,9 @@ void gimp_double_adjustment_update (GtkAdjustment *adjustment,
|
|||
void gimp_unit_menu_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
void gimp_color_update_uchar (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
/*
|
||||
* Helper Functions
|
||||
*/
|
||||
|
|
|
@ -60,7 +60,7 @@ static GtkWidgetClass *parent_class = NULL;
|
|||
static void gimp_color_area_class_init (GimpColorAreaClass *class);
|
||||
static void gimp_color_area_init (GimpColorArea *gca);
|
||||
static void gimp_color_area_destroy (GtkObject *object);
|
||||
static void gimp_color_area_paint (GimpColorArea *gca);
|
||||
static void gimp_color_area_update (GimpColorArea *gca);
|
||||
|
||||
static void gimp_color_area_drag_begin (GtkWidget *widget,
|
||||
GdkDragContext *context);
|
||||
|
@ -121,16 +121,16 @@ gimp_color_area_class_init (GimpColorAreaClass *class)
|
|||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpColorAreaClass,
|
||||
color_changed),
|
||||
gtk_marshal_NONE__POINTER,
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE,
|
||||
1, GTK_TYPE_POINTER);
|
||||
0);
|
||||
|
||||
gtk_object_class_add_signals (object_class, gimp_color_area_signals,
|
||||
LAST_SIGNAL);
|
||||
|
||||
class->color_changed = NULL;
|
||||
|
||||
object_class->destroy = gimp_color_area_destroy;
|
||||
object_class->destroy = gimp_color_area_destroy;
|
||||
|
||||
widget_class->drag_begin = gimp_color_area_drag_begin;
|
||||
widget_class->drag_end = gimp_color_area_drag_end;
|
||||
|
@ -160,8 +160,9 @@ gimp_color_area_destroy (GtkObject *object)
|
|||
|
||||
/**
|
||||
* gimp_color_area_new:
|
||||
* @color: An array of guchar holding the color (RGB or RGBA)
|
||||
* @bpp: May be 3 for RGB or 4 for RGBA.
|
||||
* @color: A pointer to a #GimpRGB struct.
|
||||
* @alpha: If the color_area should show alpha.
|
||||
* @drag_mask: The event_mask that should trigger drags.
|
||||
*
|
||||
* Creates a new #GimpColorArea widget.
|
||||
*
|
||||
|
@ -171,8 +172,9 @@ 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 (GimpRGB *color,
|
||||
gboolean alpha,
|
||||
GdkModifierType drag_mask)
|
||||
{
|
||||
GimpColorArea *gca;
|
||||
|
||||
|
@ -181,15 +183,19 @@ 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), "size_allocate",
|
||||
GTK_SIGNAL_FUNC (gimp_color_area_paint),
|
||||
gtk_signal_connect_after (GTK_OBJECT (gca), "realize",
|
||||
GTK_SIGNAL_FUNC (gimp_color_area_update),
|
||||
NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (gca), "size_allocate",
|
||||
GTK_SIGNAL_FUNC (gimp_color_area_update),
|
||||
NULL);
|
||||
|
||||
gtk_drag_dest_set (GTK_WIDGET (gca),
|
||||
GTK_DEST_DEFAULT_HIGHLIGHT |
|
||||
|
@ -197,10 +203,15 @@ gimp_color_area_new (GimpRGB *color,
|
|||
GTK_DEST_DEFAULT_DROP,
|
||||
targets, 1,
|
||||
GDK_ACTION_COPY);
|
||||
gtk_drag_source_set (GTK_WIDGET (gca),
|
||||
GDK_BUTTON2_MASK,
|
||||
targets, 1,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
|
||||
/* do we need this ?? */
|
||||
drag_mask &= (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK);
|
||||
|
||||
if (drag_mask)
|
||||
gtk_drag_source_set (GTK_WIDGET (gca),
|
||||
drag_mask,
|
||||
targets, 1,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
|
||||
return GTK_WIDGET (gca);
|
||||
}
|
||||
|
@ -224,27 +235,47 @@ gimp_color_area_set_color (GimpColorArea *gca,
|
|||
{
|
||||
gca->color = *color;
|
||||
|
||||
gimp_color_area_paint (gca);
|
||||
gimp_color_area_update (gca);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (gca),
|
||||
gimp_color_area_signals[COLOR_CHANGED],
|
||||
&gca->color);
|
||||
gimp_color_area_signals[COLOR_CHANGED]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_area_paint (GimpColorArea *gca)
|
||||
void
|
||||
gimp_color_area_get_color (GimpColorArea *gca,
|
||||
GimpRGB *color)
|
||||
{
|
||||
gint x, y;
|
||||
gdouble c0, c1;
|
||||
g_return_if_fail (gca != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_AREA (gca));
|
||||
|
||||
*color = gca->color;
|
||||
}
|
||||
|
||||
gboolean
|
||||
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;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_area_update (GimpColorArea *gca)
|
||||
{
|
||||
guint x, y;
|
||||
guint width, height;
|
||||
guchar *p0, *p1;
|
||||
guchar *even, *odd;
|
||||
guchar light[3];
|
||||
guchar dark[3];
|
||||
guchar opaque[3];
|
||||
guchar *p;
|
||||
guchar *buf;
|
||||
|
||||
g_return_if_fail (gca != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_AREA (gca));
|
||||
|
||||
if (! GTK_WIDGET_DRAWABLE (GTK_WIDGET (gca)))
|
||||
if (! GTK_WIDGET_REALIZED (GTK_WIDGET (gca)))
|
||||
return;
|
||||
|
||||
gdk_window_get_size (GTK_WIDGET (gca)->window, &width, &height);
|
||||
|
@ -252,55 +283,72 @@ gimp_color_area_paint (GimpColorArea *gca)
|
|||
if (!width || !height)
|
||||
return;
|
||||
|
||||
p0 = even = g_new (guchar, width * 3);
|
||||
p1 = odd = g_new (guchar, width * 3);
|
||||
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)
|
||||
{
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
if ((x / GIMP_CHECK_SIZE_SM) & 1)
|
||||
{
|
||||
c0 = GIMP_CHECK_LIGHT;
|
||||
c1 = GIMP_CHECK_DARK;
|
||||
}
|
||||
else
|
||||
{
|
||||
c0 = GIMP_CHECK_DARK;
|
||||
c1 = GIMP_CHECK_LIGHT;
|
||||
}
|
||||
|
||||
*p0++ = (c0 + (gca->color.r - c0) * gca->color.a) * 255.999;
|
||||
*p1++ = (c1 + (gca->color.r - c1) * gca->color.a) * 255.999;
|
||||
*p0++ = (c0 + (gca->color.g - c0) * gca->color.a) * 255.999;
|
||||
*p1++ = (c1 + (gca->color.g - c1) * gca->color.a) * 255.999;
|
||||
*p0++ = (c0 + (gca->color.b - c0) * gca->color.a) * 255.999;
|
||||
*p1++ = (c1 + (gca->color.b - c1) * gca->color.a) * 255.999;
|
||||
}
|
||||
light[0] = (GIMP_CHECK_LIGHT +
|
||||
(gca->color.r - GIMP_CHECK_LIGHT) * gca->color.a) * 255.999;
|
||||
dark[0] = (GIMP_CHECK_DARK +
|
||||
(gca->color.r - GIMP_CHECK_DARK) * gca->color.a) * 255.999;
|
||||
light[1] = (GIMP_CHECK_LIGHT +
|
||||
(gca->color.g - GIMP_CHECK_LIGHT) * gca->color.a) * 255.999;
|
||||
dark[1] = (GIMP_CHECK_DARK +
|
||||
(gca->color.g - GIMP_CHECK_DARK) * gca->color.a) * 255.999;
|
||||
light[2] = (GIMP_CHECK_LIGHT +
|
||||
(gca->color.b - GIMP_CHECK_LIGHT) * gca->color.a) * 255.999;
|
||||
dark[2] = (GIMP_CHECK_DARK +
|
||||
(gca->color.b - GIMP_CHECK_DARK) * gca->color.a) * 255.999;
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
if ((y / GIMP_CHECK_SIZE_SM) & 1)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (gca), odd, 0, y, width);
|
||||
else
|
||||
gtk_preview_draw_row (GTK_PREVIEW (gca), even, 0, y, width);
|
||||
p = buf;
|
||||
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
if (x <= y)
|
||||
{
|
||||
*p++ = opaque[0];
|
||||
*p++ = opaque[1];
|
||||
*p++ = opaque[2];
|
||||
}
|
||||
else if (((x / GIMP_CHECK_SIZE_SM) ^ (y / GIMP_CHECK_SIZE_SM))
|
||||
& 1)
|
||||
{
|
||||
*p++ = light[0];
|
||||
*p++ = light[1];
|
||||
*p++ = light[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
*p++ = dark[0];
|
||||
*p++ = dark[1];
|
||||
*p++ = dark[2];
|
||||
}
|
||||
}
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW (gca), buf,
|
||||
0, height - y - 1, width);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
*p0++ = gca->color.r;
|
||||
*p0++ = gca->color.g;
|
||||
*p0++ = gca->color.b;
|
||||
*p++ = opaque[0];
|
||||
*p++ = opaque[1];
|
||||
*p++ = opaque[2];
|
||||
}
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (gca), even, 0, y, width);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (gca), buf, 0, y, width);
|
||||
}
|
||||
|
||||
g_free (even);
|
||||
g_free (odd);
|
||||
g_free (buf);
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (gca));
|
||||
}
|
||||
|
@ -309,28 +357,35 @@ static void
|
|||
gimp_color_area_drag_begin (GtkWidget *widget,
|
||||
GdkDragContext *context)
|
||||
{
|
||||
GimpColorArea *gca;
|
||||
GtkWidget *window;
|
||||
GdkColor bg;
|
||||
|
||||
gca = GIMP_COLOR_AREA (widget);
|
||||
GimpRGB color;
|
||||
GtkWidget *window;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *color_area;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
|
||||
gtk_widget_set_usize (window, DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
|
||||
gtk_widget_realize (window);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (window), frame);
|
||||
|
||||
gimp_color_area_get_color (GIMP_COLOR_AREA (widget), &color);
|
||||
|
||||
color_area =
|
||||
gimp_color_area_new (&color,
|
||||
gimp_color_area_has_alpha (GIMP_COLOR_AREA (widget)),
|
||||
0);
|
||||
|
||||
gtk_widget_set_usize (color_area, DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
|
||||
gtk_container_add (GTK_CONTAINER (frame), color_area);
|
||||
gtk_widget_show (color_area);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
gtk_object_set_data_full (GTK_OBJECT (widget),
|
||||
"gimp-color-area-drag-window",
|
||||
window,
|
||||
(GtkDestroyNotify) gtk_widget_destroy);
|
||||
|
||||
bg.red = gca->color.r * 0xffff;
|
||||
bg.green = gca->color.g * 0xffff;
|
||||
bg.blue = gca->color.b * 0xffff;
|
||||
|
||||
gdk_color_alloc (gtk_widget_get_colormap (window), &bg);
|
||||
gdk_window_set_background (window->window, &bg);
|
||||
|
||||
gtk_drag_set_icon_widget (context, window, DRAG_ICON_OFFSET, DRAG_ICON_OFFSET);
|
||||
}
|
||||
|
||||
|
@ -393,9 +448,14 @@ gimp_color_area_drag_data_get (GtkWidget *widget,
|
|||
vals[0] = gca->color.r * 0xffff;
|
||||
vals[1] = gca->color.g * 0xffff;
|
||||
vals[2] = gca->color.b * 0xffff;
|
||||
vals[3] = gca->color.a * 0xffff;
|
||||
|
||||
if (gca->alpha)
|
||||
vals[3] = gca->color.a * 0xffff;
|
||||
else
|
||||
vals[3] = 0xffff;
|
||||
|
||||
gtk_selection_data_set (selection_data,
|
||||
gdk_atom_intern ("application/x-color", FALSE),
|
||||
16, (guchar *)vals, 8);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,16 +50,19 @@ struct _GimpColorAreaClass
|
|||
{
|
||||
GtkPreviewClass parent_class;
|
||||
|
||||
void (* color_changed) (GimpColorArea *gca,
|
||||
GimpRGB *color);
|
||||
void (* color_changed) (GimpColorArea *gca);
|
||||
};
|
||||
|
||||
|
||||
GtkType gimp_color_area_get_type (void);
|
||||
GtkWidget * gimp_color_area_new (GimpRGB *color,
|
||||
gboolean alpha);
|
||||
void gimp_color_area_set_color (GimpColorArea *gca,
|
||||
GimpRGB *color);
|
||||
GtkWidget * gimp_color_area_new (GimpRGB *color,
|
||||
gboolean alpha,
|
||||
GdkModifierType drag_mask);
|
||||
void gimp_color_area_set_color (GimpColorArea *gca,
|
||||
GimpRGB *color);
|
||||
void gimp_color_area_get_color (GimpColorArea *gca,
|
||||
GimpRGB *color); /* returns */
|
||||
gboolean gimp_color_area_has_alpha (GimpColorArea *gca);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpcolorbutton.c
|
||||
* Copyright (C) 1999 Sven Neumann
|
||||
* Copyright (C) 1999-2001 Sven Neumann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -20,14 +20,6 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* TODO:
|
||||
*
|
||||
* handle bytes != 3|4 -- would we have to provide a special color
|
||||
* select dialog for that case? Another possibility
|
||||
* could be to hide or destroy all color-related
|
||||
* widgets in the gtk colorselector.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
@ -36,87 +28,49 @@
|
|||
|
||||
#include "gimpuitypes.h"
|
||||
|
||||
#include "gimpcolorarea.h"
|
||||
#include "gimpcolorbutton.h"
|
||||
#include "gimplimits.h"
|
||||
|
||||
#include "libgimp-intl.h"
|
||||
|
||||
|
||||
/* DND -- remove as soon as gimpdnd is in libgimp */
|
||||
#define DRAG_PREVIEW_SIZE 32
|
||||
#define DRAG_ICON_OFFSET -8
|
||||
|
||||
static void gimp_color_button_drag_begin (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data);
|
||||
static void gimp_color_button_drag_end (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data);
|
||||
static void gimp_color_button_drop_handle (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data);
|
||||
static void gimp_color_button_drag_handle (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data);
|
||||
|
||||
static const GtkTargetEntry targets[] = { { "application/x-color", 0 } };
|
||||
|
||||
|
||||
/* end of DND */
|
||||
|
||||
struct _GimpColorButton
|
||||
{
|
||||
GtkButton button;
|
||||
GtkButton button;
|
||||
|
||||
gboolean double_color;
|
||||
|
||||
gchar *title;
|
||||
gpointer color;
|
||||
gint bpp;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
gdouble *dcolor;
|
||||
GtkWidget *preview;
|
||||
|
||||
GtkWidget *color_area;
|
||||
GtkWidget *dialog;
|
||||
GtkItemFactory *item_factory;
|
||||
|
||||
guchar *even;
|
||||
guchar *odd;
|
||||
};
|
||||
|
||||
|
||||
static void gimp_color_button_destroy (GtkObject *object);
|
||||
static void gimp_color_button_clicked (GtkButton *button);
|
||||
static void gimp_color_button_paint (GimpColorButton *gcb);
|
||||
static void gimp_color_button_state_changed (GtkWidget *widget,
|
||||
GtkStateType previous_state);
|
||||
|
||||
static void gimp_color_button_dialog_ok (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_color_button_dialog_cancel (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_color_button_dialog_ok (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_color_button_dialog_cancel (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static void gimp_color_button_use_fg (gpointer callback_data,
|
||||
guint callback_action,
|
||||
GtkWidget *widget);
|
||||
static void gimp_color_button_use_bg (gpointer callback_data,
|
||||
guint callback_action,
|
||||
GtkWidget *widget);
|
||||
static void gimp_color_button_use_fg (gpointer callback_data,
|
||||
guint callback_action,
|
||||
GtkWidget *widget);
|
||||
static void gimp_color_button_use_bg (gpointer callback_data,
|
||||
guint callback_action,
|
||||
GtkWidget *widget);
|
||||
|
||||
static gint gimp_color_button_menu_popup (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static gchar* gimp_color_button_menu_translate (const gchar *path,
|
||||
gpointer func_data);
|
||||
static gint gimp_color_button_menu_popup (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static gchar * gimp_color_button_menu_translate (const gchar *path,
|
||||
gpointer func_data);
|
||||
|
||||
static void gimp_color_button_color_changed (GtkObject *object,
|
||||
gpointer data);
|
||||
|
||||
|
||||
static GtkItemFactoryEntry menu_items[] =
|
||||
|
@ -150,10 +104,9 @@ gimp_color_button_destroy (GtkObject *object)
|
|||
if (gcb->dialog)
|
||||
gtk_widget_destroy (gcb->dialog);
|
||||
|
||||
g_free (gcb->dcolor);
|
||||
g_free (gcb->even);
|
||||
g_free (gcb->odd);
|
||||
|
||||
if (gcb->color_area)
|
||||
gtk_widget_destroy (gcb->color_area);
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
@ -178,7 +131,9 @@ gimp_color_button_class_init (GimpColorButtonClass *class)
|
|||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpColorButtonClass,
|
||||
color_changed),
|
||||
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE,
|
||||
0);
|
||||
|
||||
gtk_object_class_add_signals (object_class, gimp_color_button_signals,
|
||||
LAST_SIGNAL);
|
||||
|
@ -194,18 +149,9 @@ gimp_color_button_class_init (GimpColorButtonClass *class)
|
|||
static void
|
||||
gimp_color_button_init (GimpColorButton *gcb)
|
||||
{
|
||||
gcb->double_color = FALSE;
|
||||
|
||||
gcb->title = NULL;
|
||||
gcb->bpp = 0;
|
||||
gcb->color = NULL;
|
||||
|
||||
gcb->dcolor = NULL;
|
||||
gcb->preview = NULL;
|
||||
gcb->color_area = NULL;
|
||||
gcb->dialog = NULL;
|
||||
|
||||
gcb->even = NULL;
|
||||
gcb->odd = NULL;
|
||||
}
|
||||
|
||||
GtkType
|
||||
|
@ -233,103 +179,13 @@ gimp_color_button_get_type (void)
|
|||
return gcb_type;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
_gimp_color_button_new (gboolean double_color,
|
||||
const gchar *title,
|
||||
gint width,
|
||||
gint height,
|
||||
gpointer color,
|
||||
gint bpp)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (width > 0 && height > 0, NULL);
|
||||
g_return_val_if_fail (bpp == 3 || bpp == 4, NULL);
|
||||
|
||||
gcb = gtk_type_new (gimp_color_button_get_type ());
|
||||
|
||||
gcb->double_color = double_color;
|
||||
|
||||
gcb->title = g_strdup (title);
|
||||
gcb->width = width;
|
||||
gcb->height = height;
|
||||
gcb->color = color;
|
||||
gcb->bpp = bpp;
|
||||
|
||||
gcb->dcolor = g_new (gdouble, 4);
|
||||
gcb->even = g_new (guchar, 3 * width);
|
||||
gcb->odd = g_new (guchar, 3 * width);
|
||||
|
||||
if (double_color)
|
||||
{
|
||||
for (i = 0; i < bpp; i++)
|
||||
gcb->dcolor[i] = ((gdouble *) color)[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < bpp; i++)
|
||||
gcb->dcolor[i] = (gdouble) ((guchar *) color)[i] / 255.0;
|
||||
}
|
||||
|
||||
if (bpp == 3)
|
||||
gcb->dcolor[3] = 1.0;
|
||||
|
||||
gcb->preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview), "destroy",
|
||||
gtk_widget_destroyed, &gcb->preview);
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (gcb->preview), width, height);
|
||||
gtk_container_add (GTK_CONTAINER (gcb), gcb->preview);
|
||||
gtk_widget_show (gcb->preview);
|
||||
gimp_color_button_paint (gcb);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* DND -- to be changed as soon as gimpdnd is in libgimp */
|
||||
gtk_drag_dest_set (gcb->preview,
|
||||
GTK_DEST_DEFAULT_HIGHLIGHT |
|
||||
GTK_DEST_DEFAULT_MOTION |
|
||||
GTK_DEST_DEFAULT_DROP,
|
||||
targets, 1,
|
||||
GDK_ACTION_COPY);
|
||||
gtk_drag_source_set (gcb->preview,
|
||||
GDK_BUTTON2_MASK,
|
||||
targets, 1,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview), "drag_begin",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_drag_begin),
|
||||
gcb);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview), "drag_end",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_drag_end),
|
||||
gcb);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview), "drag_data_get",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_drag_handle),
|
||||
gcb);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview), "drag_data_received",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_drop_handle),
|
||||
gcb);
|
||||
/* end of DND */
|
||||
|
||||
return GTK_WIDGET (gcb);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_button_new:
|
||||
* @title: String that will be used as title for the color_selector.
|
||||
* @width: Width of the colorpreview in pixels.
|
||||
* @height: Height of the colorpreview in pixels.
|
||||
* @color: An array of guchar holding the color (RGB or RGBA)
|
||||
* @bpp: May be 3 for RGB or 4 for RGBA.
|
||||
* @color: A pointer to a #GimpRGB color.
|
||||
* @alpha: TRUE if the button should show alpha.
|
||||
*
|
||||
* Creates a new #GimpColorButton widget.
|
||||
*
|
||||
|
@ -343,76 +199,86 @@ _gimp_color_button_new (gboolean double_color,
|
|||
**/
|
||||
GtkWidget *
|
||||
gimp_color_button_new (const gchar *title,
|
||||
gint width,
|
||||
gint height,
|
||||
guchar *color,
|
||||
gint bpp)
|
||||
guint width,
|
||||
guint height,
|
||||
GimpRGB *color,
|
||||
gboolean alpha)
|
||||
{
|
||||
return _gimp_color_button_new (FALSE, title, width, height,
|
||||
(gpointer) color, bpp);
|
||||
GimpColorButton *gcb;
|
||||
|
||||
g_return_val_if_fail (width > 0 && height > 0, NULL);
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
gcb = gtk_type_new (gimp_color_button_get_type ());
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_button_double_new:
|
||||
* @title: String that wil be used as title for the color_selector.
|
||||
* @width: Width of the colorpreview in pixels.
|
||||
* @height: Height of the colorpreview in pixels.
|
||||
* @color: An array of gdouble holding the color (RGB or RGBA)
|
||||
* @bpp: May be 3 for RGB or 4 for RGBA.
|
||||
*
|
||||
* Creates a new #GimpColorButton widget.
|
||||
*
|
||||
* This returns a button with a preview showing the color.
|
||||
* When the button is clicked a GtkColorSelectionDialog is opened.
|
||||
* If the user changes the color the new color is written into the
|
||||
* array that was used to pass the initial color and the "color_changed"
|
||||
* signal is emitted.
|
||||
*
|
||||
* Returns: Pointer to the new GimpColorButton widget.
|
||||
**/
|
||||
GtkWidget *
|
||||
gimp_color_button_double_new (const gchar *title,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble *color,
|
||||
gint bpp)
|
||||
{
|
||||
return _gimp_color_button_new (TRUE, title, width, height,
|
||||
(gpointer) color, bpp);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_button_update:
|
||||
* gimp_color_button_set_color:
|
||||
* @gcb: Pointer to a #GimpColorButton.
|
||||
* @color: Pointer to the new #GimpRGB color.
|
||||
*
|
||||
* Should be used after the color controlled by a #GimpColorButton
|
||||
* was changed. The color is then reread and the change is propagated
|
||||
* to the preview and the GtkColorSelectionDialog if one is open.
|
||||
**/
|
||||
void
|
||||
gimp_color_button_update (GimpColorButton *gcb)
|
||||
gimp_color_button_set_color (GimpColorButton *gcb,
|
||||
GimpRGB *color)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (gcb != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb));
|
||||
|
||||
if (gcb->double_color)
|
||||
{
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
gcb->dcolor[i] = ((gdouble *) gcb->color)[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
gcb->dcolor[i] = (gdouble) ((guchar *) gcb->color)[i] / 255.0;
|
||||
}
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
gimp_color_button_paint (gcb);
|
||||
gimp_color_area_set_color (GIMP_COLOR_AREA (gcb->color_area), color);
|
||||
}
|
||||
|
||||
if (gcb->dialog)
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel),
|
||||
gcb->dcolor);
|
||||
/**
|
||||
* gimp_color_button_get_color:
|
||||
* @gcb: Pointer to a #GimpColorButton.
|
||||
*
|
||||
**/
|
||||
void
|
||||
gimp_color_button_get_color (GimpColorButton *gcb,
|
||||
GimpRGB *color)
|
||||
{
|
||||
g_return_if_fail (gcb != NULL);
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
gimp_color_area_get_color (GIMP_COLOR_AREA (gcb->color_area), color);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_button_has_alpha:
|
||||
* @gcb: Pointer to a #GimpColorButton.
|
||||
*
|
||||
**/
|
||||
gboolean
|
||||
gimp_color_button_has_alpha (GimpColorButton *gcb)
|
||||
{
|
||||
g_return_val_if_fail (gcb != NULL, FALSE);
|
||||
|
||||
return gimp_color_area_has_alpha (GIMP_COLOR_AREA (gcb->color_area));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -464,155 +330,79 @@ static void
|
|||
gimp_color_button_clicked (GtkButton *button)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
GtkColorSelection *colorsel;
|
||||
GimpRGB color;
|
||||
gdouble dcolor[4];
|
||||
|
||||
g_return_if_fail (button != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
|
||||
|
||||
gcb = GIMP_COLOR_BUTTON (button);
|
||||
|
||||
gimp_color_button_get_color (gcb, &color);
|
||||
|
||||
dcolor[0] = color.r;
|
||||
dcolor[1] = color.g;
|
||||
dcolor[2] = color.b;
|
||||
dcolor[3] = color.a;
|
||||
|
||||
if (!gcb->dialog)
|
||||
{
|
||||
gcb->dialog = gtk_color_selection_dialog_new (gcb->title);
|
||||
colorsel = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel);
|
||||
gtk_color_selection_set_opacity (colorsel, (gcb->bpp == 4));
|
||||
gtk_color_selection_set_color (colorsel, gcb->dcolor);
|
||||
|
||||
gtk_color_selection_set_opacity (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), gimp_color_button_has_alpha (gcb));
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), dcolor);
|
||||
|
||||
gtk_widget_destroy (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->help_button);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (gcb->dialog), 2);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->dialog), "destroy",
|
||||
(GtkSignalFunc) gtk_widget_destroyed, &gcb->dialog);
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&gcb->dialog);
|
||||
gtk_signal_connect (GTK_OBJECT (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->ok_button),
|
||||
"clicked",
|
||||
(GtkSignalFunc) gimp_color_button_dialog_ok, gcb);
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_dialog_ok),
|
||||
gcb);
|
||||
gtk_signal_connect (GTK_OBJECT (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->cancel_button),
|
||||
"clicked",
|
||||
(GtkSignalFunc) gimp_color_button_dialog_cancel, gcb);
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_dialog_cancel),
|
||||
gcb);
|
||||
gtk_window_set_position (GTK_WINDOW (gcb->dialog), GTK_WIN_POS_MOUSE);
|
||||
}
|
||||
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel),
|
||||
gcb->dcolor);
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), dcolor);
|
||||
|
||||
gtk_widget_show (gcb->dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_paint (GimpColorButton *gcb)
|
||||
{
|
||||
gint x, y, i;
|
||||
gdouble c0, c1;
|
||||
guchar *p0, *p1;
|
||||
|
||||
g_return_if_fail (gcb != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb));
|
||||
|
||||
p0 = gcb->even;
|
||||
p1 = gcb->odd;
|
||||
|
||||
if (gcb->bpp == 3)
|
||||
{
|
||||
for (x = 0; x < gcb->width; x++)
|
||||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
*p0++ = gcb->dcolor[i] * 255.999;
|
||||
}
|
||||
for (y = 0; y < gcb->height; y++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->even,
|
||||
0, y, gcb->width);
|
||||
}
|
||||
else /* gcb->bpp == 4 */
|
||||
{
|
||||
for (x = 0; x < gcb->width; x++)
|
||||
{
|
||||
if ((x / GIMP_CHECK_SIZE_SM) & 1)
|
||||
{
|
||||
c0 = GIMP_CHECK_LIGHT;
|
||||
c1 = GIMP_CHECK_DARK;
|
||||
}
|
||||
else
|
||||
{
|
||||
c0 = GIMP_CHECK_DARK;
|
||||
c1 = GIMP_CHECK_LIGHT;
|
||||
}
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
*p0++ = (c0 + (gcb->dcolor[i] - c0) * gcb->dcolor[3]) * 255.999;
|
||||
*p1++ = (c1 + (gcb->dcolor[i] - c1) * gcb->dcolor[3]) * 255.999;
|
||||
}
|
||||
}
|
||||
for (y = 0; y < gcb->height; y++)
|
||||
{
|
||||
if ((y / GIMP_CHECK_SIZE_SM) & 1)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->odd,
|
||||
0, y, gcb->width);
|
||||
else
|
||||
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->even,
|
||||
0, y, gcb->width);
|
||||
}
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw (gcb->preview);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_dialog_ok (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
gboolean color_changed = FALSE;
|
||||
gint i;
|
||||
GimpRGB color;
|
||||
gdouble dcolor[4];
|
||||
|
||||
g_return_if_fail (data != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (data));
|
||||
|
||||
gcb = GIMP_COLOR_BUTTON (data);
|
||||
|
||||
gtk_color_selection_get_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), gcb->dcolor);
|
||||
gtk_color_selection_get_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), dcolor);
|
||||
|
||||
if (gcb->double_color)
|
||||
{
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
{
|
||||
if (gcb->dcolor[i] != ((gdouble *) gcb->color)[i])
|
||||
color_changed = TRUE;
|
||||
((gdouble *) gcb->color)[i] = gcb->dcolor[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
guchar new_color[4];
|
||||
gimp_rgba_set (&color, dcolor[0], dcolor[1], dcolor[2], dcolor[3]);
|
||||
gimp_color_button_set_color (gcb, &color);
|
||||
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
{
|
||||
new_color[i] = gcb->dcolor[i] * 255.999;
|
||||
if (new_color[i] != ((guchar *) gcb->color)[i])
|
||||
color_changed = TRUE;
|
||||
((guchar *) gcb->color)[i] = new_color[i];
|
||||
}
|
||||
}
|
||||
|
||||
gtk_widget_hide (gcb->dialog);
|
||||
|
||||
if (color_changed)
|
||||
{
|
||||
gimp_color_button_paint (gcb);
|
||||
gtk_signal_emit (GTK_OBJECT (gcb),
|
||||
gimp_color_button_signals[COLOR_CHANGED]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_dialog_cancel (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
|
||||
g_return_if_fail (data != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (data));
|
||||
|
||||
gcb = GIMP_COLOR_BUTTON (data);
|
||||
|
||||
gtk_widget_hide (gcb->dialog);
|
||||
gtk_widget_hide (GIMP_COLOR_BUTTON (data)->dialog);
|
||||
}
|
||||
|
||||
|
||||
|
@ -621,65 +411,66 @@ gimp_color_button_use_fg (gpointer callback_data,
|
|||
guint callback_action,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
guchar fg_color[3];
|
||||
gint i;
|
||||
GimpRGB color;
|
||||
guchar fg_color[3];
|
||||
|
||||
g_return_if_fail (callback_data != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data));
|
||||
|
||||
gcb = GIMP_COLOR_BUTTON (callback_data);
|
||||
gimp_palette_get_foreground (&fg_color[0], &fg_color[1], &fg_color[2]);
|
||||
|
||||
gimp_palette_get_foreground (fg_color, &fg_color[1], &fg_color[2]);
|
||||
|
||||
if (gcb->double_color)
|
||||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
((gdouble *) gcb->color)[i] = fg_color[i] / 255.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 3; i ++)
|
||||
((guchar *) gcb->color)[i] = fg_color[i];
|
||||
}
|
||||
|
||||
gimp_color_button_update (gcb);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (gcb),
|
||||
gimp_color_button_signals[COLOR_CHANGED]);
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (callback_data), &color);
|
||||
gimp_rgb_set (&color,
|
||||
fg_color[0] / 255.0,
|
||||
fg_color[1] / 255.0,
|
||||
fg_color[2] / 255.0);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (callback_data), &color);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_color_button_use_bg (gpointer callback_data,
|
||||
guint callback_action,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
guchar bg_color[3];
|
||||
gint i;
|
||||
GimpRGB color;
|
||||
guchar bg_color[3];
|
||||
|
||||
g_return_if_fail (callback_data != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data));
|
||||
|
||||
gcb = GIMP_COLOR_BUTTON (callback_data);
|
||||
gimp_palette_get_background (&bg_color[0], &bg_color[1], &bg_color[2]);
|
||||
|
||||
gimp_palette_get_background (bg_color, &bg_color[1], &bg_color[2]);
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (callback_data), &color);
|
||||
gimp_rgb_set (&color,
|
||||
bg_color[0] / 255.0,
|
||||
bg_color[1] / 255.0,
|
||||
bg_color[2] / 255.0);
|
||||
|
||||
if (gcb->double_color)
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (callback_data), &color);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_color_changed (GtkObject *object,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb = GIMP_COLOR_BUTTON (data);
|
||||
|
||||
if (gcb->dialog)
|
||||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
((gdouble *) gcb->color)[i] = bg_color[i] / 255.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 3; i ++)
|
||||
((guchar *) gcb->color)[i] = bg_color[i];
|
||||
GimpRGB color;
|
||||
gdouble dcolor[4];
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
|
||||
dcolor[0] = color.r;
|
||||
dcolor[1] = color.g;
|
||||
dcolor[2] = color.b;
|
||||
dcolor[3] = color.a;
|
||||
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), dcolor);
|
||||
}
|
||||
|
||||
gimp_color_button_update (gcb);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (gcb),
|
||||
gtk_signal_emit (GTK_OBJECT (gcb),
|
||||
gimp_color_button_signals[COLOR_CHANGED]);
|
||||
}
|
||||
|
||||
|
@ -689,126 +480,3 @@ gimp_color_button_menu_translate (const gchar *path,
|
|||
{
|
||||
return (gettext (path));
|
||||
}
|
||||
|
||||
/* DND -- remove as soon as gimpdnd is in libgimp */
|
||||
|
||||
static void
|
||||
gimp_color_button_drag_begin (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb = data;
|
||||
GtkWidget *window;
|
||||
GdkColor bg;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
|
||||
gtk_widget_set_usize (window, DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
|
||||
gtk_widget_realize (window);
|
||||
gtk_object_set_data_full (GTK_OBJECT (widget),
|
||||
"gimp-color-button-drag-window",
|
||||
window,
|
||||
(GtkDestroyNotify) gtk_widget_destroy);
|
||||
|
||||
bg.red = 0xffff * gcb->dcolor[0];
|
||||
bg.green = 0xffff * gcb->dcolor[1];
|
||||
bg.blue = 0xffff * gcb->dcolor[2];
|
||||
|
||||
gdk_color_alloc (gtk_widget_get_colormap (window), &bg);
|
||||
gdk_window_set_background (window->window, &bg);
|
||||
|
||||
gtk_drag_set_icon_widget (context, window, DRAG_ICON_OFFSET, DRAG_ICON_OFFSET);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_drag_end (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_object_set_data (GTK_OBJECT (widget),
|
||||
"gimp-color-button-drag-window", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_drop_handle (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb = data;
|
||||
guint16 *vals;
|
||||
gboolean color_changed = FALSE;
|
||||
gint i;
|
||||
|
||||
if (selection_data->length < 0)
|
||||
return;
|
||||
|
||||
if ((selection_data->format != 16) ||
|
||||
(selection_data->length != 8))
|
||||
{
|
||||
g_warning ("Received invalid color data\n");
|
||||
return;
|
||||
}
|
||||
|
||||
vals = (guint16 *)selection_data->data;
|
||||
|
||||
if (gcb->double_color)
|
||||
{
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
{
|
||||
gcb->dcolor[i] = (gdouble) vals[i] / 0xffff;
|
||||
if (gcb->dcolor[i] != ((gdouble *) gcb->color)[i])
|
||||
color_changed = TRUE;
|
||||
((gdouble *) gcb->color)[i] = gcb->dcolor[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
guchar new_color[4];
|
||||
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
{
|
||||
gcb->dcolor[i] = (gdouble) vals[i] / 0xffff;
|
||||
new_color[i] = gcb->dcolor[i] * 255.999;
|
||||
if (new_color[i] != ((guchar *) gcb->color)[i])
|
||||
color_changed = TRUE;
|
||||
((guchar *) gcb->color)[i] = new_color[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (color_changed)
|
||||
{
|
||||
gimp_color_button_paint (gcb);
|
||||
gtk_signal_emit (GTK_OBJECT (gcb),
|
||||
gimp_color_button_signals[COLOR_CHANGED]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_drag_handle (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb = data;
|
||||
guint16 vals[4];
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
vals[i] = gcb->dcolor[i] * 0xffff;
|
||||
|
||||
if (i == 3)
|
||||
vals[3] = 0xffff;
|
||||
|
||||
gtk_selection_data_set (selection_data,
|
||||
gdk_atom_intern ("application/x-color", FALSE),
|
||||
16, (guchar *)vals, 8);
|
||||
}
|
||||
|
||||
/* end of DND */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpcolorbutton.h
|
||||
* Copyright (C) 1999 Sven Neumann
|
||||
* Copyright (C) 1999-2001 Sven Neumann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -52,16 +52,15 @@ struct _GimpColorButtonClass
|
|||
|
||||
GtkType gimp_color_button_get_type (void);
|
||||
GtkWidget * gimp_color_button_new (const gchar *title,
|
||||
gint width,
|
||||
gint height,
|
||||
guchar *color,
|
||||
gint bpp);
|
||||
GtkWidget * gimp_color_button_double_new (const gchar *title,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble *color,
|
||||
gint bpp);
|
||||
void gimp_color_button_update (GimpColorButton *gcb);
|
||||
guint width,
|
||||
guint height,
|
||||
GimpRGB *color,
|
||||
gboolean alpha);
|
||||
void gimp_color_button_set_color (GimpColorButton *gcb,
|
||||
GimpRGB *color);
|
||||
void gimp_color_button_get_color (GimpColorButton *gcb,
|
||||
GimpRGB *color);/* returns */
|
||||
gboolean gimp_color_button_has_alpha (GimpColorButton *gcb);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include "gimptypes.h"
|
||||
#include "gimpuitypes.h"
|
||||
|
||||
#include "gimpcolorarea.h"
|
||||
#include "gimpcolorbutton.h"
|
||||
#include "gimpchainbutton.h"
|
||||
#include "gimphelpui.h"
|
||||
#include "gimppixmap.h"
|
||||
|
@ -1337,6 +1339,51 @@ gimp_unit_menu_update (GtkWidget *widget,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_update:
|
||||
* @widget: A pointer to a #GimpColorArea or #GimpColorButton.
|
||||
* @data: A pointer to an array of #guchar that will be set to the new color.
|
||||
*
|
||||
* This function will go away.
|
||||
**/
|
||||
void
|
||||
gimp_color_update_uchar (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB color;
|
||||
gboolean alpha;
|
||||
guchar *dest;
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_AREA (widget) ||
|
||||
GIMP_IS_COLOR_BUTTON (widget));
|
||||
|
||||
if (GIMP_IS_COLOR_AREA (widget))
|
||||
{
|
||||
gimp_color_area_get_color (GIMP_COLOR_AREA (widget), &color);
|
||||
alpha = gimp_color_area_has_alpha (GIMP_COLOR_AREA (widget));
|
||||
}
|
||||
else if (GIMP_IS_COLOR_BUTTON (widget))
|
||||
{
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (widget), &color);
|
||||
alpha = gimp_color_button_has_alpha (GIMP_COLOR_BUTTON (widget));
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
dest = (guchar *) data;
|
||||
|
||||
*dest++ = color.r * 255.999;
|
||||
*dest++ = color.g * 255.999;
|
||||
*dest++ = color.b * 255.999;
|
||||
|
||||
if (alpha)
|
||||
*dest++ = color.a * 255.999;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Helper Functions
|
||||
*/
|
||||
|
|
|
@ -227,6 +227,9 @@ void gimp_double_adjustment_update (GtkAdjustment *adjustment,
|
|||
void gimp_unit_menu_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
void gimp_color_update_uchar (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
/*
|
||||
* Helper Functions
|
||||
*/
|
||||
|
|
|
@ -33,21 +33,21 @@ enum
|
|||
|
||||
typedef struct
|
||||
{
|
||||
gdouble ambient_int;
|
||||
gdouble diffuse_int;
|
||||
gdouble diffuse_ref;
|
||||
gdouble specular_ref;
|
||||
gdouble highlight;
|
||||
gdouble ambient_int;
|
||||
gdouble diffuse_int;
|
||||
gdouble diffuse_ref;
|
||||
gdouble specular_ref;
|
||||
gdouble highlight;
|
||||
GimpRGB color;
|
||||
} MaterialSettings;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LightType type;
|
||||
GimpVector3 position;
|
||||
GimpVector3 direction;
|
||||
LightType type;
|
||||
GimpVector3 position;
|
||||
GimpVector3 direction;
|
||||
GimpRGB color;
|
||||
gdouble intensity;
|
||||
gdouble intensity;
|
||||
} LightSettings;
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -587,9 +587,12 @@ create_light_page (void)
|
|||
|
||||
gimp_help_set_help_data (optionmenu, _("Type of light source to apply"), NULL);
|
||||
|
||||
colorbutton = gimp_color_button_double_new (_("Select Lightsource Color"),
|
||||
64, 16,
|
||||
&mapvals.lightsource.color.r, 3);
|
||||
colorbutton = gimp_color_button_new (_("Select Lightsource Color"),
|
||||
64, 16,
|
||||
&mapvals.lightsource.color, FALSE);
|
||||
gtk_signal_connect (GTK_OBJECT (colorbutton), "color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||
&mapvals.lightsource.color);
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
||||
_("Light Color:"), 1.0, 0.5,
|
||||
colorbutton, 1, TRUE);
|
||||
|
|
|
@ -29,21 +29,21 @@ typedef enum
|
|||
|
||||
typedef struct
|
||||
{
|
||||
gdouble ambient_int;
|
||||
gdouble diffuse_int;
|
||||
gdouble diffuse_ref;
|
||||
gdouble specular_ref;
|
||||
gdouble highlight;
|
||||
gdouble ambient_int;
|
||||
gdouble diffuse_int;
|
||||
gdouble diffuse_ref;
|
||||
gdouble specular_ref;
|
||||
gdouble highlight;
|
||||
GimpRGB color;
|
||||
} MaterialSettings;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LightType type;
|
||||
GimpVector3 position;
|
||||
GimpVector3 direction;
|
||||
LightType type;
|
||||
GimpVector3 position;
|
||||
GimpVector3 direction;
|
||||
GimpRGB color;
|
||||
gdouble intensity;
|
||||
gdouble intensity;
|
||||
} LightSettings;
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -730,9 +730,12 @@ create_light_page (void)
|
|||
|
||||
gimp_help_set_help_data (optionmenu, _("Type of light source to apply"), NULL);
|
||||
|
||||
colorbutton = gimp_color_button_double_new (_("Select Lightsource Color"),
|
||||
64, 16,
|
||||
&mapvals.lightsource.color.r, 3);
|
||||
colorbutton = gimp_color_button_new (_("Select Lightsource Color"),
|
||||
64, 16,
|
||||
&mapvals.lightsource.color, FALSE);
|
||||
gtk_signal_connect (GTK_OBJECT (colorbutton), "color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||
&mapvals.lightsource.color);
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
||||
_("Lightsource Color:"), 1.0, 0.5,
|
||||
colorbutton, 1, TRUE);
|
||||
|
|
|
@ -66,10 +66,6 @@ static void colorify_ok_callback (GtkWidget *widget,
|
|||
gpointer data);
|
||||
static void predefined_color_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void set_preview_color (GtkWidget *preview,
|
||||
guchar red,
|
||||
guchar green,
|
||||
guchar blue);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -81,13 +77,6 @@ typedef struct
|
|||
gint run;
|
||||
} ColorifyInterface;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
guchar red;
|
||||
guchar green;
|
||||
guchar blue;
|
||||
} ButtonColor;
|
||||
|
||||
static ColorifyInterface cint =
|
||||
{
|
||||
FALSE
|
||||
|
@ -98,15 +87,15 @@ static ColorifyVals cvals =
|
|||
{ 255, 255, 255 }
|
||||
};
|
||||
|
||||
static ButtonColor button_color[] =
|
||||
static GimpRGB button_color[] =
|
||||
{
|
||||
{ 255, 0, 0 },
|
||||
{ 255, 255, 0 },
|
||||
{ 0, 255, 0 },
|
||||
{ 0, 255, 255 },
|
||||
{ 0, 0, 255 },
|
||||
{ 255, 0, 255 },
|
||||
{ 255, 255, 255 },
|
||||
{ 1.0, 0.0, 0.0, 1.0 },
|
||||
{ 1.0, 1.0, 0.0, 1.0 },
|
||||
{ 0.0, 1.0, 0.0, 1.0 },
|
||||
{ 0.0, 1.0, 1.0, 1.0 },
|
||||
{ 0.0, 0.0, 1.0, 1.0 },
|
||||
{ 1.0, 0.0, 1.0, 1.0 },
|
||||
{ 1.0, 1.0, 1.0, 1.0 },
|
||||
};
|
||||
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
|
@ -119,7 +108,6 @@ GimpPlugInInfo PLUG_IN_INFO =
|
|||
|
||||
static gint sel_x1, sel_x2, sel_y1, sel_y2;
|
||||
static gint sel_width, sel_height;
|
||||
static GtkWidget *preview;
|
||||
static GtkWidget *custum_color_button = NULL;
|
||||
|
||||
static gint lum_red_lookup[256];
|
||||
|
@ -315,6 +303,8 @@ colorify_dialog (guchar red,
|
|||
GtkWidget *button;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *table;
|
||||
GtkWidget *color_area;
|
||||
GimpRGB color;
|
||||
gint i;
|
||||
|
||||
gimp_ui_init ("colorify", TRUE);
|
||||
|
@ -353,27 +343,33 @@ colorify_dialog (guchar red,
|
|||
GTK_FILL, GTK_FILL, 0, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
gimp_rgb_set (&color,
|
||||
(gdouble) cvals.color[0] / 255.0,
|
||||
(gdouble) cvals.color[1] / 255.0,
|
||||
(gdouble) cvals.color[2] / 255.0);
|
||||
custum_color_button = gimp_color_button_new (_("Colorify Custom Color"),
|
||||
COLOR_SIZE, COLOR_SIZE,
|
||||
cvals.color, 3);
|
||||
&color, FALSE);
|
||||
gtk_signal_connect (GTK_OBJECT (custum_color_button), "color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_update_uchar),
|
||||
cvals.color);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (table), custum_color_button, 6, 7, 0, 1,
|
||||
GTK_FILL, GTK_FILL, 0, 0);
|
||||
gtk_widget_show (custum_color_button);
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
/* should actually use gimp_color_button() here */
|
||||
button = gtk_button_new ();
|
||||
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (preview), COLOR_SIZE, COLOR_SIZE);
|
||||
gtk_container_add (GTK_CONTAINER (button), preview);
|
||||
set_preview_color (preview,
|
||||
button_color[i].red,
|
||||
button_color[i].green,
|
||||
button_color[i].blue);
|
||||
color_area = gimp_color_area_new (&button_color[i], FALSE,
|
||||
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK);
|
||||
gtk_widget_set_usize (GTK_WIDGET (color_area), COLOR_SIZE, COLOR_SIZE);
|
||||
gtk_container_add (GTK_CONTAINER (button), color_area);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) predefined_color_callback,
|
||||
&button_color[i]);
|
||||
gtk_widget_show (preview);
|
||||
NULL);
|
||||
gtk_widget_show (color_area);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (table), button, i, i + 1, 1, 2,
|
||||
GTK_FILL, GTK_FILL, 0, 0);
|
||||
|
@ -397,39 +393,14 @@ colorify_ok_callback (GtkWidget *widget,
|
|||
gtk_widget_destroy (GTK_WIDGET (data));
|
||||
}
|
||||
|
||||
static void
|
||||
set_preview_color (GtkWidget *preview,
|
||||
guchar red,
|
||||
guchar green,
|
||||
guchar blue)
|
||||
{
|
||||
gint i;
|
||||
guchar buf[3 * COLOR_SIZE];
|
||||
|
||||
for (i = 0; i < COLOR_SIZE; i ++)
|
||||
{
|
||||
buf [3 * i] = red;
|
||||
buf [3 * i + 1] = green;
|
||||
buf [3 * i + 2] = blue;
|
||||
}
|
||||
|
||||
for (i = 0; i < COLOR_SIZE; i ++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (preview), buf, 0, i, COLOR_SIZE);
|
||||
|
||||
gtk_widget_draw (preview, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
predefined_color_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
ButtonColor *color;
|
||||
GimpRGB color;
|
||||
|
||||
color = (ButtonColor *) data;
|
||||
|
||||
cvals.color[0] = color->red;
|
||||
cvals.color[1] = color->green;
|
||||
cvals.color[2] = color->blue;
|
||||
|
||||
gimp_color_button_update (GIMP_COLOR_BUTTON (custum_color_button));
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (widget), &color);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (custum_color_button), &color);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -396,6 +396,7 @@ colortoalpha_dialog (GimpDrawable *drawable)
|
|||
GtkWidget *table;
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
GimpRGB color;
|
||||
|
||||
gimp_ui_init ("colortoalpha", TRUE);
|
||||
|
||||
|
@ -431,9 +432,16 @@ colortoalpha_dialog (GimpDrawable *drawable)
|
|||
gtk_table_attach_defaults (GTK_TABLE(table), label, 0, 1, 0, 1);
|
||||
gtk_widget_show (label);
|
||||
|
||||
gimp_rgb_set (&color,
|
||||
(gdouble) pvals.color[0] / 255.0,
|
||||
(gdouble) pvals.color[1] / 255.0,
|
||||
(gdouble) pvals.color[2] / 255.0);
|
||||
button = gimp_color_button_new (_("Color to Alpha Color Picker"),
|
||||
PRV_WIDTH, PRV_HEIGHT,
|
||||
pvals.color, 3);
|
||||
&color, FALSE);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_update_uchar),
|
||||
pvals.color);
|
||||
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1,
|
||||
GTK_FILL, GTK_SHRINK, 0, 0) ;
|
||||
gtk_widget_show (button);
|
||||
|
|
|
@ -271,6 +271,7 @@ preview_event_handler (GtkWidget *widget,
|
|||
guint red_handler = 0;
|
||||
guint green_handler = 0;
|
||||
guint blue_handler = 0;
|
||||
GimpRGB color;
|
||||
GtkAdjustment *r, *g, *b;
|
||||
|
||||
buf = GTK_PREVIEW (widget)->buffer;
|
||||
|
@ -308,7 +309,13 @@ preview_event_handler (GtkWidget *widget,
|
|||
gtk_signal_handler_unblock (GTK_OBJECT (g), green_handler);
|
||||
gtk_signal_handler_unblock (GTK_OBJECT (b), blue_handler);
|
||||
|
||||
gimp_color_button_update(GIMP_COLOR_BUTTON(from_colorbutton));
|
||||
gimp_rgb_set (&color,
|
||||
(gdouble) xargs.fromred / 255.0,
|
||||
(gdouble) xargs.fromgreen / 255.0,
|
||||
(gdouble) xargs.fromblue / 255.0);
|
||||
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (from_colorbutton),
|
||||
&color);
|
||||
update_preview();
|
||||
break;
|
||||
|
||||
|
@ -335,6 +342,7 @@ exchange_dialog (void)
|
|||
GtkObject *red_threshold = NULL;
|
||||
GtkObject *green_threshold = NULL;
|
||||
GtkObject *blue_threshold = NULL;
|
||||
GimpRGB color;
|
||||
gint framenumber;
|
||||
|
||||
gimp_ui_init ("exchange", TRUE);
|
||||
|
@ -409,19 +417,29 @@ exchange_dialog (void)
|
|||
gtk_container_add (GTK_CONTAINER (frame), table);
|
||||
gtk_widget_show (table);
|
||||
|
||||
if (framenumber)
|
||||
gimp_rgb_set (&color,
|
||||
(gdouble) xargs.tored / 255.0,
|
||||
(gdouble) xargs.togreen / 255.0,
|
||||
(gdouble) xargs.toblue / 255.0);
|
||||
else
|
||||
gimp_rgb_set (&color,
|
||||
(gdouble) xargs.fromred / 255.0,
|
||||
(gdouble) xargs.fromgreen / 255.0,
|
||||
(gdouble) xargs.fromblue / 255.0);
|
||||
|
||||
|
||||
colorbutton = gimp_color_button_new (framenumber ?
|
||||
_("Color Exchange: To Color") :
|
||||
_("Color Exchange: From Color"),
|
||||
SCALE_WIDTH / 2, 16,
|
||||
framenumber ?
|
||||
&xargs.tored : &xargs.fromred,
|
||||
3);
|
||||
&color, FALSE);
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||
NULL, 0.0, 0.0,
|
||||
colorbutton, 1, TRUE);
|
||||
gtk_signal_connect (GTK_OBJECT (colorbutton), "color_changed",
|
||||
GTK_SIGNAL_FUNC (color_button_callback),
|
||||
NULL);
|
||||
GINT_TO_POINTER (framenumber));
|
||||
|
||||
if (framenumber)
|
||||
to_colorbutton = colorbutton;
|
||||
|
@ -593,10 +611,25 @@ color_button_callback (GtkWidget *widget,
|
|||
GtkObject *red_adj;
|
||||
GtkObject *green_adj;
|
||||
GtkObject *blue_adj;
|
||||
guint red_handler;
|
||||
guint green_handler;
|
||||
guint blue_handler;
|
||||
GimpRGB color;
|
||||
|
||||
guint red_handler;
|
||||
guint green_handler;
|
||||
guint blue_handler;
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (widget), &color);
|
||||
|
||||
if (data)
|
||||
{
|
||||
xargs.tored = color.r * 255.0;
|
||||
xargs.togreen = color.g * 255.0;
|
||||
xargs.toblue = color.b * 255.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
xargs.fromred = color.r * 255.0;
|
||||
xargs.fromgreen = color.g * 255.0;
|
||||
xargs.fromblue = color.b * 255.0;
|
||||
}
|
||||
|
||||
red_adj = (GtkObject *) gtk_object_get_data (GTK_OBJECT (widget), "red");
|
||||
green_adj = (GtkObject *) gtk_object_get_data (GTK_OBJECT (widget), "green");
|
||||
|
@ -648,7 +681,8 @@ scale_callback (GtkAdjustment *adj,
|
|||
|
||||
if (GIMP_IS_COLOR_BUTTON (object))
|
||||
{
|
||||
gimp_color_button_update (GIMP_COLOR_BUTTON (object));
|
||||
/* FIXME */
|
||||
/* gimp_color_button_update (GIMP_COLOR_BUTTON (object)); */
|
||||
}
|
||||
else if (GTK_IS_ADJUSTMENT (object) && lock_threshold == TRUE)
|
||||
{
|
||||
|
|
|
@ -1169,8 +1169,9 @@ film_dialog (gint32 image_ID)
|
|||
GtkWidget *button;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *sep;
|
||||
gint32 *image_id_list;
|
||||
gint nimages, j, row;
|
||||
GimpRGB color;
|
||||
gint32 *image_id_list;
|
||||
gint nimages, j, row;
|
||||
|
||||
gimp_ui_init ("film", TRUE);
|
||||
|
||||
|
@ -1248,9 +1249,17 @@ film_dialog (gint32 image_ID)
|
|||
filmvals.keep_height);
|
||||
|
||||
/* Film color */
|
||||
gimp_rgb_set (&color,
|
||||
(gdouble) filmvals.film_color[0] / 255.0,
|
||||
(gdouble) filmvals.film_color[1] / 255.0,
|
||||
(gdouble) filmvals.film_color[2] / 255.0);
|
||||
button = gimp_color_button_new (_("Select Film Color"),
|
||||
COLOR_BUTTON_WIDTH, COLOR_BUTTON_HEIGHT,
|
||||
filmvals.film_color, 3);
|
||||
&color, FALSE);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_update_uchar),
|
||||
filmvals.film_color);
|
||||
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
||||
_("Color:"), 1.0, 0.5,
|
||||
button, 1, TRUE);
|
||||
|
@ -1292,9 +1301,16 @@ film_dialog (gint32 image_ID)
|
|||
entry, 1, FALSE);
|
||||
|
||||
/* Numbering color */
|
||||
gimp_rgb_set (&color,
|
||||
(gdouble) filmvals.number_color[0] / 255.0,
|
||||
(gdouble) filmvals.number_color[1] / 255.0,
|
||||
(gdouble) filmvals.number_color[2] / 255.0);
|
||||
button = gimp_color_button_new (_("Select Number Color"),
|
||||
COLOR_BUTTON_WIDTH, COLOR_BUTTON_HEIGHT,
|
||||
filmvals.number_color, 3);
|
||||
&color, FALSE);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_update_uchar),
|
||||
filmvals.number_color);
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
|
||||
_("Color:"), 1.0, 0.5,
|
||||
button, 1, TRUE);
|
||||
|
|
|
@ -577,25 +577,17 @@ entry_callback (GtkWidget *widget,
|
|||
|
||||
|
||||
static void
|
||||
color_callback (GtkWidget *widget,
|
||||
color_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gint i;
|
||||
|
||||
if (gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (data)))
|
||||
{
|
||||
if (widget == hcolor_button)
|
||||
{
|
||||
for (i = 0; i < 4; i++)
|
||||
grid_cfg.vcolor[i] = grid_cfg.hcolor[i];
|
||||
gimp_color_button_update (GIMP_COLOR_BUTTON (vcolor_button));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 4; i++)
|
||||
grid_cfg.hcolor[i] = grid_cfg.vcolor[i];
|
||||
gimp_color_button_update (GIMP_COLOR_BUTTON (hcolor_button));
|
||||
}
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (widget), &color);
|
||||
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (vcolor_button), &color);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (hcolor_button), &color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -645,6 +637,7 @@ dialog (gint32 image_ID,
|
|||
GtkWidget *chain_button;
|
||||
GtkWidget *table;
|
||||
GtkWidget *align;
|
||||
GimpRGB color;
|
||||
GimpUnit unit;
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
|
@ -902,8 +895,9 @@ dialog (gint32 image_ID,
|
|||
gtk_table_attach_defaults (GTK_TABLE (table), chain_button, 0, 2, 0, 1);
|
||||
gtk_widget_show (chain_button);
|
||||
|
||||
/* connect to the 'value_changed' and "unit_changed" signals because we have to
|
||||
take care of keeping the entries in sync when the chainbutton is active */
|
||||
/* connect to the 'value_changed' and "unit_changed" signals because we
|
||||
have to take care of keeping the entries in sync when the chainbutton
|
||||
is active */
|
||||
gtk_signal_connect (GTK_OBJECT (offset), "value_changed",
|
||||
(GtkSignalFunc) entry_callback, chain_button);
|
||||
gtk_signal_connect (GTK_OBJECT (offset), "unit_changed",
|
||||
|
@ -917,18 +911,37 @@ dialog (gint32 image_ID,
|
|||
gtk_widget_show (chain_button);
|
||||
|
||||
/* attach color selectors */
|
||||
hcolor_button = gimp_color_button_new (_("Horizontal Color"), COLOR_BUTTON_WIDTH, 16,
|
||||
grid_cfg.hcolor, 4);
|
||||
gimp_rgba_set (&color,
|
||||
(gdouble) grid_cfg.hcolor[0] / 255.0,
|
||||
(gdouble) grid_cfg.hcolor[1] / 255.0,
|
||||
(gdouble) grid_cfg.hcolor[2] / 255.0,
|
||||
(gdouble) grid_cfg.hcolor[3] / 255.0);
|
||||
hcolor_button = gimp_color_button_new (_("Horizontal Color"),
|
||||
COLOR_BUTTON_WIDTH, 16,
|
||||
&color, TRUE);
|
||||
gtk_signal_connect (GTK_OBJECT (hcolor_button), "color_changed",
|
||||
(GtkSignalFunc) color_callback, chain_button);
|
||||
(GtkSignalFunc) gimp_color_update_uchar,
|
||||
grid_cfg.hcolor);
|
||||
gtk_signal_connect (GTK_OBJECT (hcolor_button), "color_changed",
|
||||
(GtkSignalFunc) color_callback,
|
||||
chain_button);
|
||||
align = gtk_alignment_new (0.0, 0.5, 0, 0);
|
||||
gtk_container_add (GTK_CONTAINER (align), hcolor_button);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), align, 0, 1, 1, 2);
|
||||
gtk_widget_show (hcolor_button);
|
||||
gtk_widget_show (align);
|
||||
|
||||
vcolor_button = gimp_color_button_new (_("Vertical Color"), COLOR_BUTTON_WIDTH, 16,
|
||||
grid_cfg.vcolor, 4);
|
||||
gimp_rgba_set (&color,
|
||||
(gdouble) grid_cfg.vcolor[0] / 255.0,
|
||||
(gdouble) grid_cfg.vcolor[1] / 255.0,
|
||||
(gdouble) grid_cfg.vcolor[2] / 255.0,
|
||||
(gdouble) grid_cfg.vcolor[3] / 255.0);
|
||||
vcolor_button = gimp_color_button_new (_("Vertical Color"),
|
||||
COLOR_BUTTON_WIDTH, 16,
|
||||
&color, TRUE);
|
||||
gtk_signal_connect (GTK_OBJECT (vcolor_button), "color_changed",
|
||||
(GtkSignalFunc) gimp_color_update_uchar,
|
||||
grid_cfg.vcolor);
|
||||
gtk_signal_connect (GTK_OBJECT (vcolor_button), "color_changed",
|
||||
(GtkSignalFunc) color_callback, chain_button);
|
||||
align = gtk_alignment_new (0.0, 0.5, 0, 0);
|
||||
|
@ -937,8 +950,17 @@ dialog (gint32 image_ID,
|
|||
gtk_widget_show (vcolor_button);
|
||||
gtk_widget_show (align);
|
||||
|
||||
button = gimp_color_button_new (_("Intersection Color"), COLOR_BUTTON_WIDTH, 16,
|
||||
grid_cfg.icolor, 4);
|
||||
gimp_rgba_set (&color,
|
||||
(gdouble) grid_cfg.icolor[0] / 255.0,
|
||||
(gdouble) grid_cfg.icolor[1] / 255.0,
|
||||
(gdouble) grid_cfg.icolor[2] / 255.0,
|
||||
(gdouble) grid_cfg.icolor[3] / 255.0);
|
||||
button = gimp_color_button_new (_("Intersection Color"),
|
||||
COLOR_BUTTON_WIDTH, 16,
|
||||
&color, TRUE);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
||||
(GtkSignalFunc) gimp_color_update_uchar,
|
||||
grid_cfg.icolor);
|
||||
align = gtk_alignment_new (0.0, 0.5, 0, 0);
|
||||
gtk_container_add (GTK_CONTAINER (align), button);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), align, 2, 3, 1, 2);
|
||||
|
|
|
@ -648,6 +648,7 @@ add_color_button (gint csel_index,
|
|||
{
|
||||
GtkWidget *label;
|
||||
GtkWidget *button;
|
||||
GimpRGB color;
|
||||
|
||||
label = gtk_label_new ((left == 0) ? _("From:") : _("To:"));
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
||||
|
@ -655,9 +656,17 @@ add_color_button (gint csel_index,
|
|||
GTK_FILL, GTK_FILL, 0, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
gimp_rgb_set (&color,
|
||||
(gdouble) plvals.colors[csel_index][0] / 255.0,
|
||||
(gdouble) plvals.colors[csel_index][1] / 255.0,
|
||||
(gdouble) plvals.colors[csel_index][2] / 255.0);
|
||||
|
||||
button = gimp_color_button_new (gettext (csel_title[csel_index]),
|
||||
PRV_WIDTH, PRV_HEIGHT,
|
||||
plvals.colors[csel_index], 3);
|
||||
&color, FALSE);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
||||
(GtkSignalFunc) gimp_color_update_uchar,
|
||||
plvals.colors[csel_index]);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
||||
GTK_SIGNAL_FUNC (color_button_color_changed_callback),
|
||||
NULL);
|
||||
|
|
|
@ -455,6 +455,7 @@ nova_dialog (GimpDrawable *drawable)
|
|||
GtkWidget *button;
|
||||
GtkWidget *center_frame;
|
||||
GtkObject *adj;
|
||||
GimpRGB color;
|
||||
|
||||
gimp_ui_init ("nova", TRUE);
|
||||
|
||||
|
@ -490,9 +491,16 @@ nova_dialog (GimpDrawable *drawable)
|
|||
gtk_table_attach (GTK_TABLE (table), center_frame, 0, 3, 0, 1,
|
||||
0, 0, 0, 0);
|
||||
|
||||
gimp_rgb_set (&color,
|
||||
(gdouble) pvals.color[0] / 255.0,
|
||||
(gdouble) pvals.color[1] / 255.0,
|
||||
(gdouble) pvals.color[2] / 255.0);
|
||||
button = gimp_color_button_new (_("SuperNova Color Picker"),
|
||||
SCALE_WIDTH - 8, 16,
|
||||
pvals.color, 3);
|
||||
&color, FALSE);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
|
||||
(GtkSignalFunc) gimp_color_update_uchar,
|
||||
pvals.color);
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "color_changed",
|
||||
GTK_SIGNAL_FUNC (nova),
|
||||
(gpointer)drawable);
|
||||
|
|
|
@ -239,6 +239,7 @@ open_dialog (void)
|
|||
GtkWidget *box;
|
||||
GtkWidget *color_button;
|
||||
GtkWidget *sep;
|
||||
GimpRGB color;
|
||||
|
||||
gimp_ui_init ("papertile", TRUE);
|
||||
|
||||
|
@ -394,9 +395,17 @@ open_dialog (void)
|
|||
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
gimp_rgba_set (&color,
|
||||
(gdouble) p.params.background_color[0] / 255.0,
|
||||
(gdouble) p.params.background_color[1] / 255.0,
|
||||
(gdouble) p.params.background_color[2] / 255.0,
|
||||
(gdouble) p.params.background_color[3] / 255.0);
|
||||
|
||||
color_button = gimp_color_button_new (_("Background Color"), 100, 16,
|
||||
p.params.background_color,
|
||||
p.drawable_has_alpha ? 4 : 3);
|
||||
&color, p.drawable_has_alpha);
|
||||
gtk_signal_connect (GTK_OBJECT (color_button), "color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_update_uchar),
|
||||
p.params.background_color);
|
||||
gtk_container_add (GTK_CONTAINER (button), color_button);
|
||||
gtk_widget_show (color_button);
|
||||
|
||||
|
|
|
@ -1583,16 +1583,19 @@ static void
|
|||
alpha_scale_cb (GtkAdjustment *adj,
|
||||
gpointer data)
|
||||
{
|
||||
guchar *val;
|
||||
guchar *val;
|
||||
GtkWidget *color_button;
|
||||
GimpRGB color;
|
||||
|
||||
val = (guchar*) data;
|
||||
|
||||
*val = (guchar)(adj->value * 255.0);
|
||||
|
||||
color_button = gtk_object_get_user_data (GTK_OBJECT (adj));
|
||||
if (GIMP_IS_COLOR_BUTTON (color_button))
|
||||
gimp_color_button_update (GIMP_COLOR_BUTTON (color_button));
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (color_button), &color);
|
||||
color.a = adj->value;
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (color_button), &color);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1688,9 +1691,10 @@ sinus_dialog (void)
|
|||
GtkWidget *spinbutton;
|
||||
GtkObject *adj;
|
||||
GtkWidget *logo;
|
||||
gint x,y;
|
||||
char buf[3*100];
|
||||
guchar *data;
|
||||
GimpRGB color;
|
||||
gint x, y;
|
||||
gchar buf[3*100];
|
||||
guchar *data;
|
||||
|
||||
gimp_ui_init ("sinus", TRUE);
|
||||
|
||||
|
@ -1896,13 +1900,29 @@ sinus_dialog (void)
|
|||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
|
||||
gimp_rgba_set (&color,
|
||||
(gdouble) svals.col1[0] / 255.0,
|
||||
(gdouble) svals.col1[1] / 255.0,
|
||||
(gdouble) svals.col1[2] / 255.0,
|
||||
(gdouble) svals.col1[3] / 255.0);
|
||||
push_col1 = gimp_color_button_new (_("First Color"),
|
||||
32, 32, svals.col1, 4);
|
||||
32, 32, &color, TRUE);
|
||||
gtk_signal_connect (GTK_OBJECT (push_col1), "color_changed",
|
||||
(GtkSignalFunc) gimp_color_update_uchar,
|
||||
svals.col1);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), push_col1, FALSE, FALSE, 0);
|
||||
gtk_widget_show (push_col1);
|
||||
|
||||
gimp_rgba_set (&color,
|
||||
(gdouble) svals.col2[0] / 255.0,
|
||||
(gdouble) svals.col2[1] / 255.0,
|
||||
(gdouble) svals.col2[2] / 255.0,
|
||||
(gdouble) svals.col2[3] / 255.0);
|
||||
push_col2 = gimp_color_button_new (_("Second Color"),
|
||||
32, 32, svals.col2, 4);
|
||||
32, 32, &color, TRUE);
|
||||
gtk_signal_connect (GTK_OBJECT (push_col2), "color_changed",
|
||||
(GtkSignalFunc) gimp_color_update_uchar,
|
||||
svals.col2);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), push_col2, FALSE, FALSE, 0);
|
||||
gtk_widget_show (push_col2);
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ static GtkWidget *message_window = NULL;
|
|||
static GtkWidget *charmap_window = NULL;
|
||||
static GtkWidget *about_dialog = NULL;
|
||||
static GtkWidget *load_file_selection = NULL;
|
||||
static guchar col[3];
|
||||
static GimpRGB color;
|
||||
|
||||
|
||||
#define COLOR_PREVIEW_WIDTH 20
|
||||
|
@ -322,15 +322,20 @@ create_main_window (GdtMainWindow **main_window,
|
|||
gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
|
||||
|
||||
/* FONT COLOR */
|
||||
col[0] = ((guint)data->color) >> 16;
|
||||
col[1] = ((guint)data->color) >> 8;
|
||||
col[2] = (guint)data->color;
|
||||
gimp_rgb_set (&color,
|
||||
(gdouble) (((guint)data->color) >> 16) / 255.0,
|
||||
(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,
|
||||
col, 3);
|
||||
&color, FALSE);
|
||||
gtk_signal_connect (GTK_OBJECT (color_button), "color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||
&color);
|
||||
gtk_button_set_relief (GTK_BUTTON (color_button), GTK_RELIEF_NONE);
|
||||
gtk_widget_show (color_button);
|
||||
gtk_toolbar_append_element (GTK_TOOLBAR(toolbar), GTK_TOOLBAR_CHILD_WIDGET, color_button,
|
||||
gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_WIDGET,
|
||||
color_button,
|
||||
NULL, _("Text color"), NULL,
|
||||
NULL,
|
||||
NULL, NULL);
|
||||
|
@ -652,6 +657,8 @@ gdt_create_ui (GdtVals *data)
|
|||
static void
|
||||
set_gdt_vals (GdtVals *data)
|
||||
{
|
||||
guint32 col[3];
|
||||
|
||||
data->preview = main_window->font_preview_enabled;
|
||||
strncpy(data->xlfd,
|
||||
font_selection_get_font_name(FONT_SELECTION(main_window->font_selection)),
|
||||
|
@ -660,7 +667,11 @@ set_gdt_vals (GdtVals *data)
|
|||
data->line_spacing = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (main_window->line_spacing));
|
||||
data->layer_alignment = main_window->layer_alignment;
|
||||
strncpy(data->text, gtk_editable_get_chars (GTK_EDITABLE(main_window->textarea), 0, -1), sizeof(data->text));
|
||||
data->color = ((gint32)col[0] << 16) + ((gint32)col[1] << 8) + (gint32)col[2];
|
||||
|
||||
col[0] = color.r * 255.0;
|
||||
col[1] = color.g * 255.0;
|
||||
col[2] = color.b * 255.0;
|
||||
data->color = (col[0] << 16) + (col[1] << 8) + col[2];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -99,12 +99,11 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
IfsColor *color;
|
||||
gchar *name;
|
||||
GimpRGB *color;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *orig_preview;
|
||||
GtkWidget *button;
|
||||
gint fixed_point;
|
||||
gboolean fixed_point;
|
||||
} ColorMap;
|
||||
|
||||
typedef struct
|
||||
|
@ -235,15 +234,13 @@ static void recompute_center_cb (GtkWidget *widget,
|
|||
|
||||
static void ifs_compose (GimpDrawable *drawable);
|
||||
|
||||
static void color_map_set_preview_color (GtkWidget *preview,
|
||||
IfsColor *color);
|
||||
static ColorMap *color_map_create (gchar *name,
|
||||
IfsColor *orig_color,
|
||||
IfsColor *data,
|
||||
gint fixed_point);
|
||||
GimpRGB *orig_color,
|
||||
GimpRGB *data,
|
||||
gboolean fixed_point);
|
||||
static void color_map_color_changed_cb (GtkWidget *widget,
|
||||
ColorMap *color_map);
|
||||
static void color_map_update (ColorMap *color_map);
|
||||
static void color_map_update (ColorMap *color_map);
|
||||
|
||||
/* interface functions */
|
||||
static void simple_color_toggled (GtkWidget *widget,gpointer data);
|
||||
|
@ -634,7 +631,7 @@ ifs_compose_color_page (void)
|
|||
GtkWidget *table;
|
||||
GtkWidget *label;
|
||||
GSList *group = NULL;
|
||||
IfsColor color;
|
||||
GimpRGB color;
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
|
||||
|
@ -656,9 +653,6 @@ ifs_compose_color_page (void)
|
|||
NULL);
|
||||
gtk_widget_show (ifsD->simple_button);
|
||||
|
||||
color.vals[0] = 1.0;
|
||||
color.vals[1] = 0.0;
|
||||
color.vals[2] = 0.0;
|
||||
ifsD->target_cmap = color_map_create (_("IfsCompose: Target"), NULL,
|
||||
&ifsD->current_vals.target_color, TRUE);
|
||||
gtk_table_attach (GTK_TABLE (table), ifsD->target_cmap->hbox, 1, 2, 0, 2,
|
||||
|
@ -703,36 +697,28 @@ ifs_compose_color_page (void)
|
|||
group = gtk_radio_button_group (GTK_RADIO_BUTTON (ifsD->full_button));
|
||||
gtk_widget_show (ifsD->full_button);
|
||||
|
||||
color.vals[0] = 1.0;
|
||||
color.vals[1] = 0.0;
|
||||
color.vals[2] = 0.0;
|
||||
ifsD->red_cmap = color_map_create (_("IfsCompose: Red"),&color,
|
||||
gimp_rgb_set (&color, 1.0, 0.0, 0.0);
|
||||
ifsD->red_cmap = color_map_create (_("IfsCompose: Red"), &color,
|
||||
&ifsD->current_vals.red_color, FALSE);
|
||||
gtk_table_attach (GTK_TABLE (table), ifsD->red_cmap->hbox, 1, 2, 2, 3,
|
||||
GTK_FILL, GTK_FILL, 0, 0);
|
||||
gtk_widget_show (ifsD->red_cmap->hbox);
|
||||
|
||||
color.vals[0] = 0.0;
|
||||
color.vals[1] = 1.0;
|
||||
color.vals[2] = 0.0;
|
||||
ifsD->green_cmap = color_map_create( _("IfsCompose: Green"),&color,
|
||||
gimp_rgb_set (&color, 0.0, 1.0, 0.0);
|
||||
ifsD->green_cmap = color_map_create( _("IfsCompose: Green"), &color,
|
||||
&ifsD->current_vals.green_color, FALSE);
|
||||
gtk_table_attach (GTK_TABLE (table), ifsD->green_cmap->hbox, 2, 3, 2, 3,
|
||||
GTK_FILL, GTK_FILL, 0, 0);
|
||||
gtk_widget_show (ifsD->green_cmap->hbox);
|
||||
|
||||
color.vals[0] = 0.0;
|
||||
color.vals[1] = 0.0;
|
||||
color.vals[2] = 2.0;
|
||||
ifsD->blue_cmap = color_map_create (_("IfsCompose: Blue"),&color,
|
||||
gimp_rgb_set (&color, 0.0, 0.0, 1.0);
|
||||
ifsD->blue_cmap = color_map_create (_("IfsCompose: Blue"), &color,
|
||||
&ifsD->current_vals.blue_color, FALSE);
|
||||
gtk_table_attach (GTK_TABLE (table), ifsD->blue_cmap->hbox, 3, 4, 2, 3,
|
||||
GTK_FILL, GTK_FILL, 0, 0);
|
||||
gtk_widget_show (ifsD->blue_cmap->hbox);
|
||||
|
||||
color.vals[0] = 0.0;
|
||||
color.vals[1] = 0.0;
|
||||
color.vals[2] = 0.0;
|
||||
gimp_rgb_set (&color, 0.0, 0.0, 0.0);
|
||||
ifsD->black_cmap = color_map_create (_("IfsCompose: Black"), &color,
|
||||
&ifsD->current_vals.black_color, FALSE);
|
||||
gtk_table_attach (GTK_TABLE (table), ifsD->black_cmap->hbox, 4, 5, 2, 3,
|
||||
|
@ -2007,69 +1993,51 @@ val_changed_update (void)
|
|||
|
||||
#define COLOR_SAMPLE_SIZE 30
|
||||
|
||||
static void
|
||||
color_map_set_preview_color (GtkWidget *preview,
|
||||
IfsColor *color)
|
||||
{
|
||||
gint i;
|
||||
guchar buf[3*COLOR_SAMPLE_SIZE];
|
||||
|
||||
for (i=0;i<COLOR_SAMPLE_SIZE;i++)
|
||||
{
|
||||
buf[3*i] = (guint)(255.999*color->vals[0]);
|
||||
buf[3*i+1] = (guint)(255.999*color->vals[1]);
|
||||
buf[3*i+2] = (guint)(255.999*color->vals[2]);
|
||||
}
|
||||
for (i=0;i<COLOR_SAMPLE_SIZE;i++)
|
||||
gtk_preview_draw_row(GTK_PREVIEW(preview),buf,0,i,COLOR_SAMPLE_SIZE);
|
||||
|
||||
gtk_widget_draw (preview, NULL);
|
||||
}
|
||||
|
||||
static ColorMap *
|
||||
color_map_create (gchar *name,
|
||||
IfsColor *orig_color,
|
||||
IfsColor *data,
|
||||
gint fixed_point)
|
||||
GimpRGB *orig_color,
|
||||
GimpRGB *data,
|
||||
gboolean fixed_point)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *arrow;
|
||||
|
||||
ColorMap *color_map = g_new (ColorMap,1);
|
||||
color_map->name = name;
|
||||
color_map->color = data;
|
||||
color_map->fixed_point = fixed_point;
|
||||
|
||||
color_map->hbox = gtk_hbox_new (FALSE,2);
|
||||
color_map->color = data;
|
||||
color_map->fixed_point = fixed_point;
|
||||
color_map->hbox = gtk_hbox_new (FALSE,2);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_box_pack_start (GTK_BOX (color_map->hbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
color_map->orig_preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (color_map->orig_preview),
|
||||
COLOR_SAMPLE_SIZE, COLOR_SAMPLE_SIZE);
|
||||
color_map->orig_preview =
|
||||
gimp_color_area_new (fixed_point ? data : orig_color,
|
||||
FALSE, 0);
|
||||
gtk_drag_dest_unset (color_map->orig_preview);
|
||||
gtk_widget_set_usize (color_map->orig_preview,
|
||||
COLOR_SAMPLE_SIZE, COLOR_SAMPLE_SIZE);
|
||||
gtk_container_add (GTK_CONTAINER(frame), color_map->orig_preview);
|
||||
gtk_widget_show (color_map->orig_preview);
|
||||
|
||||
if (fixed_point)
|
||||
color_map_set_preview_color(color_map->orig_preview,data);
|
||||
else
|
||||
color_map_set_preview_color(color_map->orig_preview,orig_color);
|
||||
|
||||
arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_IN);
|
||||
gtk_box_pack_start (GTK_BOX (color_map->hbox), arrow, FALSE, FALSE, 0);
|
||||
gtk_widget_show (arrow);
|
||||
|
||||
color_map->button = gimp_color_button_double_new (color_map->name,
|
||||
COLOR_SAMPLE_SIZE, COLOR_SAMPLE_SIZE,
|
||||
color_map->color->vals, 3);
|
||||
|
||||
color_map->button = gimp_color_button_new (name,
|
||||
COLOR_SAMPLE_SIZE,
|
||||
COLOR_SAMPLE_SIZE,
|
||||
data, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (color_map->hbox), color_map->button,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (color_map->button);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (color_map->button), "color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||
data);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (color_map->button), "color_changed",
|
||||
GTK_SIGNAL_FUNC (color_map_color_changed_cb),
|
||||
color_map);
|
||||
|
@ -2086,21 +2054,23 @@ color_map_color_changed_cb (GtkWidget *widget,
|
|||
|
||||
elements[ifsD->current_element]->v = ifsD->current_vals;
|
||||
elements[ifsD->current_element]->v.theta *= G_PI/180.0;
|
||||
aff_element_compute_color_trans(elements[ifsD->current_element]);
|
||||
aff_element_compute_color_trans (elements[ifsD->current_element]);
|
||||
|
||||
update_values();
|
||||
update_values ();
|
||||
|
||||
if (ifsD->auto_preview)
|
||||
ifs_compose_preview_callback(NULL,ifsD->preview);
|
||||
ifs_compose_preview_callback (NULL, ifsD->preview);
|
||||
}
|
||||
|
||||
static void
|
||||
color_map_update (ColorMap *color_map)
|
||||
{
|
||||
gimp_color_button_update (GIMP_COLOR_BUTTON (color_map->button));
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (color_map->button),
|
||||
color_map->color);
|
||||
|
||||
if (color_map->fixed_point)
|
||||
color_map_set_preview_color(color_map->orig_preview, color_map->color);
|
||||
gimp_color_area_set_color (GIMP_COLOR_AREA (color_map->orig_preview),
|
||||
color_map->color);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2407,7 +2377,7 @@ recompute_center (gboolean save_undo)
|
|||
undo_update(i);
|
||||
aff_element_compute_trans(elements[i],1,ifsvals.aspect_ratio,
|
||||
ifsvals.center_x, ifsvals.center_y);
|
||||
aff2_fixed_point(&elements[i]->trans,&x,&y);
|
||||
aff2_fixed_point (&elements[i]->trans, &x, &y);
|
||||
center_x += x;
|
||||
center_y += y;
|
||||
}
|
||||
|
@ -2458,15 +2428,16 @@ flip_check_button_callback (GtkWidget *widget,
|
|||
static void
|
||||
ifs_compose_set_defaults (void)
|
||||
{
|
||||
gint i;
|
||||
IfsColor color;
|
||||
guchar rc,bc,gc;
|
||||
gint i;
|
||||
GimpRGB color;
|
||||
guchar r, g, b;
|
||||
|
||||
gimp_palette_get_foreground (&rc,&gc,&bc);
|
||||
gimp_palette_get_foreground (&r, &g, &b);
|
||||
|
||||
color.vals[0] = (gdouble)rc/255;
|
||||
color.vals[1] = (gdouble)gc/255;
|
||||
color.vals[2] = (gdouble)bc/255;
|
||||
gimp_rgb_set (&color,
|
||||
(gdouble) r / 255.0,
|
||||
(gdouble) g / 255.0,
|
||||
(gdouble) b / 255.0);
|
||||
|
||||
ifsvals.aspect_ratio = (gdouble)ifsD->drawable_height/ifsD->drawable_width;
|
||||
|
||||
|
@ -2479,13 +2450,13 @@ ifs_compose_set_defaults (void)
|
|||
element_selected = g_realloc(element_selected,
|
||||
ifsvals.num_elements*sizeof(gint));
|
||||
|
||||
elements[0] = aff_element_new(0.3,0.37*ifsvals.aspect_ratio,color,
|
||||
elements[0] = aff_element_new(0.3,0.37*ifsvals.aspect_ratio, &color,
|
||||
++count_for_naming);
|
||||
element_selected[0] = FALSE;
|
||||
elements[1] = aff_element_new(0.7,0.37*ifsvals.aspect_ratio,color,
|
||||
elements[1] = aff_element_new(0.7,0.37*ifsvals.aspect_ratio, &color,
|
||||
++count_for_naming);
|
||||
element_selected[1] = FALSE;
|
||||
elements[2] = aff_element_new(0.5,0.7*ifsvals.aspect_ratio,color,
|
||||
elements[2] = aff_element_new(0.5,0.7*ifsvals.aspect_ratio, &color,
|
||||
++count_for_naming);
|
||||
element_selected[2] = FALSE;
|
||||
|
||||
|
@ -2544,8 +2515,8 @@ static void
|
|||
ifs_compose_new_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
IfsColor color;
|
||||
guchar rc,bc,gc;
|
||||
GimpRGB color;
|
||||
guchar r, g, b;
|
||||
gint i;
|
||||
gdouble width = ifsDesign->area->allocation.width;
|
||||
gdouble height = ifsDesign->area->allocation.height;
|
||||
|
@ -2553,13 +2524,13 @@ ifs_compose_new_callback (GtkWidget *widget,
|
|||
|
||||
undo_begin();
|
||||
|
||||
gimp_palette_get_foreground (&rc,&gc,&bc);
|
||||
gimp_palette_get_foreground (&r, &g, &b);
|
||||
gimp_rgb_set (&color,
|
||||
(gdouble) r / 255.0,
|
||||
(gdouble) g / 255.0,
|
||||
(gdouble) b / 255.0);
|
||||
|
||||
color.vals[0] = (gdouble)rc/255;
|
||||
color.vals[1] = (gdouble)gc/255;
|
||||
color.vals[2] = (gdouble)bc/255;
|
||||
|
||||
elem = aff_element_new(0.5, 0.5*height/width,color,
|
||||
elem = aff_element_new(0.5, 0.5*height/width, &color,
|
||||
++count_for_naming);
|
||||
|
||||
ifsvals.num_elements++;
|
||||
|
|
|
@ -29,32 +29,28 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
GdkPoint *points;
|
||||
gint npoints;
|
||||
gint npoints;
|
||||
} IPolygon;
|
||||
|
||||
typedef struct {
|
||||
gdouble vals[3];
|
||||
} IfsColor;
|
||||
gdouble x, y;
|
||||
gdouble theta;
|
||||
gdouble scale;
|
||||
gdouble asym;
|
||||
gdouble shear;
|
||||
gint flip;
|
||||
|
||||
typedef struct {
|
||||
gdouble x, y;
|
||||
gdouble theta;
|
||||
gdouble scale;
|
||||
gdouble asym;
|
||||
gdouble shear;
|
||||
gint flip;
|
||||
GimpRGB red_color;
|
||||
GimpRGB green_color;
|
||||
GimpRGB blue_color;
|
||||
GimpRGB black_color;
|
||||
|
||||
IfsColor red_color;
|
||||
IfsColor green_color;
|
||||
IfsColor blue_color;
|
||||
IfsColor black_color;
|
||||
GimpRGB target_color;
|
||||
gdouble hue_scale;
|
||||
gdouble value_scale;
|
||||
|
||||
IfsColor target_color;
|
||||
gdouble hue_scale;
|
||||
gdouble value_scale;
|
||||
|
||||
gint simple_color;
|
||||
gdouble prob;
|
||||
gint simple_color;
|
||||
gdouble prob;
|
||||
} AffElementVals;
|
||||
|
||||
typedef struct
|
||||
|
@ -108,7 +104,7 @@ gint ipolygon_contains (IPolygon *poly, gint xt, gint yt);
|
|||
|
||||
|
||||
/* manipulation of composite transforms */
|
||||
AffElement *aff_element_new (gdouble x, gdouble y,IfsColor color,gint count);
|
||||
AffElement *aff_element_new (gdouble x, gdouble y, GimpRGB *color, gint count);
|
||||
void aff_element_free (AffElement *elem);
|
||||
void aff_element_compute_trans (AffElement *elem, gdouble width,
|
||||
gdouble height,
|
||||
|
|
|
@ -19,8 +19,10 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
||||
#include "ifscompose.h"
|
||||
|
||||
enum {
|
||||
|
@ -84,31 +86,41 @@ static struct
|
|||
static guint nsymbols = sizeof (symbols) / sizeof (symbols[0]);
|
||||
|
||||
static GTokenType
|
||||
ifsvals_parse_color (GScanner *scanner, IfsColor *result)
|
||||
ifsvals_parse_color (GScanner *scanner,
|
||||
GimpRGB *result)
|
||||
{
|
||||
GTokenType token;
|
||||
int i;
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_LEFT_CURLY)
|
||||
return G_TOKEN_LEFT_CURLY;
|
||||
|
||||
for (i=0; i<3; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_COMMA)
|
||||
return G_TOKEN_COMMA;
|
||||
}
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_FLOAT)
|
||||
return G_TOKEN_FLOAT;
|
||||
|
||||
result->vals[i] = scanner->value.v_float;
|
||||
}
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_FLOAT)
|
||||
return G_TOKEN_FLOAT;
|
||||
|
||||
result->r = scanner->value.v_float;
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_COMMA)
|
||||
return G_TOKEN_COMMA;
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_FLOAT)
|
||||
return G_TOKEN_FLOAT;
|
||||
|
||||
result->g = scanner->value.v_float;
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_COMMA)
|
||||
return G_TOKEN_COMMA;
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_FLOAT)
|
||||
return G_TOKEN_FLOAT;
|
||||
|
||||
result->b = scanner->value.v_float;
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_RIGHT_CURLY)
|
||||
return G_TOKEN_RIGHT_CURLY;
|
||||
|
@ -286,7 +298,7 @@ ifsvals_parse (GScanner *scanner, IfsComposeVals *vals, AffElement ***elements)
|
|||
GTokenType token, expected_token;
|
||||
AffElement *el;
|
||||
IfsComposeVals new_vals;
|
||||
IfsColor color = {{0.0,0.0,0.0}}; /* Dummy for aff_element_new */
|
||||
GimpRGB color;
|
||||
|
||||
GList *el_list = NULL;
|
||||
GList *tmp_list;
|
||||
|
@ -347,7 +359,7 @@ ifsvals_parse (GScanner *scanner, IfsComposeVals *vals, AffElement ***elements)
|
|||
break;
|
||||
|
||||
case TOKEN_ELEMENT:
|
||||
el = aff_element_new(0.0,0.0,color,++i);
|
||||
el = aff_element_new (0.0,0.0, &color, ++i);
|
||||
expected_token = ifsvals_parse_element (scanner, &el->v);
|
||||
|
||||
if (expected_token == G_TOKEN_NONE)
|
||||
|
@ -455,25 +467,25 @@ ifsvals_stringify (IfsComposeVals *vals, AffElement **elements)
|
|||
g_string_sprintfa (result, " shear %f\n", elements[i]->v.shear);
|
||||
g_string_sprintfa (result, " flip %d\n", elements[i]->v.flip);
|
||||
g_string_sprintfa (result, " red_color { %f,%f,%f }\n",
|
||||
elements[i]->v.red_color.vals[0],
|
||||
elements[i]->v.red_color.vals[1],
|
||||
elements[i]->v.red_color.vals[2]);
|
||||
elements[i]->v.red_color.r,
|
||||
elements[i]->v.red_color.g,
|
||||
elements[i]->v.red_color.b);
|
||||
g_string_sprintfa (result, " green_color { %f,%f,%f }\n",
|
||||
elements[i]->v.green_color.vals[0],
|
||||
elements[i]->v.green_color.vals[1],
|
||||
elements[i]->v.green_color.vals[2]);
|
||||
elements[i]->v.green_color.r,
|
||||
elements[i]->v.green_color.g,
|
||||
elements[i]->v.green_color.b);
|
||||
g_string_sprintfa (result, " blue_color { %f,%f,%f }\n",
|
||||
elements[i]->v.blue_color.vals[0],
|
||||
elements[i]->v.blue_color.vals[1],
|
||||
elements[i]->v.blue_color.vals[2]);
|
||||
elements[i]->v.blue_color.r,
|
||||
elements[i]->v.blue_color.g,
|
||||
elements[i]->v.blue_color.b);
|
||||
g_string_sprintfa (result, " black_color { %f,%f,%f }\n",
|
||||
elements[i]->v.black_color.vals[0],
|
||||
elements[i]->v.black_color.vals[1],
|
||||
elements[i]->v.black_color.vals[2]);
|
||||
elements[i]->v.black_color.r,
|
||||
elements[i]->v.black_color.g,
|
||||
elements[i]->v.black_color.b);
|
||||
g_string_sprintfa (result, " target_color { %f,%f,%f }\n",
|
||||
elements[i]->v.target_color.vals[0],
|
||||
elements[i]->v.target_color.vals[1],
|
||||
elements[i]->v.target_color.vals[2]);
|
||||
elements[i]->v.target_color.r,
|
||||
elements[i]->v.target_color.g,
|
||||
elements[i]->v.target_color.b);
|
||||
g_string_sprintfa (result, " hue_scale %f\n", elements[i]->v.hue_scale);
|
||||
g_string_sprintfa (result, " value_scale %f\n", elements[i]->v.value_scale);
|
||||
g_string_sprintfa (result, " simple_color %d\n", elements[i]->v.simple_color);
|
||||
|
|
|
@ -363,55 +363,104 @@ aff_element_compute_color_trans(AffElement *elem)
|
|||
|
||||
if (elem->v.simple_color)
|
||||
{
|
||||
gdouble mag2 = 0;
|
||||
for (i=0;i<3;i++)
|
||||
mag2 += SQR(elem->v.target_color.vals[i]);
|
||||
gdouble mag2;
|
||||
|
||||
mag2 = SQR(elem->v.target_color.r);
|
||||
mag2 += SQR(elem->v.target_color.g);
|
||||
mag2 += SQR(elem->v.target_color.b);
|
||||
|
||||
/* For mag2 == 0, the transformation blows up in general
|
||||
but is well defined for hue_scale == value_scale, so
|
||||
we assume that special case. */
|
||||
if (mag2 == 0)
|
||||
for (i=0;i<3;i++)
|
||||
for (i=0; i<3; i++)
|
||||
{
|
||||
for (j=0;j<4;j++)
|
||||
for (j=0; j<4; j++)
|
||||
elem->color_trans.vals[i][j] = 0.0;
|
||||
|
||||
elem->color_trans.vals[i][i] = elem->v.hue_scale;
|
||||
}
|
||||
else
|
||||
for (i=0;i<3;i++)
|
||||
{
|
||||
for (j=0;j<3;j++)
|
||||
{
|
||||
elem->color_trans.vals[i][j] = elem->v.target_color.vals[i]
|
||||
/ mag2 * (elem->v.value_scale - elem->v.hue_scale);
|
||||
if (i==j)
|
||||
elem->color_trans.vals[i][j] += elem->v.hue_scale;
|
||||
}
|
||||
elem->color_trans.vals[i][3] =
|
||||
(1-elem->v.value_scale)*elem->v.target_color.vals[i];
|
||||
{
|
||||
/* red */
|
||||
for (j=0; j<3; j++)
|
||||
{
|
||||
elem->color_trans.vals[0][j] = elem->v.target_color.r
|
||||
/ mag2 * (elem->v.value_scale - elem->v.hue_scale);
|
||||
}
|
||||
|
||||
/* green */
|
||||
for (j=0; j<3; j++)
|
||||
{
|
||||
elem->color_trans.vals[1][j] = elem->v.target_color.g
|
||||
/ mag2 * (elem->v.value_scale - elem->v.hue_scale);
|
||||
}
|
||||
|
||||
/* blue */
|
||||
for (j=0; j<3; j++)
|
||||
{
|
||||
elem->color_trans.vals[2][j] = elem->v.target_color.g
|
||||
/ mag2 * (elem->v.value_scale - elem->v.hue_scale);
|
||||
}
|
||||
|
||||
elem->color_trans.vals[0][0] += elem->v.hue_scale;
|
||||
elem->color_trans.vals[1][1] += elem->v.hue_scale;
|
||||
elem->color_trans.vals[2][2] += elem->v.hue_scale;
|
||||
|
||||
|
||||
elem->color_trans.vals[0][3] =
|
||||
(1-elem->v.value_scale)*elem->v.target_color.r;
|
||||
elem->color_trans.vals[1][3] =
|
||||
(1-elem->v.value_scale)*elem->v.target_color.g;
|
||||
elem->color_trans.vals[2][3] =
|
||||
(1-elem->v.value_scale)*elem->v.target_color.b;
|
||||
|
||||
}
|
||||
aff3_apply(&elem->color_trans,1.0,0.0,0.0,&elem->v.red_color.vals[0],
|
||||
&elem->v.red_color.vals[1],&elem->v.red_color.vals[2]);
|
||||
aff3_apply(&elem->color_trans,0.0,1.0,0.0,&elem->v.green_color.vals[0],
|
||||
&elem->v.green_color.vals[1],&elem->v.green_color.vals[2]);
|
||||
aff3_apply(&elem->color_trans,0.0,0.0,1.0,&elem->v.blue_color.vals[0],
|
||||
&elem->v.blue_color.vals[1],&elem->v.blue_color.vals[2]);
|
||||
aff3_apply(&elem->color_trans,0.0,0.0,0.0,&elem->v.black_color.vals[0],
|
||||
&elem->v.black_color.vals[1],&elem->v.black_color.vals[2]);
|
||||
|
||||
|
||||
aff3_apply (&elem->color_trans, 1.0, 0.0, 0.0,
|
||||
&elem->v.red_color.r,
|
||||
&elem->v.red_color.g,
|
||||
&elem->v.red_color.b);
|
||||
aff3_apply (&elem->color_trans, 0.0, 1.0, 0.0,
|
||||
&elem->v.green_color.r,
|
||||
&elem->v.green_color.g,
|
||||
&elem->v.green_color.b);
|
||||
aff3_apply (&elem->color_trans, 0.0, 0.0, 1.0,
|
||||
&elem->v.blue_color.r,
|
||||
&elem->v.blue_color.g,
|
||||
&elem->v.blue_color.b);
|
||||
aff3_apply (&elem->color_trans, 0.0, 0.0, 0.0,
|
||||
&elem->v.black_color.r,
|
||||
&elem->v.black_color.g,
|
||||
&elem->v.black_color.b);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=0;i<3;i++)
|
||||
elem->color_trans.vals[i][0] = elem->v.red_color.vals[i]
|
||||
- elem->v.black_color.vals[i];
|
||||
for (i=0;i<3;i++)
|
||||
elem->color_trans.vals[i][1] = elem->v.green_color.vals[i]
|
||||
- elem->v.black_color.vals[i];
|
||||
for (i=0;i<3;i++)
|
||||
elem->color_trans.vals[i][2] = elem->v.blue_color.vals[i]
|
||||
- elem->v.black_color.vals[i];
|
||||
for (i=0;i<3;i++)
|
||||
elem->color_trans.vals[i][3] = elem->v.black_color.vals[i];
|
||||
elem->color_trans.vals[0][0] =
|
||||
elem->v.red_color.r - elem->v.black_color.r;
|
||||
elem->color_trans.vals[1][0] =
|
||||
elem->v.red_color.g - elem->v.black_color.g;
|
||||
elem->color_trans.vals[2][0] =
|
||||
elem->v.red_color.b - elem->v.black_color.b;
|
||||
|
||||
elem->color_trans.vals[0][1] =
|
||||
elem->v.green_color.r - elem->v.black_color.r;
|
||||
elem->color_trans.vals[1][1] =
|
||||
elem->v.green_color.g - elem->v.black_color.g;
|
||||
elem->color_trans.vals[2][1] =
|
||||
elem->v.green_color.b - elem->v.black_color.b;
|
||||
|
||||
elem->color_trans.vals[0][2] =
|
||||
elem->v.blue_color.r - elem->v.black_color.r;
|
||||
elem->color_trans.vals[1][2] =
|
||||
elem->v.blue_color.g - elem->v.black_color.g;
|
||||
elem->color_trans.vals[2][2] =
|
||||
elem->v.blue_color.b - elem->v.black_color.b;
|
||||
|
||||
elem->color_trans.vals[0][3] = elem->v.black_color.r;
|
||||
elem->color_trans.vals[1][3] = elem->v.black_color.g;
|
||||
elem->color_trans.vals[2][3] = elem->v.black_color.b;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -642,10 +691,10 @@ aff_element_draw(AffElement *elem, gint selected,
|
|||
}
|
||||
|
||||
AffElement *
|
||||
aff_element_new(gdouble x, gdouble y, IfsColor color, gint count)
|
||||
aff_element_new (gdouble x, gdouble y, GimpRGB *color, gint count)
|
||||
{
|
||||
AffElement *elem = g_new(AffElement, 1);
|
||||
char buffer[16];
|
||||
gchar buffer[16];
|
||||
|
||||
elem->v.x = x;
|
||||
elem->v.y = y;
|
||||
|
@ -655,12 +704,12 @@ aff_element_new(gdouble x, gdouble y, IfsColor color, gint count)
|
|||
elem->v.shear = 0.0;
|
||||
elem->v.flip = 0;
|
||||
|
||||
elem->v.red_color = color;
|
||||
elem->v.blue_color = color;
|
||||
elem->v.green_color = color;
|
||||
elem->v.black_color = color;
|
||||
elem->v.red_color = *color;
|
||||
elem->v.blue_color = *color;
|
||||
elem->v.green_color = *color;
|
||||
elem->v.black_color = *color;
|
||||
|
||||
elem->v.target_color = color;
|
||||
elem->v.target_color = *color;
|
||||
elem->v.hue_scale = 0.5;
|
||||
elem->v.value_scale = 0.5;
|
||||
|
||||
|
@ -669,11 +718,11 @@ aff_element_new(gdouble x, gdouble y, IfsColor color, gint count)
|
|||
elem->draw_boundary = NULL;
|
||||
elem->click_boundary = NULL;
|
||||
|
||||
aff_element_compute_color_trans(elem);
|
||||
aff_element_compute_color_trans (elem);
|
||||
|
||||
elem->v.prob = 1.0;
|
||||
|
||||
sprintf(buffer,"%d",count);
|
||||
sprintf (buffer,"%d",count);
|
||||
elem->name = g_strdup(buffer);
|
||||
|
||||
return elem;
|
||||
|
|
|
@ -118,7 +118,7 @@ typedef union
|
|||
gint32 sfa_drawable;
|
||||
gint32 sfa_layer;
|
||||
gint32 sfa_channel;
|
||||
guchar sfa_color[3];
|
||||
GimpRGB sfa_color;
|
||||
gint32 sfa_toggle;
|
||||
gchar *sfa_value;
|
||||
SFAdjustment sfa_adjustment;
|
||||
|
@ -540,10 +540,14 @@ script_fu_add_script (LISP a)
|
|||
color_list = cdr (color_list);
|
||||
color[2] =
|
||||
(guchar)(CLAMP (get_c_long (car (color_list)), 0, 255));
|
||||
memcpy (script->arg_defaults[i].sfa_color,
|
||||
color, sizeof (guchar) * 3);
|
||||
memcpy (script->arg_values[i].sfa_color,
|
||||
color, sizeof (guchar) * 3);
|
||||
|
||||
gimp_rgb_set (&script->arg_defaults[i].sfa_color,
|
||||
color[0] / 255.0,
|
||||
color[1] / 255.0,
|
||||
color[2] / 255.0);
|
||||
|
||||
script->arg_values[i].sfa_color =
|
||||
script->arg_defaults[i].sfa_color;
|
||||
|
||||
args[i + 1].type = GIMP_PDB_COLOR;
|
||||
args[i + 1].name = "color";
|
||||
|
@ -1303,7 +1307,11 @@ 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, 3);
|
||||
&script->arg_values[i].sfa_color, FALSE);
|
||||
gtk_signal_connect (GTK_OBJECT (sf_interface->args_widgets[i]),
|
||||
"color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||
&script->arg_values[i].sfa_color);
|
||||
break;
|
||||
|
||||
case SF_TOGGLE:
|
||||
|
@ -1800,9 +1808,9 @@ script_fu_ok_callback (GtkWidget *widget,
|
|||
|
||||
case SF_COLOR:
|
||||
g_snprintf (buffer, sizeof (buffer), "'(%d %d %d)",
|
||||
script->arg_values[i].sfa_color[0],
|
||||
script->arg_values[i].sfa_color[1],
|
||||
script->arg_values[i].sfa_color[2]);
|
||||
(gint) (script->arg_values[i].sfa_color.r * 255.999),
|
||||
(gint) (script->arg_values[i].sfa_color.g * 255.999),
|
||||
(gint) (script->arg_values[i].sfa_color.b * 255.999));
|
||||
text = buffer;
|
||||
break;
|
||||
|
||||
|
@ -2056,7 +2064,7 @@ static void
|
|||
script_fu_reset_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gint i, j;
|
||||
gint i;
|
||||
|
||||
SFScript *script = (SFScript *) data;
|
||||
|
||||
|
@ -2070,12 +2078,10 @@ script_fu_reset_callback (GtkWidget *widget,
|
|||
break;
|
||||
|
||||
case SF_COLOR:
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
script->arg_values[i].sfa_color[j] =
|
||||
script->arg_defaults[i].sfa_color[j];
|
||||
}
|
||||
gimp_color_button_update (GIMP_COLOR_BUTTON (sf_interface->args_widgets[i]));
|
||||
script->arg_values[i].sfa_color =
|
||||
script->arg_defaults[i].sfa_color;
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (sf_interface->args_widgets[i]),
|
||||
&script->arg_values[i].sfa_color);
|
||||
break;
|
||||
|
||||
case SF_TOGGLE:
|
||||
|
|
|
@ -118,7 +118,7 @@ typedef union
|
|||
gint32 sfa_drawable;
|
||||
gint32 sfa_layer;
|
||||
gint32 sfa_channel;
|
||||
guchar sfa_color[3];
|
||||
GimpRGB sfa_color;
|
||||
gint32 sfa_toggle;
|
||||
gchar *sfa_value;
|
||||
SFAdjustment sfa_adjustment;
|
||||
|
@ -540,10 +540,14 @@ script_fu_add_script (LISP a)
|
|||
color_list = cdr (color_list);
|
||||
color[2] =
|
||||
(guchar)(CLAMP (get_c_long (car (color_list)), 0, 255));
|
||||
memcpy (script->arg_defaults[i].sfa_color,
|
||||
color, sizeof (guchar) * 3);
|
||||
memcpy (script->arg_values[i].sfa_color,
|
||||
color, sizeof (guchar) * 3);
|
||||
|
||||
gimp_rgb_set (&script->arg_defaults[i].sfa_color,
|
||||
color[0] / 255.0,
|
||||
color[1] / 255.0,
|
||||
color[2] / 255.0);
|
||||
|
||||
script->arg_values[i].sfa_color =
|
||||
script->arg_defaults[i].sfa_color;
|
||||
|
||||
args[i + 1].type = GIMP_PDB_COLOR;
|
||||
args[i + 1].name = "color";
|
||||
|
@ -1303,7 +1307,11 @@ 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, 3);
|
||||
&script->arg_values[i].sfa_color, FALSE);
|
||||
gtk_signal_connect (GTK_OBJECT (sf_interface->args_widgets[i]),
|
||||
"color_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
|
||||
&script->arg_values[i].sfa_color);
|
||||
break;
|
||||
|
||||
case SF_TOGGLE:
|
||||
|
@ -1800,9 +1808,9 @@ script_fu_ok_callback (GtkWidget *widget,
|
|||
|
||||
case SF_COLOR:
|
||||
g_snprintf (buffer, sizeof (buffer), "'(%d %d %d)",
|
||||
script->arg_values[i].sfa_color[0],
|
||||
script->arg_values[i].sfa_color[1],
|
||||
script->arg_values[i].sfa_color[2]);
|
||||
(gint) (script->arg_values[i].sfa_color.r * 255.999),
|
||||
(gint) (script->arg_values[i].sfa_color.g * 255.999),
|
||||
(gint) (script->arg_values[i].sfa_color.b * 255.999));
|
||||
text = buffer;
|
||||
break;
|
||||
|
||||
|
@ -2056,7 +2064,7 @@ static void
|
|||
script_fu_reset_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gint i, j;
|
||||
gint i;
|
||||
|
||||
SFScript *script = (SFScript *) data;
|
||||
|
||||
|
@ -2070,12 +2078,10 @@ script_fu_reset_callback (GtkWidget *widget,
|
|||
break;
|
||||
|
||||
case SF_COLOR:
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
script->arg_values[i].sfa_color[j] =
|
||||
script->arg_defaults[i].sfa_color[j];
|
||||
}
|
||||
gimp_color_button_update (GIMP_COLOR_BUTTON (sf_interface->args_widgets[i]));
|
||||
script->arg_values[i].sfa_color =
|
||||
script->arg_defaults[i].sfa_color;
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (sf_interface->args_widgets[i]),
|
||||
&script->arg_values[i].sfa_color);
|
||||
break;
|
||||
|
||||
case SF_TOGGLE:
|
||||
|
|
Loading…
Reference in New Issue