Re: Core Animation geometry, layer hosting, and resolution independence
Re: Core Animation geometry, layer hosting, and resolution independence
- Subject: Re: Core Animation geometry, layer hosting, and resolution independence
- From: Nathan Vander Wilt <email@hidden>
- Date: Wed, 12 Mar 2008 16:49:23 -0500 (CDT)
--- Quincey Morris <email@hidden>
escribió:
> On Mar 12, 2008, at 13:13, Jens Alfke wrote:
>
> > On 12 Mar '08, at 12:13 PM, Nathan Vander Wilt
> wrote:
> >
> >> I want to be able to convert a mouse
> >> coordinate into a point suitable for
> -hitTest:'ing on
> >> my root layer. I can convert from the mouse
> >> coordinates to the view's coordinates, but then I
> am
> >> not sure how to proceed.
> >
> > There doesn't seem to be any API for converting
> between the
> > coordinates of a view and its root layer. You
> could probably do it
> > by getting the root layer's transform property,
> and then running the
> > point in view coordinates through that.
>
> Is this what the new NSView convertPointTo/FromBase:
> are for?
Aha! Yes, that does seem to be the solution. If I
change the hit testing in GeekGameBoard to:
CGPoint where = NSPointToCGPoint([self
convertPointToBase:[self convertPoint:
locationInWindow fromView: nil]]);
where = [_gameboard convertPoint: where fromLayer:
self.layer];
CALayer *layer = [_gameboard hitTest: where];
It works a bit better (there's still some dragging
issues to be cleaned up elsewhere, but picking up
cards is fixed.)
I don't understand what this "base" coordinate system
is (not the window's, otherwise the conversions would
likely be offset by the view's position therein,
right?). But whatever it is, it seems to be shared by
the CALayer. I'd appreciate a greater understanding of
all this, but those functions seem to be necessary for
any coordinate work in the layers that needs to relate
to the NSView world.
thanks,
-natevw
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
Regístrate ya - http://correo.espanol.yahoo.com/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden