button/widget: don't rely on private variables to track hover state
The way MxWidget tracks the hover state is wrong, because it can be overridden by a subclass. Therefor we should rely on the styling state which is shared amongst all subclasses. Also, when setting the tooltip text, display the tooltip if the widget is already hovered.
This commit is contained in:
parent
2ea22b7a6e
commit
35e71d4507
|
@ -90,7 +90,6 @@ struct _MxButtonPrivate
|
|||
guint8 old_opacity;
|
||||
|
||||
guint is_pressed : 1;
|
||||
guint is_hover : 1;
|
||||
guint is_toggle : 1;
|
||||
guint is_toggled : 1;
|
||||
|
||||
|
@ -395,7 +394,6 @@ static gboolean
|
|||
mx_button_enter (ClutterActor *actor,
|
||||
ClutterCrossingEvent *event)
|
||||
{
|
||||
MxButton *button = MX_BUTTON (actor);
|
||||
MxWidget *widget = MX_WIDGET (actor);
|
||||
|
||||
if (event->source != actor)
|
||||
|
@ -408,8 +406,6 @@ mx_button_enter (ClutterActor *actor,
|
|||
|
||||
mx_stylable_style_pseudo_class_add (MX_STYLABLE (widget), "hover");
|
||||
|
||||
button->priv->is_hover = 1;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -431,9 +427,6 @@ mx_button_leave (ClutterActor *actor,
|
|||
if (mx_widget_get_disabled (MX_WIDGET (actor)))
|
||||
return FALSE;
|
||||
|
||||
|
||||
button->priv->is_hover = 0;
|
||||
|
||||
if (button->priv->is_pressed)
|
||||
{
|
||||
//clutter_ungrab_pointer ();
|
||||
|
|
|
@ -63,7 +63,6 @@ struct _MxWidgetPrivate
|
|||
ClutterActor *background_image;
|
||||
ClutterColor *bg_color;
|
||||
|
||||
guint is_hovered : 1;
|
||||
guint is_disabled : 1;
|
||||
guint parent_disabled : 1;
|
||||
|
||||
|
@ -793,13 +792,11 @@ mx_widget_enter (ClutterActor *actor,
|
|||
ClutterCrossingEvent *event)
|
||||
{
|
||||
MxWidget *widget = MX_WIDGET (actor);
|
||||
MxWidgetPrivate *priv = widget->priv;
|
||||
|
||||
/* This is also expected to handle enter events from child actors
|
||||
because they will bubble up */
|
||||
|
||||
mx_stylable_style_pseudo_class_add (MX_STYLABLE (widget), "hover");
|
||||
priv->is_hovered = TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -809,7 +806,6 @@ mx_widget_leave (ClutterActor *actor,
|
|||
ClutterCrossingEvent *event)
|
||||
{
|
||||
MxWidget *widget = MX_WIDGET (actor);
|
||||
MxWidgetPrivate *priv = widget->priv;
|
||||
|
||||
/* If the leave event is simply moving to a child actor then we'll
|
||||
ignore it so that the actor will retain its hover state until the
|
||||
|
@ -823,7 +819,6 @@ mx_widget_leave (ClutterActor *actor,
|
|||
mx_widget_long_press_cancel (widget);
|
||||
mx_stylable_style_pseudo_class_remove (MX_STYLABLE (widget), "active");
|
||||
mx_stylable_style_pseudo_class_remove (MX_STYLABLE (widget), "hover");
|
||||
priv->is_hovered = FALSE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1457,6 +1452,8 @@ mx_widget_set_has_tooltip (MxWidget *widget,
|
|||
{
|
||||
priv->tooltip = g_object_new (MX_TYPE_TOOLTIP, NULL);
|
||||
clutter_actor_set_parent (CLUTTER_ACTOR (priv->tooltip), actor);
|
||||
if (mx_stylable_style_pseudo_class_contains (MX_STYLABLE (widget), "hover"))
|
||||
mx_widget_show_tooltip (widget);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue