Resolve theme issues, change size of knob

This commit is contained in:
Gregory John Casamento 2020-04-22 17:34:14 -04:00
parent d4b7a0c76d
commit f57e5184c3
5 changed files with 58 additions and 22 deletions

View file

@ -971,10 +971,7 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
- (void) drawSwitchInRect: (NSRect)rect
forState: (NSControlStateValue)state
enabled: (BOOL)enabled
bezelOnColor: (NSColor *)bOnColor
bezelOffColor: (NSColor *)bOffColor
knobColor: (NSColor *)kColor;
enabled: (BOOL)enabled;
// NSSegmentedControl drawing methods

View file

@ -33,8 +33,6 @@
extern "C" {
#endif
@protocol NSAccessibilityElement <NSObject>
- (NSRect)accessibilityFrame;
- (NSString *)accessibilityIdentifier;

View file

@ -35,7 +35,7 @@
extern "C" {
#endif
@interface NSSwitch : NSControl
@interface NSSwitch : NSControl <NSAccessibilitySwitch>
{
NSControlStateValue _state;
id _target;

View file

@ -899,16 +899,16 @@
if(value == NSControlStateValueOff)
{
rect = NSMakeRect(frame.origin.x + 4,
frame.origin.y + 3,
frame.origin.y + 2,
w - 2,
frame.size.height - 6);
frame.size.height - 5);
}
else
{
rect = NSMakeRect(frame.origin.x + ((frame.size.width - w) - 2),
frame.origin.y + 3,
frame.origin.y + 2,
w - 2,
frame.size.height - 6);
frame.size.height - 5);
}
@ -929,20 +929,17 @@
- (void) drawSwitchInRect: (NSRect)rect
forState: (NSControlStateValue)state
enabled: (BOOL)enabled
bezelOnColor: (NSColor *)bOnColor
bezelOffColor: (NSColor *)bOffColor
knobColor: (NSColor *)kColor
{
// Draw the well bezel
[self drawSwitchBezel: rect
withOnColor: bOnColor
withOffColor: bOffColor
withOnColor: [NSColor selectedControlColor]
withOffColor: [NSColor windowBackgroundColor]
forState: state];
// Draw the knob
[self drawSwitchKnob: rect
withColor: kColor
forState: state];
withColor: [NSColor windowBackgroundColor]
forState: state];
}
// NSSegmentedControl drawing methods

View file

@ -127,10 +127,7 @@
{
[[GSTheme theme] drawSwitchInRect: rect
forState: _state
enabled: [self isEnabled]
bezelOnColor: [NSColor selectedControlColor]
bezelOffColor: [NSColor windowBackgroundColor]
knobColor: [NSColor windowBackgroundColor]];
enabled: [self isEnabled]];
}
- (void) mouseDown: (NSEvent *)event
@ -157,6 +154,53 @@
}
}
// Accessibility
- (NSRect)accessibilityFrame
{
return [self frame];
}
- (NSString *)accessibilityIdentifier
{
return nil;
}
- (id)accessibilityParent
{
return nil;
}
- (BOOL)isAccessibilityFocused
{
return NO;
}
- (NSString *)accessibilityLabel
{
return nil;
}
- (BOOL)accessibilityPerformPress
{
return NO;
}
- (BOOL) accessibilityPerformDecrement
{
return NO;
}
- (BOOL) accessibilityPerformIncrement
{
return NO;
}
- (NSString *) accessibilityValue
{
return nil;
}
// NSCoding
- (id) initWithCoder: (NSCoder *)coder
{
if ((self = [super initWithCoder: coder]) != nil)