Issue #1788 - Inconsistency between FG color and selected color in...
...palette views despite selected color being in the currently
selected pallette
As suggested by Massimo, changing the color comparison EPSILON in
gimppalette.c from 1e-10 to 1e-6 fixes this, and is really small
enough.
Also, generally clean up color comparison epsilons:
- use a #define, not hardcoded values for all uses of
gimp_rgb[a]_distance()
- call the #defines RGB_EPSILON and RGBA_EPSILON
- make them all 1e-6 or larger
(cherry picked from commit abd7cbfc8d
)
This commit is contained in:
@ -54,6 +54,9 @@
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define RGBA_EPSILON 1e-6
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void channels_new_callback (GtkWidget *dialog,
|
||||
@ -505,7 +508,7 @@ channels_edit_attributes_callback (GtkWidget *dialog,
|
||||
GimpItem *item = GIMP_ITEM (channel);
|
||||
|
||||
if (strcmp (channel_name, gimp_object_get_name (channel)) ||
|
||||
gimp_rgba_distance (channel_color, &channel->color) > 0.0001 ||
|
||||
gimp_rgba_distance (channel_color, &channel->color) > RGBA_EPSILON ||
|
||||
channel_visible != gimp_item_get_visible (item) ||
|
||||
channel_linked != gimp_item_get_linked (item) ||
|
||||
channel_color_tag != gimp_item_get_color_tag (item) ||
|
||||
@ -519,7 +522,7 @@ channels_edit_attributes_callback (GtkWidget *dialog,
|
||||
if (strcmp (channel_name, gimp_object_get_name (channel)))
|
||||
gimp_item_rename (GIMP_ITEM (channel), channel_name, NULL);
|
||||
|
||||
if (gimp_rgba_distance (channel_color, &channel->color) > 0.0001)
|
||||
if (gimp_rgba_distance (channel_color, &channel->color) > RGBA_EPSILON)
|
||||
gimp_channel_set_color (channel, channel_color, TRUE);
|
||||
|
||||
if (channel_visible != gimp_item_get_visible (item))
|
||||
|
@ -42,6 +42,9 @@
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define RGBA_EPSILON 1e-6
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void quick_mask_configure_callback (GtkWidget *dialog,
|
||||
@ -167,7 +170,7 @@ quick_mask_configure_callback (GtkWidget *dialog,
|
||||
|
||||
gimp_image_get_quick_mask_color (image, &old_color);
|
||||
|
||||
if (gimp_rgba_distance (&old_color, channel_color) > 0.0001)
|
||||
if (gimp_rgba_distance (&old_color, channel_color) > RGBA_EPSILON)
|
||||
{
|
||||
gimp_image_set_quick_mask_color (image, channel_color);
|
||||
gimp_image_flush (image);
|
||||
|
@ -59,6 +59,8 @@
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define RGBA_EPSILON 1e-6
|
||||
|
||||
enum
|
||||
{
|
||||
COLOR_CHANGED,
|
||||
@ -1695,7 +1697,7 @@ gimp_channel_set_color (GimpChannel *channel,
|
||||
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
if (gimp_rgba_distance (&channel->color, color) > 0.0001)
|
||||
if (gimp_rgba_distance (&channel->color, color) > RGBA_EPSILON)
|
||||
{
|
||||
if (push_undo && gimp_item_is_attached (GIMP_ITEM (channel)))
|
||||
{
|
||||
|
@ -57,10 +57,11 @@
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define RGBA_EPSILON 1e-10
|
||||
|
||||
typedef void (* GimpContextCopyPropFunc) (GimpContext *src,
|
||||
GimpContext *dest);
|
||||
|
||||
|
||||
#define context_find_defined(context, prop) \
|
||||
while (!(((context)->defined_props) & (1 << (prop))) && (context)->parent) \
|
||||
(context) = (context)->parent
|
||||
@ -2319,7 +2320,7 @@ static void
|
||||
gimp_context_real_set_foreground (GimpContext *context,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
if (gimp_rgba_distance (&context->foreground, color) < 0.0001)
|
||||
if (gimp_rgba_distance (&context->foreground, color) < RGBA_EPSILON)
|
||||
return;
|
||||
|
||||
context->foreground = *color;
|
||||
@ -2370,7 +2371,7 @@ static void
|
||||
gimp_context_real_set_background (GimpContext *context,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
if (gimp_rgba_distance (&context->background, color) < 0.0001)
|
||||
if (gimp_rgba_distance (&context->background, color) < RGBA_EPSILON)
|
||||
return;
|
||||
|
||||
context->background = *color;
|
||||
|
@ -37,7 +37,9 @@
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
#define EPSILON 1e-10
|
||||
|
||||
#define RGB_EPSILON 1e-6
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
@ -648,11 +650,11 @@ gimp_palette_find_entry (GimpPalette *palette,
|
||||
for (list = palette->colors; list; list = g_list_next (list))
|
||||
{
|
||||
entry = (GimpPaletteEntry *) list->data;
|
||||
if (gimp_rgb_distance (&entry->color, color) < EPSILON)
|
||||
if (gimp_rgb_distance (&entry->color, color) < RGB_EPSILON)
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
else if (gimp_rgb_distance (&start_from->color, color) < EPSILON)
|
||||
else if (gimp_rgb_distance (&start_from->color, color) < RGB_EPSILON)
|
||||
{
|
||||
return start_from;
|
||||
}
|
||||
@ -674,7 +676,7 @@ gimp_palette_find_entry (GimpPalette *palette,
|
||||
if (next)
|
||||
{
|
||||
entry = (GimpPaletteEntry *) next->data;
|
||||
if (gimp_rgb_distance (&entry->color, color) < EPSILON)
|
||||
if (gimp_rgb_distance (&entry->color, color) < RGB_EPSILON)
|
||||
return entry;
|
||||
|
||||
next = next->next;
|
||||
@ -683,7 +685,7 @@ gimp_palette_find_entry (GimpPalette *palette,
|
||||
if (prev)
|
||||
{
|
||||
entry = (GimpPaletteEntry *) prev->data;
|
||||
if (gimp_rgb_distance (&entry->color, color) < EPSILON)
|
||||
if (gimp_rgb_distance (&entry->color, color) < RGB_EPSILON)
|
||||
return entry;
|
||||
|
||||
prev = prev->prev;
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define RGBA_EPSILON 1e-4
|
||||
|
||||
enum
|
||||
{
|
||||
COLOR_HISTORY = 1
|
||||
@ -205,7 +207,7 @@ gimp_palette_mru_add (GimpPaletteMru *mru,
|
||||
{
|
||||
GimpPaletteEntry *entry = list->data;
|
||||
|
||||
if (gimp_rgba_distance (&entry->color, color) < 0.0001)
|
||||
if (gimp_rgba_distance (&entry->color, color) < RGBA_EPSILON)
|
||||
{
|
||||
found = entry;
|
||||
|
||||
@ -228,7 +230,7 @@ gimp_palette_mru_add (GimpPaletteMru *mru,
|
||||
GimpPaletteEntry *entry2 = list2->data;
|
||||
|
||||
if (gimp_rgba_distance (&entry->color,
|
||||
&entry2->color) < 0.0001)
|
||||
&entry2->color) < RGBA_EPSILON)
|
||||
{
|
||||
found = entry2;
|
||||
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define RGBA_EPSILON 1e-6
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
@ -565,7 +567,7 @@ gimp_color_frame_set_color (GimpColorFrame *frame,
|
||||
frame->sample_format == sample_format &&
|
||||
frame->x == x &&
|
||||
frame->y == y &&
|
||||
gimp_rgba_distance (&frame->color, color) < 0.0001)
|
||||
gimp_rgba_distance (&frame->color, color) < RGBA_EPSILON)
|
||||
{
|
||||
frame->color = *color;
|
||||
return;
|
||||
|
@ -49,7 +49,7 @@
|
||||
|
||||
|
||||
#define BORDER 6
|
||||
#define EPSILON 1e-10
|
||||
#define RGB_EPSILON 1e-6
|
||||
|
||||
#define HAVE_COLORMAP(image) \
|
||||
(image != NULL && \
|
||||
@ -458,7 +458,7 @@ gimp_colormap_editor_get_index (GimpColormapEditor *editor,
|
||||
|
||||
gimp_image_get_colormap_entry (image, index, &temp);
|
||||
|
||||
if (gimp_rgb_distance (&temp, search) > EPSILON)
|
||||
if (gimp_rgb_distance (&temp, search) > RGB_EPSILON)
|
||||
{
|
||||
gint n_colors = gimp_image_get_colormap_size (image);
|
||||
gint i;
|
||||
@ -467,7 +467,7 @@ gimp_colormap_editor_get_index (GimpColormapEditor *editor,
|
||||
{
|
||||
gimp_image_get_colormap_entry (image, i, &temp);
|
||||
|
||||
if (gimp_rgb_distance (&temp, search) < EPSILON)
|
||||
if (gimp_rgb_distance (&temp, search) < RGB_EPSILON)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include "gimpcolorpanel.h"
|
||||
|
||||
|
||||
#define RGBA_EPSILON 1e-6
|
||||
|
||||
enum
|
||||
{
|
||||
RESPONSE,
|
||||
@ -255,7 +257,7 @@ gimp_color_panel_color_changed (GimpColorButton *button)
|
||||
gimp_color_dialog_get_color (GIMP_COLOR_DIALOG (panel->color_dialog),
|
||||
&dialog_color);
|
||||
|
||||
if (gimp_rgba_distance (&color, &dialog_color) > 0.00001 ||
|
||||
if (gimp_rgba_distance (&color, &dialog_color) > RGBA_EPSILON ||
|
||||
color.a != dialog_color.a)
|
||||
{
|
||||
gimp_color_dialog_set_color (GIMP_COLOR_DIALOG (panel->color_dialog),
|
||||
|
@ -53,6 +53,8 @@
|
||||
#include "gimp-priorities.h"
|
||||
|
||||
|
||||
#define RGB_EPSILON 1e-6
|
||||
|
||||
enum
|
||||
{
|
||||
UPDATE,
|
||||
@ -502,7 +504,7 @@ gimp_view_renderer_set_border_color (GimpViewRenderer *renderer,
|
||||
g_return_if_fail (GIMP_IS_VIEW_RENDERER (renderer));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
if (gimp_rgb_distance (&renderer->border_color, color))
|
||||
if (gimp_rgb_distance (&renderer->border_color, color) > RGB_EPSILON)
|
||||
{
|
||||
renderer->border_color = *color;
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
**/
|
||||
|
||||
|
||||
#define RGBA_EPSILON 1e-6
|
||||
#define DRAG_PREVIEW_SIZE 32
|
||||
#define DRAG_ICON_OFFSET -8
|
||||
|
||||
@ -508,7 +509,7 @@ gimp_color_area_set_color (GimpColorArea *area,
|
||||
g_return_if_fail (GIMP_IS_COLOR_AREA (area));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
if (gimp_rgba_distance (&area->color, color) < 0.000001)
|
||||
if (gimp_rgba_distance (&area->color, color) < RGBA_EPSILON)
|
||||
return;
|
||||
|
||||
area->color = *color;
|
||||
|
Reference in New Issue
Block a user