Re: NSView, scrolling colorWithPatternImage
Re: NSView, scrolling colorWithPatternImage
- Subject: Re: NSView, scrolling colorWithPatternImage
- From: Serge Meynard <email@hidden>
- Date: Sun, 10 Apr 2005 13:48:45 -0400
On Apr 10, 2005, at 12:31, glenn andreas wrote:
On Apr 9, 2005, at 9:24 PM, Duncan Campbell wrote:
Hi folks.
I'm trying to create a custom toolbar at the top of a window using an
NSView that has it's size set it to stick to the top of the window
(and auto-resize sideways).
I'm filling it with a pattern using [NSColor colorWithPatternImage:
which is working correctly, however when I resize my window on the
vertical (i.e. up and down), then the pattern in the NSView seems to
scroll.
Is there any way I can "lock" the image or turn off this behavior?
regards,
It is locked - it's just that patterns are locked to the origin (which
is the bottom left by default) and so the pattern moves with the
bottom of the window (making it appear to be scrolling).
I don't remember if "isFlipped" resolves this, but you can always just
explicitly set where the pattern origin phase is (effectively
scrolling as far as the bottom left is concerned, but making it appear
fixed for the top left).
This is the code which I have in my (non-flipped) custom view to keep
the pattern stable:
NSPoint visOrigin = [self visibleRect].origin;
[curContext setPatternPhase:NSMakePoint(-visOrigin.x, -visOrigin.y)];
I call this every time I am about to fill a rect with the background
pattern, although I suppose it would be enough to call it every time
the visible rect changes.
Serge
_______________________________________________
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