[gimp] app: implement GimpTool::cursor_update() in GimpDrawTool
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: implement GimpTool::cursor_update() in GimpDrawTool
- Date: Tue, 27 Jun 2017 20:42:24 +0000 (UTC)
commit 375acda3ed727ceaab4dbd94336931bd4aa65937
Author: Michael Natterer <mitch gimp org>
Date: Tue Jun 27 22:41:25 2017 +0200
app: implement GimpTool::cursor_update() in GimpDrawTool
using the set widget. Remove or simplify cursor_update()
implementations in some subclasses.
app/tools/gimpblendtool.c | 27 +++++++++++++--------------
app/tools/gimpcroptool.c | 28 +---------------------------
app/tools/gimpdrawtool.c | 36 ++++++++++++++++++++++++++++++++++++
app/tools/gimpmeasuretool.c | 30 ++----------------------------
app/tools/gimptransformtool.c | 29 ++++++++++-------------------
app/tools/gimpvectortool.c | 36 ++++++++++++++++--------------------
6 files changed, 78 insertions(+), 108 deletions(-)
---
diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c
index cb488cf..76e2baa 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -412,30 +412,29 @@ gimp_blend_tool_cursor_update (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
- GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
- GimpImage *image = gimp_display_get_image (display);
- GimpDrawable *drawable = gimp_image_get_active_drawable (image);
- GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE;
+ GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
+ GimpImage *image = gimp_display_get_image (display);
+ GimpDrawable *drawable = gimp_image_get_active_drawable (image);
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)) ||
gimp_item_is_content_locked (GIMP_ITEM (drawable)) ||
! gimp_item_is_visible (GIMP_ITEM (drawable)))
{
- modifier = GIMP_CURSOR_MODIFIER_BAD;
+ gimp_tool_set_cursor (tool, display,
+ gimp_tool_control_get_cursor (tool->control),
+ gimp_tool_control_get_tool_cursor (tool->control),
+ GIMP_CURSOR_MODIFIER_BAD);
+ return;
}
else if (display != tool->display || ! blend_tool->line)
{
- modifier = GIMP_CURSOR_MODIFIER_PLUS;
- }
- else if (blend_tool->line)
- {
- gimp_tool_widget_get_cursor (blend_tool->line,
- coords, state,
- NULL, NULL, &modifier);
+ gimp_tool_set_cursor (tool, display,
+ gimp_tool_control_get_cursor (tool->control),
+ gimp_tool_control_get_tool_cursor (tool->control),
+ GIMP_CURSOR_MODIFIER_PLUS);
+ return;
}
- gimp_tool_control_set_cursor_modifier (tool->control, modifier);
-
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
}
diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c
index b8ad67a..a9de5c7 100644
--- a/app/tools/gimpcroptool.c
+++ b/app/tools/gimpcroptool.c
@@ -66,10 +66,6 @@ static void gimp_crop_tool_motion (GimpTool
guint32 time,
GdkModifierType state,
GimpDisplay *display);
-static void gimp_crop_tool_cursor_update (GimpTool *tool,
- const GimpCoords *coords,
- GdkModifierType state,
- GimpDisplay *display);
static void gimp_crop_tool_options_notify (GimpTool *tool,
GimpToolOptions *options,
const GParamSpec *pspec);
@@ -136,7 +132,6 @@ gimp_crop_tool_class_init (GimpCropToolClass *klass)
tool_class->button_press = gimp_crop_tool_button_press;
tool_class->button_release = gimp_crop_tool_button_release;
tool_class->motion = gimp_crop_tool_motion;
- tool_class->cursor_update = gimp_crop_tool_cursor_update;
tool_class->options_notify = gimp_crop_tool_options_notify;
}
@@ -148,6 +143,7 @@ gimp_crop_tool_init (GimpCropTool *crop_tool)
gimp_tool_control_set_wants_click (tool->control, TRUE);
gimp_tool_control_set_precision (tool->control,
GIMP_CURSOR_PRECISION_PIXEL_BORDER);
+ gimp_tool_control_set_cursor (tool->control, GIMP_CURSOR_CROSSHAIR_SMALL);
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_CROP);
}
@@ -276,28 +272,6 @@ gimp_crop_tool_motion (GimpTool *tool,
}
static void
-gimp_crop_tool_cursor_update (GimpTool *tool,
- const GimpCoords *coords,
- GdkModifierType state,
- GimpDisplay *display)
-{
- GimpCropTool *crop_tool = GIMP_CROP_TOOL (tool);
- GimpCursorType cursor = GIMP_CURSOR_CROSSHAIR_SMALL;
- GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE;
-
- if (crop_tool->rectangle && display == tool->display)
- {
- gimp_tool_widget_get_cursor (crop_tool->rectangle, coords, state,
- &cursor, NULL, &modifier);
- }
-
- gimp_tool_control_set_cursor (tool->control, cursor);
- gimp_tool_control_set_cursor_modifier (tool->control, modifier);
-
- GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
-}
-
-static void
gimp_crop_tool_options_notify (GimpTool *tool,
GimpToolOptions *options,
const GParamSpec *pspec)
diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c
index 5addfe5..80413d3 100644
--- a/app/tools/gimpdrawtool.c
+++ b/app/tools/gimpdrawtool.c
@@ -91,6 +91,10 @@ static void gimp_draw_tool_oper_update (GimpTool *tool,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display);
+static void gimp_draw_tool_cursor_update (GimpTool *tool,
+ const GimpCoords *coords,
+ GdkModifierType state,
+ GimpDisplay *display);
static void gimp_draw_tool_widget_status (GimpToolWidget *widget,
const gchar *status,
@@ -137,6 +141,7 @@ gimp_draw_tool_class_init (GimpDrawToolClass *klass)
tool_class->modifier_key = gimp_draw_tool_modifier_key;
tool_class->active_modifier_key = gimp_draw_tool_active_modifier_key;
tool_class->oper_update = gimp_draw_tool_oper_update;
+ tool_class->cursor_update = gimp_draw_tool_cursor_update;
klass->draw = gimp_draw_tool_real_draw;
}
@@ -320,6 +325,37 @@ gimp_draw_tool_oper_update (GimpTool *tool,
}
static void
+gimp_draw_tool_cursor_update (GimpTool *tool,
+ const GimpCoords *coords,
+ GdkModifierType state,
+ GimpDisplay *display)
+{
+ GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
+
+ if (draw_tool->widget && display == draw_tool->display)
+ {
+ GimpCursorType cursor;
+ GimpToolCursorType tool_cursor;
+ GimpCursorModifier modifier;
+
+ cursor = gimp_tool_control_get_cursor (tool->control);
+ tool_cursor = gimp_tool_control_get_tool_cursor (tool->control);
+ modifier = gimp_tool_control_get_cursor_modifier (tool->control);
+
+ if (gimp_tool_widget_get_cursor (draw_tool->widget, coords, state,
+ &cursor, &tool_cursor, &modifier))
+ {
+ gimp_tool_set_cursor (tool, display,
+ cursor, tool_cursor, modifier);
+ return;
+ }
+ }
+
+ GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state,
+ display);
+}
+
+static void
gimp_draw_tool_widget_status (GimpToolWidget *rectangle,
const gchar *status,
GimpTool *tool)
diff --git a/app/tools/gimpmeasuretool.c b/app/tools/gimpmeasuretool.c
index 33d35b2..04f7469 100644
--- a/app/tools/gimpmeasuretool.c
+++ b/app/tools/gimpmeasuretool.c
@@ -72,10 +72,6 @@ static void gimp_measure_tool_motion (GimpTool *tool,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
-static void gimp_measure_tool_cursor_update (GimpTool *tool,
- const GimpCoords *coords,
- GdkModifierType state,
- GimpDisplay *display);
static void gimp_measure_tool_compass_changed (GimpToolWidget *widget,
GimpMeasureTool *measure);
@@ -139,7 +135,6 @@ gimp_measure_tool_class_init (GimpMeasureToolClass *klass)
tool_class->button_press = gimp_measure_tool_button_press;
tool_class->button_release = gimp_measure_tool_button_release;
tool_class->motion = gimp_measure_tool_motion;
- tool_class->cursor_update = gimp_measure_tool_cursor_update;
}
static void
@@ -150,6 +145,8 @@ gimp_measure_tool_init (GimpMeasureTool *measure)
gimp_tool_control_set_handle_empty_image (tool->control, TRUE);
gimp_tool_control_set_precision (tool->control,
GIMP_CURSOR_PRECISION_PIXEL_BORDER);
+ gimp_tool_control_set_cursor (tool->control,
+ GIMP_CURSOR_CROSSHAIR_SMALL);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_MEASURE);
@@ -269,29 +266,6 @@ gimp_measure_tool_motion (GimpTool *tool,
}
static void
-gimp_measure_tool_cursor_update (GimpTool *tool,
- const GimpCoords *coords,
- GdkModifierType state,
- GimpDisplay *display)
-{
- GimpMeasureTool *measure = GIMP_MEASURE_TOOL (tool);
- GimpCursorType cursor = GIMP_CURSOR_CROSSHAIR_SMALL;
- GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE;
-
- if (display == tool->display && measure->compass)
- {
- gimp_tool_widget_get_cursor (measure->compass,
- coords, state,
- &cursor, NULL, &modifier);
- }
-
- gimp_tool_control_set_cursor (tool->control, cursor);
- gimp_tool_control_set_cursor_modifier (tool->control, modifier);
-
- GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
-}
-
-static void
gimp_measure_tool_compass_changed (GimpToolWidget *widget,
GimpMeasureTool *measure)
{
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index b1e4728..b48213b 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -213,6 +213,8 @@ gimp_transform_tool_init (GimpTransformTool *tr_tool)
GIMP_DIRTY_ACTIVE_DRAWABLE);
gimp_tool_control_set_precision (tool->control,
GIMP_CURSOR_PRECISION_SUBPIXEL);
+ gimp_tool_control_set_cursor (tool->control,
+ GIMP_CURSOR_CROSSHAIR_SMALL);
tr_tool->progress_text = _("Transforming");
@@ -511,29 +513,18 @@ gimp_transform_tool_cursor_update (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
- GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
- GimpImage *image = gimp_display_get_image (display);
- GimpCursorType cursor = GIMP_CURSOR_CROSSHAIR_SMALL;
- GimpToolCursorType tool_cursor = GIMP_TOOL_CURSOR_NONE;
- GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE;
+ GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
+ GimpImage *image = gimp_display_get_image (display);
- if (tr_tool->widget)
+ if (! gimp_transform_tool_check_active_item (tr_tool, image, TRUE, NULL))
{
- if (display == tool->display)
- {
- gimp_tool_widget_get_cursor (tr_tool->widget,
- coords, state,
- &cursor, &tool_cursor, &modifier);
- }
+ gimp_tool_set_cursor (tool, display,
+ gimp_tool_control_get_cursor (tool->control),
+ gimp_tool_control_get_tool_cursor (tool->control),
+ GIMP_CURSOR_MODIFIER_BAD);
+ return;
}
- if (! gimp_transform_tool_check_active_item (tr_tool, image, TRUE, NULL))
- modifier = GIMP_CURSOR_MODIFIER_BAD;
-
- gimp_tool_control_set_cursor (tool->control, cursor);
- gimp_tool_control_set_tool_cursor (tool->control, tool_cursor);
- gimp_tool_control_set_cursor_modifier (tool->control, modifier);
-
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
}
diff --git a/app/tools/gimpvectortool.c b/app/tools/gimpvectortool.c
index e3c4b01..9f1dc60 100644
--- a/app/tools/gimpvectortool.c
+++ b/app/tools/gimpvectortool.c
@@ -355,29 +355,25 @@ gimp_vector_tool_cursor_update (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
- GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (tool);
- GimpDisplayShell *shell = gimp_display_get_shell (display);
- GimpToolCursorType tool_cursor = GIMP_TOOL_CURSOR_PATHS;
- GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE;
+ GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (tool);
+ GimpDisplayShell *shell = gimp_display_get_shell (display);
- if (display == tool->display && vector_tool->path)
+ if (display != tool->display || ! vector_tool->path)
{
- gimp_tool_widget_get_cursor (vector_tool->path,
- coords, state,
- NULL, &tool_cursor, &modifier);
- }
- else if (gimp_image_pick_vectors (gimp_display_get_image (display),
- coords->x, coords->y,
- FUNSCALEX (shell,
- GIMP_TOOL_HANDLE_SIZE_CIRCLE / 2),
- FUNSCALEY (shell,
- GIMP_TOOL_HANDLE_SIZE_CIRCLE / 2)))
- {
- tool_cursor = GIMP_TOOL_CURSOR_HAND;
- }
+ GimpToolCursorType tool_cursor = GIMP_TOOL_CURSOR_PATHS;
+
+ if (gimp_image_pick_vectors (gimp_display_get_image (display),
+ coords->x, coords->y,
+ FUNSCALEX (shell,
+ GIMP_TOOL_HANDLE_SIZE_CIRCLE / 2),
+ FUNSCALEY (shell,
+ GIMP_TOOL_HANDLE_SIZE_CIRCLE / 2)))
+ {
+ tool_cursor = GIMP_TOOL_CURSOR_HAND;
+ }
- gimp_tool_control_set_tool_cursor (tool->control, tool_cursor);
- gimp_tool_control_set_cursor_modifier (tool->control, modifier);
+ gimp_tool_control_set_tool_cursor (tool->control, tool_cursor);
+ }
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]