Re: Core Animation and NSImageView
Re: Core Animation and NSImageView
- Subject: Re: Core Animation and NSImageView
- From: Bill Dudney <email@hidden>
- Date: Thu, 24 Jan 2008 07:47:08 -0700
Hi Mário,
I'm not sure I understand your question. Let me try to rephrase as I
understand it and answer what I think you are asking, if I'm way off
base ping back.
You have an image view that you are trying to animate growing and
shrinking as well as switching the image?
Animating the resize is a snap;
[[myimageview animator] setFrame:newFrame];
Animating the image change however is not so straight forward with
NSImageView.
If you wanted to move to a layer hosting view (as opposed to a layer
backed view) you would get animation (default fade transition) from
calling myLayer.contents = newImage but that requires a bunch of other
stuff (CGImageRef instead of NSIMage etc).
I think an easier solution would be to have 2 image views one small
with the small image, one large with the large image.
When the button is clicked replace one image view with the other;
[[myContainerView animator] replaceSubview:view1 with:view2];
as long as myContainerView is layer backed (the check box in IB) this
will perform the default fade transition animation.
This will not animate the size transition though. I think to get both
you are going to have to go to layer hosting views and create some
layers of your own.
HTH,
-bd-
http://bill.dudney.net/roller/objc
On Jan 23, 2008, at 7:29 PM, Mário Freitas wrote:
Hi there,I have a problem with an application when I enable Core
Animation.
Basically, I have a HUD window, a tab view, a button and a
NSImageView. When
I click the button, I raise an action on the application controller
which
basically does the following:
[imageview setImage:toggle_image];
[imageview setFrame:toggle_rect];
[imageview setToolTip:toggle_tooltip];
When I click the button I want to toggle the
frame, image, and tooltip depending on 2 states. In the 1st state
(initial) the image is smaller and in the 2nd state it's bigger. The
origin of the image view is also repositioned.
An illustration of the 2 frame configurations would be:
|x| (width = 10, height = 10, x origin = 30, y origin = 0) 1st
state
|xxxx| (width = 40, height = 10, x origin = 0, y origin = 0) 2nd state
Actually, this works great when core animation is disabled. However,
When I'm using core animation on a tab view which embeds the picture,
this doesn't work as expected: the first transition (1->2) works
nicely, but not the next (2->1). If I reverse the order, the first
transition (2->1) doesn't work. By "doesn't work as expected" I mean
the image and tooltips are correctly toggled but not the image frame.
When the frame becomes bigger (2->1), the frame
is
constantly kept _visually_ at this size in the following clicks and
never reduces
to the small size. One "interesting" thing
I've noticed is that, although the image is kept constant (in big
size), the tool tip only appears If I position the cursor in the area
where it would be considered correct (
e.g., after a 2->1 transition, the image frame is incorrectly kept big
but the the tooltip
only appears as if the frame would be correctly changed to small).
At first
I thought this would be related to "dirty" screen buffers but that
wouldn't
be possible since the image is updated all over the (incorrect)
frame size.
Even so, I tried forcing the drawing on the NSImageView and tab view
but
didn't produce any effect.
Although I haven't tried,
I believe that instead of using the same NSImageView I could use 2 for
the 2 different states, but still it doesn't make sense for me why
this isn't working.
Any hints?
Thanks in advance,
Mário Freitas
_______________________________________________
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
_______________________________________________
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