Esempio n. 1
0
static gboolean
st_scroll_view_scroll_event (ClutterActor       *self,
                             ClutterScrollEvent *event)
{
  StScrollViewPrivate *priv = ST_SCROLL_VIEW (self)->priv;

  /* don't handle scroll events if requested not to */
  if (!priv->mouse_scroll)
    return FALSE;

  if (clutter_event_is_pointer_emulated ((ClutterEvent *) event))
    return TRUE;

  switch (event->direction)
    {
    case CLUTTER_SCROLL_SMOOTH:
      {
        gdouble delta_x, delta_y;
        clutter_event_get_scroll_delta ((ClutterEvent *)event, &delta_x, &delta_y);
        st_adjustment_adjust_for_scroll_event (priv->hadjustment, delta_x);
        st_adjustment_adjust_for_scroll_event (priv->vadjustment, delta_y);
      }
      break;
    case CLUTTER_SCROLL_UP:
    case CLUTTER_SCROLL_DOWN:
      adjust_with_direction (priv->vadjustment, event->direction);
      break;
    case CLUTTER_SCROLL_LEFT:
    case CLUTTER_SCROLL_RIGHT:
      adjust_with_direction (priv->hadjustment, event->direction);
      break;
    }

  return TRUE;
}
Esempio n. 2
0
static gboolean
st_scroll_bar_scroll_event (ClutterActor       *actor,
                            ClutterScrollEvent *event)
{
  StScrollBarPrivate *priv = ST_SCROLL_BAR (actor)->priv;

  if (clutter_event_is_pointer_emulated ((ClutterEvent *) event))
    return TRUE;

  switch (event->direction)
    {
    case CLUTTER_SCROLL_SMOOTH:
      {
        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_DOWN:
    case CLUTTER_SCROLL_LEFT:
    case CLUTTER_SCROLL_RIGHT:
      adjust_with_direction (priv->adjustment, event->direction);
      break;
    }

  return TRUE;
}
Esempio n. 3
0
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;
    }

  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);
      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_RIGHT:
      st_adjustment_set_value (priv->adjustment, value + step);
      break;
    }

  return TRUE;
}
Esempio n. 4
0
static gboolean
st_scroll_view_scroll_event (ClutterActor       *self,
                             ClutterScrollEvent *event)
{
  StScrollViewPrivate *priv = ST_SCROLL_VIEW (self)->priv;
  gdouble value, step, hvalue, vvalue, delta_x, delta_y;

  /* don't handle scroll events if requested not to */
  if (!priv->mouse_scroll)
    return FALSE;

  switch (event->direction)
    {
    case CLUTTER_SCROLL_SMOOTH:
      clutter_event_get_scroll_delta ((ClutterEvent *)event,
                                      &delta_x, &delta_y);
      g_object_get (priv->hadjustment,
                    "value", &hvalue,
                    NULL);
      g_object_get (priv->vadjustment,
                    "value", &vvalue,
                    NULL);
      break;
    case CLUTTER_SCROLL_UP:
    case CLUTTER_SCROLL_DOWN:
      g_object_get (priv->vadjustment,
                    "step-increment", &step,
                    "value", &value,
                    NULL);
      break;
    case CLUTTER_SCROLL_LEFT:
    case CLUTTER_SCROLL_RIGHT:
      g_object_get (priv->hadjustment,
                    "step-increment", &step,
                    "value", &value,
                    NULL);
      break;
    }

  switch (event->direction)
    {
    case CLUTTER_SCROLL_SMOOTH:
      st_adjustment_set_value (priv->hadjustment, hvalue + delta_x);
      st_adjustment_set_value (priv->vadjustment, vvalue + delta_y);
      break;
    case CLUTTER_SCROLL_UP:
      st_adjustment_set_value (priv->vadjustment, value - step);
      break;
    case CLUTTER_SCROLL_DOWN:
      st_adjustment_set_value (priv->vadjustment, value + step);
      break;
    case CLUTTER_SCROLL_LEFT:
      st_adjustment_set_value (priv->hadjustment, value - step);
      break;
    case CLUTTER_SCROLL_RIGHT:
      st_adjustment_set_value (priv->hadjustment, value + step);
      break;
    }

  return TRUE;
}