app: add boolean "mask_inverted" to GimpDisplayShell
and to gimp_display_shell_set_mask(). It allows to choose whether the mask is drawn inverted, instead of always drawing it inverted.
This commit is contained in:
@ -205,8 +205,6 @@ gimp_display_shell_render (GimpDisplayShell *shell,
|
|||||||
|
|
||||||
if (shell->mask)
|
if (shell->mask)
|
||||||
{
|
{
|
||||||
gint mask_height;
|
|
||||||
|
|
||||||
if (! shell->mask_surface)
|
if (! shell->mask_surface)
|
||||||
{
|
{
|
||||||
shell->mask_surface =
|
shell->mask_surface =
|
||||||
@ -231,8 +229,10 @@ gimp_display_shell_render (GimpDisplayShell *shell,
|
|||||||
data, stride,
|
data, stride,
|
||||||
GEGL_ABYSS_CLAMP);
|
GEGL_ABYSS_CLAMP);
|
||||||
|
|
||||||
/* invert the mask so what is *not* the foreground object is masked */
|
if (shell->mask_inverted)
|
||||||
mask_height = scaled_height;
|
{
|
||||||
|
gint mask_height = scaled_height;
|
||||||
|
|
||||||
while (mask_height--)
|
while (mask_height--)
|
||||||
{
|
{
|
||||||
gint mask_width = scaled_width;
|
gint mask_width = scaled_width;
|
||||||
@ -248,6 +248,7 @@ gimp_display_shell_render (GimpDisplayShell *shell,
|
|||||||
data += stride;
|
data += stride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* put it to the screen */
|
/* put it to the screen */
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
|
@ -1918,15 +1918,16 @@ gimp_display_shell_set_highlight (GimpDisplayShell *shell,
|
|||||||
* @shell: a #GimpDisplayShell
|
* @shell: a #GimpDisplayShell
|
||||||
* @mask: a #GimpDrawable (1 byte per pixel)
|
* @mask: a #GimpDrawable (1 byte per pixel)
|
||||||
* @color: the color to use for drawing the mask
|
* @color: the color to use for drawing the mask
|
||||||
|
* @inverted: #TRUE if the mask should be drawn inverted
|
||||||
*
|
*
|
||||||
* Previews a selection (used by the foreground selection tool).
|
* Previews an image-sized mask. Depending on @inverted, pixels that
|
||||||
* Pixels that are not selected (> 127) in the mask are tinted with
|
* are selected or not selected are tinted with the given color.
|
||||||
* the given color.
|
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gimp_display_shell_set_mask (GimpDisplayShell *shell,
|
gimp_display_shell_set_mask (GimpDisplayShell *shell,
|
||||||
GeglBuffer *mask,
|
GeglBuffer *mask,
|
||||||
const GimpRGB *color)
|
const GimpRGB *color,
|
||||||
|
gboolean inverted)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||||
g_return_if_fail (mask == NULL || GEGL_IS_BUFFER (mask));
|
g_return_if_fail (mask == NULL || GEGL_IS_BUFFER (mask));
|
||||||
@ -1943,5 +1944,7 @@ gimp_display_shell_set_mask (GimpDisplayShell *shell,
|
|||||||
if (mask)
|
if (mask)
|
||||||
shell->mask_color = *color;
|
shell->mask_color = *color;
|
||||||
|
|
||||||
|
shell->mask_inverted = inverted;
|
||||||
|
|
||||||
gimp_display_shell_expose_full (shell);
|
gimp_display_shell_expose_full (shell);
|
||||||
}
|
}
|
||||||
|
@ -191,6 +191,7 @@ struct _GimpDisplayShell
|
|||||||
|
|
||||||
GeglBuffer *mask;
|
GeglBuffer *mask;
|
||||||
GimpRGB mask_color;
|
GimpRGB mask_color;
|
||||||
|
gboolean mask_inverted;
|
||||||
|
|
||||||
GimpMotionBuffer *motion_buffer;
|
GimpMotionBuffer *motion_buffer;
|
||||||
|
|
||||||
@ -281,7 +282,8 @@ void gimp_display_shell_set_highlight (GimpDisplayShell *shell,
|
|||||||
const GdkRectangle *highlight);
|
const GdkRectangle *highlight);
|
||||||
void gimp_display_shell_set_mask (GimpDisplayShell *shell,
|
void gimp_display_shell_set_mask (GimpDisplayShell *shell,
|
||||||
GeglBuffer *mask,
|
GeglBuffer *mask,
|
||||||
const GimpRGB *color);
|
const GimpRGB *color,
|
||||||
|
gboolean inverted);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_DISPLAY_SHELL_H__ */
|
#endif /* __GIMP_DISPLAY_SHELL_H__ */
|
||||||
|
@ -944,7 +944,7 @@ gimp_foreground_select_tool_halt (GimpForegroundSelectTool *fg_select)
|
|||||||
|
|
||||||
if (tool->display)
|
if (tool->display)
|
||||||
gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
|
gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
|
||||||
NULL, NULL);
|
NULL, NULL, FALSE);
|
||||||
|
|
||||||
gimp_tool_control_set_tool_cursor (tool->control,
|
gimp_tool_control_set_tool_cursor (tool->control,
|
||||||
GIMP_TOOL_CURSOR_FREE_SELECT);
|
GIMP_TOOL_CURSOR_FREE_SELECT);
|
||||||
@ -1006,7 +1006,7 @@ gimp_foreground_select_tool_set_trimap (GimpForegroundSelectTool *fg_select)
|
|||||||
|
|
||||||
gimp_foreground_select_options_get_mask_color (options, &color);
|
gimp_foreground_select_options_get_mask_color (options, &color);
|
||||||
gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
|
gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
|
||||||
fg_select->trimap, &color);
|
fg_select->trimap, &color, TRUE);
|
||||||
|
|
||||||
gimp_tool_control_set_tool_cursor (tool->control,
|
gimp_tool_control_set_tool_cursor (tool->control,
|
||||||
GIMP_TOOL_CURSOR_PAINTBRUSH);
|
GIMP_TOOL_CURSOR_PAINTBRUSH);
|
||||||
@ -1034,7 +1034,7 @@ gimp_foreground_select_tool_set_preview (GimpForegroundSelectTool *fg_select)
|
|||||||
|
|
||||||
gimp_foreground_select_options_get_mask_color (options, &color);
|
gimp_foreground_select_options_get_mask_color (options, &color);
|
||||||
gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
|
gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
|
||||||
fg_select->mask, &color);
|
fg_select->mask, &color, TRUE);
|
||||||
|
|
||||||
gimp_tool_control_set_tool_cursor (tool->control,
|
gimp_tool_control_set_tool_cursor (tool->control,
|
||||||
GIMP_TOOL_CURSOR_PAINTBRUSH);
|
GIMP_TOOL_CURSOR_PAINTBRUSH);
|
||||||
|
Reference in New Issue
Block a user