NSAmimatablePropertyContainer property animation troubles...

  • The release notes on NSAmimatablePropertyContainer protocol give an example like this;

    @implementation MyView
    + (id)defaultAnimationForKey:(NSString *)key {
        if ([key isEqualToString:@"borderColor"]) {
            // By default, animate border color changes with simple linear interpolation to the new color value.
            return [CABasicAnimation animation];
        } else {
            // Defer to super's implementation for any keys we don't specifically handle.
            return [super defaultAnimationForKeyKey:key];
        }
    }
    @end

    But I don't see the search for animations being performed on properties that are not part of the primitives (double, float, NSPoint, NSSize or NSRect). I have two properties on my NSView one is float and does get animated, the other is an NSColor and the defaultAnimationForKey: never gets called for this property.

    Anyone else had a chance to mess with this api yet and seen the same thing?

    Thanks,

    -bd-
    http://bill.dudney.net/roller/objc
  • Hi Bill,

    Animation of NSColor properties isn't supported yet; that's why your
    code isn't being asked to provide an animation to use.

    As an alternative, you could drive a float or double typed property
    using an animation, and vary the color you use in response to changes
    in that property.

    Troy

    On Nov 1, 2007, at 1:41 PM, Bill Dudney wrote:

    > The release notes on NSAmimatablePropertyContainer protocol give an
    > example like this;
    >
    > @implementation MyView
    > + (id)defaultAnimationForKey:(NSString *)key {
    > if ([key isEqualToString:@"borderColor"]) {
    > // By default, animate border color changes with simple
    > linear interpolation to the new color value.
    > return [CABasicAnimation animation];
    > } else {
    > // Defer to super's implementation for any keys we don't
    > specifically handle.
    > return [super defaultAnimationForKeyKey:key];
    > }
    > }
    > @end
    >
    > But I don't see the search for animations being performed on
    > properties that are not part of the primitives (double, float,
    > NSPoint, NSSize or NSRect). I have two properties on my NSView one
    > is float and does get animated, the other is an NSColor and the
    > defaultAnimationForKey: never gets called for this property.
    >
    > Anyone else had a chance to mess with this api yet and seen the same
    > thing?
    >
    > Thanks,
    >
    > -bd-
    > http://bill.dudney.net/roller/objc
  • Hi Troy,

    Thanks for the reply.

    What got me looking was I first tried to use an NSNumber for a property I wanted to animate. When it didn't work i started searching and landed on the release notes which show color. Spent some more time poking around with the code and found that if I switched my initial property to a float it worked. So I tried the color example from the release notes and found it did not work either. And thus the post...

    So it seems that if I were to subclass basic animation I could animate color changes. Is that the eventual goal, the API sure looks that way even if the docs and particulars are lacking. My real goal is to be able to provide an animation for arbitrary properties. Not because any app in particular needs it but just because it looks like it should be possible and I want to write up an example of doing that.

    Thanks again for the response!

    TTFN,

    -bd-
    http://bill.dudney.net/roller/objc


    On Thursday, November 01, 2007, at 03:05PM, "Troy Stephens" <tstephens...> wrote:
    > Hi Bill,
    >
    > Animation of NSColor properties isn't supported yet; that's why your
    > code isn't being asked to provide an animation to use.
    >
    > As an alternative, you could drive a float or double typed property
    > using an animation, and vary the color you use in response to changes
    > in that property.
    >
    > Troy
    >
    > On Nov 1, 2007, at 1:41 PM, Bill Dudney wrote:
    >
    >> The release notes on NSAmimatablePropertyContainer protocol give an
    >> example like this;
    >>
    >> @implementation MyView
    >> + (id)defaultAnimationForKey:(NSString *)key {
    >> if ([key isEqualToString:@"borderColor"]) {
    >> // By default, animate border color changes with simple
    >> linear interpolation to the new color value.
    >> return [CABasicAnimation animation];
    >> } else {
    >> // Defer to super's implementation for any keys we don't
    >> specifically handle.
    >> return [super defaultAnimationForKeyKey:key];
    >> }
    >> }
    >> @end
    >>
    >> But I don't see the search for animations being performed on
    >> properties that are not part of the primitives (double, float,
    >> NSPoint, NSSize or NSRect). I have two properties on my NSView one
    >> is float and does get animated, the other is an NSColor and the
    >> defaultAnimationForKey: never gets called for this property.
    >>
    >> Anyone else had a chance to mess with this api yet and seen the same
    >> thing?
    >>
    >> Thanks,
    >>
    >> -bd-
    >> http://bill.dudney.net/roller/objc
    >
    >
    >
  • On Nov 1, 2007, at 2:43 PM, Bill Dudney wrote:
    > Hi Troy,
    >
    > Thanks for the reply.
    >
    > What got me looking was I first tried to use an NSNumber for a
    > property I wanted to animate. When it didn't work i started
    > searching and landed on the release notes which show color.

    So they do.  That's a mistake; sorry about that.  The intent was there
    to support NSColor interpolation but it didn't make the cut for 10.5.
    I'll see that that example in the release notes gets fixed.

    Note that Core Animation itself does support animation of CGColors.
    The corresponsing support just isn't there for NSColor yet.

    > Spent some more time poking around with the code and found that if I
    > switched my initial property to a float it worked. So I tried the
    > color example from the release notes and found it did not work
    > either. And thus the post...
    >
    > So it seems that if I were to subclass basic animation I could
    > animate color changes. Is that the eventual goal, the API sure looks
    > that way even if the docs and particulars are lacking. My real goal
    > is to be able to provide an animation for arbitrary properties. Not
    > because any app in particular needs it but just because it looks
    > like it should be possible and I want to write up an example of
    > doing that.

    The API was designed to allow for animating arbitrary property types.
    The implementation currently supports float, double, NSPoint, NSSize,
    and NSRect values.

    Troy

    > On Thursday, November 01, 2007, at 03:05PM, "Troy Stephens" <tstephens...>
    >> wrote:
    >> Hi Bill,
    >>
    >> Animation of NSColor properties isn't supported yet; that's why your
    >> code isn't being asked to provide an animation to use.
    >>
    >> As an alternative, you could drive a float or double typed property
    >> using an animation, and vary the color you use in response to changes
    >> in that property.
    >>
    >> Troy
    >>
    >> On Nov 1, 2007, at 1:41 PM, Bill Dudney wrote:
    >>
    >>> The release notes on NSAmimatablePropertyContainer protocol give an
    >>> example like this;
    >>>
    >>> @implementation MyView
    >>> + (id)defaultAnimationForKey:(NSString *)key {
    >>> if ([key isEqualToString:@"borderColor"]) {
    >>> // By default, animate border color changes with simple
    >>> linear interpolation to the new color value.
    >>> return [CABasicAnimation animation];
    >>> } else {
    >>> // Defer to super's implementation for any keys we don't
    >>> specifically handle.
    >>> return [super defaultAnimationForKeyKey:key];
    >>> }
    >>> }
    >>> @end
    >>>
    >>> But I don't see the search for animations being performed on
    >>> properties that are not part of the primitives (double, float,
    >>> NSPoint, NSSize or NSRect). I have two properties on my NSView one
    >>> is float and does get animated, the other is an NSColor and the
    >>> defaultAnimationForKey: never gets called for this property.
    >>>
    >>> Anyone else had a chance to mess with this api yet and seen the same
    >>> thing?
    >>>
    >>> Thanks,
    >>>
    >>> -bd-
    >>> http://bill.dudney.net/roller/objc
    >>
    >>
    >>

previous month november 2007 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