RE: iMovie-like sliding ready for drag
RE: iMovie-like sliding ready for drag
- Subject: RE: iMovie-like sliding ready for drag
- From: Keith Blount <email@hidden>
- Date: Mon, 4 Jul 2005 14:21:54 -0700 (PDT)
Many thanks to both of you for your replies - sorry
for taking a couple of days to thank you, but I wanted
to test this out first and finally got the chance
today.
The NSTimer idea seems to work nicely. I've only tried
it in a test app so far, firing the animation with
buttons, and have yet to sit down and figure out the
details for firing it on drops from drags, but that
should (hopefully) just be down to details. All I'm
doing currently is exactly as Josh suggested - firing
of a timer, which calls a method that moves my card
rectangles (the card rectangles aren't even views,
just an array of NSRects that are used to draw
information). So I just adjust the horizontal origins
and then call setNeedsDisplay: each time the timer
method is called, and then invalidate the timer when I
get to the desired position. This seems okay.
As SA Dev points out, the hard part is going to be
working out when to stop and restart sliding movements
when the pointer moves, invalidating the timer and
then moving the rects from where they are.
Many thanks again for the help,
Keith
--- Josh Ferguson <email@hidden> wrote:
> 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 You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.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