[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NSSwitch drawRect bug
From: |
Fred Kiefer |
Subject: |
Re: NSSwitch drawRect bug |
Date: |
Mon, 14 Aug 2023 08:55:24 +0200 |
> Am 14.08.2023 um 08:36 schrieb H. Nikolaus Schaller <hns@goldelico.com>:
>
>> Am 13.08.2023 um 22:40 schrieb dr_clow@me.com:
>>
>> Nice! Maybe even just drawSwitchInRect:dirtyRect:forState:enabled: Though,
>> with your way, you could get more information from the control without
>> having to enlarge method arguments every time we wanted to add something
>> else.
>>
>> So maybe -(void) drawSwitch:(NSSwitch*)switch inRect:(CGRect)rect
>> dirtyRect:(CGRect)dirtyRect {}
>
> I am not sure if passing the dirtyRect is necessary and useful.
> The idea is that -drawRect: is usually called after setting a clipping rect
> within -display so that drawing with bounds size is correct but will be
> clipped away.
This is not about correctness, as you wrote the NSView clipping will take care
of that, this idea is about performance. When we pass on the dirty rectangle
the drawing will be able to decide which parts actually require a redraw. This
isn’t important for a small component like an NSSwitch but for something like
NSMatrix or NSTableView it allows us to speed up drawing a lot. We only redraw
and compute bits that will be visible.
In general we should always draw a view within the assigned bounds and use the
dirty rectangle to speed things up, where this is useful. Somebody should go
through the NSView subclasses to see where corrections in the code are required.
Hope this clears things up,
Fred