Proper way to implement zoom in CA?

  • (I sent this message to the Quartz list and didn't get any response.
    Given that this list is higher traffic and seems to be talking about
    CA I'm reposting it here.)

    I wrote an application under OpenGL under Tiger that I have been
    porting to CoreAnimation over the last four months. I basically found
    that the GL engine I was writing replicated most of the  layering
    functionality of CoreAnimation, so it was just easier to move the
    project entirely over. (And implicit animations are pretty...)

    My experience so far with CoreAnimation has been good, but the one
    thing I have never really gotten working again is zoom. In my OpenGL
    version, I would simply change the bounds of the gl viewport in order
    to change the scale of the entire composition.

    CoreAnimation seems to have a facility to do something similar using
    setBounds and autoresizingMask, but so far I haven't gotten it
    working. I set my sublayers resizing mask for width and height, and
    then adjust the bounds of the parent layer, and my layers don't
    actually draw at the correct size.

    The admittedly cheap hack I've been using in the mean time is simply
    doing a 3D transform and pushing the layer forward or away on the Z
    axis. I have a few issues with this approach. First, layers don't
    redraw with new bounds when I zoom in. So when I zoom in to layers
    that are drawn on the fly, they are all pixelated because they are
    still being drawn at a 1.0 scale bounds. The second issue is that
    there are some layers that I would like not to scale. It seems like
    the setBounds/autoresizingMask route would also address this, as it
    looks like I can adjust scaling behavior on a per layer basis.

    I'm hoping all of this makes sense to someone. :) I'm just looking for
    a few pointers if anyone else has run into this issue.

    Thanks,
    Colin
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today