mirror of https://github.com/GNOME/gimp.git
app, libgimpcolor: more move to GeglColor.
- New libgimpcolor functions: gimp_color_parse_hex() and gimp_color_parse_name(). - GimpColorHexEntry is now space-invaded. Though recognized color names and hexadecimal syntax are sRGB only (because CSS and SVG specifications explicitly say that this syntax is for sRGB values), it is possible to enter non-sRGB values with gimp_color_hex_entry_set_color(). - GimpColorSelection is now space-invaded.
This commit is contained in:
parent
ee19ad54d6
commit
093d00572a
|
@ -339,6 +339,7 @@ gimp_color_dialog_response (GtkDialog *gtk_dialog,
|
|||
GimpImage *image = NULL;
|
||||
GimpColormapSelection *colormap_selection;
|
||||
gint col_index;
|
||||
GeglColor *color = NULL;
|
||||
GimpRGB rgb;
|
||||
|
||||
colormap_selection = GIMP_COLORMAP_SELECTION (dialog->colormap_selection);
|
||||
|
@ -358,21 +359,18 @@ gimp_color_dialog_response (GtkDialog *gtk_dialog,
|
|||
break;
|
||||
|
||||
case GTK_RESPONSE_OK:
|
||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
&rgb);
|
||||
color = gimp_color_selection_get_color (GIMP_COLOR_SELECTION (dialog->selection));
|
||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||
|
||||
if (dialog->colormap_editing && image)
|
||||
{
|
||||
GeglColor *color = gegl_color_new (NULL);
|
||||
GimpRGB old_color;
|
||||
GeglColor *old_color;
|
||||
|
||||
dialog->colormap_editing = FALSE;
|
||||
|
||||
/* Restore old color for undo */
|
||||
gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (dialog->selection), &old_color);
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &old_color);
|
||||
gimp_image_set_colormap_entry (image, col_index, color, FALSE);
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||
old_color = gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (dialog->selection));
|
||||
gimp_image_set_colormap_entry (image, col_index, old_color, FALSE);
|
||||
gimp_image_set_colormap_entry (image, col_index, color, TRUE);
|
||||
gimp_image_flush (image);
|
||||
|
||||
|
@ -380,40 +378,39 @@ gimp_color_dialog_response (GtkDialog *gtk_dialog,
|
|||
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
||||
&rgb, GIMP_COLOR_DIALOG_UPDATE);
|
||||
|
||||
g_object_unref (color);
|
||||
g_object_unref (old_color);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
||||
&rgb, GIMP_COLOR_DIALOG_OK);
|
||||
}
|
||||
|
||||
g_object_unref (color);
|
||||
break;
|
||||
|
||||
default:
|
||||
gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
&rgb);
|
||||
color = gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (dialog->selection));
|
||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||
|
||||
if (dialog->colormap_editing && image)
|
||||
{
|
||||
GeglColor *color = gegl_color_new (NULL);
|
||||
|
||||
dialog->colormap_editing = FALSE;
|
||||
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||
gimp_image_set_colormap_entry (image, col_index, color, FALSE);
|
||||
gimp_projection_flush (gimp_image_get_projection (image));
|
||||
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (dialog->stack), "colormap");
|
||||
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
||||
&rgb, GIMP_COLOR_DIALOG_UPDATE);
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
||||
&rgb, GIMP_COLOR_DIALOG_CANCEL);
|
||||
}
|
||||
|
||||
g_object_unref (color);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -431,12 +428,13 @@ gimp_color_dialog_new (GimpViewable *viewable,
|
|||
GtkWidget *parent,
|
||||
GimpDialogFactory *dialog_factory,
|
||||
const gchar *dialog_identifier,
|
||||
const GimpRGB *color,
|
||||
const GimpRGB *rgb,
|
||||
gboolean wants_updates,
|
||||
gboolean show_alpha)
|
||||
{
|
||||
GimpColorDialog *dialog;
|
||||
const gchar *role;
|
||||
GeglColor *color;
|
||||
gboolean use_header_bar;
|
||||
|
||||
g_return_val_if_fail (viewable == NULL || GIMP_IS_VIEWABLE (viewable), NULL);
|
||||
|
@ -446,7 +444,7 @@ gimp_color_dialog_new (GimpViewable *viewable,
|
|||
GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
|
||||
g_return_val_if_fail (dialog_factory == NULL || dialog_identifier != NULL,
|
||||
NULL);
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
g_return_val_if_fail (rgb != NULL, NULL);
|
||||
|
||||
role = dialog_identifier ? dialog_identifier : "gimp-color-selector";
|
||||
|
||||
|
@ -517,29 +515,37 @@ gimp_color_dialog_new (GimpViewable *viewable,
|
|||
g_object_set_data (G_OBJECT (context->gimp->config->color_management),
|
||||
"gimp-context", NULL);
|
||||
|
||||
color = gegl_color_new (NULL);
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
color);
|
||||
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
color);
|
||||
g_object_unref (color);
|
||||
|
||||
return GTK_WIDGET (dialog);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_color_dialog_set_color (GimpColorDialog *dialog,
|
||||
const GimpRGB *color)
|
||||
const GimpRGB *rgb)
|
||||
{
|
||||
GeglColor *color;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_DIALOG (dialog));
|
||||
g_return_if_fail (color != NULL);
|
||||
g_return_if_fail (rgb != NULL);
|
||||
|
||||
g_signal_handlers_block_by_func (dialog->selection,
|
||||
gimp_color_dialog_color_changed,
|
||||
dialog);
|
||||
|
||||
color = gegl_color_new (NULL);
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
color);
|
||||
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
color);
|
||||
g_object_unref (color);
|
||||
|
||||
g_signal_handlers_unblock_by_func (dialog->selection,
|
||||
gimp_color_dialog_color_changed,
|
||||
|
@ -548,13 +554,16 @@ gimp_color_dialog_set_color (GimpColorDialog *dialog,
|
|||
|
||||
void
|
||||
gimp_color_dialog_get_color (GimpColorDialog *dialog,
|
||||
GimpRGB *color)
|
||||
GimpRGB *rgb)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_COLOR_DIALOG (dialog));
|
||||
g_return_if_fail (color != NULL);
|
||||
GeglColor *color;
|
||||
|
||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
color);
|
||||
g_return_if_fail (GIMP_IS_COLOR_DIALOG (dialog));
|
||||
g_return_if_fail (rgb != NULL);
|
||||
|
||||
color = gimp_color_selection_get_color (GIMP_COLOR_SELECTION (dialog->selection));
|
||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
|
||||
|
@ -636,9 +645,9 @@ gimp_color_dialog_color_changed (GimpColorSelection *selection,
|
|||
GimpColorDialog *dialog)
|
||||
{
|
||||
GimpViewableDialog *viewable_dialog = GIMP_VIEWABLE_DIALOG (dialog);
|
||||
GimpRGB rgb;
|
||||
GeglColor *color;
|
||||
|
||||
gimp_color_selection_get_color (selection, &rgb);
|
||||
color = gimp_color_selection_get_color (selection);
|
||||
|
||||
if (dialog->colormap_editing && viewable_dialog->context)
|
||||
{
|
||||
|
@ -649,7 +658,6 @@ gimp_color_dialog_color_changed (GimpColorSelection *selection,
|
|||
if (image)
|
||||
{
|
||||
GimpColormapSelection *colormap_selection;
|
||||
GeglColor *color = gegl_color_new (NULL);
|
||||
gboolean push_undo = FALSE;
|
||||
gint col_index;
|
||||
|
||||
|
@ -657,32 +665,35 @@ gimp_color_dialog_color_changed (GimpColorSelection *selection,
|
|||
col_index = gimp_colormap_selection_get_index (colormap_selection, NULL);
|
||||
if (push_undo)
|
||||
{
|
||||
GimpRGB old_color;
|
||||
GeglColor *old_color;
|
||||
|
||||
gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (dialog->selection), &old_color);
|
||||
old_color = gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (dialog->selection));
|
||||
|
||||
/* Restore old color for undo */
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &old_color);
|
||||
gimp_image_set_colormap_entry (image, col_index, color, FALSE);
|
||||
gimp_image_set_colormap_entry (image, col_index, old_color, FALSE);
|
||||
|
||||
g_object_unref (old_color);
|
||||
}
|
||||
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||
gimp_image_set_colormap_entry (image, col_index, color, push_undo);
|
||||
|
||||
if (push_undo)
|
||||
gimp_image_flush (image);
|
||||
else
|
||||
gimp_projection_flush (gimp_image_get_projection (image));
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
}
|
||||
|
||||
if (dialog->wants_updates)
|
||||
{
|
||||
GimpRGB rgb;
|
||||
|
||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
||||
&rgb, GIMP_COLOR_DIALOG_UPDATE);
|
||||
}
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
|
||||
|
@ -694,14 +705,15 @@ gimp_color_history_add_clicked (GtkWidget *widget,
|
|||
{
|
||||
GimpViewableDialog *viewable_dialog = GIMP_VIEWABLE_DIALOG (dialog);
|
||||
GimpPalette *history;
|
||||
GimpRGB color;
|
||||
GeglColor *color;
|
||||
GimpRGB rgb;
|
||||
|
||||
history = gimp_palettes_get_color_history (viewable_dialog->context->gimp);
|
||||
|
||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
&color);
|
||||
color = gimp_color_selection_get_color (GIMP_COLOR_SELECTION (dialog->selection));
|
||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||
|
||||
gimp_palette_mru_add (GIMP_PALETTE_MRU (history), &color);
|
||||
gimp_palette_mru_add (GIMP_PALETTE_MRU (history), &rgb);
|
||||
}
|
||||
|
||||
/* Color history callback */
|
||||
|
@ -711,8 +723,11 @@ gimp_color_dialog_history_selected (GimpColorHistory *history,
|
|||
const GimpRGB *rgb,
|
||||
GimpColorDialog *dialog)
|
||||
{
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
rgb);
|
||||
GeglColor *color = gegl_color_new (NULL);
|
||||
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection), color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
/* Context-related callbacks */
|
||||
|
|
|
@ -559,8 +559,7 @@ gimp_color_editor_set_color (GimpColorEditor *editor,
|
|||
gimp_color_editor_entry_changed,
|
||||
editor);
|
||||
|
||||
gimp_color_hex_entry_set_color (GIMP_COLOR_HEX_ENTRY (editor->hex_entry),
|
||||
&rgb);
|
||||
gimp_color_hex_entry_set_color (GIMP_COLOR_HEX_ENTRY (editor->hex_entry), color);
|
||||
|
||||
g_signal_handlers_unblock_by_func (editor->hex_entry,
|
||||
gimp_color_editor_entry_changed,
|
||||
|
@ -591,11 +590,12 @@ gimp_color_editor_color_changed (GimpColorSelector *selector,
|
|||
const GimpHSV *hsv,
|
||||
GimpColorEditor *editor)
|
||||
{
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
||||
|
||||
if (editor->context)
|
||||
{
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
||||
if (editor->edit_bg)
|
||||
{
|
||||
g_signal_handlers_block_by_func (editor->context,
|
||||
|
@ -620,20 +620,19 @@ gimp_color_editor_color_changed (GimpColorSelector *selector,
|
|||
gimp_color_editor_fg_changed,
|
||||
editor);
|
||||
}
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
g_signal_handlers_block_by_func (editor->hex_entry,
|
||||
gimp_color_editor_entry_changed,
|
||||
editor);
|
||||
|
||||
gimp_color_hex_entry_set_color (GIMP_COLOR_HEX_ENTRY (editor->hex_entry),
|
||||
rgb);
|
||||
gimp_color_hex_entry_set_color (GIMP_COLOR_HEX_ENTRY (editor->hex_entry), color);
|
||||
|
||||
g_signal_handlers_unblock_by_func (editor->hex_entry,
|
||||
gimp_color_editor_entry_changed,
|
||||
editor);
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -717,11 +716,9 @@ static void
|
|||
gimp_color_editor_entry_changed (GimpColorHexEntry *entry,
|
||||
GimpColorEditor *editor)
|
||||
{
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
GimpRGB rgb;
|
||||
GeglColor *color;
|
||||
|
||||
gimp_color_hex_entry_get_color (entry, &rgb);
|
||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||
color = gimp_color_hex_entry_get_color (entry);
|
||||
|
||||
if (editor->context)
|
||||
{
|
||||
|
|
|
@ -399,15 +399,14 @@ gimp_colormap_editor_color_update (GimpColorDialog *dialog,
|
|||
NULL);
|
||||
if (push_undo)
|
||||
{
|
||||
GimpRGB old_color;
|
||||
GeglColor *old_color;
|
||||
|
||||
gimp_color_selection_get_old_color (
|
||||
GIMP_COLOR_SELECTION (dialog->selection), &old_color);
|
||||
old_color = gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (dialog->selection));
|
||||
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &old_color);
|
||||
/* Restore old color for undo */
|
||||
gimp_image_set_colormap_entry (image, col_index, color, FALSE);
|
||||
gimp_image_set_colormap_entry (image, col_index, old_color, FALSE);
|
||||
|
||||
g_object_unref (old_color);
|
||||
}
|
||||
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
||||
|
|
|
@ -245,7 +245,7 @@ gimp_colormap_selection_init (GimpColormapSelection *selection)
|
|||
selection->color_entry = gimp_color_hex_entry_new ();
|
||||
gtk_widget_set_halign (selection->color_entry, GTK_ALIGN_START);
|
||||
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 1,
|
||||
_("HTML notation:"), 0.0, 0.5,
|
||||
_("HTML notation (sRGB):"), 0.0, 0.5,
|
||||
selection->color_entry, 1);
|
||||
|
||||
g_signal_connect (selection->color_entry, "color-changed",
|
||||
|
@ -590,15 +590,16 @@ gimp_colormap_selection_update_entries (GimpColormapSelection *selection)
|
|||
}
|
||||
else
|
||||
{
|
||||
GeglColor *color;
|
||||
guchar rgb[3];
|
||||
gchar *string;
|
||||
GeglColor *color;
|
||||
guchar rgb[3];
|
||||
gchar *string;
|
||||
|
||||
gtk_adjustment_set_value (selection->index_adjustment,
|
||||
selection->col_index);
|
||||
color = gimp_image_get_colormap_entry (image, selection->col_index);
|
||||
/* The color entry shows an HTML notation, which we assumes mean
|
||||
* sRGB for most people. But is it really what we want? TODO
|
||||
/* The color entry shows a CSS/SVG notation, which so far means
|
||||
* sRGB. But is it really what we want? Don't we want to edit
|
||||
* colors in the image's specific RGB color space? TODO
|
||||
*/
|
||||
gegl_color_get_pixel (color, babl_format ("R'G'B' u8"), rgb);
|
||||
|
||||
|
@ -689,14 +690,13 @@ gimp_colormap_hex_entry_changed (GimpColorHexEntry *entry,
|
|||
|
||||
if (image)
|
||||
{
|
||||
GeglColor *color = gegl_color_new (NULL);
|
||||
GimpRGB rgb;
|
||||
GeglColor *color;
|
||||
|
||||
gimp_color_hex_entry_get_color (entry, &rgb);
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||
color = gimp_color_hex_entry_get_color (entry);
|
||||
|
||||
gimp_image_set_colormap_entry (image, selection->col_index, color, TRUE);
|
||||
gimp_image_flush (image);
|
||||
g_object_unref (color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -127,16 +127,12 @@ color_area_foreground_changed (GimpContext *context,
|
|||
{
|
||||
if (edit_color == GIMP_ACTIVE_COLOR_FOREGROUND)
|
||||
{
|
||||
GimpRGB rgb;
|
||||
|
||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||
g_signal_handlers_block_by_func (dialog,
|
||||
color_area_dialog_update,
|
||||
context);
|
||||
|
||||
/* FIXME this should use GimpColorDialog API */
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
&rgb);
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection), color);
|
||||
|
||||
g_signal_handlers_unblock_by_func (dialog,
|
||||
color_area_dialog_update,
|
||||
|
@ -151,16 +147,12 @@ color_area_background_changed (GimpContext *context,
|
|||
{
|
||||
if (edit_color == GIMP_ACTIVE_COLOR_BACKGROUND)
|
||||
{
|
||||
GimpRGB rgb;
|
||||
|
||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||
g_signal_handlers_block_by_func (dialog,
|
||||
color_area_dialog_update,
|
||||
context);
|
||||
|
||||
/* FIXME this should use GimpColorDialog API */
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
&rgb);
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection), color);
|
||||
|
||||
g_signal_handlers_unblock_by_func (dialog,
|
||||
color_area_dialog_update,
|
||||
|
|
|
@ -240,6 +240,70 @@ gimp_color_parse_css (const gchar *css,
|
|||
return color;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_parse_hex:
|
||||
* @hex: (array length=len): a string describing a color in hexadecimal notation
|
||||
* @len: the length of @hex, in bytes. or -1 if @hex is nul-terminated
|
||||
*
|
||||
* Attempts to parse a string describing an RGB color in hexadecimal
|
||||
* notation (optionally prefixed with a '#').
|
||||
*
|
||||
* This function does not touch the alpha component of @rgb.
|
||||
*
|
||||
* Returns: (transfer full): a newly allocated color representing @hex.
|
||||
*
|
||||
* Since: 2.2
|
||||
**/
|
||||
GeglColor *
|
||||
gimp_color_parse_hex (const gchar *hex,
|
||||
gint len)
|
||||
{
|
||||
GeglColor *result;
|
||||
gchar *tmp;
|
||||
|
||||
g_return_val_if_fail (hex != NULL, FALSE);
|
||||
|
||||
tmp = gimp_color_parse_strip (hex, len);
|
||||
|
||||
result = gimp_color_parse_hex_internal (tmp);
|
||||
|
||||
g_free (tmp);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_parse_name:
|
||||
* @name: (array length=len): a color name (in UTF-8 encoding)
|
||||
* @len: the length of @name, in bytes. or -1 if @name is nul-terminated
|
||||
*
|
||||
* Attempts to parse a color name. This function accepts [SVG 1.1 color
|
||||
* keywords](https://www.w3.org/TR/SVG11/types.html#ColorKeywords).
|
||||
*
|
||||
* Returns: (transfer full): a sRGB color as defined in "4.4. Recognized color
|
||||
* keyword names" list of SVG 1.1 specification, if @name was parsed
|
||||
* successfully, %NULL otherwise
|
||||
*
|
||||
* Since: 2.2
|
||||
**/
|
||||
GeglColor *
|
||||
gimp_color_parse_name (const gchar *name,
|
||||
gint len)
|
||||
{
|
||||
gchar *tmp;
|
||||
GeglColor *result;
|
||||
|
||||
g_return_val_if_fail (name != NULL, FALSE);
|
||||
|
||||
tmp = gimp_color_parse_strip (name, len);
|
||||
|
||||
result = gimp_color_parse_name_internal (tmp);
|
||||
|
||||
g_free (tmp);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* Private functions. */
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ EXPORTS
|
|||
gimp_color_managed_simulation_intent_changed
|
||||
gimp_color_managed_simulation_profile_changed
|
||||
gimp_color_parse_css
|
||||
gimp_color_parse_hex
|
||||
gimp_color_parse_name
|
||||
gimp_color_profile_get_copyright
|
||||
gimp_color_profile_get_description
|
||||
gimp_color_profile_get_format
|
||||
|
|
|
@ -55,6 +55,10 @@ gboolean gimp_color_is_perceptually_identical (GeglColor *color1,
|
|||
|
||||
GeglColor * gimp_color_parse_css (const gchar *css,
|
||||
gint len);
|
||||
GeglColor * gimp_color_parse_hex (const gchar *hex,
|
||||
gint len);
|
||||
GeglColor * gimp_color_parse_name (const gchar *name,
|
||||
gint len);
|
||||
|
||||
gboolean gimp_color_is_out_of_self_gamut (GeglColor *color);
|
||||
gboolean gimp_color_is_out_of_gamut (GeglColor *color,
|
||||
|
|
|
@ -540,7 +540,6 @@ gimp_color_button_clicked (GtkButton *button)
|
|||
GimpColorButton *color_button = GIMP_COLOR_BUTTON (button);
|
||||
GimpColorButtonPrivate *priv = GET_PRIVATE (button);
|
||||
GeglColor *color;
|
||||
GimpRGB rgb;
|
||||
|
||||
if (! priv->dialog)
|
||||
{
|
||||
|
@ -593,10 +592,8 @@ gimp_color_button_clicked (GtkButton *button)
|
|||
gimp_color_button_selection_changed,
|
||||
button);
|
||||
|
||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (priv->selection), &rgb);
|
||||
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (priv->selection),
|
||||
&rgb);
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (priv->selection), color);
|
||||
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (priv->selection), color);
|
||||
|
||||
g_signal_handlers_unblock_by_func (priv->selection,
|
||||
gimp_color_button_selection_changed,
|
||||
|
@ -835,16 +832,12 @@ gimp_color_button_set_update (GimpColorButton *button,
|
|||
if (priv->selection)
|
||||
{
|
||||
GeglColor *color;
|
||||
GimpRGB rgb;
|
||||
|
||||
color = gegl_color_new (NULL);
|
||||
|
||||
if (priv->continuous_update)
|
||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (priv->selection), &rgb);
|
||||
color = gimp_color_selection_get_color (GIMP_COLOR_SELECTION (priv->selection));
|
||||
else
|
||||
gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (priv->selection), &rgb);
|
||||
color = gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (priv->selection));
|
||||
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||
gimp_color_button_set_color (button, color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
@ -914,11 +907,8 @@ gimp_color_button_dialog_response (GtkWidget *dialog,
|
|||
gint response_id,
|
||||
GimpColorButton *button)
|
||||
{
|
||||
GimpColorButtonPrivate *priv = GET_PRIVATE (button);
|
||||
GeglColor *color;
|
||||
GimpRGB rgb;
|
||||
|
||||
color = gegl_color_new (NULL);
|
||||
GimpColorButtonPrivate *priv = GET_PRIVATE (button);
|
||||
GeglColor *color = NULL;
|
||||
|
||||
switch (response_id)
|
||||
{
|
||||
|
@ -929,9 +919,7 @@ gimp_color_button_dialog_response (GtkWidget *dialog,
|
|||
case GTK_RESPONSE_OK:
|
||||
if (! priv->continuous_update)
|
||||
{
|
||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (priv->selection),
|
||||
&rgb);
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||
color = gimp_color_selection_get_color (GIMP_COLOR_SELECTION (priv->selection));
|
||||
gimp_color_button_set_color (button, color);
|
||||
}
|
||||
|
||||
|
@ -941,9 +929,7 @@ gimp_color_button_dialog_response (GtkWidget *dialog,
|
|||
default:
|
||||
if (priv->continuous_update)
|
||||
{
|
||||
gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (priv->selection),
|
||||
&rgb);
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||
color = gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (priv->selection)),
|
||||
gimp_color_button_set_color (button, color);
|
||||
}
|
||||
|
||||
|
@ -951,7 +937,7 @@ gimp_color_button_dialog_response (GtkWidget *dialog,
|
|||
break;
|
||||
}
|
||||
|
||||
g_object_unref (color);
|
||||
g_clear_object (&color);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1005,7 +991,6 @@ gimp_color_button_area_changed (GtkWidget *color_area,
|
|||
if (priv->selection)
|
||||
{
|
||||
GeglColor *color;
|
||||
GimpRGB rgb;
|
||||
|
||||
color = gimp_color_button_get_color (button);
|
||||
|
||||
|
@ -1013,9 +998,7 @@ gimp_color_button_area_changed (GtkWidget *color_area,
|
|||
gimp_color_button_selection_changed,
|
||||
button);
|
||||
|
||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (priv->selection),
|
||||
&rgb);
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (priv->selection), color);
|
||||
|
||||
g_signal_handlers_unblock_by_func (priv->selection,
|
||||
gimp_color_button_selection_changed,
|
||||
|
@ -1036,24 +1019,22 @@ gimp_color_button_selection_changed (GtkWidget *selection,
|
|||
if (priv->continuous_update)
|
||||
{
|
||||
GeglColor *color;
|
||||
GimpRGB rgb;
|
||||
|
||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (selection), &rgb);
|
||||
color = gimp_color_selection_get_color (GIMP_COLOR_SELECTION (selection));
|
||||
|
||||
g_signal_handlers_block_by_func (priv->color_area,
|
||||
gimp_color_button_area_changed,
|
||||
button);
|
||||
|
||||
color = gegl_color_new (NULL);
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||
gimp_color_area_set_color (GIMP_COLOR_AREA (priv->color_area), color);
|
||||
g_object_unref (color);
|
||||
|
||||
g_signal_handlers_unblock_by_func (priv->color_area,
|
||||
gimp_color_button_area_changed,
|
||||
button);
|
||||
|
||||
g_signal_emit (button, gimp_color_button_signals[COLOR_CHANGED], 0);
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,8 @@
|
|||
* @title: GimpColorHexEntry
|
||||
* @short_description: Widget for entering a color's hex triplet.
|
||||
*
|
||||
* Widget for entering a color's hex triplet.
|
||||
* Widget for entering a color's hex triplet. The syntax follows CSS and
|
||||
* SVG specifications, which means that only sRGB colors are supported.
|
||||
**/
|
||||
|
||||
|
||||
|
@ -63,16 +64,14 @@ enum
|
|||
|
||||
struct _GimpColorHexEntryPrivate
|
||||
{
|
||||
GimpRGB color;
|
||||
GeglColor *color;
|
||||
};
|
||||
|
||||
#define GET_PRIVATE(obj) (((GimpColorHexEntry *) (obj))->priv)
|
||||
|
||||
|
||||
static void gimp_color_hex_entry_constructed (GObject *object);
|
||||
|
||||
static gboolean gimp_color_hex_entry_events (GtkWidget *widget,
|
||||
GdkEvent *event);
|
||||
static void gimp_color_hex_entry_finalize (GObject *object);
|
||||
|
||||
static gboolean gimp_color_hex_entry_events (GtkWidget *widget,
|
||||
GdkEvent *event);
|
||||
|
@ -105,6 +104,7 @@ gimp_color_hex_entry_class_init (GimpColorHexEntryClass *klass)
|
|||
G_TYPE_NONE, 0);
|
||||
|
||||
object_class->constructed = gimp_color_hex_entry_constructed;
|
||||
object_class->finalize = gimp_color_hex_entry_finalize;
|
||||
|
||||
klass->color_changed = NULL;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ gimp_color_hex_entry_init (GimpColorHexEntry *entry)
|
|||
"CSS. This entry also accepts CSS color names."),
|
||||
NULL);
|
||||
|
||||
gimp_rgba_set (&private->color, 0.0, 0.0, 0.0, 1.0);
|
||||
private->color = gegl_color_new ("black");
|
||||
|
||||
store = gtk_list_store_new (NUM_COLUMNS, G_TYPE_STRING, GIMP_TYPE_RGB);
|
||||
|
||||
|
@ -191,6 +191,16 @@ gimp_color_hex_entry_constructed (GObject *object)
|
|||
gtk_entry_set_text (GTK_ENTRY (object), "000000");
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_hex_entry_finalize (GObject *object)
|
||||
{
|
||||
GimpColorHexEntryPrivate *private = GET_PRIVATE (object);
|
||||
|
||||
g_object_unref (private->color);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_hex_entry_new:
|
||||
*
|
||||
|
@ -217,25 +227,25 @@ gimp_color_hex_entry_new (void)
|
|||
**/
|
||||
void
|
||||
gimp_color_hex_entry_set_color (GimpColorHexEntry *entry,
|
||||
const GimpRGB *color)
|
||||
GeglColor *color)
|
||||
{
|
||||
GimpColorHexEntryPrivate *private;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_HEX_ENTRY (entry));
|
||||
g_return_if_fail (color != NULL);
|
||||
g_return_if_fail (GEGL_IS_COLOR (color));
|
||||
|
||||
private = GET_PRIVATE (entry);
|
||||
|
||||
if (gimp_rgb_distance (&private->color, color) > 0.0)
|
||||
if (! gimp_color_is_perceptually_identical (private->color, color))
|
||||
{
|
||||
gchar buffer[8];
|
||||
guchar r, g, b;
|
||||
gchar buffer[8];
|
||||
guchar rgb[3];
|
||||
|
||||
gimp_rgb_set (&private->color, color->r, color->g, color->b);
|
||||
gimp_rgb_clamp (&private->color);
|
||||
g_object_unref (private->color);
|
||||
private->color = gegl_color_duplicate (color);
|
||||
|
||||
gimp_rgb_get_uchar (&private->color, &r, &g, &b);
|
||||
g_snprintf (buffer, sizeof (buffer), "%.2x%.2x%.2x", r, g, b);
|
||||
gegl_color_get_pixel (color, babl_format ("R'G'B' u8"), rgb);
|
||||
g_snprintf (buffer, sizeof (buffer), "%.2x%.2x%.2x", rgb[0], rgb[1], rgb[2]);
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (entry), buffer);
|
||||
|
||||
|
@ -249,24 +259,23 @@ gimp_color_hex_entry_set_color (GimpColorHexEntry *entry,
|
|||
/**
|
||||
* gimp_color_hex_entry_get_color:
|
||||
* @entry: a #GimpColorHexEntry widget
|
||||
* @color: (out caller-allocates): pointer to a #GimpRGB
|
||||
*
|
||||
* Retrieves the color value displayed by a #GimpColorHexEntry.
|
||||
*
|
||||
* Returns: (transfer full): the color stored in @entry.
|
||||
*
|
||||
* Since: 2.2
|
||||
**/
|
||||
void
|
||||
gimp_color_hex_entry_get_color (GimpColorHexEntry *entry,
|
||||
GimpRGB *color)
|
||||
GeglColor *
|
||||
gimp_color_hex_entry_get_color (GimpColorHexEntry *entry)
|
||||
{
|
||||
GimpColorHexEntryPrivate *private;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_HEX_ENTRY (entry));
|
||||
g_return_if_fail (color != NULL);
|
||||
g_return_val_if_fail (GIMP_IS_COLOR_HEX_ENTRY (entry), NULL);
|
||||
|
||||
private = GET_PRIVATE (entry);
|
||||
|
||||
*color = private->color;
|
||||
return gegl_color_duplicate (private->color);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -293,23 +302,24 @@ gimp_color_hex_entry_events (GtkWidget *widget,
|
|||
{
|
||||
const gchar *text;
|
||||
gchar buffer[8];
|
||||
guchar r, g, b;
|
||||
guchar rgb[3];
|
||||
|
||||
text = gtk_entry_get_text (GTK_ENTRY (widget));
|
||||
|
||||
gimp_rgb_get_uchar (&private->color, &r, &g, &b);
|
||||
g_snprintf (buffer, sizeof (buffer), "%.2x%.2x%.2x", r, g, b);
|
||||
gegl_color_get_pixel (private->color, babl_format ("R'G'B' u8"), rgb);
|
||||
g_snprintf (buffer, sizeof (buffer), "%.2x%.2x%.2x", rgb[0], rgb[1], rgb[2]);
|
||||
|
||||
if (g_ascii_strcasecmp (buffer, text) != 0)
|
||||
{
|
||||
GimpRGB color;
|
||||
gsize len = strlen (text);
|
||||
GeglColor *color = NULL;
|
||||
gsize len = strlen (text);
|
||||
|
||||
if (len > 0 &&
|
||||
(gimp_rgb_parse_hex (&color, text, len) ||
|
||||
gimp_rgb_parse_name (&color, text, -1)))
|
||||
((color = gimp_color_parse_hex (text, len)) ||
|
||||
(color = gimp_color_parse_name (text, -1))))
|
||||
{
|
||||
gimp_color_hex_entry_set_color (entry, &color);
|
||||
gimp_color_hex_entry_set_color (entry, color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -333,17 +343,18 @@ gimp_color_hex_entry_matched (GtkEntryCompletion *completion,
|
|||
GtkTreeIter *iter,
|
||||
GimpColorHexEntry *entry)
|
||||
{
|
||||
gchar *name;
|
||||
GimpRGB color;
|
||||
gchar *name = NULL;
|
||||
GeglColor *color = NULL;
|
||||
|
||||
gtk_tree_model_get (model, iter,
|
||||
COLUMN_NAME, &name,
|
||||
-1);
|
||||
|
||||
if (gimp_rgb_parse_name (&color, name, -1))
|
||||
gimp_color_hex_entry_set_color (entry, &color);
|
||||
if ((color = gimp_color_parse_name (name, -1)))
|
||||
gimp_color_hex_entry_set_color (entry, color);
|
||||
|
||||
g_free (name);
|
||||
g_clear_object (&color);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -70,9 +70,8 @@ GType gimp_color_hex_entry_get_type (void) G_GNUC_CONST;
|
|||
GtkWidget * gimp_color_hex_entry_new (void);
|
||||
|
||||
void gimp_color_hex_entry_set_color (GimpColorHexEntry *entry,
|
||||
const GimpRGB *color);
|
||||
void gimp_color_hex_entry_get_color (GimpColorHexEntry *entry,
|
||||
GimpRGB *color);
|
||||
GeglColor *color);
|
||||
GeglColor * gimp_color_hex_entry_get_color (GimpColorHexEntry *entry);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -84,8 +84,7 @@ struct _GimpColorSelectionPrivate
|
|||
{
|
||||
gboolean show_alpha;
|
||||
|
||||
GimpHSV hsv;
|
||||
GimpRGB rgb;
|
||||
GeglColor *color;
|
||||
GimpColorSelectorChannel channel;
|
||||
|
||||
GtkWidget *left_vbox;
|
||||
|
@ -101,6 +100,7 @@ struct _GimpColorSelectionPrivate
|
|||
#define GET_PRIVATE(obj) (((GimpColorSelection *) (obj))->priv)
|
||||
|
||||
|
||||
static void gimp_color_selection_finalize (GObject *object);
|
||||
static void gimp_color_selection_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
|
@ -146,6 +146,7 @@ gimp_color_selection_class_init (GimpColorSelectionClass *klass)
|
|||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gimp_color_selection_finalize;
|
||||
object_class->set_property = gimp_color_selection_set_property;
|
||||
|
||||
klass->color_changed = NULL;
|
||||
|
@ -181,7 +182,8 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
|||
GtkWidget *button;
|
||||
GtkSizeGroup *new_group;
|
||||
GtkSizeGroup *old_group;
|
||||
GeglColor *color;
|
||||
GimpRGB rgb;
|
||||
GimpHSV hsv;
|
||||
|
||||
selection->priv = gimp_color_selection_get_instance_private (selection);
|
||||
|
||||
|
@ -192,8 +194,10 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
|||
gtk_orientable_set_orientation (GTK_ORIENTABLE (selection),
|
||||
GTK_ORIENTATION_VERTICAL);
|
||||
|
||||
gimp_rgba_set (&priv->rgb, 0.0, 0.0, 0.0, 1.0);
|
||||
gimp_rgb_to_hsv (&priv->rgb, &priv->hsv);
|
||||
priv->color = gegl_color_new ("black");
|
||||
|
||||
gegl_color_get_pixel (priv->color, babl_format ("R'G'B'A double"), &rgb);
|
||||
gegl_color_get_pixel (priv->color, babl_format ("HSVA double"), &hsv);
|
||||
|
||||
priv->channel = GIMP_COLOR_SELECTOR_RED;
|
||||
|
||||
|
@ -214,9 +218,7 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
|||
}
|
||||
|
||||
priv->notebook = gimp_color_selector_new (GIMP_TYPE_COLOR_NOTEBOOK,
|
||||
&priv->rgb,
|
||||
&priv->hsv,
|
||||
priv->channel);
|
||||
&rgb, &hsv, priv->channel);
|
||||
|
||||
if (_gimp_ensure_modules_func)
|
||||
g_type_class_unref (g_type_class_peek (GIMP_TYPE_COLOR_SELECT));
|
||||
|
@ -273,9 +275,7 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
|||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
color = gegl_color_new (NULL);
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &priv->rgb);
|
||||
priv->new_color = gimp_color_area_new (color,
|
||||
priv->new_color = gimp_color_area_new (priv->color,
|
||||
priv->show_alpha ?
|
||||
GIMP_COLOR_AREA_SMALL_CHECKS :
|
||||
GIMP_COLOR_AREA_FLAT,
|
||||
|
@ -289,7 +289,7 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
|||
G_CALLBACK (gimp_color_selection_new_color_changed),
|
||||
selection);
|
||||
|
||||
priv->old_color = gimp_color_area_new (color,
|
||||
priv->old_color = gimp_color_area_new (priv->color,
|
||||
priv->show_alpha ?
|
||||
GIMP_COLOR_AREA_SMALL_CHECKS :
|
||||
GIMP_COLOR_AREA_FLAT,
|
||||
|
@ -307,9 +307,7 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
|||
gtk_widget_show (priv->right_vbox);
|
||||
|
||||
priv->scales = gimp_color_selector_new (GIMP_TYPE_COLOR_SCALES,
|
||||
&priv->rgb,
|
||||
&priv->hsv,
|
||||
priv->channel);
|
||||
&rgb, &hsv, priv->channel);
|
||||
gimp_color_selector_set_toggles_visible
|
||||
(GIMP_COLOR_SELECTOR (priv->scales), TRUE);
|
||||
gimp_color_selector_set_show_alpha (GIMP_COLOR_SELECTOR (priv->scales),
|
||||
|
@ -353,8 +351,16 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
|||
g_signal_connect (entry, "color-changed",
|
||||
G_CALLBACK (gimp_color_selection_entry_changed),
|
||||
selection);
|
||||
}
|
||||
|
||||
g_object_unref (color);
|
||||
static void
|
||||
gimp_color_selection_finalize (GObject *object)
|
||||
{
|
||||
GimpColorSelectionPrivate *priv = GET_PRIVATE (object);
|
||||
|
||||
g_object_unref (priv->color);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -453,17 +459,17 @@ gimp_color_selection_get_show_alpha (GimpColorSelection *selection)
|
|||
**/
|
||||
void
|
||||
gimp_color_selection_set_color (GimpColorSelection *selection,
|
||||
const GimpRGB *color)
|
||||
GeglColor *color)
|
||||
{
|
||||
GimpColorSelectionPrivate *priv;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
||||
g_return_if_fail (color != NULL);
|
||||
g_return_if_fail (GEGL_IS_COLOR (color));
|
||||
|
||||
priv = GET_PRIVATE (selection);
|
||||
|
||||
priv->rgb = *color;
|
||||
gimp_rgb_to_hsv (&priv->rgb, &priv->hsv);
|
||||
g_object_unref (priv->color);
|
||||
priv->color = gegl_color_duplicate (color);
|
||||
|
||||
gimp_color_selection_update (selection, UPDATE_ALL);
|
||||
|
||||
|
@ -473,19 +479,17 @@ gimp_color_selection_set_color (GimpColorSelection *selection,
|
|||
/**
|
||||
* gimp_color_selection_get_color:
|
||||
* @selection: A #GimpColorSelection widget.
|
||||
* @color: (out caller-allocates): Return location for the
|
||||
* @selection's current @color.
|
||||
*
|
||||
* This function returns the #GimpColorSelection's current color.
|
||||
*
|
||||
* Returns: (transfer full): the currently selected color.
|
||||
**/
|
||||
void
|
||||
gimp_color_selection_get_color (GimpColorSelection *selection,
|
||||
GimpRGB *color)
|
||||
GeglColor *
|
||||
gimp_color_selection_get_color (GimpColorSelection *selection)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
||||
g_return_if_fail (color != NULL);
|
||||
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), NULL);
|
||||
|
||||
*color = GET_PRIVATE (selection)->rgb;
|
||||
return gegl_color_duplicate (GET_PRIVATE (selection)->color);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -497,45 +501,34 @@ gimp_color_selection_get_color (GimpColorSelection *selection,
|
|||
**/
|
||||
void
|
||||
gimp_color_selection_set_old_color (GimpColorSelection *selection,
|
||||
const GimpRGB *rgb)
|
||||
GeglColor *color)
|
||||
{
|
||||
GimpColorSelectionPrivate *priv;
|
||||
GeglColor *color;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
||||
g_return_if_fail (rgb != NULL);
|
||||
g_return_if_fail (GEGL_IS_COLOR (color));
|
||||
|
||||
priv = GET_PRIVATE (selection);
|
||||
|
||||
color = gegl_color_new (NULL);
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
||||
gimp_color_area_set_color (GIMP_COLOR_AREA (priv->old_color), color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_selection_get_old_color:
|
||||
* @selection: A #GimpColorSelection widget.
|
||||
* @color: (out caller-allocates): Return location for the
|
||||
* @selection's old @color.
|
||||
*
|
||||
* This function returns the #GimpColorSelection's old color.
|
||||
* Returns: (transfer full): the old color.
|
||||
**/
|
||||
void
|
||||
gimp_color_selection_get_old_color (GimpColorSelection *selection,
|
||||
GimpRGB *rgb)
|
||||
GeglColor *
|
||||
gimp_color_selection_get_old_color (GimpColorSelection *selection)
|
||||
{
|
||||
GimpColorSelectionPrivate *priv;
|
||||
GeglColor *color;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
||||
g_return_if_fail (rgb != NULL);
|
||||
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), NULL);
|
||||
|
||||
priv = GET_PRIVATE (selection);
|
||||
|
||||
color = gimp_color_area_get_color (GIMP_COLOR_AREA (priv->old_color));
|
||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
||||
g_object_unref (color);
|
||||
return gimp_color_area_get_color (GIMP_COLOR_AREA (priv->old_color));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -549,15 +542,13 @@ gimp_color_selection_reset (GimpColorSelection *selection)
|
|||
{
|
||||
GimpColorSelectionPrivate *priv;
|
||||
GeglColor *color;
|
||||
GimpRGB rgb;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
||||
|
||||
priv = GET_PRIVATE (selection);
|
||||
|
||||
color = gimp_color_area_get_color (GIMP_COLOR_AREA (priv->old_color));
|
||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||
gimp_color_selection_set_color (selection, &rgb);
|
||||
gimp_color_selection_set_color (selection, color);
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
@ -696,8 +687,7 @@ gimp_color_selection_notebook_changed (GimpColorSelector *selector,
|
|||
{
|
||||
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
||||
|
||||
priv->hsv = *hsv;
|
||||
priv->rgb = *rgb;
|
||||
gegl_color_set_pixel (priv->color, babl_format ("HSVA double"), hsv);
|
||||
|
||||
gimp_color_selection_update (selection,
|
||||
UPDATE_SCALES | UPDATE_ENTRY | UPDATE_COLOR);
|
||||
|
@ -712,8 +702,7 @@ gimp_color_selection_scales_changed (GimpColorSelector *selector,
|
|||
{
|
||||
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
||||
|
||||
priv->rgb = *rgb;
|
||||
priv->hsv = *hsv;
|
||||
gegl_color_set_pixel (priv->color, babl_format ("HSVA double"), hsv);
|
||||
|
||||
gimp_color_selection_update (selection,
|
||||
UPDATE_ENTRY | UPDATE_NOTEBOOK | UPDATE_COLOR);
|
||||
|
@ -725,7 +714,12 @@ gimp_color_selection_color_picked (GtkWidget *widget,
|
|||
const GimpRGB *rgb,
|
||||
GimpColorSelection *selection)
|
||||
{
|
||||
gimp_color_selection_set_color (selection, rgb);
|
||||
GeglColor *color = gegl_color_new (NULL);
|
||||
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
||||
gimp_color_selection_set_color (selection, color);
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -734,9 +728,8 @@ gimp_color_selection_entry_changed (GimpColorHexEntry *entry,
|
|||
{
|
||||
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
||||
|
||||
gimp_color_hex_entry_get_color (entry, &priv->rgb);
|
||||
|
||||
gimp_rgb_to_hsv (&priv->rgb, &priv->hsv);
|
||||
g_object_unref (priv->color);
|
||||
priv->color = gimp_color_hex_entry_get_color (entry);
|
||||
|
||||
gimp_color_selection_update (selection,
|
||||
UPDATE_NOTEBOOK | UPDATE_SCALES | UPDATE_COLOR);
|
||||
|
@ -761,17 +754,13 @@ gimp_color_selection_new_color_changed (GtkWidget *widget,
|
|||
GimpColorSelection *selection)
|
||||
{
|
||||
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
||||
GeglColor *color;
|
||||
|
||||
color = gimp_color_area_get_color (GIMP_COLOR_AREA (widget));
|
||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &priv->rgb);
|
||||
gegl_color_get_pixel (color, babl_format ("HSVA double"), &priv->hsv);
|
||||
g_object_unref (priv->color);
|
||||
priv->color = gimp_color_area_get_color (GIMP_COLOR_AREA (widget));
|
||||
|
||||
gimp_color_selection_update (selection,
|
||||
UPDATE_NOTEBOOK | UPDATE_SCALES | UPDATE_ENTRY);
|
||||
gimp_color_selection_color_changed (selection);
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -779,6 +768,11 @@ gimp_color_selection_update (GimpColorSelection *selection,
|
|||
UpdateType update)
|
||||
{
|
||||
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
||||
GimpRGB rgb;
|
||||
GimpHSV hsv;
|
||||
|
||||
gegl_color_get_pixel (priv->color, babl_format ("R'G'B'A double"), &rgb);
|
||||
gegl_color_get_pixel (priv->color, babl_format ("HSVA double"), &hsv);
|
||||
|
||||
if (update & UPDATE_NOTEBOOK)
|
||||
{
|
||||
|
@ -787,8 +781,7 @@ gimp_color_selection_update (GimpColorSelection *selection,
|
|||
selection);
|
||||
|
||||
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (priv->notebook),
|
||||
&priv->rgb,
|
||||
&priv->hsv);
|
||||
&rgb, &hsv);
|
||||
|
||||
g_signal_handlers_unblock_by_func (priv->notebook,
|
||||
gimp_color_selection_notebook_changed,
|
||||
|
@ -802,8 +795,7 @@ gimp_color_selection_update (GimpColorSelection *selection,
|
|||
selection);
|
||||
|
||||
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (priv->scales),
|
||||
&priv->rgb,
|
||||
&priv->hsv);
|
||||
&rgb, &hsv);
|
||||
|
||||
g_signal_handlers_unblock_by_func (priv->scales,
|
||||
gimp_color_selection_scales_changed,
|
||||
|
@ -820,7 +812,7 @@ gimp_color_selection_update (GimpColorSelection *selection,
|
|||
gimp_color_selection_entry_changed,
|
||||
selection);
|
||||
|
||||
gimp_color_hex_entry_set_color (entry, &priv->rgb);
|
||||
gimp_color_hex_entry_set_color (entry, priv->color);
|
||||
|
||||
g_signal_handlers_unblock_by_func (entry,
|
||||
gimp_color_selection_entry_changed,
|
||||
|
@ -829,20 +821,14 @@ gimp_color_selection_update (GimpColorSelection *selection,
|
|||
|
||||
if (update & UPDATE_COLOR)
|
||||
{
|
||||
GeglColor *color;
|
||||
|
||||
g_signal_handlers_block_by_func (priv->new_color,
|
||||
gimp_color_selection_new_color_changed,
|
||||
selection);
|
||||
|
||||
color = gegl_color_new (NULL);
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &priv->rgb);
|
||||
gimp_color_area_set_color (GIMP_COLOR_AREA (priv->new_color), color);
|
||||
gimp_color_area_set_color (GIMP_COLOR_AREA (priv->new_color), priv->color);
|
||||
|
||||
g_signal_handlers_unblock_by_func (priv->new_color,
|
||||
gimp_color_selection_new_color_changed,
|
||||
selection);
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,14 +76,12 @@ void gimp_color_selection_set_show_alpha (GimpColorSelection *selection,
|
|||
gboolean gimp_color_selection_get_show_alpha (GimpColorSelection *selection);
|
||||
|
||||
void gimp_color_selection_set_color (GimpColorSelection *selection,
|
||||
const GimpRGB *color);
|
||||
void gimp_color_selection_get_color (GimpColorSelection *selection,
|
||||
GimpRGB *color);
|
||||
GeglColor *color);
|
||||
GeglColor * gimp_color_selection_get_color (GimpColorSelection *selection);
|
||||
|
||||
void gimp_color_selection_set_old_color (GimpColorSelection *selection,
|
||||
const GimpRGB *color);
|
||||
void gimp_color_selection_get_old_color (GimpColorSelection *selection,
|
||||
GimpRGB *color);
|
||||
GeglColor *color);
|
||||
GeglColor * gimp_color_selection_get_old_color (GimpColorSelection *selection);
|
||||
|
||||
void gimp_color_selection_reset (GimpColorSelection *selection);
|
||||
|
||||
|
|
Loading…
Reference in New Issue