Re: Card Game (like Spider-Solitaire) in Cocoa -- Conceptual ideas needed

2009-06-12 Thread Brian Christensen

On Jun 11, 2009, at 14:04, Florian Witteler wrote:

I would like to know, how you experiences cocoa-developers would  
handle the drawing in a solitaire-game.


You may want to have a look at GeekGameBoard as a reference point:

http://mooseyard.com/hg/hgwebdir.cgi/GeekGameBoard/archive/tip.zip
http://mooseyard.com/Jens/2008/03/geekgameboard-getting-closer-to-iphone-ready/

/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: CALayer wierdness

2009-02-12 Thread Brian Christensen

On Feb 12, 2009, at 21:23, David Blanton wrote:


I set up a CALayer

is shows in the iPhone Simulator
does not show in the iPhone

How can that be?


I doubt anyone can answer your question without seeing relevant code  
snippets.


/brian

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Newbie CALayer Questions

2008-07-20 Thread Brian Christensen

On Jul 20, 2008, at 20:00, Bob Barnes wrote:

  I have some questions related to CALayer drawing. I want to be  
able to display images, text, 2D graphics or a PDF page. I'm able to  
display an image by directly setting the contents property using a  
CGImageRef or subclassing CALayer, overriding display and sending  
setNeedsDisplay, but nothing I do seems to trigger the call to  
drawInContext. I've tried using a delegate for the CALayer and   
subclassing CALayer, but drawInContext never gets called. Is there  
something fundamental that I'm missing?


Is the needsDisplayOnBoundsChange property set to YES on your layer?

/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Core animation

2008-06-30 Thread Brian Christensen

Am Jun 30, 2008 um 07:04 schrieb Papa-Raboon:


I was wondering if many of you have had a go at core animation yet?
I am personally looking at making a piece of text fade in and fade  
out as a
confirmation that something worked in my latest project. Currently I  
am just

popping a bit of text on screen using:
[succcessFlag setStringValue:@"Record Added"];

I presume we are talking pretty simple here but the question is how  
simple.
If any of you knows of any cool tutorials on really quick and simple  
core

animation text effects could you please give me the heads up.


It's difficult to know exactly what you need based on what you wrote  
above. Do you really need to drop down to Core Animation layers or  
would AppKit's animation proxies be good enough for your purposes? Is  
there a reason you would need to manipulate a CATextLayer directly? Is  
"successFlag" supposed to be a layer or is it an NSTextField?


If successFlag is in fact an NSTextField (or, for that matter, any  
NSView or subclass thereof), then [[successFlag animator]  
setHidden:YES] (or setHidden:NO) should give you a default fade  
effect, provided a superview somewhere up the view hierarchy is layer  
backed.


Here are some excellent starting points for learning OS X animation  
technologies. I highly recommend reading these guides. A "cool  
tutorial" should not be a substitute for reading Apple's  
documentation, IMHO:











Following that, Bill Dudney is authoring a Core Animation book  
(currently in beta, available in PDF form right now) that seems to be  
coming along nicely so far: 


/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Layer Backed Views and CoreAnimation neither animate nor stay in place

2008-06-27 Thread Brian Christensen

On Jun 27, 2008, at 08:56, Chilton Webb wrote:

(3) Even when everything else is working right, the first time I  
perform my animation method, the animation does not work. Instead,  
it quickly swaps out the old view with the new one, and displays it  
in the foreground, on top of all other views, even if all other  
views are layer backed. This is obviously *not* 'replacing' the view  
in the order I want. After that, it animates properly, but on top of  
the other views instead of behind them.


I'm surprised it doesn't work as intended. Maybe it's a bug in the  
replaceSubview:with: method. If you change your testSwap: method to  
the following it should maintain the view ordering:


- (IBAction) testSwap:(id) sender
{
// (2) If I set this anywhere else, the animations don't work.
//  [self setWantsLayer:YES];

// (3) See notes above

	ColoredSubView *svx = [[ColoredSubView alloc]  
initWithFrame:NSMakeRect(50,50,200,200)];

[svx setColor:[self anothercolor]];
//	[[self animator] replaceSubview:[[self subviews] objectAtIndex:1]  
with: svx];


NSView *viewToReplace = [[self subviews] objectAtIndex:1];
	[[self animator] addSubview:svx positioned:NSWindowAbove  
relativeTo:viewToReplace];

[[viewToReplace animator] removeFromSuperview];

[svx release];
}

It looks like you'll have to add this as well:

- (void)awakeFromNib
{
[self setWantsLayer:YES];
}

Your transition probably won't work as intended with this solution  
though (it works fine with the default fade animation, however), so to  
get the effect you want you may need to position the new view outside  
the visible boundaries of the superview and then use something like  
this to perform the transition:


[NSAnimationContext beginGrouping];
[NSAnimationContext setDuration:0.5];

[[svx animator] setFrameOrigin:destinationFrameOrigin];
[[viewToReplace animator]  
setFrameOrigin:somewhereOutsideVisibleBoundaries];


[NSAnimationContext endGrouping];

[viewToReplace performSelector:@selector(removeFromSuperview)  
withObject:nil afterDelay:0.5];


(I'm not sure that the transition you specified would work with  
replaceSubview:with: either. It seems to perform the animation on the  
entire superview, not just the subview being changed.)


/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: hitTest question

2008-06-20 Thread Brian Christensen

On Jun 20, 2008, at 4:04 , Brian Christensen wrote:


for (Component *subcomponent in [hitComponent subcomponents])


Sorry, that line should be:

for (Component *subcomponent in [match subcomponents])
{
// ...
}

/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: hitTest question

2008-06-20 Thread Brian Christensen

On Jun 20, 2008, at 2:50 , Eugen Belyakov wrote:

I need to implement custom visual component system in OpenGL. And I  
want to
use hitTest-like behavior ( with rotated frame rectangles and so on)  
to

determine component under cursor.
Could anyone with knowledge of how -hitTest works point me in the  
right

direction?


I don't have knowledge of how hitTest: is implemented, but I can tell  
you what I would do if I were implementing something like it. Assuming  
you have an NSView-style hierarchy of your visual components, the  
hitTest: method you'll implement should first check if the point is  
inside itself. If so, continue iterating through all of its sub- 
components (by invoking hitTest: on each one) until you've located the  
deepest component that still contains the point. You should send the  
hitTest: method to the root component in your hierarchy. Something  
like the following (pseudo-code written in Mail, so standard  
disclaimer applies):


- (Component *)hitTest:(NSPoint)point
{
if (!NSPointInRect( point, [self frame] ))
return nil;

Component *match = self;

for (Component *subcomponent in [hitComponent subcomponents])
{
Component *nextComponentToTest = [subcomponent hitTest:point];

if (nextComponentToTest)
match = nextComponentToTest;
}

return match;
}

You may need to do coordinate conversions as well, depending on  
whether or not your components maintain their own coordinate spaces  
relative to their supercomponents. If you need to take rotation into  
account, then you'll still use NSPointInRect() to find out if the  
point is at least within the bounding rectangle. Beyond that you'll  
probably need to work out some vector algebra to get a more accurate  
hit result.


/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Problems with a Layer backed NSView in a NSScrollView

2008-06-19 Thread Brian Christensen

On Jun 19, 2008, at 5:14 , Gordon Apple wrote:


I've tried a variety of things including regenerating
the CALayers, but so far haven't been able to get the layers to  
scale to the
coordinates of the underlying view.  Again, I'll probably figure it  
out
eventually, but this stuff just shouldn't be that difficult.  IMHO,  
there is
not enough automatic coupling adjustments between the view and its  
layer

parameters to handle these issues.


What exactly are you doing to try to scale the layer?

/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Cocoa, C++, Keyboard input and Timers

2008-06-16 Thread Brian Christensen

On Jun 16, 2008, at 6:43 , Brian Christensen wrote:

(I do not know what the difference is, if any, between using  
mach_absolute_time() and UpTime().)


Apparently, the answer is that there isn't really a difference: <http://lists.apple.com/archives/perfoptimization-dev/2007/Oct/msg3.html 
>. UpTime() appears to be more convenient though, so I'd probably use  
that.


/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Cocoa, C++, Keyboard input and Timers

2008-06-16 Thread Brian Christensen

On Jun 16, 2008, at 5:47 , Josh de Lioncourt wrote:

Next, I need to be able to keep track of real-time during the game.   
In Windows, we'd use something like GetTickCount to accomplish  
this.  Is there an equivalent on the Mac side?  Again, pointing me  
in the right direction would be tremendously appreciated.


mach_absolute_time() will give you high precision timing. There's a  
technote on this subject here: 


Alternately, you can retrieve the absolute time using UpTime() (found  
in , which you'd likely need to import  
anyway for the conversion routines AbsoluteToNanoseconds() and  
AbsoluteToDuration().


(I do not know what the difference is, if any, between using  
mach_absolute_time() and UpTime().)


/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: CoreAnimation removeFromSuperlayer flicker

2008-06-16 Thread Brian Christensen

On Jun 14, 2008, at 2:29 , Milen Dzhumerov wrote:

I've got a root layer which has got a solid background and I've  
got one sublayer. If I call removeFromSuperlayer on the sublayer  
when the root layer is small in size, it removes itself with  
animation and there are no problems. But if I increase the size of  
the window (the hosting view and the root layer consequently  
increase their size as ewll) and remove the sublayer again, I can  
see that the root layer changes to become all white for a fraction  
of a second and then goes back to normal (the sublayer is removed  
with animation normally). Are there any reasons for the flicker  
(e.g. wrong usage of removeFromSuperlayer)?


How large is your root layer when you start seeing the flickering?


Probably about  700x500.


Have you tried using an explicit animation to set the opacity property  
to 0.0 and then upon completion of said animation (by implementing the  
appropriate delegate method) remove the sublayer? Maybe that will  
eliminate the flickering by fading it out before actual removal.


/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: CoreAnimation removeFromSuperlayer flicker

2008-06-14 Thread Brian Christensen

On Jun 14, 2008, at 10:28 , Milen Dzhumerov wrote:

I've got a root layer which has got a solid background and I've got  
one sublayer. If I call removeFromSuperlayer on the sublayer when  
the root layer is small in size, it removes itself with animation  
and there are no problems. But if I increase the size of the window  
(the hosting view and the root layer consequently increase their  
size as ewll) and remove the sublayer again, I can see that the root  
layer changes to become all white for a fraction of a second and  
then goes back to normal (the sublayer is removed with animation  
normally). Are there any reasons for the flicker (e.g. wrong usage  
of removeFromSuperlayer)?


How large is your root layer when you start seeing the flickering?

/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Most efficient way to "merge" CA layers

2008-06-11 Thread Brian Christensen

On Jun 11, 2008, at 6:34 , Huibert Aalbers wrote:

I am writing an app that uses multiple layers to display objects  
that move

over a static background (which is drawn in its own layer). After the
animation completes, I do no longer need all those layers and I  
guess that
it would be more efficient to "merge" all these layers into a single  
one.

Does anyone have an opinion on what would be the most efficient way to
perform such an operation?


Are you actually seeing a performance hit during profiling (ie. in  
Instruments) by keeping the extra layers around? How many layers are  
we talking about? I would not necessarily assume that merging the  
layers would be any more efficient. And if profiling doesn't indicate  
a performance issue, I wouldn't waste my time on it.


/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: CALayer scale transform

2008-06-11 Thread Brian Christensen

On Jun 11, 2008, at 12:37 , David Duncan wrote:

Effectively a CALayer represents a texture with the layer's contents  
on the video card. As the docs say, transforms only affect geometry.  
The texture does not include geometry, thus the current content is  
scaled rather than being re-rendered. At even moderate zoom factors  
scaling the content could cause issues with maximum texture sizes on  
the video card your running on.


I see. Thanks for the explanation. My solution will then be to simply  
maintain my own scaleFactor and apply that to my drawing calculations  
in place of a transformation (or in the case of a text layer, simply  
fontSize * scaleFactor).


/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

CALayer scale transform

2008-06-11 Thread Brian Christensen
Is it expected behavior that when applying a CATransform3DMakeScale()  
transform to a CALayer the layer's current bitmap information is what  
gets scaled (using some type of filter) rather than asking the layer  
to actually redraw itself into the, presumably, freshly transformed  
context? Currently applying a scale transform appears to result in  
unacceptable pixelation.


Here is an example:

_textLayer = [[CATextLayer alloc] init];

[_textLayer setFrame:CGRectMake( 300.0, 300.0, 1000.0, 36.0 )];
[_textLayer setString:@"Hello world"];
[_textLayer setTransform:CATransform3DMakeScale( 1.5, 1.5, 1.0 )];

This will scale the text up to 1.5x its size, but the result is  
essentially useless. It becomes even more pronounced if I set the  
minification/magnification filters to nil:


[_textLayer setMinificationFilter:nil];
[_textLayer setMagnificationFilter:nil];

I can't seem to find anything in the documentation on this behavior.  
The relevant sections discuss it as "transforming a layer's geometry."  
Maybe I'm not understanding something fundamental, but I would have  
figured that a geometry transform wouldn't simply stretch the existing  
device pixel based bitmap content using minification/magnification  
filters to fit into the newly scaled unit size (at least, from my  
understanding, this certainly isn't how a transform applied to the  
drawing context would cause regular Cocoa drawing to behave). I can  
understand this being done if the layer content is a bitmap image to  
begin with, but I certainly wouldn't expect this to be the case for  
text.


Can anyone shed any light on this?

/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: CATextLayer question

2008-06-05 Thread Brian Christensen

On Jun 5, 2008, at 1:44 , Davide Scheriani wrote:


nooo I dont believe it! :)
I come from Flash and Core Animation is like Fuse Framework of Moses.
Is a way to have some sort of "collision" method of one or more  
layers?


I'm not quite sure what you're trying to say or accomplish, but if you  
want to find out when the bounds of two layers intersect you'll need  
to perform that calculation yourself.


/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: CATextLayer question

2008-06-05 Thread Brian Christensen

On Jun 5, 2008, at 9:04 , Davide Scheriani wrote:


I was playing with my NSView and CATextLayer.
I placed this code:

-(void)mouseDown:(NSEvent *)theEvent
{
// [...snip...]

[rootLayer addSublayer:textLayer];
}

what ive noticed is when I click,the text appear with a fadein.
Any reason of this behaviour?


Modifying most layer properties as well as adding/removing sublayers  
generates implicit animations. You can temporarily disable animations  
by wrapping the relevant code in a CATransaction:


- (void)mouseDown:(NSEvent *)theEvent
{
[CATransaction begin];
	[CATransaction setValue:(id)kCFBooleanTrue  
forKey:kCATransactionDisableActions];


// [...snip...]
[rootLayer addSublayer:textLayer];

[CATransaction commit];
}

/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: CALayer subclass question

2008-06-04 Thread Brian Christensen

On Jun 4, 2008, at 11:57 , Huibert Aalbers wrote:

Thanks, but it didn't work. My understanding is that either  
setNeedsDisplay or setNeedsDisplayOnBoundsChange:YES can be used to  
force the layer to draw its content, but something is not working  
for me.


Some snippets of your code might help narrow down the issue. For  
example, what does your drawInContext: method look like?


/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: CALayer subclass question

2008-06-04 Thread Brian Christensen

On Jun 4, 2008, at 11:19, Huibert Aalbers wrote:

I am starting to work with Core Animation. I have tried to subclass  
CALayer but I am having problems because for some reason the  
drawInContext method never gets called, even though I invoke  
setNeedsDisplay on the layer.


What is weird though is that if I override the display method I can  
see that it gets called properly. My understanding is that the  
default implementation of the display method invokes drawInContext.  
So, my question is, what could I be doing wrong that could explain  
this behaviour?


Have you tried setting the "needsDisplayOnBoundsChange" property of  
the layer to YES? That should do the trick.


This is probably a pretty basic question but I haven't been able to  
find any complete examples on how to properly subclass NSLayer.  
Everyone seems to believe that it is either unnecessary or complex.


Jens Alfke wrote a turn-based game engine using Core Animation and he  
makes fairly extensive use of CALayer subclassing. It's a great  
starting point, even just to poke around and see how some things can  
be done. You can grab it here: 


/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: How to implement window fade-in fade-out effects

2008-06-03 Thread Brian Christensen

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



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: NSArray

2008-06-01 Thread Brian Christensen

On Jun 1, 2008, at 8:02 , Nathan wrote:


here's my code:

int x;
- (IBAction)addNew:(id)sender {
NSString *temp = @"Enter Todo Item Here";
   [Items addObject: temp];
x=[Items count];
[label setIntValue: x];
[tableView setDataSource: Items];
[tableView reloadData];
}



An NSArray object cannot be made a data source of a table view.




/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Leak when animating Core Animation Superlayer

2008-06-01 Thread Brian Christensen

On Jun 1, 2008, at 10:28 , Stéphane Droux wrote:


If you kill the timer after its been running for a while, does the
memory usage drop back down?  Maybe the implicit animations are never
completing before a new one gets added, so they're just stacking up  
on

top of each other.



I don't think they should stack up. Core animation default duration  
is 0.25

second and these animations are triggered every 0.4 secs.
Anyway, I added a timer to invalidate the first one after 60  
seconds. The

memory usage only became constant. It was about 60% more than when the
application started. No memory was released.


I would consider that to be expected behavior. If you aren't ever  
releasing the layers you created, why would any of the relevant memory  
be freed? The timer and the animations it is causing to be performed  
should not really be incurring a very significant memory footprint in  
addition to what the layers on their own are already using (my own  
observations at least indicate that running the test app with or  
without the timer makes very little difference in that regard).


Are the two methods you posted really the only two methods in your  
entire test app? Or are you doing something else somewhere in addition  
to this? Feel free to e-mail me the test project off-list if you like.


/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Leak when animating Core Animation Superlayer

2008-06-01 Thread Brian Christensen

On Jun 1, 2008, at 5:03 , Stéphane Droux wrote:

I've changed the timer function to do random animations and this  
time it

really "leaks":

- (void) fromTimer: (NSTimer *) t
{
   l2.frame = CGRectMake((double)random() / RAND_MAX*30,  
(double)random() /

RAND_MAX*30, (double)random() / RAND_MAX*40, (double)random() /
RAND_MAX*40);
   l1.opacity = (double)random() / RAND_MAX;
}


I ran it in Object alloc and can see a trend of increasing memory  
usage :
the memory usage keeps changing up and down but the general trend is  
up and

it doubled after a minute or so.

Could that be caused by some kind of caching in  Core Animation ?
If it is, is there a way to flush the cache ?


Even with this new code I'm still not observing any leaking. Are you  
using garbage collection? With GC enabled you will observe  
fluctuations until the collector gets a chance to free up unused  
memory, but even then after a few minutes or so the usage level should  
periodically return to a reduced level.


I am not privy to the caching Core Animation is doing internally, but  
also keep in mind that it maintains both presentation and model layers  
behind the scenes, in addition to whatever internal caching might be  
happening to improve performance.


What kind of hardware are you running? I suspect we may be seeing some  
differences in our results based on that (perhaps different graphics  
hardware is causing Core Animation to have to do more - or different -  
work on your machine). I still don't see why this would be leaking on  
your machine though.


/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Leak when animating Core Animation Superlayer

2008-06-01 Thread Brian Christensen

On Jun 1, 2008, at 2:55 , Stéphane Droux wrote:

When I run the program in Mallocdebug, it seems that one of the  
threads used

by Core Animation to animate the layers doesn't release its memory.
So it looks like a bug in Core Animation. However, since animating  
non-leaf
layers is such a core feature of Core Animation, I guess there's  
something

missing in my code


Are you sure you're getting a leak? I ran your sample code in  
Instruments with the Object Alloc and Leaks tools and I didn't detect  
any leaks. Object allocation and memory usage remained constant.  
Whether l1 or l2 were being animated made no discernible difference.


/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Leak when animating Core Animation Superlayer

2008-05-31 Thread Brian Christensen

On May 31, 2008, at 16:39, "Stéphane Droux" <[EMAIL PROTECTED]>

> When I run the program in MallocDebug, the memory usage goes up  
every time the timer function is executed. If I change the animation  
to be on l2 instead of l1, or if I create l2 as a sublayer of  
mainLayer, the memory usage remains constant. Am I doing something  
wrong ?



An NSTimer is not really the appropriate way to do this. Have a look  
at CABasicAnimation, which you might use in the following manner  
(untested code written on an iPhone, so no guarantees):


CABasicAnimation *anim = [CABasicAnimation  
animationWithKeyPath:@"opacity"];


[anim setFromValue:1.0];
[anim setToValue:0.2];
[anim setAutoreverses:YES];
[anim setDuration:1.0];

[l2 addAnimation:anim forKey:nil];

I would recommend reviewing the Core Animation documentation for  
additional examples.


/brian

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CATransactions not working

2008-05-19 Thread Brian Christensen

On May 19, 2008, at 1:06 , Adam Radestock wrote:

It's in a function called from within the mouseDown: handler in my  
subclass. I just don't get why the implicit animation isn't working?



A couple of things:

1) Make sure that somewhere up the hierarchy of your button's  
superviews one of them has the "Wants Layer" option in IB checked, or  
that you're setting "[someSuperviewOfCustomButton setWantsLayer:YES]"  
in code somewhere.


2) If #1 isn't the issue, it would help if you posted your entire  
mouseDown: method. I have run into an issue with animations not  
happening when they should be, but I don't know if your issue is the  
same as the one I had recently without seeing more context.


/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: CATransactions not working

2008-05-18 Thread Brian Christensen

On May 18, 2008, at 12:00 , Adam Radestock wrote:


Hi everyone,

I've been struggling to work out how to animate some properties on  
my NSButton subclass. I have looked through all the examples given  
in Apple's docs, but can't work out why my code doesn't animate.


Where exactly are you invoking this code? Is it in awakeFromNib?

/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: NSView enterFullScreenMode:withOptions: woes; window levels

2008-03-17 Thread Brian Christensen

On Mar 17, 2008, at 4:51 , Sean McBride wrote:


Hi all,

Is anyone using the new NSView full screen methods in 10.5?

I have a window which contains a 'group view', it is basically an  
NSView

that contains two subviews: a button, and an custom NSView that draws
pretty pictures.  The button displays a floating palette (NSPanel).

My ultimate goal is to make the 'group view' full screen but allow the
floating palette to be above it.

If I do:

NSDictionary* options = [NSDictionary
 dictionaryWithObjectsAndKeys:
  [NSNumber numberWithInt:kCGNormalWindowLevel],
   NSFullScreenModeWindowLevel, nil];
[groupView enterFullScreenMode:[NSScreen mainScreen]
 withOptions:options];
NSLog (@"level %d", [[groupView window] level]);

Then it does go fullscreen, but the window level is
kCGMaximumWindowLevel-1, not kCGNormalWindowLevel.  As such, my panel
(at kCGFloatingWindowLevel) is invisible.

Am I doing something wrong here?  Shouldn't the window level be what I
told it to be?


I am unsure why this is even presented as an option for the mode  
dictionary. To my knowledge the CGDirectDisplay API (which is what the  
enterFullScreenMode: method is using under the hood) does not support  
specifying your own shielding window level. The result is that the  
window hosting your NSView is going to have to be promoted to a window  
level that is equal to or higher than the result of  
CGShieldingWindowLevel(). Otherwise it would be covered by the  
blanking window created by the display API.


You might alternately try to set the window level on your floating  
palette instead, ie. [paletteWindow setLevel:kCGMaximumWindowLevel].


/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]