Commit ef281823 authored by Ell's avatar Ell

app: fix cursor precision of source tools

In GimpCloneTool, set the cursor precision to PIXEL_CENTER while
setting a source, and have GimpBrushTool snap the brush outline to
pixel centers.
parent 158705e4
......@@ -339,7 +339,7 @@ gimp_brush_tool_create_outline (GimpBrushTool *brush_tool,
gdouble x,
gdouble y)
{
GimpPaintOptions *options;
GimpTool *tool;
GimpDisplayShell *shell;
const GimpBezierDesc *boundary = NULL;
gint width = 0;
......@@ -362,8 +362,8 @@ gimp_brush_tool_create_outline (GimpBrushTool *brush_tool,
if (! boundary)
return NULL;
options = GIMP_PAINT_TOOL_GET_OPTIONS (brush_tool);
shell = gimp_display_get_shell (display);
tool = GIMP_TOOL (brush_tool);
shell = gimp_display_get_shell (display);
/* don't draw the boundary if it becomes too small */
if (SCALEX (shell, width) > 4 &&
......@@ -372,7 +372,8 @@ gimp_brush_tool_create_outline (GimpBrushTool *brush_tool,
x -= width / 2.0;
y -= height / 2.0;
if (gimp_paint_options_get_brush_mode (options) == GIMP_BRUSH_HARD)
if (gimp_tool_control_get_precision (tool->control) ==
GIMP_CURSOR_PRECISION_PIXEL_CENTER)
{
#define EPSILON 0.000001
/* Add EPSILON before rounding since e.g.
......
......@@ -249,12 +249,20 @@ gimp_source_tool_modifier_key (GimpTool *tool,
paint_tool->status = source_tool->status_set_source;
source_tool->show_source_outline = FALSE;
source_tool->saved_precision =
gimp_tool_control_get_precision (tool->control);
gimp_tool_control_set_precision (tool->control,
GIMP_CURSOR_PRECISION_PIXEL_CENTER);
}
else
{
paint_tool->status = source_tool->status_paint;
source_tool->show_source_outline = TRUE;
gimp_tool_control_set_precision (tool->control,
source_tool->saved_precision);
}
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
......
......@@ -37,20 +37,21 @@ typedef struct _GimpSourceToolClass GimpSourceToolClass;
struct _GimpSourceTool
{
GimpBrushTool parent_instance;
GimpBrushTool parent_instance;
GimpDisplay *src_display;
gint src_x;
gint src_y;
GimpDisplay *src_display;
gint src_x;
gint src_y;
gboolean show_source_outline;
gboolean show_source_outline;
GimpCursorPrecision saved_precision;
GimpCanvasItem *src_handle;
GimpCanvasItem *src_outline;
GimpCanvasItem *src_handle;
GimpCanvasItem *src_outline;
const gchar *status_paint;
const gchar *status_set_source;
const gchar *status_set_source_ctrl;
const gchar *status_paint;
const gchar *status_set_source;
const gchar *status_set_source_ctrl;
};
struct _GimpSourceToolClass
......
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