mirror of https://github.com/GNOME/gimp.git
libgimpwidgets/Makefile.am libgimpwidgets/gimpwidgets.def
2004-07-26 Sven Neumann <sven@gimp.org> * libgimpwidgets/Makefile.am * libgimpwidgets/gimpwidgets.def * libgimpwidgets/gimpwidgets.h * libgimpwidgets/gimpwidgetstypes.h * libgimpwidgets/gimpcellrenderercolor.[ch]: added a GimpRGB cell renderer. * libgimpwidgets/gimpcolorarea.[ch]: exported the function that renders the color to a buffer for internal use in libgimpwidgets. * libgimpwidgets/gimpcolorhexentry.c: use the new cell renderer for the completion popup.
This commit is contained in:
parent
89995843ab
commit
763bbcd496
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2004-07-26 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpwidgets/Makefile.am
|
||||
* libgimpwidgets/gimpwidgets.def
|
||||
* libgimpwidgets/gimpwidgets.h
|
||||
* libgimpwidgets/gimpwidgetstypes.h
|
||||
* libgimpwidgets/gimpcellrenderercolor.[ch]: added a GimpRGB cell
|
||||
renderer.
|
||||
|
||||
* libgimpwidgets/gimpcolorarea.[ch]: exported the function that
|
||||
renders the color to a buffer for internal use in libgimpwidgets.
|
||||
|
||||
* libgimpwidgets/gimpcolorhexentry.c: use the new cell renderer
|
||||
for the completion popup.
|
||||
|
||||
2004-07-26 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpcolor/gimpcolor.def
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
</chapter>
|
||||
|
||||
<xi:include href="xml/gimpbutton.xml" />
|
||||
<xi:include href="xml/gimpcellrenderercolor.xml" />
|
||||
<xi:include href="xml/gimpchainbutton.xml" />
|
||||
<xi:include href="xml/gimpcolorarea.xml" />
|
||||
<xi:include href="xml/gimpcolorbutton.xml" />
|
||||
|
|
|
@ -1,3 +1,36 @@
|
|||
<SECTION>
|
||||
<FILE>gimpbutton</FILE>
|
||||
<TITLE>GimpButton</TITLE>
|
||||
GimpButton
|
||||
gimp_button_new
|
||||
gimp_button_extended_clicked
|
||||
<SUBSECTION Standard>
|
||||
GIMP_BUTTON
|
||||
GIMP_IS_BUTTON
|
||||
GIMP_TYPE_BUTTON
|
||||
gimp_button_get_type
|
||||
GimpButtonClass
|
||||
GIMP_BUTTON_CLASS
|
||||
GIMP_IS_BUTTON_CLASS
|
||||
GIMP_BUTTON_GET_CLASS
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gimpcellrenderercolor</FILE>
|
||||
<TITLE>GimpCellRendererColor</TITLE>
|
||||
GimpCellRendererColor
|
||||
gimp_cell_renderer_color_new
|
||||
<SUBSECTION Standard>
|
||||
GimpCellRendererColorClass
|
||||
GIMP_CELL_RENDERER_COLOR
|
||||
GIMP_IS_CELL_RENDERER_COLOR
|
||||
GIMP_TYPE_CELL_RENDERER_COLOR
|
||||
gimp_cell_renderer_color_get_type
|
||||
GIMP_CELL_RENDERER_COLOR_CLASS
|
||||
GIMP_IS_CELL_RENDERER_COLOR_CLASS
|
||||
GIMP_CELL_RENDERER_COLOR_GET_CLASS
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gimpchainbutton</FILE>
|
||||
<TITLE>GimpChainButton</TITLE>
|
||||
|
@ -307,23 +340,6 @@ GIMP_IS_UNIT_MENU_CLASS
|
|||
GIMP_UNIT_MENU_GET_CLASS
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gimpbutton</FILE>
|
||||
<TITLE>GimpButton</TITLE>
|
||||
GimpButton
|
||||
gimp_button_new
|
||||
gimp_button_extended_clicked
|
||||
<SUBSECTION Standard>
|
||||
GIMP_BUTTON
|
||||
GIMP_IS_BUTTON
|
||||
GIMP_TYPE_BUTTON
|
||||
gimp_button_get_type
|
||||
GimpButtonClass
|
||||
GIMP_BUTTON_CLASS
|
||||
GIMP_IS_BUTTON_CLASS
|
||||
GIMP_BUTTON_GET_CLASS
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gimpoffsetarea</FILE>
|
||||
<TITLE>GimpOffsetArea</TITLE>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "devel-docs/libgimpwidgets/libgimpwidgets-include.c"
|
||||
|
||||
gimp_button_get_type
|
||||
gimp_cell_renderer_color_get_type
|
||||
gimp_chain_button_get_type
|
||||
gimp_color_area_get_type
|
||||
gimp_color_button_get_type
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<!-- ##### SECTION Title ##### -->
|
||||
GimpCellRendererColor
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### STRUCT GimpCellRendererColor ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### ARG GimpCellRendererColor:color ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### ARG GimpCellRendererColor:icon-size ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### ARG GimpCellRendererColor:opaque ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### FUNCTION gimp_cell_renderer_color_new ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@Returns:
|
||||
|
||||
|
|
@ -64,6 +64,8 @@ libgimpwidgets_2_0_la_sources = \
|
|||
gimpwidgetstypes.h \
|
||||
gimpbutton.c \
|
||||
gimpbutton.h \
|
||||
gimpcellrenderercolor.c \
|
||||
gimpcellrenderercolor.h \
|
||||
gimpchainbutton.c \
|
||||
gimpchainbutton.h \
|
||||
gimpcolorarea.c \
|
||||
|
|
|
@ -0,0 +1,308 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpcellrenderercolor.c
|
||||
* Copyright (C) 2004 Sven Neuman <sven1@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
|
||||
#include "gimpwidgetstypes.h"
|
||||
|
||||
#include "gimpcolorarea.h"
|
||||
#include "gimpcellrenderercolor.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_COLOR,
|
||||
PROP_OPAQUE,
|
||||
PROP_SIZE
|
||||
};
|
||||
|
||||
|
||||
static void gimp_cell_renderer_color_class_init (GimpCellRendererColorClass *klass);
|
||||
static void gimp_cell_renderer_color_init (GimpCellRendererColor *cell);
|
||||
|
||||
static void gimp_cell_renderer_color_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_cell_renderer_color_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_cell_renderer_color_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *rectangle,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height);
|
||||
static void gimp_cell_renderer_color_render (GtkCellRenderer *cell,
|
||||
GdkWindow *window,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
GtkCellRendererState flags);
|
||||
|
||||
|
||||
static GtkCellRendererClass *parent_class = NULL;
|
||||
|
||||
|
||||
GType
|
||||
gimp_cell_renderer_color_get_type (void)
|
||||
{
|
||||
static GType cell_type = 0;
|
||||
|
||||
if (! cell_type)
|
||||
{
|
||||
static const GTypeInfo cell_info =
|
||||
{
|
||||
sizeof (GimpCellRendererColorClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) gimp_cell_renderer_color_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpCellRendererColor),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_cell_renderer_color_init,
|
||||
};
|
||||
|
||||
cell_type = g_type_register_static (GTK_TYPE_CELL_RENDERER,
|
||||
"GimpCellRendererColor",
|
||||
&cell_info, 0);
|
||||
}
|
||||
|
||||
return cell_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_cell_renderer_color_class_init (GimpCellRendererColorClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->get_property = gimp_cell_renderer_color_get_property;
|
||||
object_class->set_property = gimp_cell_renderer_color_set_property;
|
||||
|
||||
cell_class->get_size = gimp_cell_renderer_color_get_size;
|
||||
cell_class->render = gimp_cell_renderer_color_render;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_COLOR,
|
||||
g_param_spec_boxed ("color", NULL, NULL,
|
||||
GIMP_TYPE_RGB,
|
||||
G_PARAM_READWRITE));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_OPAQUE,
|
||||
g_param_spec_boolean ("opaque", NULL, NULL,
|
||||
TRUE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_SIZE,
|
||||
g_param_spec_int ("icon_size", NULL, NULL,
|
||||
0, G_MAXINT,
|
||||
GTK_ICON_SIZE_MENU,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_cell_renderer_color_init (GimpCellRendererColor *cell)
|
||||
{
|
||||
gimp_rgba_set (&cell->color, 0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_cell_renderer_color_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpCellRendererColor *cell = GIMP_CELL_RENDERER_COLOR (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_COLOR:
|
||||
g_value_set_boxed (value, &cell->color);
|
||||
break;
|
||||
case PROP_OPAQUE:
|
||||
g_value_set_boolean (value, cell->opaque);
|
||||
break;
|
||||
case PROP_SIZE:
|
||||
g_value_set_int (value, cell->size);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_cell_renderer_color_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpCellRendererColor *cell = GIMP_CELL_RENDERER_COLOR (object);
|
||||
GimpRGB *color;
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_COLOR:
|
||||
color = g_value_get_boxed (value);
|
||||
cell->color = *color;
|
||||
break;
|
||||
case PROP_OPAQUE:
|
||||
cell->opaque = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_SIZE:
|
||||
cell->size = g_value_get_int (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_cell_renderer_color_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *cell_area,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GimpCellRendererColor *color = GIMP_CELL_RENDERER_COLOR (cell);
|
||||
GtkSettings *settings;
|
||||
gint calc_width;
|
||||
gint calc_height;
|
||||
|
||||
settings = gtk_settings_get_for_screen (gtk_widget_get_screen (widget));
|
||||
|
||||
gtk_icon_size_lookup_for_settings (settings,
|
||||
color->size, &calc_width, &calc_height);
|
||||
|
||||
calc_width += 2 + 2 * cell->xpad;
|
||||
calc_height += 2 + 2 * cell->ypad;
|
||||
|
||||
if (cell_area && color->size > 0)
|
||||
{
|
||||
if (x_offset)
|
||||
{
|
||||
*x_offset = (((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ?
|
||||
1.0 - cell->xalign : cell->xalign) *
|
||||
(cell_area->width - calc_width - 2 * cell->xpad));
|
||||
*x_offset = MAX (*x_offset, 0) + cell->xpad;
|
||||
}
|
||||
if (y_offset)
|
||||
{
|
||||
*y_offset = (cell->yalign *
|
||||
(cell_area->height - calc_height - 2 * cell->ypad));
|
||||
*y_offset = MAX (*y_offset, 0) + cell->ypad;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x_offset)
|
||||
*x_offset = 0;
|
||||
if (y_offset)
|
||||
*y_offset = 0;
|
||||
}
|
||||
|
||||
if (width)
|
||||
*width = calc_width;
|
||||
if (height)
|
||||
*height = calc_height;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_cell_renderer_color_render (GtkCellRenderer *cell,
|
||||
GdkWindow *window,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
GtkCellRendererState flags)
|
||||
{
|
||||
GimpCellRendererColor *color = GIMP_CELL_RENDERER_COLOR (cell);
|
||||
GdkRectangle rect;
|
||||
|
||||
gimp_cell_renderer_color_get_size (cell, widget, cell_area,
|
||||
&rect.x,
|
||||
&rect.y,
|
||||
&rect.width,
|
||||
&rect.height);
|
||||
|
||||
rect.x += cell_area->x + cell->xpad;
|
||||
rect.y += cell_area->y + cell->ypad;
|
||||
rect.width -= 2 * cell->xpad;
|
||||
rect.height -= 2 * cell->ypad;
|
||||
|
||||
if (rect.width > 2 && rect.height > 2)
|
||||
{
|
||||
GtkStateType state;
|
||||
guchar *buf;
|
||||
guint rowstride = 3 * (rect.width - 2);
|
||||
|
||||
if (rowstride & 3)
|
||||
rowstride += 4 - (rowstride & 3);
|
||||
|
||||
buf = g_alloca (rowstride * (rect.height - 2));
|
||||
|
||||
_gimp_color_area_render_buf ((color->opaque ?
|
||||
GIMP_COLOR_AREA_FLAT :
|
||||
GIMP_COLOR_AREA_SMALL_CHECKS),
|
||||
buf,
|
||||
rect.width - 2, rect.height - 2, rowstride,
|
||||
&color->color);
|
||||
|
||||
gdk_draw_rgb_image_dithalign (window,
|
||||
widget->style->black_gc,
|
||||
rect.x + 1, rect.y + 1,
|
||||
rect.width - 2, rect.height - 2,
|
||||
GDK_RGB_DITHER_MAX,
|
||||
buf, rowstride, rect.x, rect.y);
|
||||
|
||||
state = (flags & GTK_CELL_RENDERER_SELECTED ?
|
||||
GTK_STATE_SELECTED : GTK_STATE_NORMAL);
|
||||
|
||||
gdk_draw_rectangle (window,
|
||||
widget->style->fg_gc[state],
|
||||
FALSE,
|
||||
rect.x, rect.y, rect.width - 1, rect.height - 1);
|
||||
}
|
||||
}
|
||||
|
||||
GtkCellRenderer *
|
||||
gimp_cell_renderer_color_new (void)
|
||||
{
|
||||
return g_object_new (GIMP_TYPE_CELL_RENDERER_COLOR, NULL);
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpcellrenderercolor.h
|
||||
* Copyright (C) 2004 Sven Neuman <sven1@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_CELL_RENDERER_COLOR_H__
|
||||
#define __GIMP_CELL_RENDERER_COLOR_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define GIMP_TYPE_CELL_RENDERER_COLOR (gimp_cell_renderer_color_get_type ())
|
||||
#define GIMP_CELL_RENDERER_COLOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CELL_RENDERER_COLOR, GimpCellRendererColor))
|
||||
#define GIMP_CELL_RENDERER_COLOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CELL_RENDERER_COLOR, GimpCellRendererColorClass))
|
||||
#define GIMP_IS_CELL_RENDERER_COLOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CELL_RENDERER_COLOR))
|
||||
#define GIMP_IS_CELL_RENDERER_COLOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CELL_RENDERER_COLOR))
|
||||
#define GIMP_CELL_RENDERER_COLOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CELL_RENDERER_COLOR, GimpCellRendererColorClass))
|
||||
|
||||
|
||||
typedef struct _GimpCellRendererColorClass GimpCellRendererColorClass;
|
||||
|
||||
struct _GimpCellRendererColor
|
||||
{
|
||||
GtkCellRenderer parent_instance;
|
||||
|
||||
GimpRGB color;
|
||||
gboolean opaque;
|
||||
gint size;
|
||||
gint border;
|
||||
};
|
||||
|
||||
struct _GimpCellRendererColorClass
|
||||
{
|
||||
GtkCellRendererClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_cell_renderer_color_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkCellRenderer * gimp_cell_renderer_color_new (void);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIMP_CELL_RENDERER_COLOR_H__ */
|
|
@ -380,10 +380,14 @@ gimp_color_area_set_draw_border (GimpColorArea *area,
|
|||
gtk_widget_queue_draw (GTK_WIDGET (area));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_area_render (GimpColorArea *area)
|
||||
void
|
||||
_gimp_color_area_render_buf (GimpColorAreaType type,
|
||||
guchar *buf,
|
||||
guint width,
|
||||
guint height,
|
||||
guint rowstride,
|
||||
GimpRGB *color)
|
||||
{
|
||||
guint width, height;
|
||||
guint x, y;
|
||||
guint check_size = 0;
|
||||
guchar light[3];
|
||||
|
@ -392,15 +396,7 @@ gimp_color_area_render (GimpColorArea *area)
|
|||
guchar *p;
|
||||
gdouble frac;
|
||||
|
||||
area->needs_render = FALSE;
|
||||
|
||||
if (! area->buf)
|
||||
return;
|
||||
|
||||
width = area->width;
|
||||
height = area->height;
|
||||
|
||||
switch (area->type)
|
||||
switch (type)
|
||||
{
|
||||
case GIMP_COLOR_AREA_FLAT:
|
||||
check_size = 0;
|
||||
|
@ -415,13 +411,13 @@ gimp_color_area_render (GimpColorArea *area)
|
|||
break;
|
||||
}
|
||||
|
||||
gimp_rgb_get_uchar (&area->color, opaque, opaque + 1, opaque + 2);
|
||||
gimp_rgb_get_uchar (color, opaque, opaque + 1, opaque + 2);
|
||||
|
||||
if (area->color.a == 1.0 || !check_size)
|
||||
if (color->a == 1.0 || !check_size)
|
||||
{
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
p = area->buf + y * area->rowstride;
|
||||
p = buf + y * rowstride;
|
||||
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
|
@ -435,21 +431,21 @@ gimp_color_area_render (GimpColorArea *area)
|
|||
}
|
||||
|
||||
light[0] = (GIMP_CHECK_LIGHT +
|
||||
(area->color.r - GIMP_CHECK_LIGHT) * area->color.a) * 255.999;
|
||||
(color->r - GIMP_CHECK_LIGHT) * color->a) * 255.999;
|
||||
dark[0] = (GIMP_CHECK_DARK +
|
||||
(area->color.r - GIMP_CHECK_DARK) * area->color.a) * 255.999;
|
||||
(color->r - GIMP_CHECK_DARK) * color->a) * 255.999;
|
||||
light[1] = (GIMP_CHECK_LIGHT +
|
||||
(area->color.g - GIMP_CHECK_LIGHT) * area->color.a) * 255.999;
|
||||
(color->g - GIMP_CHECK_LIGHT) * color->a) * 255.999;
|
||||
dark[1] = (GIMP_CHECK_DARK +
|
||||
(area->color.g - GIMP_CHECK_DARK) * area->color.a) * 255.999;
|
||||
(color->g - GIMP_CHECK_DARK) * color->a) * 255.999;
|
||||
light[2] = (GIMP_CHECK_LIGHT +
|
||||
(area->color.b - GIMP_CHECK_LIGHT) * area->color.a) * 255.999;
|
||||
(color->b - GIMP_CHECK_LIGHT) * color->a) * 255.999;
|
||||
dark[2] = (GIMP_CHECK_DARK +
|
||||
(area->color.b - GIMP_CHECK_DARK) * area->color.a) * 255.999;
|
||||
(color->b - GIMP_CHECK_DARK) * color->a) * 255.999;
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
p = area->buf + y * area->rowstride;
|
||||
p = buf + y * rowstride;
|
||||
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
|
@ -503,6 +499,19 @@ gimp_color_area_render (GimpColorArea *area)
|
|||
}
|
||||
}
|
||||
}
|
||||
static void
|
||||
gimp_color_area_render (GimpColorArea *area)
|
||||
{
|
||||
area->needs_render = FALSE;
|
||||
|
||||
if (! area->buf)
|
||||
return;
|
||||
|
||||
_gimp_color_area_render_buf (area->type,
|
||||
area->buf,
|
||||
area->width, area->height, area->rowstride,
|
||||
&area->color);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_area_drag_begin (GtkWidget *widget,
|
||||
|
|
|
@ -89,6 +89,13 @@ void gimp_color_area_set_type (GimpColorArea *area,
|
|||
void gimp_color_area_set_draw_border (GimpColorArea *area,
|
||||
gboolean draw_border);
|
||||
|
||||
/* only for private use in libgimpwidgets */
|
||||
void _gimp_color_area_render_buf (GimpColorAreaType type,
|
||||
guchar *buf,
|
||||
guint width,
|
||||
guint height,
|
||||
guint rowstride,
|
||||
GimpRGB *color);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "gimpwidgetstypes.h"
|
||||
|
||||
#include "gimpcellrenderercolor.h"
|
||||
#include "gimpcolorhexentry.h"
|
||||
|
||||
|
||||
|
@ -43,6 +44,7 @@ enum
|
|||
enum
|
||||
{
|
||||
COLUMN_NAME,
|
||||
COLUMN_COLOR,
|
||||
NUM_COLUMNS
|
||||
};
|
||||
|
||||
|
@ -108,6 +110,7 @@ static void
|
|||
gimp_color_hex_entry_init (GimpColorHexEntry *entry)
|
||||
{
|
||||
GtkEntryCompletion *completion;
|
||||
GtkCellRenderer *cell;
|
||||
GtkListStore *store;
|
||||
GimpRGB *colors;
|
||||
const gchar **names;
|
||||
|
@ -116,7 +119,7 @@ gimp_color_hex_entry_init (GimpColorHexEntry *entry)
|
|||
|
||||
gimp_rgba_set (&entry->color, 0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
store = gtk_list_store_new (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
|
||||
store = gtk_list_store_new (NUM_COLUMNS, G_TYPE_STRING, GIMP_TYPE_RGB);
|
||||
|
||||
num_colors = gimp_rgb_list_names (&names, &colors);
|
||||
|
||||
|
@ -126,7 +129,8 @@ gimp_color_hex_entry_init (GimpColorHexEntry *entry)
|
|||
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter,
|
||||
COLUMN_NAME, names[i],
|
||||
COLUMN_NAME, names[i],
|
||||
COLUMN_COLOR, colors + i,
|
||||
-1);
|
||||
}
|
||||
|
||||
|
@ -138,6 +142,12 @@ gimp_color_hex_entry_init (GimpColorHexEntry *entry)
|
|||
NULL);
|
||||
g_object_unref (store);
|
||||
|
||||
cell = gimp_cell_renderer_color_new ();
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion), cell, FALSE);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (completion), cell,
|
||||
"color", COLUMN_COLOR,
|
||||
NULL);
|
||||
|
||||
gtk_entry_completion_set_text_column (completion, COLUMN_NAME);
|
||||
|
||||
gtk_entry_set_completion (GTK_ENTRY (entry), completion);
|
||||
|
@ -257,9 +267,11 @@ gimp_color_hex_entry_events (GtkWidget *widget,
|
|||
(gimp_rgb_parse_name (&color, text, -1)))
|
||||
{
|
||||
gimp_color_hex_entry_set_color (entry, &color);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_entry_set_text (GTK_ENTRY (entry), buffer);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ EXPORTS
|
|||
gimp_button_extended_clicked
|
||||
gimp_button_get_type
|
||||
gimp_button_new
|
||||
gimp_cell_renderer_color_get_type
|
||||
gimp_cell_renderer_color_new
|
||||
gimp_chain_button_get_active
|
||||
gimp_chain_button_get_type
|
||||
gimp_chain_button_new
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <libgimpwidgets/gimpwidgetstypes.h>
|
||||
|
||||
#include <libgimpwidgets/gimpbutton.h>
|
||||
#include <libgimpwidgets/gimpcellrenderercolor.h>
|
||||
#include <libgimpwidgets/gimpchainbutton.h>
|
||||
#include <libgimpwidgets/gimpcolorarea.h>
|
||||
#include <libgimpwidgets/gimpcolorbutton.h>
|
||||
|
|
|
@ -55,32 +55,33 @@ typedef enum
|
|||
} GimpSizeEntryUpdatePolicy;
|
||||
|
||||
|
||||
typedef struct _GimpButton GimpButton;
|
||||
typedef struct _GimpChainButton GimpChainButton;
|
||||
typedef struct _GimpColorArea GimpColorArea;
|
||||
typedef struct _GimpColorButton GimpColorButton;
|
||||
typedef struct _GimpColorDisplay GimpColorDisplay;
|
||||
typedef struct _GimpColorDisplayStack GimpColorDisplayStack;
|
||||
typedef struct _GimpColorHexEntry GimpColorHexEntry;
|
||||
typedef struct _GimpColorNotebook GimpColorNotebook;
|
||||
typedef struct _GimpColorScale GimpColorScale;
|
||||
typedef struct _GimpColorScales GimpColorScales;
|
||||
typedef struct _GimpColorSelector GimpColorSelector;
|
||||
typedef struct _GimpColorSelect GimpColorSelect;
|
||||
typedef struct _GimpColorSelection GimpColorSelection;
|
||||
typedef struct _GimpController GimpController;
|
||||
typedef struct _GimpDialog GimpDialog;
|
||||
typedef struct _GimpFileEntry GimpFileEntry;
|
||||
typedef struct _GimpFrame GimpFrame;
|
||||
typedef struct _GimpIntComboBox GimpIntComboBox;
|
||||
typedef struct _GimpIntStore GimpIntStore;
|
||||
typedef struct _GimpMemsizeEntry GimpMemsizeEntry;
|
||||
typedef struct _GimpOffsetArea GimpOffsetArea;
|
||||
typedef struct _GimpPathEditor GimpPathEditor;
|
||||
typedef struct _GimpPickButton GimpPickButton;
|
||||
typedef struct _GimpPixmap GimpPixmap;
|
||||
typedef struct _GimpSizeEntry GimpSizeEntry;
|
||||
typedef struct _GimpUnitMenu GimpUnitMenu;
|
||||
typedef struct _GimpButton GimpButton;
|
||||
typedef struct _GimpCellRendererColor GimpCellRendererColor;
|
||||
typedef struct _GimpChainButton GimpChainButton;
|
||||
typedef struct _GimpColorArea GimpColorArea;
|
||||
typedef struct _GimpColorButton GimpColorButton;
|
||||
typedef struct _GimpColorDisplay GimpColorDisplay;
|
||||
typedef struct _GimpColorDisplayStack GimpColorDisplayStack;
|
||||
typedef struct _GimpColorHexEntry GimpColorHexEntry;
|
||||
typedef struct _GimpColorNotebook GimpColorNotebook;
|
||||
typedef struct _GimpColorScale GimpColorScale;
|
||||
typedef struct _GimpColorScales GimpColorScales;
|
||||
typedef struct _GimpColorSelector GimpColorSelector;
|
||||
typedef struct _GimpColorSelect GimpColorSelect;
|
||||
typedef struct _GimpColorSelection GimpColorSelection;
|
||||
typedef struct _GimpController GimpController;
|
||||
typedef struct _GimpDialog GimpDialog;
|
||||
typedef struct _GimpFileEntry GimpFileEntry;
|
||||
typedef struct _GimpFrame GimpFrame;
|
||||
typedef struct _GimpIntComboBox GimpIntComboBox;
|
||||
typedef struct _GimpIntStore GimpIntStore;
|
||||
typedef struct _GimpMemsizeEntry GimpMemsizeEntry;
|
||||
typedef struct _GimpOffsetArea GimpOffsetArea;
|
||||
typedef struct _GimpPathEditor GimpPathEditor;
|
||||
typedef struct _GimpPickButton GimpPickButton;
|
||||
typedef struct _GimpPixmap GimpPixmap;
|
||||
typedef struct _GimpSizeEntry GimpSizeEntry;
|
||||
typedef struct _GimpUnitMenu GimpUnitMenu;
|
||||
|
||||
|
||||
typedef void (* GimpHelpFunc) (const gchar *help_id,
|
||||
|
|
Loading…
Reference in New Issue