Commit 02b8eea0 authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

app: restrict sample point drawing to the exposed region

With the same limitation as for guides in the last commit.
parent 6e4be79b
......@@ -2281,7 +2281,7 @@ gimp_display_shell_canvas_expose_image (GimpDisplayShell *shell,
gimp_display_shell_draw_guides (shell, eevent->region);
/* draw the sample points */
gimp_display_shell_draw_sample_points (shell);
gimp_display_shell_draw_sample_points (shell, eevent->region);
/* and the cursor (if we have a software cursor) */
gimp_display_shell_draw_cursor (shell);
......
......@@ -432,9 +432,10 @@ gimp_display_shell_draw_pen (GimpDisplayShell *shell,
}
void
gimp_display_shell_draw_sample_point (GimpDisplayShell *shell,
GimpSamplePoint *sample_point,
gboolean active)
gimp_display_shell_draw_sample_point (GimpDisplayShell *shell,
GimpSamplePoint *sample_point,
const GdkRectangle *area,
gboolean active)
{
GimpImage *image;
GimpCanvasStyle style;
......@@ -469,6 +470,12 @@ gimp_display_shell_draw_sample_point (GimpDisplayShell *shell,
y > h + GIMP_SAMPLE_POINT_DRAW_SIZE)
return;
if (area && (x + GIMP_SAMPLE_POINT_DRAW_SIZE < area->x ||
y + GIMP_SAMPLE_POINT_DRAW_SIZE < area->y ||
x - GIMP_SAMPLE_POINT_DRAW_SIZE >= area->x + area->width ||
y - GIMP_SAMPLE_POINT_DRAW_SIZE >= area->y + area->height))
return;
if (active)
style = GIMP_CANVAS_STYLE_SAMPLE_POINT_ACTIVE;
else
......@@ -501,23 +508,31 @@ gimp_display_shell_draw_sample_point (GimpDisplayShell *shell,
}
void
gimp_display_shell_draw_sample_points (GimpDisplayShell *shell)
gimp_display_shell_draw_sample_points (GimpDisplayShell *shell,
const GdkRegion *region)
{
GimpImage *image;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (region != NULL);
image = gimp_display_get_image (shell->display);
if (image && gimp_display_shell_get_show_sample_points (shell))
{
GList *list;
GdkRectangle area;
GList *list;
if (region)
gdk_region_get_clipbox (region, &area);
for (list = gimp_image_get_sample_points (image);
list;
list = g_list_next (list))
{
gimp_display_shell_draw_sample_point (shell, list->data, FALSE);
gimp_display_shell_draw_sample_point (shell, list->data,
region ? &area : NULL,
FALSE);
}
}
}
......
......@@ -43,8 +43,10 @@ void gimp_display_shell_draw_pen (GimpDisplayShell *shell,
gint width);
void gimp_display_shell_draw_sample_point (GimpDisplayShell *shell,
GimpSamplePoint *sample_point,
const GdkRectangle *area,
gboolean active);
void gimp_display_shell_draw_sample_points (GimpDisplayShell *shell);
void gimp_display_shell_draw_sample_points (GimpDisplayShell *shell,
const GdkRegion *region);
void gimp_display_shell_draw_vector (GimpDisplayShell *shell,
GimpVectors *vectors);
void gimp_display_shell_draw_vectors (GimpDisplayShell *shell);
......
......@@ -210,15 +210,15 @@ gimp_color_tool_control (GimpTool *tool,
case GIMP_TOOL_ACTION_RESUME:
if (color_tool->sample_point &&
gimp_display_shell_get_show_sample_points (shell))
gimp_display_shell_draw_sample_point (shell,
color_tool->sample_point, TRUE);
gimp_display_shell_draw_sample_point (shell, color_tool->sample_point,
NULL, TRUE);
break;
case GIMP_TOOL_ACTION_HALT:
if (color_tool->sample_point &&
gimp_display_shell_get_show_sample_points (shell))
gimp_display_shell_draw_sample_point (shell,
color_tool->sample_point, FALSE);
gimp_display_shell_draw_sample_point (shell, color_tool->sample_point,
NULL, FALSE);
break;
}
......@@ -357,7 +357,7 @@ gimp_color_tool_button_release (GimpTool *tool,
if (color_tool->sample_point)
gimp_display_shell_draw_sample_point (shell, color_tool->sample_point,
TRUE);
NULL, TRUE);
color_tool->moving_sample_point = FALSE;
color_tool->sample_point_x = -1;
......@@ -497,7 +497,7 @@ gimp_color_tool_oper_update (GimpTool *tool,
if (color_tool->sample_point)
gimp_display_shell_draw_sample_point (shell, color_tool->sample_point,
TRUE);
NULL, TRUE);
}
static void
......@@ -824,7 +824,8 @@ gimp_color_tool_start_sample_point (GimpTool *tool,
if (color_tool->sample_point)
gimp_display_shell_draw_sample_point (gimp_display_get_shell (display),
color_tool->sample_point, FALSE);
color_tool->sample_point,
NULL, FALSE);
color_tool->sample_point = NULL;
color_tool->moving_sample_point = TRUE;
......
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