Commit 375acda3 authored by Michael Natterer's avatar Michael Natterer 😴

app: implement GimpTool::cursor_update() in GimpDrawTool

using the set widget. Remove or simplify cursor_update()
implementations in some subclasses.
parent 4d9d4d84
......@@ -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);
}
......
......@@ -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);
}
......@@ -275,28 +271,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,
......
......@@ -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;
}
......@@ -319,6 +324,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,
......
......@@ -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);
......@@ -268,29 +265,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)
......
......@@ -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);
}
......
......@@ -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);
}
......
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