app: implement GimpToolWidget::leave_notify() in various tool widgets

... by having them disable item highlights, and any other proximity
indication, when the cursor leaves the widget.
This commit is contained in:
Ell 2018-06-02 01:50:50 -04:00
parent be7eff980e
commit 5e736c697f
6 changed files with 109 additions and 7 deletions

View File

@ -134,6 +134,7 @@ static void gimp_tool_compass_hover (GimpToolWidget *widget
const GimpCoords *coords,
GdkModifierType state,
gboolean proximity);
static void gimp_tool_compass_leave_notify (GimpToolWidget *widget);
static void gimp_tool_compass_motion_modifier (GimpToolWidget *widget,
GdkModifierType key,
gboolean press,
@ -170,6 +171,7 @@ gimp_tool_compass_class_init (GimpToolCompassClass *klass)
widget_class->button_release = gimp_tool_compass_button_release;
widget_class->motion = gimp_tool_compass_motion;
widget_class->hover = gimp_tool_compass_hover;
widget_class->leave_notify = gimp_tool_compass_leave_notify;
widget_class->motion_modifier = gimp_tool_compass_motion_modifier;
widget_class->get_cursor = gimp_tool_compass_get_cursor;
@ -886,6 +888,22 @@ gimp_tool_compass_hover (GimpToolWidget *widget,
}
}
void
gimp_tool_compass_leave_notify (GimpToolWidget *widget)
{
GimpToolCompass *compass = GIMP_TOOL_COMPASS (widget);
GimpToolCompassPrivate *private = compass->private;
if (private->point != -1)
{
private->point = -1;
gimp_tool_compass_update_hilight (compass);
}
GIMP_TOOL_WIDGET_CLASS (parent_class)->leave_notify (widget);
}
static void
gimp_tool_compass_motion_modifier (GimpToolWidget *widget,
GdkModifierType key,

View File

@ -78,6 +78,7 @@ struct _GimpToolHandleGridPrivate
gdouble last_x;
gdouble last_y;
gboolean hover;
gdouble mouse_x;
gdouble mouse_y;
@ -116,6 +117,7 @@ static void gimp_tool_handle_grid_hover (GimpToolWidget *widge
const GimpCoords *coords,
GdkModifierType state,
gboolean proximity);
static void gimp_tool_handle_grid_leave_notify (GimpToolWidget *widget);
static gboolean gimp_tool_handle_grid_get_cursor (GimpToolWidget *widget,
const GimpCoords *coords,
GdkModifierType state,
@ -168,6 +170,7 @@ gimp_tool_handle_grid_class_init (GimpToolHandleGridClass *klass)
widget_class->button_release = gimp_tool_handle_grid_button_release;
widget_class->motion = gimp_tool_handle_grid_motion;
widget_class->hover = gimp_tool_handle_grid_hover;
widget_class->leave_notify = gimp_tool_handle_grid_leave_notify;
widget_class->get_cursor = gimp_tool_handle_grid_get_cursor;
g_object_class_install_property (object_class, PROP_HANDLE_MODE,
@ -803,6 +806,7 @@ gimp_tool_handle_grid_hover (GimpToolWidget *widget,
gchar *status = NULL;
gint i;
private->hover = TRUE;
private->mouse_x = coords->x;
private->mouse_y = coords->y;
@ -876,6 +880,20 @@ gimp_tool_handle_grid_hover (GimpToolWidget *widget,
gimp_tool_handle_grid_update_hilight (grid);
}
static void
gimp_tool_handle_grid_leave_notify (GimpToolWidget *widget)
{
GimpToolHandleGrid *grid = GIMP_TOOL_HANDLE_GRID (widget);
GimpToolHandleGridPrivate *private = grid->private;
private->hover = FALSE;
private->handle = 0;
gimp_tool_handle_grid_update_hilight (grid);
GIMP_TOOL_WIDGET_CLASS (parent_class)->leave_notify (widget);
}
static gboolean
gimp_tool_handle_grid_get_cursor (GimpToolWidget *widget,
const GimpCoords *coords,
@ -951,12 +969,17 @@ gimp_tool_handle_grid_update_hilight (GimpToolHandleGrid *grid)
if (item)
{
gdouble diameter =
gimp_canvas_handle_calc_size (item,
private->mouse_x,
private->mouse_y,
GIMP_CANVAS_HANDLE_SIZE_CIRCLE,
2 * GIMP_CANVAS_HANDLE_SIZE_CIRCLE);
gdouble diameter = GIMP_CANVAS_HANDLE_SIZE_CIRCLE;
if (private->hover)
{
diameter = gimp_canvas_handle_calc_size (
item,
private->mouse_x,
private->mouse_y,
GIMP_CANVAS_HANDLE_SIZE_CIRCLE,
2 * GIMP_CANVAS_HANDLE_SIZE_CIRCLE);
}
gimp_canvas_handle_set_size (item, diameter, diameter);
gimp_canvas_item_set_highlight (item, (i + 1) == private->handle);

View File

@ -158,6 +158,7 @@ static void gimp_tool_line_hover (GimpToolWidget *widget,
const GimpCoords *coords,
GdkModifierType state,
gboolean proximity);
static void gimp_tool_line_leave_notify (GimpToolWidget *widget);
static gboolean gimp_tool_line_key_press (GimpToolWidget *widget,
GdkEventKey *kevent);
static void gimp_tool_line_motion_modifier (GimpToolWidget *widget,
@ -224,6 +225,7 @@ gimp_tool_line_class_init (GimpToolLineClass *klass)
widget_class->button_release = gimp_tool_line_button_release;
widget_class->motion = gimp_tool_line_motion;
widget_class->hover = gimp_tool_line_hover;
widget_class->leave_notify = gimp_tool_line_leave_notify;
widget_class->key_press = gimp_tool_line_key_press;
widget_class->motion_modifier = gimp_tool_line_motion_modifier;
widget_class->get_cursor = gimp_tool_line_get_cursor;
@ -896,6 +898,20 @@ gimp_tool_line_hover (GimpToolWidget *widget,
gimp_tool_line_update_status (line, state, proximity);
}
static void
gimp_tool_line_leave_notify (GimpToolWidget *widget)
{
GimpToolLine *line = GIMP_TOOL_LINE (widget);
GimpToolLinePrivate *private = line->private;
private->hover = GIMP_TOOL_LINE_HANDLE_NONE;
gimp_tool_line_update_handles (line);
gimp_tool_line_update_circle (line);
GIMP_TOOL_WIDGET_CLASS (parent_class)->leave_notify (widget);
}
static gboolean
gimp_tool_line_key_press (GimpToolWidget *widget,
GdkEventKey *kevent)

View File

@ -115,6 +115,7 @@ struct _GimpToolPolygonPrivate
gboolean supress_handles;
/* Last _oper_update or _motion coords */
gboolean hover;
GimpVector2 last_coords;
/* A double-click commits the selection, keep track of last
@ -165,6 +166,7 @@ static void gimp_tool_polygon_hover (GimpToolWidget *widget
const GimpCoords *coords,
GdkModifierType state,
gboolean proximity);
static void gimp_tool_polygon_leave_notify (GimpToolWidget *widget);
static gboolean gimp_tool_polygon_key_press (GimpToolWidget *widget,
GdkEventKey *kevent);
static void gimp_tool_polygon_motion_modifier (GimpToolWidget *widget,
@ -206,6 +208,7 @@ gimp_tool_polygon_class_init (GimpToolPolygonClass *klass)
widget_class->button_release = gimp_tool_polygon_button_release;
widget_class->motion = gimp_tool_polygon_motion;
widget_class->hover = gimp_tool_polygon_hover;
widget_class->leave_notify = gimp_tool_polygon_leave_notify;
widget_class->key_press = gimp_tool_polygon_key_press;
widget_class->motion_modifier = gimp_tool_polygon_motion_modifier;
widget_class->hover_modifier = gimp_tool_polygon_hover_modifier;
@ -956,7 +959,8 @@ gimp_tool_polygon_changed (GimpToolWidget *widget)
handle = g_ptr_array_index (private->handles, i);
point = &private->points[private->segment_indices[i]];
if (handles_wants_to_show &&
if (private->hover &&
handles_wants_to_show &&
! private->supress_handles &&
/* If the first point is hovered while button1 is held down,
@ -1197,6 +1201,7 @@ gimp_tool_polygon_hover (GimpToolWidget *widget,
gboolean hovering_first_point;
priv->grabbed_segment_index = INVALID_INDEX;
priv->hover = TRUE;
if (! priv->supress_handles)
{
@ -1280,6 +1285,19 @@ gimp_tool_polygon_hover (GimpToolWidget *widget,
gimp_tool_polygon_changed (widget);
}
static void
gimp_tool_polygon_leave_notify (GimpToolWidget *widget)
{
GimpToolPolygon *polygon = GIMP_TOOL_POLYGON (widget);
GimpToolPolygonPrivate *priv = polygon->private;
priv->grabbed_segment_index = INVALID_INDEX;
priv->hover = FALSE;
priv->show_pending_point = FALSE;
gimp_tool_polygon_changed (widget);
}
static gboolean
gimp_tool_polygon_key_press (GimpToolWidget *widget,
GdkEventKey *kevent)

View File

@ -305,6 +305,7 @@ static void gimp_tool_rectangle_hover (GimpToolWidget *widg
const GimpCoords *coords,
GdkModifierType state,
gboolean proximity);
static void gimp_tool_rectangle_leave_notify (GimpToolWidget *widget);
static gboolean gimp_tool_rectangle_key_press (GimpToolWidget *widget,
GdkEventKey *kevent);
static void gimp_tool_rectangle_motion_modifier (GimpToolWidget *widget,
@ -449,6 +450,7 @@ gimp_tool_rectangle_class_init (GimpToolRectangleClass *klass)
widget_class->button_release = gimp_tool_rectangle_button_release;
widget_class->motion = gimp_tool_rectangle_motion;
widget_class->hover = gimp_tool_rectangle_hover;
widget_class->leave_notify = gimp_tool_rectangle_leave_notify;
widget_class->key_press = gimp_tool_rectangle_key_press;
widget_class->motion_modifier = gimp_tool_rectangle_motion_modifier;
widget_class->get_cursor = gimp_tool_rectangle_get_cursor;
@ -1747,6 +1749,16 @@ gimp_tool_rectangle_hover (GimpToolWidget *widget,
gimp_tool_rectangle_set_function (rectangle, function);
}
static void
gimp_tool_rectangle_leave_notify (GimpToolWidget *widget)
{
GimpToolRectangle *rectangle = GIMP_TOOL_RECTANGLE (widget);
gimp_tool_rectangle_set_function (rectangle, GIMP_TOOL_RECTANGLE_DEAD);
GIMP_TOOL_WIDGET_CLASS (parent_class)->leave_notify (widget);
}
static gboolean
gimp_tool_rectangle_key_press (GimpToolWidget *widget,
GdkEventKey *kevent)

View File

@ -177,6 +177,7 @@ static void gimp_tool_transform_grid_hover (GimpToolWidget *
const GimpCoords *coords,
GdkModifierType state,
gboolean proximity);
static void gimp_tool_transform_grid_leave_notify (GimpToolWidget *widget);
static void gimp_tool_transform_grid_hover_modifier (GimpToolWidget *widget,
GdkModifierType key,
gboolean press,
@ -217,6 +218,7 @@ gimp_tool_transform_grid_class_init (GimpToolTransformGridClass *klass)
widget_class->button_release = gimp_tool_transform_grid_button_release;
widget_class->motion = gimp_tool_transform_grid_motion;
widget_class->hover = gimp_tool_transform_grid_hover;
widget_class->leave_notify = gimp_tool_transform_grid_leave_notify;
widget_class->hover_modifier = gimp_tool_transform_grid_hover_modifier;
widget_class->get_cursor = gimp_tool_transform_grid_get_cursor;
@ -1970,6 +1972,19 @@ gimp_tool_transform_grid_hover (GimpToolWidget *widget,
gimp_tool_transform_grid_update_hilight (grid);
}
void
gimp_tool_transform_grid_leave_notify (GimpToolWidget *widget)
{
GimpToolTransformGrid *grid = GIMP_TOOL_TRANSFORM_GRID (widget);
GimpToolTransformGridPrivate *private = grid->private;
private->handle = GIMP_TRANSFORM_HANDLE_NONE;
gimp_tool_transform_grid_update_hilight (grid);
GIMP_TOOL_WIDGET_CLASS (parent_class)->leave_notify (widget);
}
static void
gimp_tool_transform_grid_modifier (GimpToolWidget *widget,
GdkModifierType key)