aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomáš Znamenáček2014-08-06 18:38:51 +0200
committerTomáš Znamenáček2015-01-07 15:42:21 +0100
commitf9f48f5ca83f7723eabdd16d0c95195092a8a514 (patch)
tree7f0442c909d5e9bd182099bfbd94d377ee5eac0f
parent444d1bccb9770738fa4ea40383c23f44a55089c2 (diff)
downloadMASShortcut-f9f48f5ca83f7723eabdd16d0c95195092a8a514.tar.bz2
Removed explicit @synthesize and renamed “appearance” to “style”.
The “appearance” property didn’t play nice with auto-synthesizing, not really sure why.
-rw-r--r--Framework/MASShortcutView.h12
-rw-r--r--Framework/MASShortcutView.m42
2 files changed, 23 insertions, 31 deletions
diff --git a/Framework/MASShortcutView.h b/Framework/MASShortcutView.h
index 8cff0ca..166be44 100644
--- a/Framework/MASShortcutView.h
+++ b/Framework/MASShortcutView.h
@@ -3,11 +3,11 @@
extern NSString *const MASShortcutBinding;
typedef enum {
- MASShortcutViewAppearanceDefault = 0, // Height = 19 px
- MASShortcutViewAppearanceTexturedRect, // Height = 25 px
- MASShortcutViewAppearanceRounded, // Height = 43 px
- MASShortcutViewAppearanceFlat
-} MASShortcutViewAppearance;
+ MASShortcutViewStyleDefault = 0, // Height = 19 px
+ MASShortcutViewStyleTexturedRect, // Height = 25 px
+ MASShortcutViewStyleRounded, // Height = 43 px
+ MASShortcutViewStyleFlat
+} MASShortcutViewStyle;
@interface MASShortcutView : NSView
@@ -16,7 +16,7 @@ typedef enum {
@property (nonatomic, getter = isRecording) BOOL recording;
@property (nonatomic, getter = isEnabled) BOOL enabled;
@property (nonatomic, copy) void (^shortcutValueChange)(MASShortcutView *sender);
-@property (nonatomic) MASShortcutViewAppearance appearance;
+@property (nonatomic, assign) MASShortcutViewStyle style;
/// Returns custom class for drawing control.
+ (Class)shortcutCellClass;
diff --git a/Framework/MASShortcutView.m b/Framework/MASShortcutView.m
index d03efbc..61df2d0 100644
--- a/Framework/MASShortcutView.m
+++ b/Framework/MASShortcutView.m
@@ -25,14 +25,6 @@ NSString *const MASShortcutBinding = @"shortcutValue";
NSTrackingArea *_hintArea;
}
-@synthesize enabled = _enabled;
-@synthesize hinting = _hinting;
-@synthesize shortcutValue = _shortcutValue;
-@synthesize shortcutPlaceholder = _shortcutPlaceholder;
-@synthesize shortcutValueChange = _shortcutValueChange;
-@synthesize recording = _recording;
-@synthesize appearance = _appearance;
-
#pragma mark -
+ (Class)shortcutCellClass
@@ -91,10 +83,10 @@ NSString *const MASShortcutBinding = @"shortcutValue";
}
}
-- (void)setAppearance:(MASShortcutViewAppearance)appearance
+- (void)setStyle:(MASShortcutViewStyle)newStyle
{
- if (_appearance != appearance) {
- _appearance = appearance;
+ if (_style != newStyle) {
+ _style = newStyle;
[self resetShortcutCellStyle];
[self setNeedsDisplay:YES];
}
@@ -102,20 +94,20 @@ NSString *const MASShortcutBinding = @"shortcutValue";
- (void)resetShortcutCellStyle
{
- switch (_appearance) {
- case MASShortcutViewAppearanceDefault: {
+ switch (_style) {
+ case MASShortcutViewStyleDefault: {
_shortcutCell.bezelStyle = NSRoundRectBezelStyle;
break;
}
- case MASShortcutViewAppearanceTexturedRect: {
+ case MASShortcutViewStyleTexturedRect: {
_shortcutCell.bezelStyle = NSTexturedRoundedBezelStyle;
break;
}
- case MASShortcutViewAppearanceRounded: {
+ case MASShortcutViewStyleRounded: {
_shortcutCell.bezelStyle = NSRoundedBezelStyle;
break;
}
- case MASShortcutViewAppearanceFlat: {
+ case MASShortcutViewStyleFlat: {
self.wantsLayer = YES;
_shortcutCell.backgroundColor = [NSColor clearColor];
_shortcutCell.bordered = NO;
@@ -178,20 +170,20 @@ NSString *const MASShortcutBinding = @"shortcutValue";
_shortcutCell.state = state;
_shortcutCell.enabled = self.enabled;
- switch (_appearance) {
- case MASShortcutViewAppearanceDefault: {
+ switch (_style) {
+ case MASShortcutViewStyleDefault: {
[_shortcutCell drawWithFrame:frame inView:self];
break;
}
- case MASShortcutViewAppearanceTexturedRect: {
+ case MASShortcutViewStyleTexturedRect: {
[_shortcutCell drawWithFrame:CGRectOffset(frame, 0.0, 1.0) inView:self];
break;
}
- case MASShortcutViewAppearanceRounded: {
+ case MASShortcutViewStyleRounded: {
[_shortcutCell drawWithFrame:CGRectOffset(frame, 0.0, 1.0) inView:self];
break;
}
- case MASShortcutViewAppearanceFlat: {
+ case MASShortcutViewStyleFlat: {
[_shortcutCell drawWithFrame:frame inView:self];
break;
}
@@ -243,10 +235,10 @@ NSString *const MASShortcutBinding = @"shortcutValue";
{
CGRect shortcutRect, hintRect;
CGFloat hintButtonWidth = HINT_BUTTON_WIDTH;
- switch (self.appearance) {
- case MASShortcutViewAppearanceTexturedRect: hintButtonWidth += 2.0; break;
- case MASShortcutViewAppearanceRounded: hintButtonWidth += 3.0; break;
- case MASShortcutViewAppearanceFlat: hintButtonWidth -= 8.0 - (_shortcutCell.font.pointSize - BUTTON_FONT_SIZE); break;
+ 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;
default: break;
}
CGRectDivide(self.bounds, &hintRect, &shortcutRect, hintButtonWidth, CGRectMaxXEdge);