Commit 7f1caddd authored by Michael Natterer's avatar Michael Natterer 😴

app: use temporary canvas items for exposing guides and sample points

and remove gimp_display_shell_expose_guide() and _sample_point().
parent aa47dd22
......@@ -24,9 +24,6 @@
#include "display-types.h"
#include "core/gimpguide.h"
#include "core/gimpsamplepoint.h"
#include "vectors/gimpvectors.h"
#include "gimpcanvasitem.h"
......@@ -88,67 +85,6 @@ gimp_display_shell_expose_item (GimpDisplayShell *shell,
}
}
void
gimp_display_shell_expose_guide (GimpDisplayShell *shell,
GimpGuide *guide)
{
gint position;
gint x, y;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (GIMP_IS_GUIDE (guide));
position = gimp_guide_get_position (guide);
if (position < 0)
return;
gimp_display_shell_transform_xy (shell,
position, position,
&x, &y);
switch (gimp_guide_get_orientation (guide))
{
case GIMP_ORIENTATION_HORIZONTAL:
gimp_display_shell_expose_area (shell, 0, y, shell->disp_width, 1);
break;
case GIMP_ORIENTATION_VERTICAL:
gimp_display_shell_expose_area (shell, x, 0, 1, shell->disp_height);
break;
default:
break;
}
}
void
gimp_display_shell_expose_sample_point (GimpDisplayShell *shell,
GimpSamplePoint *sample_point)
{
gdouble x, y;
gint x1, y1, x2, y2;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (sample_point != NULL);
if (sample_point->x < 0)
return;
gimp_display_shell_transform_xy_f (shell,
sample_point->x + 0.5,
sample_point->y + 0.5,
&x, &y);
x1 = MAX (0, floor (x - GIMP_SAMPLE_POINT_DRAW_SIZE));
y1 = MAX (0, floor (y - GIMP_SAMPLE_POINT_DRAW_SIZE));
x2 = MIN (shell->disp_width, ceil (x + GIMP_SAMPLE_POINT_DRAW_SIZE));
y2 = MIN (shell->disp_height, ceil (y + GIMP_SAMPLE_POINT_DRAW_SIZE));
/* HACK: add 4 instead of 1 so the number gets cleared too */
gimp_display_shell_expose_area (shell, x1, y1, x2 - x1 + 4, y2 - y1 + 4);
}
void
gimp_display_shell_expose_vectors (GimpDisplayShell *shell,
GimpVectors *vectors)
......
......@@ -19,20 +19,16 @@
#define __GIMP_DISPLAY_SHELL_EXPOSE_H__
void gimp_display_shell_expose_area (GimpDisplayShell *shell,
gint x,
gint y,
gint w,
gint h);
void gimp_display_shell_expose_item (GimpDisplayShell *shell,
GimpCanvasItem *item);
void gimp_display_shell_expose_guide (GimpDisplayShell *shell,
GimpGuide *guide);
void gimp_display_shell_expose_sample_point (GimpDisplayShell *shell,
GimpSamplePoint *sample_point);
void gimp_display_shell_expose_vectors (GimpDisplayShell *shell,
GimpVectors *vectors);
void gimp_display_shell_expose_full (GimpDisplayShell *shell);
void gimp_display_shell_expose_area (GimpDisplayShell *shell,
gint x,
gint y,
gint w,
gint h);
void gimp_display_shell_expose_item (GimpDisplayShell *shell,
GimpCanvasItem *item);
void gimp_display_shell_expose_vectors (GimpDisplayShell *shell,
GimpVectors *vectors);
void gimp_display_shell_expose_full (GimpDisplayShell *shell);
#endif /* __GIMP_DISPLAY_SHELL_EXPOSE_H__ */
......@@ -31,16 +31,20 @@
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpguide.h"
#include "core/gimpimage.h"
#include "core/gimpimage-grid.h"
#include "core/gimpimage-quick-mask.h"
#include "core/gimpitem.h"
#include "core/gimpsamplepoint.h"
#include "core/gimptreehandler.h"
#include "file/file-utils.h"
#include "widgets/gimpwidgets-utils.h"
#include "gimpcanvasguide.h"
#include "gimpcanvassamplepoint.h"
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-appearance.h"
......@@ -463,7 +467,15 @@ gimp_display_shell_update_guide_handler (GimpImage *image,
GimpGuide *guide,
GimpDisplayShell *shell)
{
gimp_display_shell_expose_guide (shell, guide);
GimpCanvasItem *item;
item = gimp_canvas_guide_new (gimp_guide_get_orientation (guide),
gimp_guide_get_position (guide));
g_object_set (item, "guide-style", TRUE, NULL);
gimp_display_shell_expose_item (shell, item);
g_object_unref (item);
}
static void
......@@ -471,7 +483,16 @@ gimp_display_shell_update_sample_point_handler (GimpImage *image,
GimpSamplePoint *sample_point,
GimpDisplayShell *shell)
{
gimp_display_shell_expose_sample_point (shell, sample_point);
GimpCanvasItem *item;
item = gimp_canvas_sample_point_new (sample_point->x,
sample_point->y,
0 /* eek */);
g_object_set (item, "sample-point-style", TRUE, NULL);
gimp_display_shell_expose_item (shell, item);
g_object_unref (item);
}
static void
......
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