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 {}

> On Aug 13, 2023, at 1:10 PM, Fred Kiefer <[email protected]> wrote:
> 
> This is a common problem in our drawing code, especially in GSTheme. In the 
> better cases we hand on the view/controller to be drawn along with the 
> requested rectangle. That way the drawing code could still optimise the 
> process, by only drawing components that are actually visible.
> 
> I will change the code as suggested by you.
> 
> Cheers,
> Fred
> 
>> Am 11.08.2023 um 21:23 schrieb Austin Clow <[email protected]>:
>> 
>> In NSSwitch.m, the method for drawRect is as follows: 
>> 
>> - (void) drawRect: (NSRect)rect
>> {
>>  [[GSTheme theme] drawSwitchInRect: rect
>>                           forState: _state
>>                            enabled: [self isEnabled]];
>> }
>> 
>> I believe it should be 
>> 
>> - (void) drawRect: (NSRect)rect
>> {
>>  [[GSTheme theme] drawSwitchInRect: [self bounds]
>>                           forState: _state
>>                            enabled: [self isEnabled]];
>> }
>> 
>> As it is right now, when it redrawing a rect, it will redraw it within rect 
>> causing it to draw bigger and smaller depending not he redraw area. I'm not 
>> comfortable yet doing pull requests for a library I am largely unfamiliar 
>> with. 
>> 
>> I know the drawing method is kinda ugly right now. I am thinking about 
>> rewriting it.
> 

Reply via email to