Issue #10998: more cases where fg/bg color was not properly updated.

Always update stored colors. When colors are perceptually identical, we
only bypass color rendering code, but not the color value update (even
small value updates need to be echoed across the code, so that what is
shown is always what is set).
This commit is contained in:
Jehan
2024-10-15 15:23:11 +02:00
parent 56add53473
commit 3ee7a922af
4 changed files with 40 additions and 41 deletions

View File

@ -2410,10 +2410,6 @@ static void
gimp_context_real_set_foreground (GimpContext *context,
GeglColor *color)
{
if (context->foreground != NULL &&
gimp_color_is_perceptually_identical (context->foreground, color))
return;
g_clear_object (&context->foreground);
context->foreground = gegl_color_duplicate (color);
gimp_color_set_alpha (context->foreground, GIMP_OPACITY_OPAQUE);
@ -2460,10 +2456,6 @@ static void
gimp_context_real_set_background (GimpContext *context,
GeglColor *color)
{
if (context->background != NULL &&
gimp_color_is_perceptually_identical (context->background, color))
return;
g_clear_object (&context->background);
context->background = gegl_color_duplicate (color);
gimp_color_set_alpha (context->background, GIMP_OPACITY_OPAQUE);

View File

@ -541,16 +541,16 @@ gimp_color_area_set_color (GimpColorArea *area,
priv = gimp_color_area_get_instance_private (area);
if (gimp_color_is_perceptually_identical (priv->color, color))
return;
if (! gimp_color_is_perceptually_identical (priv->color, color))
{
priv->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (area));
}
color = gegl_color_duplicate (color);
g_clear_object (&priv->color);
priv->color = color;
priv->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (area));
g_object_notify (G_OBJECT (area), "color");
g_signal_emit (area, gimp_color_area_signals[COLOR_CHANGED], 0);

View File

@ -227,30 +227,26 @@ gimp_color_hex_entry_set_color (GimpColorHexEntry *entry,
GeglColor *color)
{
GimpColorHexEntryPrivate *private;
gchar buffer[8];
guchar rgb[3];
g_return_if_fail (GIMP_IS_COLOR_HEX_ENTRY (entry));
g_return_if_fail (GEGL_IS_COLOR (color));
private = gimp_color_hex_entry_get_instance_private (entry);
if (! gimp_color_is_perceptually_identical (private->color, color))
{
gchar buffer[8];
guchar rgb[3];
g_object_unref (private->color);
private->color = gegl_color_duplicate (color);
g_object_unref (private->color);
private->color = gegl_color_duplicate (color);
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]);
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);
gtk_entry_set_text (GTK_ENTRY (entry), buffer);
/* move cursor to the end */
gtk_editable_set_position (GTK_EDITABLE (entry), -1);
/* move cursor to the end */
gtk_editable_set_position (GTK_EDITABLE (entry), -1);
g_signal_emit (entry, entry_signals[COLOR_CHANGED], 0);
}
g_signal_emit (entry, entry_signals[COLOR_CHANGED], 0);
}
/**

View File

@ -457,6 +457,7 @@ gimp_color_selection_set_color (GimpColorSelection *selection,
{
GimpColorSelectionPrivate *priv;
GeglColor *old_color;
UpdateType update;
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
g_return_if_fail (GEGL_IS_COLOR (color));
@ -466,11 +467,12 @@ gimp_color_selection_set_color (GimpColorSelection *selection,
old_color = priv->color;
priv->color = gegl_color_duplicate (color);
if (! gimp_color_is_perceptually_identical (priv->color, old_color))
{
gimp_color_selection_update (selection, UPDATE_ALL);
gimp_color_selection_color_changed (selection);
}
update = UPDATE_ALL;
if (gimp_color_is_perceptually_identical (color, old_color))
update &= ~UPDATE_COLOR;
gimp_color_selection_update (selection, update);
gimp_color_selection_color_changed (selection);
g_object_unref (old_color);
}
@ -731,18 +733,19 @@ gimp_color_selection_notebook_changed (GimpColorSelector *selector,
{
GimpColorSelectionPrivate *priv;
GeglColor *old_color;
UpdateType update;
priv = gimp_color_selection_get_instance_private (selection);
old_color = priv->color;
priv->color = gegl_color_duplicate (color);
if (! gimp_color_is_perceptually_identical (priv->color, old_color))
{
gimp_color_selection_update (selection,
UPDATE_SCALES | UPDATE_ENTRY | UPDATE_COLOR);
gimp_color_selection_color_changed (selection);
}
update = UPDATE_SCALES | UPDATE_ENTRY;
if (! gimp_color_is_perceptually_identical (color, old_color))
update |= UPDATE_COLOR;
gimp_color_selection_update (selection, update);
gimp_color_selection_color_changed (selection);
g_object_unref (old_color);
}
@ -753,15 +756,23 @@ gimp_color_selection_scales_changed (GimpColorSelector *selector,
GimpColorSelection *selection)
{
GimpColorSelectionPrivate *priv;
UpdateType update;
GeglColor *old_color;
priv = gimp_color_selection_get_instance_private (selection);
g_object_unref (priv->color);
old_color = priv->color;
priv->color = gegl_color_duplicate (color);
gimp_color_selection_update (selection,
UPDATE_ENTRY | UPDATE_NOTEBOOK | UPDATE_COLOR);
update = UPDATE_ENTRY | UPDATE_NOTEBOOK;
if (! gimp_color_is_perceptually_identical (color, old_color))
update |= UPDATE_COLOR;
gimp_color_selection_update (selection, update);
gimp_color_selection_color_changed (selection);
g_object_unref (old_color);
}
static void