Browse Source

Update SRRecorderControl.m

pull/101/head
Abhishek 3 years ago
parent
commit
7226b3b129
  1. 126
      Clocker/Clocker/ShortcutRecorder-master/Library/SRRecorderControl.m

126
Clocker/Clocker/ShortcutRecorder-master/Library/SRRecorderControl.m

@ -475,7 +475,7 @@ typedef NS_ENUM(NSUInteger, _SRRecorderControlButtonTag)
static NSDictionary *NormalAttributes = nil; static NSDictionary *NormalAttributes = nil;
dispatch_once(&OnceToken, ^{ dispatch_once(&OnceToken, ^{
NSMutableParagraphStyle *p = [[NSMutableParagraphStyle alloc] init]; NSMutableParagraphStyle *p = [[NSMutableParagraphStyle alloc] init];
p.alignment = NSCenterTextAlignment; p.alignment = NSTextAlignmentCenter;
p.lineBreakMode = NSLineBreakByTruncatingTail; p.lineBreakMode = NSLineBreakByTruncatingTail;
p.baseWritingDirection = NSWritingDirectionLeftToRight; p.baseWritingDirection = NSWritingDirectionLeftToRight;
NormalAttributes = @{ NormalAttributes = @{
@ -493,7 +493,7 @@ typedef NS_ENUM(NSUInteger, _SRRecorderControlButtonTag)
static NSDictionary *RecordingAttributes = nil; static NSDictionary *RecordingAttributes = nil;
dispatch_once(&OnceToken, ^{ dispatch_once(&OnceToken, ^{
NSMutableParagraphStyle *p = [[NSMutableParagraphStyle alloc] init]; NSMutableParagraphStyle *p = [[NSMutableParagraphStyle alloc] init];
p.alignment = NSCenterTextAlignment; p.alignment = NSTextAlignmentCenter;
p.lineBreakMode = NSLineBreakByTruncatingTail; p.lineBreakMode = NSLineBreakByTruncatingTail;
p.baseWritingDirection = NSWritingDirectionLeftToRight; p.baseWritingDirection = NSWritingDirectionLeftToRight;
RecordingAttributes = @{ RecordingAttributes = @{
@ -511,7 +511,7 @@ typedef NS_ENUM(NSUInteger, _SRRecorderControlButtonTag)
static NSDictionary *DisabledAttributes = nil; static NSDictionary *DisabledAttributes = nil;
dispatch_once(&OnceToken, ^{ dispatch_once(&OnceToken, ^{
NSMutableParagraphStyle *p = [[NSMutableParagraphStyle alloc] init]; NSMutableParagraphStyle *p = [[NSMutableParagraphStyle alloc] init];
p.alignment = NSCenterTextAlignment; p.alignment = NSTextAlignmentCenter;
p.lineBreakMode = NSLineBreakByTruncatingTail; p.lineBreakMode = NSLineBreakByTruncatingTail;
p.baseWritingDirection = NSWritingDirectionLeftToRight; p.baseWritingDirection = NSWritingDirectionLeftToRight;
DisabledAttributes = @{ DisabledAttributes = @{
@ -543,7 +543,7 @@ typedef NS_ENUM(NSUInteger, _SRRecorderControlButtonTag)
_SRImages[4], _SRImages[4],
_SRImages[5], _SRImages[5],
NO, NO,
NSCompositeSourceOver, NSCompositingOperationSourceOver,
1.0, 1.0,
self.isFlipped); self.isFlipped);
} }
@ -558,7 +558,7 @@ typedef NS_ENUM(NSUInteger, _SRRecorderControlButtonTag)
_SRImages[1], _SRImages[1],
_SRImages[2], _SRImages[2],
NO, NO,
NSCompositeSourceOver, NSCompositingOperationSourceOver,
1.0, 1.0,
self.isFlipped); self.isFlipped);
} }
@ -569,7 +569,7 @@ typedef NS_ENUM(NSUInteger, _SRRecorderControlButtonTag)
_SRImages[7], _SRImages[7],
_SRImages[8], _SRImages[8],
NO, NO,
NSCompositeSourceOver, NSCompositingOperationSourceOver,
1.0, 1.0,
self.isFlipped); self.isFlipped);
} }
@ -581,7 +581,7 @@ typedef NS_ENUM(NSUInteger, _SRRecorderControlButtonTag)
_SRImages[10], _SRImages[10],
_SRImages[11], _SRImages[11],
NO, NO,
NSCompositeSourceOver, NSCompositingOperationSourceOver,
1.0, 1.0,
self.isFlipped); self.isFlipped);
} }
@ -592,7 +592,7 @@ typedef NS_ENUM(NSUInteger, _SRRecorderControlButtonTag)
_SRImages[17], _SRImages[17],
_SRImages[18], _SRImages[18],
NO, NO,
NSCompositeSourceOver, NSCompositingOperationSourceOver,
1.0, 1.0,
self.isFlipped); self.isFlipped);
} }
@ -643,14 +643,14 @@ typedef NS_ENUM(NSUInteger, _SRRecorderControlButtonTag)
{ {
[_SRImages[14] drawInRect:imageRect [_SRImages[14] drawInRect:imageRect
fromRect:NSZeroRect fromRect:NSZeroRect
operation:NSCompositeSourceOver operation:NSCompositingOperationSourceOver
fraction:1.0]; fraction:1.0];
} }
else else
{ {
[_SRImages[15] drawInRect:imageRect [_SRImages[15] drawInRect:imageRect
fromRect:NSZeroRect fromRect:NSZeroRect
operation:NSCompositeSourceOver operation:NSCompositingOperationSourceOver
fraction:1.0]; fraction:1.0];
} }
@ -680,14 +680,14 @@ typedef NS_ENUM(NSUInteger, _SRRecorderControlButtonTag)
{ {
[_SRImages[12] drawInRect:imageRect [_SRImages[12] drawInRect:imageRect
fromRect:NSZeroRect fromRect:NSZeroRect
operation:NSCompositeSourceOver operation:NSCompositingOperationSourceOver
fraction:1.0]; fraction:1.0];
} }
else else
{ {
[_SRImages[13] drawInRect:imageRect [_SRImages[13] drawInRect:imageRect
fromRect:NSZeroRect fromRect:NSZeroRect
operation:NSCompositeSourceOver operation:NSCompositingOperationSourceOver
fraction:1.0]; fraction:1.0];
} }
@ -828,108 +828,6 @@ typedef NS_ENUM(NSUInteger, _SRRecorderControlButtonTag)
return self.objectValue; return self.objectValue;
} }
#pragma mark NSAccessibility
- (BOOL)accessibilityIsIgnored
{
return NO;
}
- (NSArray *)accessibilityAttributeNames
{
static NSArray *AttributeNames = nil;
static dispatch_once_t OnceToken;
dispatch_once(&OnceToken, ^
{
AttributeNames = [[super accessibilityAttributeNames] mutableCopy];
NSArray *newAttributes = @[
NSAccessibilityRoleAttribute,
NSAccessibilityTitleAttribute,
NSAccessibilityEnabledAttribute
];
for (NSString *attributeName in newAttributes)
{
if (![AttributeNames containsObject:attributeName])
[(NSMutableArray *)AttributeNames addObject:attributeName];
}
AttributeNames = [AttributeNames copy];
});
return AttributeNames;
}
- (id)accessibilityAttributeValue:(NSString *)anAttributeName
{
if ([anAttributeName isEqualToString:NSAccessibilityRoleAttribute])
return NSAccessibilityButtonRole;
else if ([anAttributeName isEqualToString:NSAccessibilityTitleAttribute])
return self.accessibilityLabel;
else if ([anAttributeName isEqualToString:NSAccessibilityEnabledAttribute])
return @(self.enabled);
else
return [super accessibilityAttributeValue:anAttributeName];
}
- (NSArray *)accessibilityActionNames
{
static NSArray *AllActions = nil;
static NSArray *ButtonStateActionNames = nil;
static NSArray *RecorderStateActionNames = nil;
static dispatch_once_t OnceToken;
dispatch_once(&OnceToken, ^
{
AllActions = @[
NSAccessibilityPressAction,
NSAccessibilityCancelAction,
NSAccessibilityDeleteAction
];
ButtonStateActionNames = @[
NSAccessibilityPressAction
];
RecorderStateActionNames = @[
NSAccessibilityCancelAction,
NSAccessibilityDeleteAction
];
});
// List of supported actions names must be fixed for 10.6, but can vary for 10.7 and above.
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
{
if (self.enabled)
{
if (self.isRecording)
return RecorderStateActionNames;
else
return ButtonStateActionNames;
}
else
return @[];
}
else
return AllActions;
}
- (NSString *)accessibilityActionDescription:(NSString *)anAction
{
return NSAccessibilityActionDescription(anAction);
}
- (void)accessibilityPerformAction:(NSString *)anAction
{
if ([anAction isEqualToString:NSAccessibilityPressAction])
[self beginRecording];
else if (self.isRecording && [anAction isEqualToString:NSAccessibilityCancelAction])
[self endRecording];
else if (self.isRecording && [anAction isEqualToString:NSAccessibilityDeleteAction])
[self clearAndEndRecording];
}
#pragma mark NSToolTipOwner #pragma mark NSToolTipOwner
- (NSString *)view:(NSView *)aView stringForToolTip:(NSToolTipTag)aTag point:(NSPoint)aPoint userData:(void *)aData - (NSString *)view:(NSView *)aView stringForToolTip:(NSToolTipTag)aTag point:(NSPoint)aPoint userData:(void *)aData

Loading…
Cancel
Save