Commit 1ade034c authored by Michael Natterer's avatar Michael Natterer 😴

app: move "show paint tool cursor" logic from GimpBrushTool to GimpPaintTool

Now all paint tools (also ink and mypaint brush) honor the setting and
can work without mouse cursor.
parent 66010e6c
......@@ -322,7 +322,7 @@ N_("When enabled, dialogs will show a help button that gives access to " \
#define SHOW_PAINT_TOOL_CURSOR_BLURB \
N_("When enabled, the mouse pointer will be shown over the image while " \
"using a brush-based paint tool.")
"using a paint tool.")
#define SHOW_MENUBAR_BLURB \
N_("When enabled, the menubar is visible by default. This can also be " \
......
......@@ -1948,7 +1948,7 @@ prefs_dialog_new (Gimp *gimp,
_("Show _brush outline"),
GTK_BOX (vbox2));
prefs_check_button_add (object, "show-paint-tool-cursor",
_("Show pointer for brush _tools"),
_("Show pointer for paint _tools"),
GTK_BOX (vbox2));
table = prefs_table_new (2, GTK_CONTAINER (vbox2));
......
......@@ -115,7 +115,6 @@ gimp_brush_tool_init (GimpBrushTool *brush_tool)
gimp_tool_control_set_action_object_1 (tool->control,
"context/context-brush-select-set");
brush_tool->show_cursor = TRUE;
brush_tool->draw_brush = TRUE;
brush_tool->brush_x = 0.0;
brush_tool->brush_y = 0.0;
......@@ -135,12 +134,8 @@ gimp_brush_tool_constructed (GObject *object)
display_config = GIMP_DISPLAY_CONFIG (tool->tool_info->gimp->config);
brush_tool->show_cursor = display_config->show_paint_tool_cursor;
brush_tool->draw_brush = display_config->show_brush_outline;
g_signal_connect_object (display_config, "notify::show-paint-tool-cursor",
G_CALLBACK (gimp_brush_tool_notify_brush),
brush_tool, 0);
g_signal_connect_object (display_config, "notify::show-brush-outline",
G_CALLBACK (gimp_brush_tool_notify_brush),
brush_tool, 0);
......@@ -241,16 +236,6 @@ gimp_brush_tool_cursor_update (GimpTool *tool,
GIMP_CURSOR_MODIFIER_BAD);
return;
}
else if (! brush_tool->show_cursor &&
gimp_tool_control_get_cursor_modifier (tool->control) !=
GIMP_CURSOR_MODIFIER_BAD)
{
gimp_tool_set_cursor (tool, display,
GIMP_CURSOR_NONE,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);
return;
}
}
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
......@@ -311,7 +296,7 @@ gimp_brush_tool_draw (GimpDrawTool *draw_tool)
gimp_paint_tool_set_draw_circle (GIMP_PAINT_TOOL (brush_tool),
TRUE, options->brush_size);
}
else if (! brush_tool->show_cursor)
else if (! GIMP_PAINT_TOOL (brush_tool)->show_cursor)
{
/* don't leave the user without any indication and draw
* a fallback crosshair
......@@ -441,8 +426,7 @@ gimp_brush_tool_notify_brush (GimpDisplayConfig *config,
{
gimp_draw_tool_pause (GIMP_DRAW_TOOL (brush_tool));
brush_tool->show_cursor = config->show_paint_tool_cursor;
brush_tool->draw_brush = config->show_brush_outline;
brush_tool->draw_brush = config->show_brush_outline;
gimp_draw_tool_resume (GIMP_DRAW_TOOL (brush_tool));
}
......@@ -36,7 +36,6 @@ struct _GimpBrushTool
{
GimpPaintTool parent_instance;
gboolean show_cursor;
gboolean draw_brush;
gdouble brush_x;
gdouble brush_y;
......
......@@ -25,6 +25,8 @@
#include "tools-types.h"
#include "config/gimpdisplayconfig.h"
#include "core/gimp.h"
#include "core/gimp-utils.h"
#include "core/gimpdrawable.h"
......@@ -94,6 +96,9 @@ static void gimp_paint_tool_draw (GimpDrawTool *draw_tool);
static void gimp_paint_tool_hard_notify (GimpPaintOptions *options,
const GParamSpec *pspec,
GimpTool *tool);
static void gimp_paint_tool_cursor_notify (GimpDisplayConfig *config,
GParamSpec *pspec,
GimpPaintTool *paint_tool);
G_DEFINE_TYPE (GimpPaintTool, gimp_paint_tool, GIMP_TYPE_COLOR_TOOL)
......@@ -134,6 +139,8 @@ gimp_paint_tool_init (GimpPaintTool *paint_tool)
paint_tool->pick_colors = FALSE;
paint_tool->draw_line = FALSE;
paint_tool->show_cursor = TRUE;
paint_tool->draw_circle = FALSE;
paint_tool->circle_radius = 0.0;
......@@ -147,16 +154,19 @@ gimp_paint_tool_init (GimpPaintTool *paint_tool)
static void
gimp_paint_tool_constructed (GObject *object)
{
GimpTool *tool = GIMP_TOOL (object);
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (object);
GimpPaintOptions *options = GIMP_PAINT_TOOL_GET_OPTIONS (tool);
GimpPaintInfo *paint_info;
GimpTool *tool = GIMP_TOOL (object);
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (object);
GimpPaintOptions *options = GIMP_PAINT_TOOL_GET_OPTIONS (tool);
GimpDisplayConfig *display_config;
GimpPaintInfo *paint_info;
G_OBJECT_CLASS (parent_class)->constructed (object);
g_assert (GIMP_IS_TOOL_INFO (tool->tool_info));
g_assert (GIMP_IS_PAINT_INFO (tool->tool_info->paint_info));
display_config = GIMP_DISPLAY_CONFIG (tool->tool_info->gimp->config);
paint_info = tool->tool_info->paint_info;
g_assert (g_type_is_a (paint_info->paint_type, GIMP_TYPE_PAINT_CORE));
......@@ -170,6 +180,12 @@ gimp_paint_tool_constructed (GObject *object)
tool, 0);
gimp_paint_tool_hard_notify (options, NULL, tool);
paint_tool->show_cursor = display_config->show_paint_tool_cursor;
g_signal_connect_object (display_config, "notify::show-paint-tool-cursor",
G_CALLBACK (gimp_paint_tool_cursor_notify),
paint_tool, 0);
}
static void
......@@ -497,6 +513,7 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpCursorModifier modifier;
GimpCursorModifier toggle_modifier;
GimpCursorModifier old_modifier;
......@@ -521,6 +538,16 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
toggle_modifier = GIMP_CURSOR_MODIFIER_BAD;
}
if (! paint_tool->show_cursor &&
modifier != GIMP_CURSOR_MODIFIER_BAD)
{
gimp_tool_set_cursor (tool, display,
GIMP_CURSOR_NONE,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);
return;
}
gimp_tool_control_set_cursor_modifier (tool->control,
modifier);
gimp_tool_control_set_toggle_cursor_modifier (tool->control,
......@@ -759,6 +786,18 @@ gimp_paint_tool_hard_notify (GimpPaintOptions *options,
GIMP_CURSOR_PRECISION_SUBPIXEL);
}
static void
gimp_paint_tool_cursor_notify (GimpDisplayConfig *config,
GParamSpec *pspec,
GimpPaintTool *paint_tool)
{
gimp_draw_tool_pause (GIMP_DRAW_TOOL (paint_tool));
paint_tool->show_cursor = config->show_paint_tool_cursor;
gimp_draw_tool_resume (GIMP_DRAW_TOOL (paint_tool));
}
/**
* gimp_paint_tool_enable_color_picker:
* @tool: a #GimpPaintTool
......
......@@ -40,6 +40,8 @@ struct _GimpPaintTool
gboolean pick_colors; /* pick color if ctrl is pressed */
gboolean draw_line;
gboolean show_cursor;
gboolean draw_circle;
gint circle_radius;
......
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