• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: iMovie-like sliding ready for drag
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iMovie-like sliding ready for drag


  • Subject: Re: iMovie-like sliding ready for drag
  • From: SA Dev <email@hidden>
  • Date: Tue, 5 Jul 2005 10:30:03 -0400

Keith:

Josh's post sort of answers this. It makes perfect sense to make it a time-based calculation. This way, when the pointer moves, just restart the timer. Wherever everything's sitting at that point, all you care about is the (easily calculated) destination, so simply restarting the animation timer (using Josh's example) would 'automagically' begin sliding everything to the new configuration no matter where you were in the last sequence.

I also like the time-based solution for performance reasons. Instead of forcing the system to go through every step, slower systems that can't move fast enough will just 'skip' parts or all of the animation. I like to consider myself fairly advanced, but animation tricks elude me and I can't believe I didn't consider going that way before.

If you get something working, please do share. This is something a lot of developers are looking to do with a lot of different types of applications.



On Jul 4, 2005, at 5:21 PM, Keith Blount wrote:

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:


source.org


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
References: 
 >RE: iMovie-like sliding ready for drag (From: Keith Blount <email@hidden>)

  • Prev by Date: Reading & writing Exif data with Cocoa
  • Next by Date: Re: NSTask Question
  • Previous by thread: RE: iMovie-like sliding ready for drag
  • Next by thread: Core Data docs clarification...
  • Index(es):
    • Date
    • Thread