Commit f162dd7e authored by Jasper St. Pierre's avatar Jasper St. Pierre
Browse files

scroll-bar: Add smooth scrolling support

Do the same for StScrollBar.

https://bugzilla.gnome.org/show_bug.cgi?id=687573
parent 06dc12e2
......@@ -433,42 +433,57 @@ st_scroll_bar_constructor (GType type,
return obj;
}
static void
adjust_with_direction (StAdjustment *adj,
ClutterScrollDirection direction)
{
gdouble delta;
switch (direction)
{
case CLUTTER_SCROLL_UP:
case CLUTTER_SCROLL_LEFT:
delta = -1.0;
break;
case CLUTTER_SCROLL_RIGHT:
case CLUTTER_SCROLL_DOWN:
delta = 1.0;
break;
case CLUTTER_SCROLL_SMOOTH:
g_assert_not_reached ();
break;
}
st_adjustment_adjust_for_scroll_event (adj, delta);
}
static gboolean
st_scroll_bar_scroll_event (ClutterActor *actor,
ClutterScrollEvent *event)
{
StScrollBarPrivate *priv = ST_SCROLL_BAR (actor)->priv;
gdouble step, value, delta_x, delta_y;
if (priv->adjustment)
{
g_object_get (priv->adjustment,
"step-increment", &step,
"value", &value,
NULL);
}
else
{
return FALSE;
}
if (clutter_event_is_pointer_emulated ((ClutterEvent *) event))
return TRUE;
switch (event->direction)
{
case CLUTTER_SCROLL_SMOOTH:
clutter_event_get_scroll_delta ((ClutterEvent *)event,
&delta_x, &delta_y);
if (fabs (delta_x) > fabs (delta_y))
st_adjustment_set_value (priv->adjustment, value + delta_x);
else
st_adjustment_set_value (priv->adjustment, value + delta_y);
{
gdouble delta_x, delta_y;
clutter_event_get_scroll_delta ((ClutterEvent *)event, &delta_x, &delta_y);
if (priv->vertical)
st_adjustment_adjust_for_scroll_event (priv->adjustment, delta_y);
else
st_adjustment_adjust_for_scroll_event (priv->adjustment, delta_x);
}
break;
case CLUTTER_SCROLL_UP:
case CLUTTER_SCROLL_LEFT:
st_adjustment_set_value (priv->adjustment, value - step);
break;
case CLUTTER_SCROLL_DOWN:
case CLUTTER_SCROLL_LEFT:
case CLUTTER_SCROLL_RIGHT:
st_adjustment_set_value (priv->adjustment, value + step);
adjust_with_direction (priv->adjustment, event->direction);
break;
}
......
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