RE: iMovie-like sliding ready for drag
RE: iMovie-like sliding ready for drag
- Subject: RE: iMovie-like sliding ready for drag
- From: "Josh Ferguson" <email@hidden>
- Date: Fri, 1 Jul 2005 15:40:21 -0500
- Thread-topic: iMovie-like sliding ready for drag
Keith,
In my experience with OpenGL animation, what you'd want to do is set up
a timer for your drawRect method. Have the timer fire drawRect at a
given interval (.10 seconds, for example). In your drawRect function,
you can calculate your movement based on the distance to your final
destination from the start position and total time elapsed (which would
also require you store the animation start time).
Each loop through, determine how much time has passed since the
animation started. Use that to determine a total fraction of the move.
In other words, lets say you want the move to take half a second - then
after .25 seconds have elapsed, your card should be half-way between the
start point and destination point. After .5 seconds have elapsed, the
move should be complete and you can stop the time. In algorithmic terms,
(total animation time)/(time elapsed since start) = (fraction of move
completed)...then, used (fraction of move completed) to determine its
position between the start point and the end point.
I don't have any sage knowledge about this - just real world problems
that I've had to solve myself - so I don't know if my implementation is
"correct" or not. There may be (and probably is) a better way to
accomplish this.
Josh Ferguson
-----Original Message-----
From: cocoa-dev-bounces+josh=email@hidden
[mailto:cocoa-dev-bounces+josh=email@hidden] On
Behalf Of Keith Blount
Sent: Friday, July 01, 2005 2:48 PM
To: email@hidden
Subject: Re: iMovie-like sliding ready for drag
I didn't think I'd get much response to this given
that it's a FUQ (Frequently Unanswered Question). :) I
am thinking of giving up on this for now as it is
really just eye-candy when I should be concentrating
on functionality at this stage, but if anyone does
have any pointers, I would be really grateful. For
instance, I don't even know whether I would have to
dig into Quartz etc to achieve this, or whether I
would just set up a timer to increment the placement
of the image of the "card" over a few seconds (but
then, wouldn't this result in the spinning beach ball
as the single-thread locks up in animation?).
Any help much appreciated (but maybe I should put this
on my future list),
All the best,
Keith
--- ORIGINAL MESSAGE ---
Hello,
Having searched the archives, Cocoadev and Google, I
know that this is a question that has been frequently
asked, but I have yet to find an answer.
I have a storyboard view that contains a row of
"cards", much like the clip tray in iMovie. Like in
iMovie, whenever the user drags a card between two
other cards, I would like the cards to slide apart to
allow room for the one that is being dropped.
Does anybody have any ideas on what the best approach
to this would be? Do I need to explore NSAnimation, or
can I set up a simple timer and just keep redrawing in
drawRect: as soon as my view detects a potential mouse
operation? I think my problem is that I don't know
where to look - I've never handled any kind of
animation in Cocoa before, so just some pointers would
be really appreciated.
Many thanks in advance,
Keith
____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden