static void gimp_color_tool_cursor_update (GimpTool *tool, const GimpCoords *coords, GdkModifierType state, GimpDisplay *display) { GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool); GimpImage *image = gimp_display_get_image (display); if (color_tool->enabled) { if (color_tool->sample_point) { gimp_tool_set_cursor (tool, display, GIMP_CURSOR_MOUSE, GIMP_TOOL_CURSOR_COLOR_PICKER, GIMP_CURSOR_MODIFIER_MOVE); } else { GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_BAD; if (gimp_image_coords_in_active_pickable (image, coords, color_tool->options->sample_merged, FALSE)) { switch (color_tool->pick_mode) { case GIMP_COLOR_PICK_MODE_NONE: modifier = GIMP_CURSOR_MODIFIER_NONE; break; case GIMP_COLOR_PICK_MODE_FOREGROUND: modifier = GIMP_CURSOR_MODIFIER_FOREGROUND; break; case GIMP_COLOR_PICK_MODE_BACKGROUND: modifier = GIMP_CURSOR_MODIFIER_BACKGROUND; break; case GIMP_COLOR_PICK_MODE_PALETTE: modifier = GIMP_CURSOR_MODIFIER_PLUS; break; } } gimp_tool_set_cursor (tool, display, GIMP_CURSOR_COLOR_PICKER, GIMP_TOOL_CURSOR_COLOR_PICKER, modifier); } return; /* don't chain up */ } GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display); }
static void gimp_region_select_tool_cursor_update (GimpTool *tool, GimpCoords *coords, GdkModifierType state, GimpDisplay *display) { GimpRegionSelectOptions *options = GIMP_REGION_SELECT_TOOL_GET_OPTIONS (tool); GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE; if (! gimp_image_coords_in_active_pickable (display->image, coords, options->sample_merged, FALSE)) modifier = GIMP_CURSOR_MODIFIER_BAD; gimp_tool_control_set_cursor_modifier (tool->control, modifier); GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display); }
static void gimp_bucket_fill_tool_cursor_update (GimpTool *tool, const GimpCoords *coords, GdkModifierType state, GimpDisplay *display) { GimpBucketFillOptions *options = GIMP_BUCKET_FILL_TOOL_GET_OPTIONS (tool); GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_BAD; GimpImage *image = gimp_display_get_image (display); if (gimp_image_coords_in_active_pickable (image, coords, options->sample_merged, TRUE)) { 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))) { switch (options->fill_mode) { case GIMP_BUCKET_FILL_FG: modifier = GIMP_CURSOR_MODIFIER_FOREGROUND; break; case GIMP_BUCKET_FILL_BG: modifier = GIMP_CURSOR_MODIFIER_BACKGROUND; break; case GIMP_BUCKET_FILL_PATTERN: modifier = GIMP_CURSOR_MODIFIER_PATTERN; break; } } } gimp_tool_control_set_cursor_modifier (tool->control, modifier); GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display); }
static void gimp_flip_tool_cursor_update (GimpTool *tool, GimpCoords *coords, GdkModifierType state, GimpDisplay *display) { GimpFlipOptions *options = GIMP_FLIP_TOOL_GET_OPTIONS (tool); GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_BAD; if (gimp_image_coords_in_active_pickable (display->image, coords, FALSE, TRUE)) { modifier = GIMP_CURSOR_MODIFIER_NONE; } gimp_tool_control_set_cursor_modifier (tool->control, modifier); gimp_tool_control_set_toggle_cursor_modifier (tool->control, modifier); gimp_tool_control_set_toggled (tool->control, options->flip_type == GIMP_ORIENTATION_VERTICAL); GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display); }
static void gimp_bucket_fill_tool_button_release (GimpTool *tool, const GimpCoords *coords, guint32 time, GdkModifierType state, GimpButtonReleaseType release_type, GimpDisplay *display) { GimpBucketFillOptions *options = GIMP_BUCKET_FILL_TOOL_GET_OPTIONS (tool); GimpImage *image = gimp_display_get_image (display); if ((release_type == GIMP_BUTTON_RELEASE_CLICK || release_type == GIMP_BUTTON_RELEASE_NO_MOTION) && gimp_image_coords_in_active_pickable (image, coords, options->sample_merged, TRUE)) { GimpDrawable *drawable = gimp_image_get_active_drawable (image); GimpContext *context = GIMP_CONTEXT (options); gint x, y; GError *error = NULL; x = coords->x; y = coords->y; if (! options->sample_merged) { gint off_x, off_y; gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y); x -= off_x; y -= off_y; } if (! gimp_drawable_bucket_fill (drawable, context, options->fill_mode, gimp_context_get_paint_mode (context), gimp_context_get_opacity (context), ! options->fill_selection, options->fill_transparent, options->fill_criterion, options->threshold, options->sample_merged, x, y, &error)) { gimp_message_literal (display->gimp, G_OBJECT (display), GIMP_MESSAGE_WARNING, error->message); g_clear_error (&error); } else { gimp_image_flush (image); } } GIMP_TOOL_CLASS (parent_class)->button_release (tool, coords, time, state, release_type, display); tool->display = NULL; tool->drawable = NULL; }
static void gimp_perspective_clone_tool_cursor_update (GimpTool *tool, const GimpCoords *coords, GdkModifierType state, GimpDisplay *display) { GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool); GimpPerspectiveCloneOptions *options; GimpImage *image; GimpToolClass *tool_class; GimpCursorType cursor = GIMP_CURSOR_MOUSE; GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE; options = GIMP_PERSPECTIVE_CLONE_TOOL_GET_OPTIONS (tool); image = gimp_display_get_image (display); if (gimp_image_coords_in_active_pickable (image, coords, FALSE, TRUE)) { cursor = GIMP_CURSOR_MOUSE; } if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_ADJUST) { /* perspective cursors */ cursor = gimp_tool_control_get_cursor (tool->control); switch (clone_tool->function) { case TRANSFORM_HANDLE_NW: cursor = GIMP_CURSOR_CORNER_TOP_LEFT; break; case TRANSFORM_HANDLE_NE: cursor = GIMP_CURSOR_CORNER_TOP_RIGHT; break; case TRANSFORM_HANDLE_SW: cursor = GIMP_CURSOR_CORNER_BOTTOM_LEFT; break; case TRANSFORM_HANDLE_SE: cursor = GIMP_CURSOR_CORNER_BOTTOM_RIGHT; break; default: cursor = GIMP_CURSOR_CROSSHAIR_SMALL; break; } } else { GdkModifierType extend_mask = gimp_get_extend_selection_mask (); GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask (); if ((state & (toggle_mask | extend_mask)) == toggle_mask) { cursor = GIMP_CURSOR_CROSSHAIR_SMALL; } else if (! GIMP_SOURCE_CORE (GIMP_PAINT_TOOL (tool)->core)->src_drawable) { modifier = GIMP_CURSOR_MODIFIER_BAD; } } gimp_tool_control_set_cursor (tool->control, cursor); gimp_tool_control_set_cursor_modifier (tool->control, modifier); /* If we are in adjust mode, skip the GimpBrushClass when chaining up. * This ensures that the cursor will be set regardless of * GimpBrushTool::show_cursor (see bug #354933). */ if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_ADJUST) tool_class = GIMP_TOOL_CLASS (g_type_class_peek_parent (parent_class)); else tool_class = GIMP_TOOL_CLASS (parent_class); tool_class->cursor_update (tool, coords, state, display); }