NSView, scrolling colorWithPatternImage
-
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,
---------------------------------------------------------------
Duncan Campbell
http://www.duncanandsarah.com/duncan
---------------------------------------------------------------
Counting in binary is just like counting in decimal -- if you are all
thumbs.
-- Glaser and Way -
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).
Glenn Andreas <gandreas...>
<http://www.gandreas.com/> oh my!
quadrium | build, mutate, evolve | images, textures, backgrounds, art -
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 -
On Sun, 10 Apr 2005 12:24:28 +1000, Duncan Campbell
<duncan...> said:
> 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?
<http://www.cocoabuilder.com/archive/message/2005/3/15/130496>
m.
--
matt neuburg, phd = <matt...>, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>



