[gimp] app: in perspective-clone tool, fix cursor presicion; hide brush while adjusting
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: in perspective-clone tool, fix cursor presicion; hide brush while adjusting
- Date: Thu, 31 Jan 2019 11:23:40 +0000 (UTC)
commit e5c9314a88aa20331027537b350a8c4f37a35da4
Author: Ell <ell_se yahoo com>
Date: Thu Jan 31 06:18:17 2019 -0500
app: in perspective-clone tool, fix cursor presicion; hide brush while adjusting
In GimpPerspectiveCloneTool, use PIXEL_CENTER cursor precision
while setting the source, and place the source-position handle at
the center of the selected pixel, rather than at its top-left
corner.
Additionally, disable the paint tool while adjusting the
perspective, so that the brush outline isn't shown, and the cursor
precision remains SUBPIXEL, even if the hard-edge option is
toggled.
app/tools/gimpperspectiveclonetool.c | 69 +++++++++++++++++++++++++++++++++---
app/tools/gimpperspectiveclonetool.h | 24 +++++++------
2 files changed, 77 insertions(+), 16 deletions(-)
---
diff --git a/app/tools/gimpperspectiveclonetool.c b/app/tools/gimpperspectiveclonetool.c
index f99223e7db..f05f010ec2 100644
--- a/app/tools/gimpperspectiveclonetool.c
+++ b/app/tools/gimpperspectiveclonetool.c
@@ -62,6 +62,8 @@ enum
};
+static void gimp_perspective_clone_tool_constructed (GObject *object);
+
static gboolean gimp_perspective_clone_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
@@ -91,6 +93,11 @@ static void gimp_perspective_clone_tool_motion (GimpTool *to
guint32 time,
GdkModifierType state,
GimpDisplay *display);
+static void gimp_perspective_clone_tool_modifier_key (GimpTool *tool,
+ GdkModifierType key,
+ gboolean press,
+ GdkModifierType state,
+ GimpDisplay *display);
static void gimp_perspective_clone_tool_cursor_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
@@ -151,9 +158,12 @@ gimp_perspective_clone_tool_register (GimpToolRegisterCallback callback,
static void
gimp_perspective_clone_tool_class_init (GimpPerspectiveCloneToolClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
+ object_class->constructed = gimp_perspective_clone_tool_constructed;
+
tool_class->initialize = gimp_perspective_clone_tool_initialize;
tool_class->has_display = gimp_perspective_clone_tool_has_display;
tool_class->has_image = gimp_perspective_clone_tool_has_image;
@@ -161,6 +171,7 @@ gimp_perspective_clone_tool_class_init (GimpPerspectiveCloneToolClass *klass)
tool_class->button_press = gimp_perspective_clone_tool_button_press;
tool_class->button_release = gimp_perspective_clone_tool_button_release;
tool_class->motion = gimp_perspective_clone_tool_motion;
+ tool_class->modifier_key = gimp_perspective_clone_tool_modifier_key;
tool_class->cursor_update = gimp_perspective_clone_tool_cursor_update;
tool_class->oper_update = gimp_perspective_clone_tool_oper_update;
tool_class->options_notify = gimp_perspective_clone_tool_options_notify;
@@ -179,6 +190,19 @@ gimp_perspective_clone_tool_init (GimpPerspectiveCloneTool *clone_tool)
gimp_matrix3_identity (&clone_tool->transform);
}
+static void
+gimp_perspective_clone_tool_constructed (GObject *object)
+{
+ GimpPerspectiveCloneOptions *options;
+
+ options = GIMP_PERSPECTIVE_CLONE_TOOL_GET_OPTIONS (object);
+
+ G_OBJECT_CLASS (parent_class)->constructed (object);
+
+ if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_ADJUST)
+ gimp_paint_tool_set_active (GIMP_PAINT_TOOL (object), FALSE);
+}
+
static gboolean
gimp_perspective_clone_tool_initialize (GimpTool *tool,
GimpDisplay *display,
@@ -447,6 +471,39 @@ gimp_perspective_clone_tool_motion (GimpTool *tool,
}
}
+static void
+gimp_perspective_clone_tool_modifier_key (GimpTool *tool,
+ GdkModifierType key,
+ gboolean press,
+ GdkModifierType state,
+ GimpDisplay *display)
+{
+ GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool);
+ GimpPerspectiveCloneOptions *options;
+
+ options = GIMP_PERSPECTIVE_CLONE_TOOL_GET_OPTIONS (tool);
+
+ if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_PAINT &&
+ key == gimp_get_toggle_behavior_mask ())
+ {
+ if (press)
+ {
+ clone_tool->saved_precision =
+ gimp_tool_control_get_precision (tool->control);
+ gimp_tool_control_set_precision (tool->control,
+ GIMP_CURSOR_PRECISION_PIXEL_CENTER);
+ }
+ else
+ {
+ gimp_tool_control_set_precision (tool->control,
+ clone_tool->saved_precision);
+ }
+ }
+
+ GIMP_TOOL_CLASS (parent_class)->modifier_key (tool, key, press, state,
+ display);
+}
+
static void
gimp_perspective_clone_tool_cursor_update (GimpTool *tool,
const GimpCoords *coords,
@@ -592,6 +649,7 @@ gimp_perspective_clone_tool_options_notify (GimpTool *tool,
const GParamSpec *pspec)
{
GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool);
+ GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpPerspectiveCloneOptions *clone_options;
clone_options = GIMP_PERSPECTIVE_CLONE_OPTIONS (options);
@@ -608,13 +666,14 @@ gimp_perspective_clone_tool_options_notify (GimpTool *tool,
if (clone_options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_PAINT)
{
- /* GimpPaintTool's notify callback will set the right precision */
- g_object_notify (G_OBJECT (options), "hard");
-
gimp_perspective_clone_set_transform (clone, &clone_tool->transform);
+
+ gimp_paint_tool_set_active (paint_tool, TRUE);
}
else
{
+ gimp_paint_tool_set_active (paint_tool, FALSE);
+
gimp_tool_control_set_precision (tool->control,
GIMP_CURSOR_PRECISION_SUBPIXEL);
@@ -692,8 +751,8 @@ gimp_perspective_clone_tool_draw (GimpDrawTool *draw_tool)
gimp_draw_tool_add_handle (draw_tool,
GIMP_HANDLE_CROSS,
- clone_tool->src_x,
- clone_tool->src_y,
+ clone_tool->src_x + 0.5,
+ clone_tool->src_y + 0.5,
GIMP_TOOL_HANDLE_SIZE_CROSS,
GIMP_TOOL_HANDLE_SIZE_CROSS,
GIMP_HANDLE_ANCHOR_CENTER);
diff --git a/app/tools/gimpperspectiveclonetool.h b/app/tools/gimpperspectiveclonetool.h
index 8ab7015ed8..d0c4697b61 100644
--- a/app/tools/gimpperspectiveclonetool.h
+++ b/app/tools/gimpperspectiveclonetool.h
@@ -38,21 +38,23 @@ typedef struct _GimpPerspectiveCloneToolClass GimpPerspectiveCloneToolClass;
struct _GimpPerspectiveCloneTool
{
- GimpBrushTool parent_instance;
+ GimpBrushTool parent_instance;
- GimpDisplay *src_display;
- gint src_x;
- gint src_y;
+ GimpDisplay *src_display;
+ gint src_x;
+ gint src_y;
- GimpMatrix3 transform; /* transformation matrix */
- TransInfo trans_info; /* transformation info */
- TransInfo old_trans_info; /* for cancelling a drag operation */
+ GimpMatrix3 transform; /* transformation matrix */
+ TransInfo trans_info; /* transformation info */
+ TransInfo old_trans_info; /* for cancelling a drag operation */
- gint x1, y1; /* upper left hand coordinate */
- gint x2, y2; /* lower right hand coords */
+ gint x1, y1; /* upper left hand coordinate */
+ gint x2, y2; /* lower right hand coords */
- GimpToolWidget *widget;
- GimpToolWidget *grab_widget;
+ GimpCursorPrecision saved_precision;
+
+ GimpToolWidget *widget;
+ GimpToolWidget *grab_widget;
};
struct _GimpPerspectiveCloneToolClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]