forked from AuroraMiddleware/gtk
range: simplify code
Instead of directly accessing the widget allocation, we can use the gadget API to test whether the coordinates are in the main gadget.
This commit is contained in:
parent
622f5aef4e
commit
2d2a81682d
@ -3390,18 +3390,11 @@ gtk_range_move_slider (GtkRange *range,
|
|||||||
gtk_widget_error_bell (GTK_WIDGET (range));
|
gtk_widget_error_bell (GTK_WIDGET (range));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define POINT_IN_RECT(xcoord, ycoord, rect) \
|
|
||||||
((xcoord) >= (rect).x && \
|
|
||||||
(xcoord) < ((rect).x + (rect).width) && \
|
|
||||||
(ycoord) >= (rect).y && \
|
|
||||||
(ycoord) < ((rect).y + (rect).height))
|
|
||||||
|
|
||||||
/* Update mouse location, return TRUE if it changes */
|
/* Update mouse location, return TRUE if it changes */
|
||||||
static void
|
static void
|
||||||
gtk_range_update_mouse_location (GtkRange *range)
|
gtk_range_update_mouse_location (GtkRange *range)
|
||||||
{
|
{
|
||||||
GtkRangePrivate *priv = range->priv;
|
GtkRangePrivate *priv = range->priv;
|
||||||
GtkAllocation allocation;
|
|
||||||
gint x, y;
|
gint x, y;
|
||||||
MouseLocation old;
|
MouseLocation old;
|
||||||
GtkWidget *widget = GTK_WIDGET (range);
|
GtkWidget *widget = GTK_WIDGET (range);
|
||||||
@ -3411,8 +3404,6 @@ gtk_range_update_mouse_location (GtkRange *range)
|
|||||||
x = priv->mouse_x;
|
x = priv->mouse_x;
|
||||||
y = priv->mouse_y;
|
y = priv->mouse_y;
|
||||||
|
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
|
||||||
|
|
||||||
if (priv->grab_location != MOUSE_OUTSIDE)
|
if (priv->grab_location != MOUSE_OUTSIDE)
|
||||||
priv->mouse_location = priv->grab_location;
|
priv->mouse_location = priv->grab_location;
|
||||||
else if (priv->stepper_a_gadget &&
|
else if (priv->stepper_a_gadget &&
|
||||||
@ -3431,7 +3422,7 @@ gtk_range_update_mouse_location (GtkRange *range)
|
|||||||
priv->mouse_location = MOUSE_SLIDER;
|
priv->mouse_location = MOUSE_SLIDER;
|
||||||
else if (gtk_css_gadget_content_box_contains_point (priv->trough_gadget, x, y))
|
else if (gtk_css_gadget_content_box_contains_point (priv->trough_gadget, x, y))
|
||||||
priv->mouse_location = MOUSE_TROUGH;
|
priv->mouse_location = MOUSE_TROUGH;
|
||||||
else if (POINT_IN_RECT (x, y, allocation))
|
else if (gtk_css_gadget_margin_box_contains_point (priv->gadget, x, y))
|
||||||
priv->mouse_location = MOUSE_WIDGET;
|
priv->mouse_location = MOUSE_WIDGET;
|
||||||
else
|
else
|
||||||
priv->mouse_location = MOUSE_OUTSIDE;
|
priv->mouse_location = MOUSE_OUTSIDE;
|
||||||
|
Loading…
Reference in New Issue
Block a user