From 67f4a5477ba5c924ba5384cf9e86408f3db2f603 Mon Sep 17 00:00:00 2001 From: Tomáš Znamenáček Date: Wed, 4 Mar 2015 16:15:47 +0100 Subject: Trivial refactoring. --- Framework/MASShortcutView.m | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'Framework/MASShortcutView.m') diff --git a/Framework/MASShortcutView.m b/Framework/MASShortcutView.m index 1e1a0d8..4952b4f 100644 --- a/Framework/MASShortcutView.m +++ b/Framework/MASShortcutView.m @@ -3,9 +3,8 @@ NSString *const MASShortcutBinding = @"shortcutValue"; -#define HINT_BUTTON_WIDTH 23.0 -#define BUTTON_FONT_SIZE 11.0 -#define SEGMENT_CHROME_WIDTH 6.0 +static const CGFloat MASHintButtonWidth = 23; +static const CGFloat MASButtonFontSize = 11; #pragma mark - @@ -56,7 +55,7 @@ NSString *const MASShortcutBinding = @"shortcutValue"; { _shortcutCell = [[[self.class shortcutCellClass] alloc] init]; _shortcutCell.buttonType = NSPushOnPushOffButton; - _shortcutCell.font = [[NSFontManager sharedFontManager] convertFont:_shortcutCell.font toSize:BUTTON_FONT_SIZE]; + _shortcutCell.font = [[NSFontManager sharedFontManager] convertFont:_shortcutCell.font toSize:MASButtonFontSize]; _shortcutValidator = [MASShortcutValidator sharedValidator]; _enabled = YES; _showsDeleteButton = YES; @@ -155,7 +154,7 @@ NSString *const MASShortcutBinding = @"shortcutValue"; _shortcutValue = shortcutValue; [self resetToolTips]; [self setNeedsDisplay:YES]; - [self propagateValue:shortcutValue forBinding:@"shortcutValue"]; + [self propagateValue:shortcutValue forBinding:MASShortcutBinding]; if (self.shortcutValueChange) { self.shortcutValueChange(self); @@ -252,11 +251,11 @@ NSString *const MASShortcutBinding = @"shortcutValue"; - (void)getShortcutRect:(CGRect *)shortcutRectRef hintRect:(CGRect *)hintRectRef { CGRect shortcutRect, hintRect; - CGFloat hintButtonWidth = HINT_BUTTON_WIDTH; + CGFloat hintButtonWidth = MASHintButtonWidth; switch (self.style) { case MASShortcutViewStyleTexturedRect: hintButtonWidth += 2.0; break; case MASShortcutViewStyleRounded: hintButtonWidth += 3.0; break; - case MASShortcutViewStyleFlat: hintButtonWidth -= 8.0 - (_shortcutCell.font.pointSize - BUTTON_FONT_SIZE); break; + case MASShortcutViewStyleFlat: hintButtonWidth -= 8.0 - (_shortcutCell.font.pointSize - MASButtonFontSize); break; default: break; } CGRectDivide(self.bounds, &hintRect, &shortcutRect, hintButtonWidth, CGRectMaxXEdge); @@ -547,7 +546,7 @@ void *kUserDataHint = &kUserDataHint; - (NSString *)accessibilityLabel { - NSString* title = _shortcutValue.description ? _shortcutValue.description : @"Empty"; + NSString* title = _shortcutValue.description ?: @"Empty"; title = [title stringByAppendingFormat:@" %@", NSLocalizedString(@"keyboard shortcut", @"VoiceOver title")]; return title; } -- cgit v1.2.3