applied a modified patch from David Gowers that changes the search

2006-09-12  Sven Neumann  <sven@gimp.org>

	* app/widgets/gimppaletteeditor.c (gimp_palette_editor_get_index):
	applied a modified patch from David Gowers that changes the search
	behaviour to favour colors in the neighborhood of the selected color
	(bug #355520).
This commit is contained in:
Sven Neumann 2006-09-12 10:37:45 +00:00 committed by Sven Neumann
parent 5a4f8ad46e
commit d19c796234
2 changed files with 47 additions and 2 deletions

View file

@ -1,3 +1,10 @@
2006-09-12 Sven Neumann <sven@gimp.org>
* app/widgets/gimppaletteeditor.c (gimp_palette_editor_get_index):
applied a modified patch from David Gowers that changes the search
behaviour to favour colors in the neighborhood of the selected color
(bug #355520).
2006-09-12 Sven Neumann <sven@gimp.org>
* configure.in: mention the Win32 twain plug-in in the summary.

View file

@ -578,11 +578,12 @@ gimp_palette_editor_get_index (GimpPaletteEditor *editor,
if (search)
{
if (! editor->color ||
gimp_rgb_distance (&editor->color->color, search) > EPSILON)
if (! editor->color)
{
GList *list;
/* search from the start */
for (list = palette->colors; list; list = g_list_next (list))
{
GimpPaletteEntry *entry = list->data;
@ -594,6 +595,43 @@ gimp_palette_editor_get_index (GimpPaletteEditor *editor,
}
}
}
else if (gimp_rgb_distance (&editor->color->color, search) > EPSILON)
{
GList *old = g_list_nth (palette->colors, editor->color->position);
GList *next = old->next;
GList *prev = old->prev;
/* proximity-based search */
while (next || prev)
{
if (next)
{
GimpPaletteEntry *entry = next->data;
if (gimp_rgb_distance (&entry->color, search) < EPSILON)
{
index = entry->position;
break;
}
next = next->next;
}
if (prev)
{
GimpPaletteEntry *entry = prev->data;
if (gimp_rgb_distance (&entry->color, search) < EPSILON)
{
index = entry->position;
break;
}
prev = prev->prev;
}
}
}
}
return index;