new enum GimpColorFrameMode.

2003-10-15  Michael Natterer  <mitch@gimp.org>

	* app/widgets/widgets-enums.[ch]: new enum GimpColorFrameMode.

	* app/widgets/Makefile.am
	* app/widgets/gimpcolorframe.[ch]: new widget GimpColorFrame which
	shows a picked color in an optionmenu-selectable color space.
	Helps getting rid in InfoDialog.

	* app/gui/info-window.c: use it for the "extended" page. Cleaned
	up that page a lot so it can be made dockable in the next step.

	* app/tools/gimpcolorpickertool.[ch]: use it here too. Don't use
	InfoDialog any more (and do not depend on gui/ any more).
This commit is contained in:
Michael Natterer 2003-10-15 15:16:50 +00:00 committed by Michael Natterer
parent 762b709a5e
commit e78c87b228
8 changed files with 530 additions and 145 deletions

View File

@ -1,3 +1,18 @@
2003-10-15 Michael Natterer <mitch@gimp.org>
* app/widgets/widgets-enums.[ch]: new enum GimpColorFrameMode.
* app/widgets/Makefile.am
* app/widgets/gimpcolorframe.[ch]: new widget GimpColorFrame which
shows a picked color in an optionmenu-selectable color space.
Helps getting rid in InfoDialog.
* app/gui/info-window.c: use it for the "extended" page. Cleaned
up that page a lot so it can be made dockable in the next step.
* app/tools/gimpcolorpickertool.[ch]: use it here too. Don't use
InfoDialog any more (and do not depend on gui/ any more).
2003-10-15 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpcontainerview.c

View File

@ -25,16 +25,12 @@
#include "tools-types.h"
#ifdef __GNUC__
#warning FIXME #include "gui/gui-types.h"
#endif
#include "gui/gui-types.h"
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimpcolorframe.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimppaletteeditor.h"
@ -42,8 +38,6 @@
#include "display/gimpdisplay.h"
#include "gui/info-dialog.h"
#include "gimpcolorpickeroptions.h"
#include "gimpcolorpickertool.h"
#include "gimptoolcontrol.h"
@ -51,9 +45,6 @@
#include "gimp-intl.h"
#define MAX_INFO_BUF 8
/* local function prototypes */
static void gimp_color_picker_tool_class_init (GimpColorPickerToolClass *klass);
@ -81,23 +72,15 @@ static void gimp_color_picker_tool_picked (GimpColorTool *color_too
GimpRGB *color,
gint color_index);
static InfoDialog * gimp_color_picker_tool_info_create (GimpTool *tool);
static void gimp_color_picker_tool_info_close (GtkWidget *widget,
gpointer data);
static void gimp_color_picker_tool_info_update (GimpImageType sample_type,
GimpRGB *color,
gint color_index);
static void gimp_color_picker_tool_info_create (GimpColorPickerTool *picker_tool);
static void gimp_color_picker_tool_info_close (GtkWidget *widget,
GimpColorPickerTool *picker_tool);
static void gimp_color_picker_tool_info_update (GimpColorPickerTool *picker_tool,
GimpImageType sample_type,
GimpRGB *color,
gint color_index);
static InfoDialog *gimp_color_picker_tool_info = NULL;
static GtkWidget *color_area = NULL;
static gchar red_buf [MAX_INFO_BUF];
static gchar green_buf[MAX_INFO_BUF];
static gchar blue_buf [MAX_INFO_BUF];
static gchar alpha_buf[3 * MAX_INFO_BUF];
static gchar index_buf[MAX_INFO_BUF];
static gchar hex_buf [MAX_INFO_BUF];
static GimpColorToolClass *parent_class = NULL;
@ -196,12 +179,10 @@ gimp_color_picker_tool_constructor (GType type,
static void
gimp_color_picker_tool_finalize (GObject *object)
{
if (gimp_color_picker_tool_info)
{
info_dialog_free (gimp_color_picker_tool_info);
gimp_color_picker_tool_info = NULL;
color_area = NULL;
}
GimpColorPickerTool *picker_tool = GIMP_COLOR_PICKER_TOOL (object);
if (picker_tool->dialog)
gimp_color_picker_tool_info_close (NULL, picker_tool);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -211,15 +192,13 @@ gimp_color_picker_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp)
{
GimpColorPickerTool *picker_tool = GIMP_COLOR_PICKER_TOOL (tool);
switch (action)
{
case HALT:
if (gimp_color_picker_tool_info)
{
info_dialog_free (gimp_color_picker_tool_info);
gimp_color_picker_tool_info = NULL;
color_area = NULL;
}
if (picker_tool->dialog)
gimp_color_picker_tool_info_close (NULL, picker_tool);
break;
default:
@ -281,14 +260,17 @@ gimp_color_picker_tool_picked (GimpColorTool *color_tool,
gint color_index)
{
GimpTool *tool;
GimpColorPickerTool *picker_tool;
GimpColorPickerOptions *options;
tool = GIMP_TOOL (color_tool);
tool = GIMP_TOOL (color_tool);
picker_tool = GIMP_COLOR_PICKER_TOOL (color_tool);
if (! gimp_color_picker_tool_info)
gimp_color_picker_tool_info = gimp_color_picker_tool_info_create (tool);
if (! picker_tool->dialog)
gimp_color_picker_tool_info_create (picker_tool);
gimp_color_picker_tool_info_update (sample_type, color, color_index);
gimp_color_picker_tool_info_update (picker_tool, sample_type,
color, color_index);
options = GIMP_COLOR_PICKER_OPTIONS (color_tool->options);
@ -315,134 +297,95 @@ gimp_color_picker_tool_picked (GimpColorTool *color_tool,
}
}
static InfoDialog *
gimp_color_picker_tool_info_create (GimpTool *tool)
static void
gimp_color_picker_tool_info_create (GimpColorPickerTool *picker_tool)
{
InfoDialog *info_dialog;
GtkWidget *hbox;
GtkWidget *frame;
GimpRGB color;
GimpTool *tool = GIMP_TOOL (picker_tool);
GtkWidget *hbox;
GtkWidget *frame;
GimpRGB color;
g_return_val_if_fail (tool->drawable != NULL, NULL);
g_return_if_fail (tool->drawable != NULL);
info_dialog = info_dialog_new (NULL,
_("Color Picker"), "color_picker",
GIMP_STOCK_TOOL_COLOR_PICKER,
_("Color Picker Information"),
gimp_standard_help_func,
tool->tool_info->help_id);
picker_tool->dialog =
gimp_viewable_dialog_new (GIMP_VIEWABLE (tool->drawable),
_("Color Picker"), "color_picker",
GIMP_STOCK_TOOL_COLOR_PICKER,
_("Color Picker Information"),
gimp_standard_help_func,
tool->tool_info->help_id,
gimp_dialog_create_action_area (GIMP_DIALOG (info_dialog->shell),
GTK_STOCK_CLOSE,
gimp_color_picker_tool_info_close,
tool, NULL, NULL, TRUE, TRUE,
GTK_STOCK_CLOSE,
gimp_color_picker_tool_info_close,
info_dialog, NULL, NULL, TRUE, TRUE,
NULL);
/* if the gdisplay is for a color image, the dialog must have RGB */
switch (GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (tool->drawable)))
{
case GIMP_RGB:
info_dialog_add_label (info_dialog, _("Red:"), red_buf);
info_dialog_add_label (info_dialog, _("Green:"), green_buf);
info_dialog_add_label (info_dialog, _("Blue:"), blue_buf);
break;
case GIMP_GRAY:
info_dialog_add_label (info_dialog, _("Intensity:"), red_buf);
break;
case GIMP_INDEXED:
info_dialog_add_label (info_dialog, _("Index:"), index_buf);
info_dialog_add_label (info_dialog, _("Red:"), red_buf);
info_dialog_add_label (info_dialog, _("Green:"), green_buf);
info_dialog_add_label (info_dialog, _("Blue:"), blue_buf);
break;
default:
g_assert_not_reached ();
break;
}
info_dialog_add_label (info_dialog, _("Alpha:"), alpha_buf);
info_dialog_add_label (info_dialog, _("Hex Triplet:"), hex_buf);
NULL);
hbox = gtk_hbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (info_dialog->vbox), hbox, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (picker_tool->dialog)->vbox), hbox,
FALSE, FALSE, 0);
gtk_widget_show (hbox);
gtk_widget_reparent (info_dialog->info_table, hbox);
picker_tool->color_frame1 = gimp_color_frame_new ();
gimp_color_frame_set_mode (GIMP_COLOR_FRAME (picker_tool->color_frame1),
GIMP_COLOR_FRAME_MODE_PIXEL);
gtk_box_pack_start (GTK_BOX (hbox), picker_tool->color_frame1,
FALSE, FALSE, 0);
gtk_widget_show (picker_tool->color_frame1);
picker_tool->color_frame2 = gimp_color_frame_new ();
gimp_color_frame_set_mode (GIMP_COLOR_FRAME (picker_tool->color_frame2),
GIMP_COLOR_FRAME_MODE_RGB);
gtk_box_pack_start (GTK_BOX (hbox), picker_tool->color_frame2,
FALSE, FALSE, 0);
gtk_widget_show (picker_tool->color_frame2);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0);
color_area = gimp_color_area_new (&color,
gimp_drawable_has_alpha (tool->drawable) ?
GIMP_COLOR_AREA_LARGE_CHECKS :
GIMP_COLOR_AREA_FLAT,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK);
gtk_widget_set_size_request (color_area, 48, 64);
gtk_drag_dest_unset (color_area);
gtk_container_add (GTK_CONTAINER (frame), color_area);
gtk_widget_show (color_area);
gtk_widget_show (frame);
picker_tool->color_area =
gimp_color_area_new (&color,
gimp_drawable_has_alpha (tool->drawable) ?
GIMP_COLOR_AREA_LARGE_CHECKS :
GIMP_COLOR_AREA_FLAT,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK);
gtk_widget_set_size_request (picker_tool->color_area, 48, -1);
gtk_drag_dest_unset (picker_tool->color_area);
gtk_container_add (GTK_CONTAINER (frame), picker_tool->color_area);
gtk_widget_show (picker_tool->color_area);
gimp_dialog_factory_add_foreign (gimp_dialog_factory_from_name ("toplevel"),
"gimp-color-picker-tool-dialog",
info_dialog->shell);
gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (info_dialog->shell),
GIMP_VIEWABLE (tool->drawable));
return info_dialog;
picker_tool->dialog);
}
static void
gimp_color_picker_tool_info_close (GtkWidget *widget,
gpointer client_data)
gimp_color_picker_tool_info_close (GtkWidget *widget,
GimpColorPickerTool *picker_tool)
{
info_dialog_free (gimp_color_picker_tool_info);
gimp_color_picker_tool_info = NULL;
gtk_widget_destroy (picker_tool->dialog);
picker_tool->dialog = NULL;
picker_tool->color_area = NULL;
picker_tool->color_frame1 = NULL;
picker_tool->color_frame2 = NULL;
}
static void
gimp_color_picker_tool_info_update (GimpImageType sample_type,
GimpRGB *color,
gint color_index)
gimp_color_picker_tool_info_update (GimpColorPickerTool *picker_tool,
GimpImageType sample_type,
GimpRGB *color,
gint color_index)
{
guchar r, g, b, a;
gimp_color_area_set_color (GIMP_COLOR_AREA (picker_tool->color_area), color);
gimp_rgba_get_uchar (color, &r, &g, &b, &a);
gimp_color_frame_set_color (GIMP_COLOR_FRAME (picker_tool->color_frame1),
sample_type, color, color_index);
gimp_color_frame_set_color (GIMP_COLOR_FRAME (picker_tool->color_frame2),
sample_type, color, color_index);
g_snprintf (red_buf, MAX_INFO_BUF, "%d", r);
g_snprintf (green_buf, MAX_INFO_BUF, "%d", g);
g_snprintf (blue_buf, MAX_INFO_BUF, "%d", b);
if (GIMP_IMAGE_TYPE_HAS_ALPHA (sample_type))
g_snprintf (alpha_buf, sizeof (alpha_buf),
"%d (%d %%)", a, (gint) (color->a * 100.0));
else
g_snprintf (alpha_buf, MAX_INFO_BUF, _("N/A"));
switch (GIMP_IMAGE_TYPE_BASE_TYPE (sample_type))
{
case GIMP_RGB:
case GIMP_GRAY:
g_snprintf (index_buf, MAX_INFO_BUF, _("N/A"));
break;
case GIMP_INDEXED:
g_snprintf (index_buf, MAX_INFO_BUF, "%d", color_index);
break;
}
g_snprintf (hex_buf, MAX_INFO_BUF, "#%.2x%.2x%.2x", r, g, b);
gimp_color_area_set_color (GIMP_COLOR_AREA (color_area), color);
info_dialog_update (gimp_color_picker_tool_info);
info_dialog_popup (gimp_color_picker_tool_info);
gtk_window_present (GTK_WINDOW (picker_tool->dialog));
}

View File

@ -38,8 +38,10 @@ struct _GimpColorPickerTool
{
GimpColorTool parent_instance;
gint centerx; /* starting x coord */
gint centery; /* starting y coord */
GtkWidget *dialog;
GtkWidget *color_area;
GtkWidget *color_frame1;
GtkWidget *color_frame2;
};
struct _GimpColorPickerToolClass

View File

@ -33,6 +33,8 @@ libappwidgets_a_sources = \
gimpchanneltreeview.h \
gimpcoloreditor.c \
gimpcoloreditor.h \
gimpcolorframe.c \
gimpcolorframe.h \
gimpcolormapeditor.c \
gimpcolormapeditor.h \
gimpcolorpanel.c \

View File

@ -0,0 +1,314 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "core/gimpimage.h"
#include "gimpcolorframe.h"
#include "gimpenummenu.h"
#include "gimp-intl.h"
/* local function prototypes */
static void gimp_color_frame_class_init (GimpColorFrameClass *klass);
static void gimp_color_frame_init (GimpColorFrame *frame);
static void gimp_color_frame_menu_callback (GtkWidget *widget,
GimpColorFrame *frame);
static void gimp_color_frame_update (GimpColorFrame *frame);
static GtkFrameClass *parent_class = NULL;
GType
gimp_color_frame_get_type (void)
{
static GType type = 0;
if (! type)
{
static const GTypeInfo frame_info =
{
sizeof (GimpColorFrameClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gimp_color_frame_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpColorFrame),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_color_frame_init,
};
type = g_type_register_static (GTK_TYPE_FRAME,
"GimpColorFrame",
&frame_info, 0);
}
return type;
}
static void
gimp_color_frame_class_init (GimpColorFrameClass *klass)
{
parent_class = g_type_class_peek_parent (klass);
}
static void
gimp_color_frame_init (GimpColorFrame *frame)
{
GtkWidget *table;
gint i;
frame->sample_valid = FALSE;
frame->sample_type = GIMP_RGB_IMAGE;
gimp_rgba_set (&frame->color, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
frame->menu =
gimp_enum_option_menu_new (GIMP_TYPE_COLOR_FRAME_MODE,
G_CALLBACK (gimp_color_frame_menu_callback),
frame);
gtk_frame_set_label_widget (GTK_FRAME (frame), frame->menu);
gtk_widget_show (frame->menu);
table = gtk_table_new (GIMP_COLOR_FRAME_ROWS, 2, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (table), 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
for (i = 0; i < GIMP_COLOR_FRAME_ROWS; i++)
{
frame->name_labels[i] = gtk_label_new (" ");
gtk_misc_set_alignment (GTK_MISC (frame->name_labels[i]), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), frame->name_labels[i],
0, 1, i, i + 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (frame->name_labels[i]);
frame->value_labels[i] = gtk_label_new (" ");
gtk_misc_set_alignment (GTK_MISC (frame->value_labels[i]), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (table), frame->value_labels[i],
1, 2, i, i + 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (frame->value_labels[i]);
}
}
GtkWidget *
gimp_color_frame_new (void)
{
GimpColorFrame *frame;
frame = g_object_new (GIMP_TYPE_COLOR_FRAME, NULL);
return GTK_WIDGET (frame);
}
void
gimp_color_frame_set_mode (GimpColorFrame *frame,
GimpColorFrameMode mode)
{
g_return_if_fail (GIMP_IS_COLOR_FRAME (frame));
gimp_option_menu_set_history (GTK_OPTION_MENU (frame->menu),
GINT_TO_POINTER (mode));
frame->frame_mode = mode;
gimp_color_frame_update (frame);
}
void
gimp_color_frame_set_color (GimpColorFrame *frame,
GimpImageType sample_type,
GimpRGB *color,
gint color_index)
{
g_return_if_fail (GIMP_IS_COLOR_FRAME (frame));
g_return_if_fail (color != NULL);
frame->sample_valid = TRUE;
frame->sample_type = sample_type;
frame->color = *color;
frame->color_index = color_index;
gimp_color_frame_update (frame);
}
void
gimp_color_frame_set_invalid (GimpColorFrame *frame)
{
g_return_if_fail (GIMP_IS_COLOR_FRAME (frame));
frame->sample_valid = FALSE;
gimp_color_frame_update (frame);
}
/* private functions */
static void
gimp_color_frame_menu_callback (GtkWidget *widget,
GimpColorFrame *frame)
{
gimp_menu_item_update (widget, &frame->frame_mode);
gimp_color_frame_update (frame);
}
static void
gimp_color_frame_update (GimpColorFrame *frame)
{
const gchar *names[GIMP_COLOR_FRAME_ROWS] = { NULL, };
gchar *values[GIMP_COLOR_FRAME_ROWS] = { NULL, };
gboolean has_alpha;
gint alpha_row = 3;
guchar r, g, b, a;
gint i;
has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (frame->sample_type);
gimp_rgba_get_uchar (&frame->color, &r, &g, &b, &a);
switch (frame->frame_mode)
{
case GIMP_COLOR_FRAME_MODE_PIXEL:
switch (GIMP_IMAGE_TYPE_BASE_TYPE (frame->sample_type))
{
case GIMP_INDEXED:
names[4] = _("Index:");
values[4] = g_strdup_printf ("%d", frame->color_index);
case GIMP_RGB:
names[0] = _("Red:");
names[1] = _("Green:");
names[2] = _("Blue:");
values[0] = g_strdup_printf ("%d", r);
values[1] = g_strdup_printf ("%d", g);
values[2] = g_strdup_printf ("%d", b);
alpha_row = 3;
break;
case GIMP_GRAY:
names[0] = _("Value:");
values[0] = g_strdup_printf ("%d", r);
alpha_row = 1;
break;
}
break;
case GIMP_COLOR_FRAME_MODE_RGB:
names[0] = _("Red:");
names[1] = _("Green:");
names[2] = _("Blue:");
values[0] = g_strdup_printf ("%d %%", ROUND (frame->color.r * 100.0));
values[1] = g_strdup_printf ("%d %%", ROUND (frame->color.g * 100.0));
values[2] = g_strdup_printf ("%d %%", ROUND (frame->color.b * 100.0));
alpha_row = 3;
names[4] = _("Hex:");
values[4] = g_strdup_printf ("%.2x%.2x%.2x", r, g, b);
break;
case GIMP_COLOR_FRAME_MODE_HSV:
{
GimpHSV hsv;
gimp_rgb_to_hsv (&frame->color, &hsv);
names[0] = _("Hue:");
names[1] = _("Sat.:");
names[2] = _("Value:");
values[0] = g_strdup_printf ("%d \302\260", ROUND (hsv.h * 360.0));
values[1] = g_strdup_printf ("%d %%", ROUND (hsv.s * 100.0));
values[2] = g_strdup_printf ("%d %%", ROUND (hsv.v * 100.0));
alpha_row = 3;
}
break;
case GIMP_COLOR_FRAME_MODE_CMYK:
{
GimpCMYK cmyk;
gimp_rgb_to_cmyk (&frame->color, 1.0, &cmyk);
names[0] = _("Cyan:");
names[1] = _("Yellow:");
names[2] = _("Magenta:");
names[3] = _("Black:");
values[0] = g_strdup_printf ("%d %%", ROUND (cmyk.c * 100.0));
values[1] = g_strdup_printf ("%d %%", ROUND (cmyk.m * 100.0));
values[2] = g_strdup_printf ("%d %%", ROUND (cmyk.y * 100.0));
values[3] = g_strdup_printf ("%d %%", ROUND (cmyk.k * 100.0));
alpha_row = 4;
}
break;
}
if (has_alpha)
{
names[alpha_row] = _("Alpha:");
if (frame->frame_mode == GIMP_COLOR_FRAME_MODE_PIXEL)
values[alpha_row] = g_strdup_printf ("%d", a);
else
values[alpha_row] = g_strdup_printf ("%d %%",
(gint) (frame->color.a * 100.0));
}
for (i = 0; i < GIMP_COLOR_FRAME_ROWS; i++)
{
if (names[i] && values[i])
{
gtk_label_set_text (GTK_LABEL (frame->name_labels[i]), names[i]);
if (frame->sample_valid)
gtk_label_set_text (GTK_LABEL (frame->value_labels[i]), values[i]);
else
gtk_label_set_text (GTK_LABEL (frame->value_labels[i]), _("N/A"));
}
else
{
gtk_label_set_text (GTK_LABEL (frame->name_labels[i]), " ");
gtk_label_set_text (GTK_LABEL (frame->value_labels[i]), " ");
}
}
}

View File

@ -0,0 +1,75 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_COLOR_FRAME_H__
#define __GIMP_COLOR_FRAME_H__
#include <gtk/gtk.h>
#define GIMP_COLOR_FRAME_ROWS 5
#define GIMP_TYPE_COLOR_FRAME (gimp_color_frame_get_type ())
#define GIMP_COLOR_FRAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_FRAME, GimpColorFrame))
#define GIMP_COLOR_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_FRAME, GimpColorFrameClass))
#define GIMP_IS_COLOR_FRAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_FRAME))
#define GIMP_IS_COLOR_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_FRAME))
#define GIMP_COLOR_FRAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_FRAME, GimpColorFrameClass))
typedef struct _GimpColorFrame GimpColorFrame;
typedef struct _GimpColorFrameClass GimpColorFrameClass;
struct _GimpColorFrame
{
GtkFrame parent_class;
gboolean sample_valid;
GimpImageType sample_type;
GimpRGB color;
gint color_index;
GimpColorFrameMode frame_mode;
GtkWidget *menu;
GtkWidget *name_labels[GIMP_COLOR_FRAME_ROWS];
GtkWidget *value_labels[GIMP_COLOR_FRAME_ROWS];
};
struct _GimpColorFrameClass
{
GtkFrameClass parent_class;
};
GType gimp_color_frame_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_color_frame_new (void);
void gimp_color_frame_set_mode (GimpColorFrame *frame,
GimpColorFrameMode mode);
void gimp_color_frame_set_color (GimpColorFrame *frame,
GimpImageType sample_type,
GimpRGB *color,
gint color_index);
void gimp_color_frame_set_invalid (GimpColorFrame *frame);
#endif /* __GIMP_COLOR_FRAME_H__ */

View File

@ -28,6 +28,27 @@ gimp_aspect_type_get_type (void)
}
static const GEnumValue gimp_color_frame_mode_enum_values[] =
{
{ GIMP_COLOR_FRAME_MODE_PIXEL, N_("Pixel Values"), "pixel" },
{ GIMP_COLOR_FRAME_MODE_RGB, N_("RGB"), "rgb" },
{ GIMP_COLOR_FRAME_MODE_HSV, N_("HSV"), "hsv" },
{ GIMP_COLOR_FRAME_MODE_CMYK, N_("CMYK"), "cmyk" },
{ 0, NULL, NULL }
};
GType
gimp_color_frame_mode_get_type (void)
{
static GType enum_type = 0;
if (!enum_type)
enum_type = g_enum_register_static ("GimpColorFrameMode", gimp_color_frame_mode_enum_values);
return enum_type;
}
static const GEnumValue gimp_help_browser_type_enum_values[] =
{
{ GIMP_HELP_BROWSER_GIMP, N_("Internal"), "gimp" },

View File

@ -36,6 +36,19 @@ typedef enum
} GimpAspectType;
#define GIMP_TYPE_COLOR_FRAME_MODE (gimp_color_frame_mode_get_type ())
GType gimp_color_frame_mode_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_COLOR_FRAME_MODE_PIXEL, /*< desc="Pixel Values" >*/
GIMP_COLOR_FRAME_MODE_RGB, /*< desc="RGB" >*/
GIMP_COLOR_FRAME_MODE_HSV, /*< desc="HSV" >*/
GIMP_COLOR_FRAME_MODE_CMYK /*< desc="CMYK" >*/
} GimpColorFrameMode;
#define GIMP_TYPE_HELP_BROWSER_TYPE (gimp_help_browser_type_get_type ())
GType gimp_help_browser_type_get_type (void) G_GNUC_CONST;