On Tue, 2008-08-19 at 11:54 +1000, Saul Lethbridge wrote:
> I'm wanting the user to be able to zoom in and out of my stage (using
> the scroll button on the mouse), what would be the best and most
> efficient way of doing this?

Hook on to the 'captured-event' signal of the stage;

[code]
g_signal_connect (clutter_stage_get_default (), "captured-event",
G_CALLBACK (your_callback), your_data);
[/code]

And if the event type is CLUTTER_SCROLL, set the scale of the stage:

[code]
static gboolean
your_callback (ClutterActor *stage, ClutterEvent *event, gpointer
your_data)
{
  gdouble scale_x, scale_y;
  ClutterScrollEvent *scroll_event;

  if (event->type != CLUTTER_SCROLL)
    return FALSE;

  scroll_event = (ClutterScrollEvent *)event;
  clutter_actor_get_scale (stage, &scale_x, &scale_y);
  if (scroll_event->direction == CLUTTER_SCROLL_UP)
    clutter_actor_set_scale (stage, scale_x + 0.1, scale_y + 0.1);
  else if (scroll_event->direction == CLUTTER_SCROLL_DOWN)
    clutter_actor_set_scale (stage, scale_x - 0.1, scale_y - 0.1);

  return TRUE;
}
[/code]

Note that I've not tried this code, so it may not work... Also,
adjusting the scale properties linearly may not produce the results you
intend (instead, you may want to multiply scale_x/scale_y, or have
preset values). Also, you'll want to put upper/lower bounds on the
values they can take too.

Hope that helps,

--Chris


-- 
To unsubscribe send a mail to [EMAIL PROTECTED]

Reply via email to