[gimp] app: add an offset to GimpDisplayShell's mask
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add an offset to GimpDisplayShell's mask
- Date: Fri, 5 Feb 2016 20:22:12 +0000 (UTC)
commit 46da951b85a3d3cc5c466f8d7aa4b518ebd3b229
Author: Michael Natterer <mitch gimp org>
Date: Fri Feb 5 21:19:17 2016 +0100
app: add an offset to GimpDisplayShell's mask
and set that offset in GimpRegionSelectTool when not in sample_merged
mode. Fixes live selection mask display for layers with a non-zero
offset.
app/display/gimpdisplayshell-render.c | 5 +++--
app/display/gimpdisplayshell.c | 10 ++++++++--
app/display/gimpdisplayshell.h | 4 ++++
app/tools/gimpforegroundselecttool.c | 6 +++---
app/tools/gimpregionselecttool.c | 16 +++++++++++++---
5 files changed, 31 insertions(+), 10 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-render.c b/app/display/gimpdisplayshell-render.c
index 6fa65e5..e39ec8d 100644
--- a/app/display/gimpdisplayshell-render.c
+++ b/app/display/gimpdisplayshell-render.c
@@ -342,12 +342,13 @@ gimp_display_shell_render (GimpDisplayShell *shell,
mask_src_y * cairo_stride + mask_src_x * 4;
gegl_buffer_get (shell->mask,
- GEGL_RECTANGLE (scaled_x, scaled_y,
+ GEGL_RECTANGLE (scaled_x - shell->mask_offset_x,
+ scaled_y - shell->mask_offset_y,
scaled_width, scaled_height),
buffer_scale,
babl_format ("Y u8"),
cairo_data, cairo_stride,
- GEGL_ABYSS_CLAMP);
+ GEGL_ABYSS_NONE);
if (shell->mask_inverted)
{
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 21e0e50..3be2c70 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -1936,12 +1936,15 @@ gimp_display_shell_set_highlight (GimpDisplayShell *shell,
* @color: the color to use for drawing the mask
* @inverted: #TRUE if the mask should be drawn inverted
*
- * Previews an image-sized mask. Depending on @inverted, pixels that
- * are selected or not selected are tinted with the given color.
+ * Previews a mask originating at offset_x, offset_x. Depending on
+ * @inverted, pixels that are selected or not selected are tinted with
+ * the given color.
**/
void
gimp_display_shell_set_mask (GimpDisplayShell *shell,
GeglBuffer *mask,
+ gint offset_x,
+ gint offset_y,
const GimpRGB *color,
gboolean inverted)
{
@@ -1957,6 +1960,9 @@ gimp_display_shell_set_mask (GimpDisplayShell *shell,
shell->mask = mask;
+ shell->mask_offset_x = offset_x;
+ shell->mask_offset_y = offset_y;
+
if (mask)
shell->mask_color = *color;
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index 2358507..33692bc 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -202,6 +202,8 @@ struct _GimpDisplayShell
gpointer scroll_info;
GeglBuffer *mask;
+ gint mask_offset_x;
+ gint mask_offset_y;
GimpRGB mask_color;
gboolean mask_inverted;
@@ -292,6 +294,8 @@ void gimp_display_shell_set_highlight (GimpDisplayShell *shell,
const GdkRectangle *highlight);
void gimp_display_shell_set_mask (GimpDisplayShell *shell,
GeglBuffer *mask,
+ gint offset_x,
+ gint offset_y,
const GimpRGB *color,
gboolean inverted);
diff --git a/app/tools/gimpforegroundselecttool.c b/app/tools/gimpforegroundselecttool.c
index e6e8074..30efe83 100644
--- a/app/tools/gimpforegroundselecttool.c
+++ b/app/tools/gimpforegroundselecttool.c
@@ -959,7 +959,7 @@ gimp_foreground_select_tool_halt (GimpForegroundSelectTool *fg_select)
if (tool->display)
gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
- NULL, NULL, FALSE);
+ NULL, 0, 0, NULL, FALSE);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_FREE_SELECT);
@@ -1021,7 +1021,7 @@ gimp_foreground_select_tool_set_trimap (GimpForegroundSelectTool *fg_select)
gimp_foreground_select_options_get_mask_color (options, &color);
gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
- fg_select->trimap, &color, TRUE);
+ fg_select->trimap, 0, 0, &color, TRUE);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_PAINTBRUSH);
@@ -1049,7 +1049,7 @@ gimp_foreground_select_tool_set_preview (GimpForegroundSelectTool *fg_select)
gimp_foreground_select_options_get_mask_color (options, &color);
gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
- fg_select->mask, &color, TRUE);
+ fg_select->mask, 0, 0, &color, TRUE);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_PAINTBRUSH);
diff --git a/app/tools/gimpregionselecttool.c b/app/tools/gimpregionselecttool.c
index 6a6cf50..5c8c69e 100644
--- a/app/tools/gimpregionselecttool.c
+++ b/app/tools/gimpregionselecttool.c
@@ -187,7 +187,7 @@ gimp_region_select_tool_button_release (GimpTool *tool,
if (options->draw_mask)
gimp_display_shell_set_mask (gimp_display_get_shell (display),
- NULL, NULL, FALSE);
+ NULL, 0, 0, NULL, FALSE);
if (release_type != GIMP_BUTTON_RELEASE_CANCEL)
{
@@ -381,13 +381,23 @@ gimp_region_select_tool_get_mask (GimpRegionSelectTool *region_sel,
if (region_sel->region_mask)
{
GimpRGB color = { 1.0, 0.0, 1.0, 1.0 };
+ gint off_x = 0;
+ gint off_y = 0;
+
+ if (! options->sample_merged)
+ {
+ GimpImage *image = gimp_display_get_image (display);
+ GimpDrawable *drawable = gimp_image_get_active_drawable (image);
+
+ gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
+ }
gimp_display_shell_set_mask (shell, region_sel->region_mask,
- &color, FALSE);
+ off_x, off_y, &color, FALSE);
}
else
{
- gimp_display_shell_set_mask (shell, NULL, NULL, FALSE);
+ gimp_display_shell_set_mask (shell, NULL, 0, 0, NULL, FALSE);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]