[gimp] app: move "show paint tool cursor" logic from GimpBrushTool to GimpPaintTool
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: move "show paint tool cursor" logic from GimpBrushTool to GimpPaintTool
- Date: Sat, 12 Apr 2014 10:57:12 +0000 (UTC)
commit 1ade034c49cda49135e313a2a537f88690342058
Author: Michael Natterer <mitch gimp org>
Date: Sat Apr 12 12:54:08 2014 +0200
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.
app/config/gimprc-blurbs.h | 2 +-
app/dialogs/preferences-dialog.c | 2 +-
app/tools/gimpbrushtool.c | 20 +--------------
app/tools/gimpbrushtool.h | 1 -
app/tools/gimppainttool.c | 47 ++++++++++++++++++++++++++++++++++---
app/tools/gimppainttool.h | 2 +
6 files changed, 49 insertions(+), 25 deletions(-)
---
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 093a6e2..fb80ab2 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -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 " \
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 6541597..300fae3 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -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));
diff --git a/app/tools/gimpbrushtool.c b/app/tools/gimpbrushtool.c
index 06b2687..80311d8 100644
--- a/app/tools/gimpbrushtool.c
+++ b/app/tools/gimpbrushtool.c
@@ -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));
}
diff --git a/app/tools/gimpbrushtool.h b/app/tools/gimpbrushtool.h
index 44db369..018db8e 100644
--- a/app/tools/gimpbrushtool.h
+++ b/app/tools/gimpbrushtool.h
@@ -36,7 +36,6 @@ struct _GimpBrushTool
{
GimpPaintTool parent_instance;
- gboolean show_cursor;
gboolean draw_brush;
gdouble brush_x;
gdouble brush_y;
diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c
index b8617f5..fe9cdb1 100644
--- a/app/tools/gimppainttool.c
+++ b/app/tools/gimppainttool.c
@@ -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
diff --git a/app/tools/gimppainttool.h b/app/tools/gimppainttool.h
index 7a20ba8..61126b6 100644
--- a/app/tools/gimppainttool.h
+++ b/app/tools/gimppainttool.h
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]