Commit d19c7962 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

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).
parent 5a4f8ad4
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.
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment