app/display/gimpdisplayshell-render.c app/display/gimpdisplayshell.[ch]

2006-03-17  Sven Neumann  <sven@gimp.org>

	* app/display/gimpdisplayshell-render.c
	* app/display/gimpdisplayshell.[ch]
	* app/tools/gimpforegroundselectoptions.[ch]
	* app/tools/gimpforegroundselecttool.c: allow to use red, green or
	blue for the selection preview used by the foreground selection tool.
This commit is contained in:
Sven Neumann
2006-03-17 13:27:08 +00:00
committed by Sven Neumann
parent 724dd6b8e7
commit ac777da954
7 changed files with 103 additions and 23 deletions

View File

@ -1,3 +1,11 @@
2006-03-17 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-render.c
* app/display/gimpdisplayshell.[ch]
* app/tools/gimpforegroundselectoptions.[ch]
* app/tools/gimpforegroundselecttool.c: allow to use red, green or
blue for the selection preview used by the foreground selection tool.
2006-03-17 Sven Neumann <sven@gimp.org>
* plug-ins/common/*.c: removed trailing period from procedure blurbs.

View File

@ -365,15 +365,45 @@ gimp_display_shell_render_mask (GimpDisplayShell *shell,
const guchar *src = info->src;
guchar *dest = info->dest;
for (x = info->x; x < xe; x++, src++, dest += 3)
{
if (*src & 0x80)
continue;
switch (shell->mask_color)
{
case GIMP_RED_CHANNEL:
for (x = info->x; x < xe; x++, src++, dest += 3)
{
if (*src & 0x80)
continue;
dest[0] = dest[0] >> 2;
dest[1] = dest[1] >> 2;
dest[1] = dest[1] >> 2;
dest[2] = dest[2] >> 2;
}
break;
case GIMP_GREEN_CHANNEL:
for (x = info->x; x < xe; x++, src++, dest += 3)
{
if (*src & 0x80)
continue;
dest[0] = dest[0] >> 2;
dest[2] = dest[2] >> 2;
}
break;
case GIMP_BLUE_CHANNEL:
for (x = info->x; x < xe; x++, src++, dest += 3)
{
if (*src & 0x80)
continue;
dest[0] = dest[0] >> 2;
dest[1] = dest[1] >> 2;
}
break;
default:
break;
}
}
}
if (++y == ye)
break;

View File

@ -1631,6 +1631,7 @@ gimp_display_shell_set_highlight (GimpDisplayShell *shell,
* gimp_display_shell_set_mask:
* @shell: a #GimpDisplayShell
* @mask: a #GimpDrawable (1 byte per pixel)
* @color: the color to use for drawing the mask
*
* Allows to preview a selection (used by the foreground selection
* tool). Pixels that are not selected (> 127) in the mask are tinted
@ -1638,20 +1639,25 @@ gimp_display_shell_set_highlight (GimpDisplayShell *shell,
**/
void
gimp_display_shell_set_mask (GimpDisplayShell *shell,
GimpDrawable *mask)
GimpDrawable *mask,
GimpChannelType color)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (mask == NULL ||
(GIMP_IS_DRAWABLE (mask) &&
gimp_drawable_bytes (mask) == 1));
if (shell->mask == mask)
if (shell->mask == mask && shell->mask_color == color)
return;
if (mask)
g_object_ref (mask);
if (shell->mask)
g_object_unref (shell->mask);
shell->mask = mask ? g_object_ref (mask) : NULL;
shell->mask = mask;
shell->mask_color = color;
gimp_display_shell_expose_full (shell);
}

View File

@ -169,6 +169,7 @@ struct _GimpDisplayShell
GdkRectangle *highlight; /* in image coordinates, can be NULL */
GimpDrawable *mask;
GimpChannelType mask_color;
gpointer scroll_info;
};
@ -240,7 +241,8 @@ void gimp_display_shell_selection_visibility (GimpDisplayShell *shell,
void gimp_display_shell_set_highlight (GimpDisplayShell *shell,
const GdkRectangle *highlight);
void gimp_display_shell_set_mask (GimpDisplayShell *shell,
GimpDrawable *mask);
GimpDrawable *mask,
GimpChannelType color);
#endif /* __GIMP_DISPLAY_SHELL_H__ */

View File

@ -42,6 +42,7 @@ enum
PROP_BACKGROUND,
PROP_STROKE_WIDTH,
PROP_SMOOTHNESS,
PROP_MASK_COLOR,
PROP_EXPANDED,
PROP_SENSITIVITY_L,
PROP_SENSITIVITY_A,
@ -92,6 +93,11 @@ gimp_foreground_select_options_class_init (GimpForegroundSelectOptionsClass *kla
"in the selection"),
0, 8, SIOX_DEFAULT_SMOOTHNESS,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_MASK_COLOR,
"mask-color", NULL,
GIMP_TYPE_CHANNEL_TYPE,
GIMP_BLUE_CHANNEL,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_EXPANDED,
"expanded", NULL,
FALSE,
@ -140,6 +146,9 @@ gimp_foreground_select_options_set_property (GObject *object,
case PROP_SMOOTHNESS:
options->smoothness = g_value_get_int (value);
break;
case PROP_MASK_COLOR:
options->mask_color = g_value_get_enum (value);
break;
case PROP_EXPANDED:
options->expanded = g_value_get_boolean (value);
break;
@ -180,6 +189,9 @@ gimp_foreground_select_options_get_property (GObject *object,
case PROP_SMOOTHNESS:
g_value_set_int (value, options->smoothness);
break;
case PROP_MASK_COLOR:
g_value_set_enum (value, options->mask_color);
break;
case PROP_EXPANDED:
g_value_set_boolean (value, options->expanded);
break;
@ -208,6 +220,7 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
GtkWidget *frame;
GtkWidget *scale;
GtkWidget *label;
GtkWidget *menu;
GtkWidget *inner_frame;
GtkWidget *table;
GtkObject *adj;
@ -259,7 +272,8 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
gtk_widget_show (scale);
/* smoothness */
table = gtk_table_new (1, 3, FALSE);
table = gtk_table_new (2, 3, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
@ -270,6 +284,12 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Smoothing:"), 0.0, 0.5, scale, 2, FALSE);
/* mask color */
menu = gimp_prop_enum_combo_box_new (config, "mask-color",
GIMP_RED_CHANNEL, GIMP_BLUE_CHANNEL);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("Preview color:"), 0.0, 0.5, menu, 2, FALSE);
/* granularity */
frame = gimp_prop_expander_new (config, "expanded", _("Color Sensitivity"));
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);

View File

@ -42,6 +42,7 @@ struct _GimpForegroundSelectOptions
gboolean background;
gint stroke_width;
gint smoothness;
GimpChannelType mask_color;
gboolean expanded;
gdouble sensitivity[3];
};

View File

@ -659,7 +659,8 @@ gimp_foreground_select_tool_set_mask (GimpForegroundSelectTool *fg_select,
GimpDisplay *gdisp,
GimpChannel *mask)
{
GimpTool *tool = GIMP_TOOL (fg_select);
GimpTool *tool = GIMP_TOOL (fg_select);
GimpForegroundSelectOptions *options;
if (fg_select->mask == mask)
return;
@ -673,8 +674,10 @@ gimp_foreground_select_tool_set_mask (GimpForegroundSelectTool *fg_select,
if (mask)
fg_select->mask = g_object_ref (mask);
options = GIMP_FOREGROUND_SELECT_OPTIONS (tool->tool_info->tool_options);
gimp_display_shell_set_mask (GIMP_DISPLAY_SHELL (gdisp->shell),
GIMP_DRAWABLE (mask));
GIMP_DRAWABLE (mask), options->mask_color);
if (mask)
{
@ -827,16 +830,26 @@ gimp_foreground_select_options_notify (GimpForegroundSelectOptions *options,
refinement = SIOX_REFINEMENT_CHANGE_SENSITIVITY;
}
if (! refinement)
return;
if (refinement)
{
fg_select->refinement |= refinement;
fg_select->refinement |= refinement;
if (fg_select->idle_id)
g_source_remove (fg_select->idle_id);
if (fg_select->idle_id)
g_source_remove (fg_select->idle_id);
fg_select->idle_id =
g_idle_add_full (G_PRIORITY_LOW,
(GSourceFunc) gimp_foreground_select_tool_idle_select,
fg_select, NULL);
}
fg_select->idle_id =
g_idle_add_full (G_PRIORITY_LOW,
(GSourceFunc) gimp_foreground_select_tool_idle_select,
fg_select, NULL);
if (strncmp (pspec->name, "mask-color", strlen ("mask-color")) == 0)
{
GimpTool *tool = GIMP_TOOL (fg_select);
if (tool->gdisp)
gimp_display_shell_set_mask (GIMP_DISPLAY_SHELL (tool->gdisp->shell),
GIMP_DRAWABLE (fg_select->mask),
options->mask_color);
}
}