Commit 05dd5029 authored by Ell's avatar Ell

app: add gimp_paint_tool_set_active()

... which can use to enable/disable certain aspects of
GimpPaintTool (in particular, brush-outline drawing).  Should be
used by subclasses, to temporarily disable the paint tool while in
a non-paint mode (currently, this is only needed by the
perspective-clone tool; see next commit.)
parent ef281823
......@@ -111,7 +111,7 @@ static gboolean gimp_paint_tool_check_alpha (GimpPaintTool *paint_tool,
static void gimp_paint_tool_hard_notify (GimpPaintOptions *options,
const GParamSpec *pspec,
GimpTool *tool);
GimpPaintTool *paint_tool);
static void gimp_paint_tool_cursor_notify (GimpDisplayConfig *config,
GParamSpec *pspec,
GimpPaintTool *paint_tool);
......@@ -153,6 +153,7 @@ gimp_paint_tool_init (GimpPaintTool *paint_tool)
gimp_tool_control_set_action_opacity (tool->control,
"context/context-opacity-set");
paint_tool->active = TRUE;
paint_tool->pick_colors = FALSE;
paint_tool->draw_line = FALSE;
......@@ -196,9 +197,9 @@ gimp_paint_tool_constructed (GObject *object)
g_signal_connect_object (options, "notify::hard",
G_CALLBACK (gimp_paint_tool_hard_notify),
tool, 0);
paint_tool, 0);
gimp_paint_tool_hard_notify (options, NULL, tool);
gimp_paint_tool_hard_notify (options, NULL, paint_tool);
paint_tool->show_cursor = display_config->show_paint_tool_cursor;
paint_tool->draw_brush = display_config->show_brush_outline;
......@@ -657,9 +658,12 @@ gimp_paint_tool_oper_update (GimpTool *tool,
static void
gimp_paint_tool_draw (GimpDrawTool *draw_tool)
{
if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (draw_tool)))
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (draw_tool);
if (paint_tool->active &&
! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (draw_tool)))
{
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (draw_tool);
GimpPaintCore *core = paint_tool->core;
GimpImage *image = gimp_display_get_image (draw_tool->display);
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
......@@ -860,12 +864,17 @@ gimp_paint_tool_check_alpha (GimpPaintTool *paint_tool,
static void
gimp_paint_tool_hard_notify (GimpPaintOptions *options,
const GParamSpec *pspec,
GimpTool *tool)
GimpPaintTool *paint_tool)
{
gimp_tool_control_set_precision (tool->control,
options->hard ?
GIMP_CURSOR_PRECISION_PIXEL_CENTER :
GIMP_CURSOR_PRECISION_SUBPIXEL);
if (paint_tool->active)
{
GimpTool *tool = GIMP_TOOL (paint_tool);
gimp_tool_control_set_precision (tool->control,
options->hard ?
GIMP_CURSOR_PRECISION_PIXEL_CENTER :
GIMP_CURSOR_PRECISION_SUBPIXEL);
}
}
static void
......@@ -881,6 +890,27 @@ gimp_paint_tool_cursor_notify (GimpDisplayConfig *config,
gimp_draw_tool_resume (GIMP_DRAW_TOOL (paint_tool));
}
void
gimp_paint_tool_set_active (GimpPaintTool *tool,
gboolean active)
{
g_return_if_fail (GIMP_IS_PAINT_TOOL (tool));
if (active != tool->active)
{
GimpPaintOptions *options = GIMP_PAINT_TOOL_GET_OPTIONS (tool);
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
tool->active = active;
if (active)
gimp_paint_tool_hard_notify (options, NULL, tool);
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
}
/**
* gimp_paint_tool_enable_color_picker:
* @tool: a #GimpPaintTool
......
......@@ -41,6 +41,7 @@ struct _GimpPaintTool
{
GimpColorTool parent_instance;
gboolean active;
gboolean pick_colors; /* pick color if ctrl is pressed */
gboolean draw_line;
......@@ -84,6 +85,9 @@ struct _GimpPaintToolClass
GType gimp_paint_tool_get_type (void) G_GNUC_CONST;
void gimp_paint_tool_set_active (GimpPaintTool *tool,
gboolean active);
void gimp_paint_tool_enable_color_picker (GimpPaintTool *tool,
GimpColorPickTarget target);
......
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