[gimp] app: restrict sample point drawing to the exposed region
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: restrict sample point drawing to the exposed region
- Date: Sun, 2 May 2010 14:05:49 +0000 (UTC)
commit 02b8eea08625a9b844a947e23c283d015a964bfe
Author: Michael Natterer <mitch gimp org>
Date: Sun May 2 15:58:51 2010 +0200
app: restrict sample point drawing to the exposed region
With the same limitation as for guides in the last commit.
app/display/gimpdisplayshell-callbacks.c | 2 +-
app/display/gimpdisplayshell-draw.c | 27 +++++++++++++++++++++------
app/display/gimpdisplayshell-draw.h | 4 +++-
app/tools/gimpcolortool.c | 15 ++++++++-------
4 files changed, 33 insertions(+), 15 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c
index 86e0e23..9214286 100644
--- a/app/display/gimpdisplayshell-callbacks.c
+++ b/app/display/gimpdisplayshell-callbacks.c
@@ -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);
diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c
index 87006a1..41ce432 100644
--- a/app/display/gimpdisplayshell-draw.c
+++ b/app/display/gimpdisplayshell-draw.c
@@ -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);
}
}
}
diff --git a/app/display/gimpdisplayshell-draw.h b/app/display/gimpdisplayshell-draw.h
index 83fced8..b756f62 100644
--- a/app/display/gimpdisplayshell-draw.h
+++ b/app/display/gimpdisplayshell-draw.h
@@ -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);
diff --git a/app/tools/gimpcolortool.c b/app/tools/gimpcolortool.c
index 07c382d..1c9e88b 100644
--- a/app/tools/gimpcolortool.c
+++ b/app/tools/gimpcolortool.c
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]