How to implement window fade-in fade-out effects

  • Hello List,

      I need someone to push me in the right direction as I have no idea
    where to start:

    I have an existing window which I'd like to show and hide using a
    zooming transition effect. I'd like something similar to the one in
    iCal (on Leopard) when you double click a calendar entry or in Finder
    when you press SPACE on an item an the QuickLook window becomes
    visible (same for hiding). How does one go about that?

    I'm on 10.5.3 and I'm targeting 10.5. Right now I'm showing the window
    using orderFrontAndMakeKey: and orderOut:

    Thanks for any pointers.
    --
  • On Jun 4, 2008, at 2:01 , Markus Spoettl wrote:

    > Hello List,
    >
    > I need someone to push me in the right direction as I have no idea
    > where to start:
    >
    > I have an existing window which I'd like to show and hide using a
    > zooming transition effect. I'd like something similar to the one in
    > iCal (on Leopard) when you double click a calendar entry or in
    > Finder when you press SPACE on an item an the QuickLook window
    > becomes visible (same for hiding). How does one go about that?
    >
    > I'm on 10.5.3 and I'm targeting 10.5. Right now I'm showing the
    > window using orderFrontAndMakeKey: and orderOut:

    The window's frame is an animatable property, so you could try
    something like this:

    - (void)showWindow:(id)window
    {
    NSRect startFrom = NSZeroRect;
    NSRect endAt = [window frame];
    CGFloat duration = 5.0;

    [window setFrame:startFrom display:NO];
    [window orderFrontAndMakeKey:nil];

    [NSAnimationContext beginGrouping];
    [[NSAnimationContext currentContext] setDuration:duration];

    [[window animator] setFrame:endAt display:YES];

    [NSAnimationContext endGrouping];
    }

    /brian
  • On Jun 3, 2008, at 11:25 PM, Brian Christensen wrote:
    > On Jun 4, 2008, at 2:01 , Markus Spoettl wrote:
    > The window's frame is an animatable property, so you could try
    > something like this:

    WOW that is very impressive. I didn't imagine it was that easy, thanks
    so much for the quick help!

    Regards
    Markus
    --
  • On Jun 4, 2008, at 2:13 AM, Markus Spoettl wrote:

    > On Jun 3, 2008, at 11:25 PM, Brian Christensen wrote:
    >> On Jun 4, 2008, at 2:01 , Markus Spoettl wrote:
    >> The window's frame is an animatable property, so you could try
    >> something like this:
    >
    >
    > WOW that is very impressive. I didn't imagine it was that easy,
    > thanks so much for the quick help!

    There's actually an even simpler method which predates Core Animation,
    setFrame:display:animate:.

    Cheers,
    Ken
  • Just curious if some frameworks have been thought of for Animation. In
    the likes of Jquery or others. For example
    window.show(fade_in, slow);

    That way animations can be very clean and simple to write and test.
  • Le 4 juin 08 à 16:10, colo a écrit :

    > Just curious if some frameworks have been thought of for Animation. In
    > the likes of Jquery or others. For example
    > window.show(fade_in, slow);
    >
    > That way animations can be very clean and simple to write and test.

    Isn't what CoreAnimation does ?
  • On Wed, Jun 4, 2008 at 7:10 AM, colo <colo0logo...> wrote:
    > Just curious if some frameworks have been thought of for Animation. In
    > the likes of Jquery or others. For example
    > window.show(fade_in, slow);
    >
    > That way animations can be very clean and simple to write and test.

    Core Animation available on Mac OS X 10.5 and later.

    <http://www.apple.com/macosx/technology/coreanimation.html>
    <http://developer.apple.com/graphicsimaging/coreanimation/>

    -Shawn
  • On 6/3/08 11:01 PM, Markus Spoettl said:

    > I have an existing window which I'd like to show and hide using a
    > zooming transition effect. I'd like something similar to the one in
    > iCal (on Leopard) when you double click a calendar entry or in Finder
    > when you press SPACE on an item an the QuickLook window becomes
    > visible (same for hiding). How does one go about that?

    Carbon has an API that does this: TransitionWindow().  You can take a
    look at its docs.  It supports the genie effect and others.  There is no
    equivalent Cocoa API.

    Matt Ball wrote some Cocoa code that uses this:
    <http://www.mattballdesign.com/code/>

    Alas, TransitionWindow() is deprecated and not available in 64.  So
    really I don't recommend it.

    --
    ____________________________________________________________
    Sean McBride, B. Eng                <sean...>
    Rogue Research                        www.rogue-research.com
    Mac Software Developer              Montréal, Québec, Canada
  • On 6/4/08 2:25 AM, Brian Christensen said:

    > The window's frame is an animatable property, so you could try
    > something like this:
    >
    > - (void)showWindow:(id)window
    > {
    > NSRect startFrom = NSZeroRect;
    > NSRect endAt = [window frame];
    > CGFloat duration = 5.0;
    >
    > [window setFrame:startFrom display:NO];
    > [window orderFrontAndMakeKey:nil];
    >
    > [NSAnimationContext beginGrouping];
    > [[NSAnimationContext currentContext] setDuration:duration];
    >
    > [[window animator] setFrame:endAt display:YES];
    >
    > [NSAnimationContext endGrouping];
    > }

    That'll work, but in my experience if any of the controls in the window
    make use of 'autoresizing springs' then they will resize incorrectly if
    starting from a window size smaller that the control's minimum size.

    --
    ____________________________________________________________
    Sean McBride, B. Eng                <sean...>
    Rogue Research                        www.rogue-research.com
    Mac Software Developer              Montréal, Québec, Canada
  • On Jun 4, 2008, at 8:24 AM, Sean McBride wrote:
    > Alas, TransitionWindow() is deprecated and not available in 64.  So
    > really I don't recommend it.

    Technically speaking, it's not deprecated (at least it's not marked a
    such in the documentation). If you don't need 64-bit support, it might
    just be the most convenient option.

    -Stefan
  • On 6/4/08 10:18 AM, Stefan Werner said:

    > On Jun 4, 2008, at 8:24 AM, Sean McBride wrote:
    >> Alas, TransitionWindow() is deprecated and not available in 64.  So
    >> really I don't recommend it.
    >
    > Technically speaking, it's not deprecated (at least it's not marked a
    > such in the documentation).

    I suppose.  It's 'almost deprecated' then. :)  Eventually, Mac OS will
    be 64 bit only, so if something is 32 bit only, I'd stay away.

    > If you don't need 64-bit support, it might
    > just be the most convenient option.

    It might, which is why I brought it up.

    --
    ____________________________________________________________
    Sean McBride, B. Eng                <sean...>
    Rogue Research                        www.rogue-research.com
    Mac Software Developer              Montréal, Québec, Canada
  • On Jun 4, 2008, at 8:32 AM, Sean McBride wrote:
    > That'll work, but in my experience if any of the controls in the
    > window
    > make use of 'autoresizing springs' then they will resize incorrectly
    > if
    > starting from a window size smaller that the control's minimum size.

    I'll keep that in mind, thanks for mentioning. The window that I
    animate doesn't resize and the controls on it don't use springs so it
    appears to be safe in this respect.

    Regards
    Markus
    --
previous month june 2008 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
Go to today