FROM : Serge Meynard
DATE : Sun Apr 10 19:48:45 2005
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
DATE : Sun Apr 10 19:48:45 2005
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
| Related mails | Author | Date |
|---|---|---|
| Duncan Campbell | Apr 10, 04:24 | |
| glenn andreas | Apr 10, 18:31 | |
| Serge Meynard | Apr 10, 19:48 | |
| Matt Neuburg | Apr 10, 20:46 |






Cocoa mail archive

