app: add a canvas sample point item class
and use it in gimp_display_shell_draw_sample_point().
This commit is contained in:
@ -39,6 +39,8 @@ libappdisplay_a_sources = \
|
|||||||
gimpcanvaspolygon.h \
|
gimpcanvaspolygon.h \
|
||||||
gimpcanvasrectangle.c \
|
gimpcanvasrectangle.c \
|
||||||
gimpcanvasrectangle.h \
|
gimpcanvasrectangle.h \
|
||||||
|
gimpcanvassamplepoint.c \
|
||||||
|
gimpcanvassamplepoint.h \
|
||||||
gimpcanvastextcursor.c \
|
gimpcanvastextcursor.c \
|
||||||
gimpcanvastextcursor.h \
|
gimpcanvastextcursor.h \
|
||||||
gimpcursorview.c \
|
gimpcursorview.c \
|
||||||
|
334
app/display/gimpcanvassamplepoint.c
Normal file
334
app/display/gimpcanvassamplepoint.c
Normal file
@ -0,0 +1,334 @@
|
|||||||
|
/* GIMP - The GNU Image Manipulation Program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimpcanvassamplepoint.c
|
||||||
|
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gegl.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "libgimpbase/gimpbase.h"
|
||||||
|
#include "libgimpmath/gimpmath.h"
|
||||||
|
|
||||||
|
#include "display-types.h"
|
||||||
|
|
||||||
|
#include "core/gimpsamplepoint.h"
|
||||||
|
|
||||||
|
#include "gimpcanvas.h"
|
||||||
|
#include "gimpcanvassamplepoint.h"
|
||||||
|
#include "gimpdisplayshell.h"
|
||||||
|
#include "gimpdisplayshell-style.h"
|
||||||
|
#include "gimpdisplayshell-transform.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_X,
|
||||||
|
PROP_Y,
|
||||||
|
PROP_INDEX,
|
||||||
|
PROP_SAMPLE_POINT_STYLE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _GimpCanvasSamplePointPrivate GimpCanvasSamplePointPrivate;
|
||||||
|
|
||||||
|
struct _GimpCanvasSamplePointPrivate
|
||||||
|
{
|
||||||
|
gint x;
|
||||||
|
gint y;
|
||||||
|
gint index;
|
||||||
|
gboolean sample_point_style;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define GET_PRIVATE(sample_point) \
|
||||||
|
G_TYPE_INSTANCE_GET_PRIVATE (sample_point, \
|
||||||
|
GIMP_TYPE_CANVAS_SAMPLE_POINT, \
|
||||||
|
GimpCanvasSamplePointPrivate)
|
||||||
|
|
||||||
|
|
||||||
|
/* local function prototypes */
|
||||||
|
|
||||||
|
static void gimp_canvas_sample_point_set_property (GObject *object,
|
||||||
|
guint property_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec);
|
||||||
|
static void gimp_canvas_sample_point_get_property (GObject *object,
|
||||||
|
guint property_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec);
|
||||||
|
static void gimp_canvas_sample_point_draw (GimpCanvasItem *item,
|
||||||
|
GimpDisplayShell *shell,
|
||||||
|
cairo_t *cr);
|
||||||
|
static GdkRegion * gimp_canvas_sample_point_get_extents (GimpCanvasItem *item,
|
||||||
|
GimpDisplayShell *shell);
|
||||||
|
static void gimp_canvas_sample_point_stroke (GimpCanvasItem *item,
|
||||||
|
GimpDisplayShell *shell,
|
||||||
|
cairo_t *cr);
|
||||||
|
static void gimp_canvas_sample_point_fill (GimpCanvasItem *item,
|
||||||
|
GimpDisplayShell *shell,
|
||||||
|
cairo_t *cr);
|
||||||
|
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GimpCanvasSamplePoint, gimp_canvas_sample_point,
|
||||||
|
GIMP_TYPE_CANVAS_ITEM)
|
||||||
|
|
||||||
|
#define parent_class gimp_canvas_sample_point_parent_class
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_canvas_sample_point_class_init (GimpCanvasSamplePointClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GimpCanvasItemClass *item_class = GIMP_CANVAS_ITEM_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->set_property = gimp_canvas_sample_point_set_property;
|
||||||
|
object_class->get_property = gimp_canvas_sample_point_get_property;
|
||||||
|
|
||||||
|
item_class->draw = gimp_canvas_sample_point_draw;
|
||||||
|
item_class->get_extents = gimp_canvas_sample_point_get_extents;
|
||||||
|
item_class->stroke = gimp_canvas_sample_point_stroke;
|
||||||
|
item_class->fill = gimp_canvas_sample_point_fill;
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class, PROP_X,
|
||||||
|
g_param_spec_int ("x", NULL, NULL,
|
||||||
|
-GIMP_MAX_IMAGE_SIZE,
|
||||||
|
GIMP_MAX_IMAGE_SIZE, 0,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class, PROP_Y,
|
||||||
|
g_param_spec_int ("y", NULL, NULL,
|
||||||
|
-GIMP_MAX_IMAGE_SIZE,
|
||||||
|
GIMP_MAX_IMAGE_SIZE, 0,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class, PROP_INDEX,
|
||||||
|
g_param_spec_int ("index", NULL, NULL,
|
||||||
|
0, G_MAXINT, 0,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class, PROP_SAMPLE_POINT_STYLE,
|
||||||
|
g_param_spec_boolean ("sample-point-style",
|
||||||
|
NULL, NULL,
|
||||||
|
FALSE,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (GimpCanvasSamplePointPrivate));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_canvas_sample_point_init (GimpCanvasSamplePoint *sample_point)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_canvas_sample_point_set_property (GObject *object,
|
||||||
|
guint property_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GimpCanvasSamplePointPrivate *private = GET_PRIVATE (object);
|
||||||
|
|
||||||
|
switch (property_id)
|
||||||
|
{
|
||||||
|
case PROP_X:
|
||||||
|
private->x = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
case PROP_Y:
|
||||||
|
private->y = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
case PROP_INDEX:
|
||||||
|
private->index = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
case PROP_SAMPLE_POINT_STYLE:
|
||||||
|
private->sample_point_style = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_canvas_sample_point_get_property (GObject *object,
|
||||||
|
guint property_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GimpCanvasSamplePointPrivate *private = GET_PRIVATE (object);
|
||||||
|
|
||||||
|
switch (property_id)
|
||||||
|
{
|
||||||
|
case PROP_X:
|
||||||
|
g_value_set_int (value, private->x);
|
||||||
|
break;
|
||||||
|
case PROP_Y:
|
||||||
|
g_value_set_int (value, private->x);
|
||||||
|
break;
|
||||||
|
case PROP_INDEX:
|
||||||
|
g_value_set_int (value, private->x);
|
||||||
|
break;
|
||||||
|
case PROP_SAMPLE_POINT_STYLE:
|
||||||
|
g_value_set_boolean (value, private->sample_point_style);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_canvas_sample_point_transform (GimpCanvasItem *item,
|
||||||
|
GimpDisplayShell *shell,
|
||||||
|
gdouble *x,
|
||||||
|
gdouble *y)
|
||||||
|
{
|
||||||
|
GimpCanvasSamplePointPrivate *private = GET_PRIVATE (item);
|
||||||
|
|
||||||
|
gimp_display_shell_transform_xy_f (shell,
|
||||||
|
private->x + 0.5,
|
||||||
|
private->y + 0.5,
|
||||||
|
x, y);
|
||||||
|
|
||||||
|
*x = floor (*x) + 0.5;
|
||||||
|
*y = floor (*y) + 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define HALF_SIZE (GIMP_SAMPLE_POINT_DRAW_SIZE / 2)
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_canvas_sample_point_draw (GimpCanvasItem *item,
|
||||||
|
GimpDisplayShell *shell,
|
||||||
|
cairo_t *cr)
|
||||||
|
{
|
||||||
|
GimpCanvasSamplePointPrivate *private = GET_PRIVATE (item);
|
||||||
|
PangoLayout *layout;
|
||||||
|
gdouble x, y;
|
||||||
|
gint x1, x2, y1, y2;
|
||||||
|
|
||||||
|
gimp_canvas_sample_point_transform (item, shell, &x, &y);
|
||||||
|
|
||||||
|
x1 = x - GIMP_SAMPLE_POINT_DRAW_SIZE;
|
||||||
|
x2 = x + GIMP_SAMPLE_POINT_DRAW_SIZE;
|
||||||
|
y1 = y - GIMP_SAMPLE_POINT_DRAW_SIZE;
|
||||||
|
y2 = y + GIMP_SAMPLE_POINT_DRAW_SIZE;
|
||||||
|
|
||||||
|
cairo_move_to (cr, x, y1);
|
||||||
|
cairo_line_to (cr, x, y1 + HALF_SIZE);
|
||||||
|
|
||||||
|
cairo_move_to (cr, x, y2);
|
||||||
|
cairo_line_to (cr, x, y2 - HALF_SIZE);
|
||||||
|
|
||||||
|
cairo_move_to (cr, x1, y);
|
||||||
|
cairo_line_to (cr, x1 + HALF_SIZE, y);
|
||||||
|
|
||||||
|
cairo_move_to (cr, x2, y);
|
||||||
|
cairo_line_to (cr, x2 - HALF_SIZE, y);
|
||||||
|
|
||||||
|
cairo_arc_negative (cr, x, y, HALF_SIZE, 0.0, 0.5 * G_PI);
|
||||||
|
|
||||||
|
_gimp_canvas_item_stroke (item, shell, cr);
|
||||||
|
|
||||||
|
layout = gimp_canvas_get_layout (GIMP_CANVAS (shell->canvas),
|
||||||
|
"%d", private->index);
|
||||||
|
|
||||||
|
cairo_move_to (cr, x + 2.5, y + 2.5);
|
||||||
|
pango_cairo_show_layout (cr, layout);
|
||||||
|
|
||||||
|
_gimp_canvas_item_fill (item, shell, cr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GdkRegion *
|
||||||
|
gimp_canvas_sample_point_get_extents (GimpCanvasItem *item,
|
||||||
|
GimpDisplayShell *shell)
|
||||||
|
{
|
||||||
|
GdkRectangle rectangle;
|
||||||
|
gdouble x, y;
|
||||||
|
gint x1, x2, y1, y2;
|
||||||
|
|
||||||
|
gimp_canvas_sample_point_transform (item, shell, &x, &y);
|
||||||
|
|
||||||
|
x1 = floor (x - GIMP_SAMPLE_POINT_DRAW_SIZE);
|
||||||
|
x2 = ceil (x + GIMP_SAMPLE_POINT_DRAW_SIZE);
|
||||||
|
y1 = floor (y - GIMP_SAMPLE_POINT_DRAW_SIZE);
|
||||||
|
y2 = ceil (y + GIMP_SAMPLE_POINT_DRAW_SIZE);
|
||||||
|
|
||||||
|
rectangle.x = x1 - 1.5;
|
||||||
|
rectangle.y = y1 - 1.5;
|
||||||
|
rectangle.width = x2 - x1 + 3.0;
|
||||||
|
rectangle.height = y2 - y1 + 3.0;
|
||||||
|
|
||||||
|
/* HACK: add 5 so the number gets cleared too */
|
||||||
|
rectangle.width += 5;
|
||||||
|
rectangle.height += 5;
|
||||||
|
|
||||||
|
return gdk_region_rectangle (&rectangle);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_canvas_sample_point_stroke (GimpCanvasItem *item,
|
||||||
|
GimpDisplayShell *shell,
|
||||||
|
cairo_t *cr)
|
||||||
|
{
|
||||||
|
GimpCanvasSamplePointPrivate *private = GET_PRIVATE (item);
|
||||||
|
|
||||||
|
if (private->sample_point_style)
|
||||||
|
{
|
||||||
|
gimp_display_shell_set_sample_point_style (shell, cr,
|
||||||
|
gimp_canvas_item_get_highlight (item));
|
||||||
|
cairo_stroke (cr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GIMP_CANVAS_ITEM_CLASS (parent_class)->stroke (item, shell, cr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_canvas_sample_point_fill (GimpCanvasItem *item,
|
||||||
|
GimpDisplayShell *shell,
|
||||||
|
cairo_t *cr)
|
||||||
|
{
|
||||||
|
GimpCanvasSamplePointPrivate *private = GET_PRIVATE (item);
|
||||||
|
|
||||||
|
if (private->sample_point_style)
|
||||||
|
{
|
||||||
|
gimp_display_shell_set_sample_point_style (shell, cr,
|
||||||
|
gimp_canvas_item_get_highlight (item));
|
||||||
|
cairo_fill (cr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GIMP_CANVAS_ITEM_CLASS (parent_class)->fill (item, shell, cr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GimpCanvasItem *
|
||||||
|
gimp_canvas_sample_point_new (gint x,
|
||||||
|
gint y,
|
||||||
|
gint index)
|
||||||
|
{
|
||||||
|
return g_object_new (GIMP_TYPE_CANVAS_SAMPLE_POINT,
|
||||||
|
"x", x,
|
||||||
|
"y", y,
|
||||||
|
"index", index,
|
||||||
|
NULL);
|
||||||
|
}
|
57
app/display/gimpcanvassamplepoint.h
Normal file
57
app/display/gimpcanvassamplepoint.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/* GIMP - The GNU Image Manipulation Program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimpcanvassamplepoint.h
|
||||||
|
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GIMP_CANVAS_SAMPLE_POINT_H__
|
||||||
|
#define __GIMP_CANVAS_SAMPLE_POINT_H__
|
||||||
|
|
||||||
|
|
||||||
|
#include "gimpcanvasitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define GIMP_TYPE_CANVAS_SAMPLE_POINT (gimp_canvas_sample_point_get_type ())
|
||||||
|
#define GIMP_CANVAS_SAMPLE_POINT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CANVAS_SAMPLE_POINT, GimpCanvasSamplePoint))
|
||||||
|
#define GIMP_CANVAS_SAMPLE_POINT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CANVAS_SAMPLE_POINT, GimpCanvasSamplePointClass))
|
||||||
|
#define GIMP_IS_CANVAS_SAMPLE_POINT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CANVAS_SAMPLE_POINT))
|
||||||
|
#define GIMP_IS_CANVAS_SAMPLE_POINT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CANVAS_SAMPLE_POINT))
|
||||||
|
#define GIMP_CANVAS_SAMPLE_POINT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CANVAS_SAMPLE_POINT, GimpCanvasSamplePointClass))
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _GimpCanvasSamplePoint GimpCanvasSamplePoint;
|
||||||
|
typedef struct _GimpCanvasSamplePointClass GimpCanvasSamplePointClass;
|
||||||
|
|
||||||
|
struct _GimpCanvasSamplePoint
|
||||||
|
{
|
||||||
|
GimpCanvasItem parent_instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpCanvasSamplePointClass
|
||||||
|
{
|
||||||
|
GimpCanvasItemClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GType gimp_canvas_sample_point_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
GimpCanvasItem * gimp_canvas_sample_point_new (gint x,
|
||||||
|
gint y,
|
||||||
|
gint index);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __GIMP_CANVAS_SAMPLE_POINT_H__ */
|
@ -49,6 +49,7 @@
|
|||||||
|
|
||||||
#include "gimpcanvas.h"
|
#include "gimpcanvas.h"
|
||||||
#include "gimpcanvasguide.h"
|
#include "gimpcanvasguide.h"
|
||||||
|
#include "gimpcanvassamplepoint.h"
|
||||||
#include "gimpdisplay.h"
|
#include "gimpdisplay.h"
|
||||||
#include "gimpdisplayshell.h"
|
#include "gimpdisplayshell.h"
|
||||||
#include "gimpdisplayshell-appearance.h"
|
#include "gimpdisplayshell-appearance.h"
|
||||||
@ -396,12 +397,8 @@ gimp_display_shell_draw_sample_point (GimpDisplayShell *shell,
|
|||||||
GimpSamplePoint *sample_point,
|
GimpSamplePoint *sample_point,
|
||||||
gboolean active)
|
gboolean active)
|
||||||
{
|
{
|
||||||
GimpImage *image;
|
GimpCanvasItem *item;
|
||||||
gdouble dx1, dy1, dx2, dy2;
|
GimpImage *image;
|
||||||
gint x1, x2, y1, y2;
|
|
||||||
gint sx1, sx2, sy1, sy2;
|
|
||||||
gdouble x, y;
|
|
||||||
PangoLayout *layout;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||||
g_return_if_fail (cr != NULL);
|
g_return_if_fail (cr != NULL);
|
||||||
@ -412,59 +409,16 @@ gimp_display_shell_draw_sample_point (GimpDisplayShell *shell,
|
|||||||
|
|
||||||
image = gimp_display_get_image (shell->display);
|
image = gimp_display_get_image (shell->display);
|
||||||
|
|
||||||
cairo_clip_extents (cr, &dx1, &dy1, &dx2, &dy2);
|
item = gimp_canvas_sample_point_new (sample_point->x,
|
||||||
|
sample_point->y,
|
||||||
|
g_list_index (gimp_image_get_sample_points (image),
|
||||||
|
sample_point) + 1);
|
||||||
|
g_object_set (item, "sample-point-style", TRUE, NULL);
|
||||||
|
gimp_canvas_item_set_highlight (item, active);
|
||||||
|
|
||||||
x1 = floor (dx1);
|
gimp_canvas_item_draw (item, shell, cr);
|
||||||
y1 = floor (dy1);
|
|
||||||
x2 = ceil (dx2);
|
|
||||||
y2 = ceil (dy2);
|
|
||||||
|
|
||||||
gimp_display_shell_transform_xy_f (shell,
|
g_object_unref (item);
|
||||||
sample_point->x + 0.5,
|
|
||||||
sample_point->y + 0.5,
|
|
||||||
&x, &y);
|
|
||||||
|
|
||||||
sx1 = floor (x - GIMP_SAMPLE_POINT_DRAW_SIZE);
|
|
||||||
sx2 = ceil (x + GIMP_SAMPLE_POINT_DRAW_SIZE);
|
|
||||||
sy1 = floor (y - GIMP_SAMPLE_POINT_DRAW_SIZE);
|
|
||||||
sy2 = ceil (y + GIMP_SAMPLE_POINT_DRAW_SIZE);
|
|
||||||
|
|
||||||
if (sx1 > x2 ||
|
|
||||||
sx2 < x1 ||
|
|
||||||
sy1 > y2 ||
|
|
||||||
sy2 < y1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
gimp_display_shell_set_sample_point_style (shell, cr, active);
|
|
||||||
|
|
||||||
#define HALF_SIZE (GIMP_SAMPLE_POINT_DRAW_SIZE / 2)
|
|
||||||
|
|
||||||
cairo_move_to (cr, x + 0.5, sy1);
|
|
||||||
cairo_line_to (cr, x + 0.5, sy1 + HALF_SIZE);
|
|
||||||
|
|
||||||
cairo_move_to (cr, x + 0.5, sy2);
|
|
||||||
cairo_line_to (cr, x + 0.5, sy2 - HALF_SIZE);
|
|
||||||
|
|
||||||
cairo_move_to (cr, sx1, y + 0.5);
|
|
||||||
cairo_line_to (cr, sx1 + HALF_SIZE, y + 0.5);
|
|
||||||
|
|
||||||
cairo_move_to (cr, sx2, y + 0.5);
|
|
||||||
cairo_line_to (cr, sx2 - HALF_SIZE, y + 0.5);
|
|
||||||
|
|
||||||
cairo_arc_negative (cr, x + 0.5, y + 0.5, HALF_SIZE, 0.0, 0.5 * G_PI);
|
|
||||||
|
|
||||||
cairo_stroke (cr);
|
|
||||||
|
|
||||||
layout =
|
|
||||||
gimp_canvas_get_layout (GIMP_CANVAS (shell->canvas),
|
|
||||||
"%d",
|
|
||||||
g_list_index (gimp_image_get_sample_points (image),
|
|
||||||
sample_point) + 1);
|
|
||||||
|
|
||||||
cairo_move_to (cr, x + 2, y + 2);
|
|
||||||
pango_cairo_show_layout (cr, layout);
|
|
||||||
|
|
||||||
cairo_fill (cr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -145,8 +145,8 @@ gimp_display_shell_expose_sample_point (GimpDisplayShell *shell,
|
|||||||
x2 = MIN (shell->disp_width, ceil (x + 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));
|
y2 = MIN (shell->disp_height, ceil (y + GIMP_SAMPLE_POINT_DRAW_SIZE));
|
||||||
|
|
||||||
/* HACK: add 3 instead of 1 so the number gets cleared too */
|
/* HACK: add 4 instead of 1 so the number gets cleared too */
|
||||||
gimp_display_shell_expose_area (shell, x1, y1, x2 - x1 + 3, y2 - y1 + 3);
|
gimp_display_shell_expose_area (shell, x1, y1, x2 - x1 + 4, y2 - y1 + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Reference in New Issue
Block a user