projects
/
enjoyable.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bf0910f
)
I had no idea you could use class property access like this it's the best thing ever.
author
Joe Wreschnig
<joe.wreschnig@gmail.com>
Sat, 2 Mar 2013 02:38:58 +0000
(
03:38
+0100)
committer
Joe Wreschnig
<joe.wreschnig@gmail.com>
Sat, 2 Mar 2013 02:38:58 +0000
(
03:38
+0100)
ApplicationController.m
patch
|
blob
|
history
ConfigsController.m
patch
|
blob
|
history
KeyInputTextView.m
patch
|
blob
|
history
Target.m
patch
|
blob
|
history
TargetConfig.m
patch
|
blob
|
history
TargetController.m
patch
|
blob
|
history
TargetMouseBtn.m
patch
|
blob
|
history
TargetMouseMove.m
patch
|
blob
|
history
TargetToggleMouseScope.m
patch
|
blob
|
history
diff --git
a/ApplicationController.m
b/ApplicationController.m
index
61910a6
..
9a2db2a
100644
(file)
--- a/
ApplicationController.m
+++ b/
ApplicationController.m
@@
-26,7
+26,7
@@
self.targetController.enabled = NO;
[self.jsController setup];
[self.configsController load];
self.targetController.enabled = NO;
[self.jsController setup];
[self.configsController load];
- [
[NSWorkspace sharedWorkspace]
.notificationCenter
+ [
NSWorkspace.sharedWorkspace
.notificationCenter
addObserver:self
selector:@selector(didSwitchApplication:)
name:NSWorkspaceDidActivateApplicationNotification
addObserver:self
selector:@selector(didSwitchApplication:)
name:NSWorkspaceDidActivateApplicationNotification
@@
-34,8
+34,8
@@
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
- [
[NSUserDefaults standardUserDefaults]
synchronize];
- [
[NSWorkspace sharedWorkspace]
.notificationCenter
+ [
NSUserDefaults.standardUserDefaults
synchronize];
+ [
NSWorkspace.sharedWorkspace
.notificationCenter
removeObserver:self
name:NSWorkspaceDidActivateApplicationNotification
object:nil];
removeObserver:self
name:NSWorkspaceDidActivateApplicationNotification
object:nil];
@@
-56,7
+56,7
@@
}
- (void)configsChanged {
}
- (void)configsChanged {
- NSInteger removeFrom =
[self firstConfigMenuIndex]
;
+ NSInteger removeFrom =
self.firstConfigMenuIndex
;
while (dockMenuBase.numberOfItems > removeFrom)
[dockMenuBase removeItemAtIndex:dockMenuBase.numberOfItems - 1];
int added = 0;
while (dockMenuBase.numberOfItems > removeFrom)
[dockMenuBase removeItemAtIndex:dockMenuBase.numberOfItems - 1];
int added = 0;
@@
-72,7
+72,7
@@
}
- (void)configChanged {
}
- (void)configChanged {
- NSInteger firstConfig =
[self firstConfigMenuIndex]
;
+ NSInteger firstConfig =
self.firstConfigMenuIndex
;
Config *current = self.configsController.currentConfig;
NSArray *configs = self.configsController.configs;
for (NSUInteger i = 0; i < configs.count; ++i)
Config *current = self.configsController.currentConfig;
NSArray *configs = self.configsController.configs;
for (NSUInteger i = 0; i < configs.count; ++i)
@@
-80,7
+80,7
@@
}
- (void)chooseConfig:(id)sender {
}
- (void)chooseConfig:(id)sender {
- NSInteger idx = [dockMenuBase indexOfItem:sender] -
[self firstConfigMenuIndex]
;
+ NSInteger idx = [dockMenuBase indexOfItem:sender] -
self.firstConfigMenuIndex
;
Config *chosen = self.configsController.configs[idx];
[_configsController activateConfig:chosen];
}
Config *chosen = self.configsController.configs[idx];
[_configsController activateConfig:chosen];
}
diff --git
a/ConfigsController.m
b/ConfigsController.m
index
a3b8bcd
..
1c100f2
100644
(file)
--- a/
ConfigsController.m
+++ b/
ConfigsController.m
@@
-50,14
+50,14
@@
_currentConfig = config;
[removeButton setEnabled:_configs[0] != config];
[targetController loadCurrent];
_currentConfig = config;
[removeButton setEnabled:_configs[0] != config];
[targetController loadCurrent];
- [(ApplicationController *)
[[NSApplication sharedApplication] delegate]
configChanged];
+ [(ApplicationController *)
NSApplication.sharedApplication.delegate
configChanged];
[tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:[_configs indexOfObject:config]] byExtendingSelection:NO];
}
- (IBAction)addPressed:(id)sender {
Config *newConfig = [[Config alloc] initWithName:@"Untitled"];
[_configs addObject:newConfig];
[tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:[_configs indexOfObject:config]] byExtendingSelection:NO];
}
- (IBAction)addPressed:(id)sender {
Config *newConfig = [[Config alloc] initWithName:@"Untitled"];
[_configs addObject:newConfig];
- [(ApplicationController *)
[[NSApplication sharedApplication] delegate]
configsChanged];
+ [(ApplicationController *)
NSApplication.sharedApplication.delegate
configsChanged];
[tableView reloadData];
[tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:_configs.count - 1] byExtendingSelection:NO];
[tableView editColumn:0 row:_configs.count - 1 withEvent:nil select:YES];
[tableView reloadData];
[tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:_configs.count - 1] byExtendingSelection:NO];
[tableView editColumn:0 row:_configs.count - 1 withEvent:nil select:YES];
@@
-69,7
+69,7
@@
[_configs removeObjectAtIndex:tableView.selectedRow];
[tableView reloadData];
[_configs removeObjectAtIndex:tableView.selectedRow];
[tableView reloadData];
- [(ApplicationController *)
[[NSApplication sharedApplication] delegate]
configsChanged];
+ [(ApplicationController *)
NSApplication.sharedApplication.delegate
configsChanged];
[self activateConfig:_configs[0]];
[self save];
}
[self activateConfig:_configs[0]];
[self save];
}
@@
-86,7
+86,7
@@
- (void)tableView:(NSTableView *)view setObjectValue:(NSString *)obj forTableColumn:(NSTableColumn *)col row:(NSInteger)index {
[(Config *)_configs[index] setName:obj];
[tableView reloadData];
- (void)tableView:(NSTableView *)view setObjectValue:(NSString *)obj forTableColumn:(NSTableColumn *)col row:(NSInteger)index {
[(Config *)_configs[index] setName:obj];
[tableView reloadData];
- [(ApplicationController *)
[[NSApplication sharedApplication] delegate]
configsChanged];
+ [(ApplicationController *)
NSApplication.sharedApplication.delegate
configsChanged];
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
@@
-99,11
+99,11
@@
- (void)save {
NSLog(@"Saving defaults.");
- (void)save {
NSLog(@"Saving defaults.");
- [
[NSUserDefaults standardUserDefaults]
setObject:[self dumpAll] forKey:@"configurations"];
+ [
NSUserDefaults.standardUserDefaults
setObject:[self dumpAll] forKey:@"configurations"];
}
- (void)load {
}
- (void)load {
- [self loadAllFrom:[
[NSUserDefaults standardUserDefaults]
objectForKey:@"configurations"]];
+ [self loadAllFrom:[
NSUserDefaults.standardUserDefaults
objectForKey:@"configurations"]];
}
- (NSDictionary *)dumpAll {
}
- (NSDictionary *)dumpAll {
@@
-141,7
+141,7
@@
current = 0;
_configs = newConfigs;
[tableView reloadData];
current = 0;
_configs = newConfigs;
[tableView reloadData];
- [(ApplicationController *)
[[NSApplication sharedApplication] delegate]
configsChanged];
+ [(ApplicationController *)
NSApplication.sharedApplication.delegate
configsChanged];
[self activateConfig:_configs[current]];
}
}
[self activateConfig:_configs[current]];
}
}
@@
-154,7
+154,7
@@
: nil;
[stream close];
: nil;
[stream close];
- if (!([serialization isKindOfClass:
[NSDictionary class]
]
+ if (!([serialization isKindOfClass:
NSDictionary.class
]
&& serialization[@"entries"])) {
*error = [NSError errorWithDomain:@"Enjoyable"
code:0
&& serialization[@"entries"])) {
*error = [NSError errorWithDomain:@"Enjoyable"
code:0
@@
-220,7
+220,7
@@
}
[self save];
}
[self save];
- [(ApplicationController *)
[[NSApplication sharedApplication] delegate]
configsChanged];
+ [(ApplicationController *)
NSApplication.sharedApplication.delegate
configsChanged];
[self activateConfig:cfg];
[targetController loadCurrent];
[self activateConfig:cfg];
[targetController loadCurrent];
diff --git
a/KeyInputTextView.m
b/KeyInputTextView.m
index
91a2a34
..
6c8e094
100644
(file)
--- a/
KeyInputTextView.m
+++ b/
KeyInputTextView.m
@@
-161,12
+161,12
@@
}
- (BOOL)becomeFirstResponder {
}
- (BOOL)becomeFirstResponder {
-
[self setBackgroundColor:[NSColor selectedTextBackgroundColor]]
;
+
self.backgroundColor = NSColor.selectedTextBackgroundColor
;
return [super becomeFirstResponder];
}
- (BOOL)resignFirstResponder {
return [super becomeFirstResponder];
}
- (BOOL)resignFirstResponder {
-
[self setBackgroundColor:[NSColor textBackgroundColor]]
;
+
self.backgroundColor = NSColor.textBackgroundColor
;
return [super resignFirstResponder];
}
return [super resignFirstResponder];
}
diff --git
a/Target.m
b/Target.m
index
36da021
..
700a151
100644
(file)
--- a/
Target.m
+++ b/
Target.m
@@
-31,17
+31,17
@@
+ (Target *)targetDeserialize:(NSDictionary *)serialization
withConfigs:(NSArray *)configs {
// Don't crash loading old configs (but don't load them either).
+ (Target *)targetDeserialize:(NSDictionary *)serialization
withConfigs:(NSArray *)configs {
// Don't crash loading old configs (but don't load them either).
- if (![serialization isKindOfClass:
[NSDictionary class]
])
+ if (![serialization isKindOfClass:
NSDictionary.class
])
return nil;
NSString *type = serialization[@"type"];
return nil;
NSString *type = serialization[@"type"];
- for (Class cls in @[
[TargetKeyboard class]
,
-
[TargetConfig class]
,
-
[TargetMouseMove class]
,
-
[TargetMouseBtn class]
,
-
[TargetMouseScroll class]
,
- [TargetToggleMouseScope class]
+ for (Class cls in @[
TargetKeyboard.class
,
+
TargetConfig.class
,
+
TargetMouseMove.class
,
+
TargetMouseBtn.class
,
+
TargetMouseScroll.class
,
+ TargetToggleMouseScope.class
]) {
]) {
- if ([type isEqualToString:
[cls serializationCode]
])
+ if ([type isEqualToString:
cls.serializationCode
])
return [cls targetDeserialize:serialization withConfigs:configs];
}
return [cls targetDeserialize:serialization withConfigs:configs];
}
diff --git
a/TargetConfig.m
b/TargetConfig.m
index
a06f3fb
..
055f782
100644
(file)
--- a/
TargetConfig.m
+++ b/
TargetConfig.m
@@
-37,7
+37,8
@@
}
- (void)trigger {
}
- (void)trigger {
- [[(ApplicationController *)[[NSApplication sharedApplication] delegate] configsController] activateConfig:_config];
+ ApplicationController *ctrl = NSApplication.sharedApplication.delegate;
+ [ctrl.configsController activateConfig:_config];
}
@end
}
@end
diff --git
a/TargetController.m
b/TargetController.m
index
2ecb060
..
75f58ab
100644
(file)
--- a/
TargetController.m
+++ b/
TargetController.m
@@
-170,10
+170,10
@@
title.stringValue = [[NSString alloc] initWithFormat:@"%@ > %@", configsController.currentConfig.name, actFullName];
}
title.stringValue = [[NSString alloc] initWithFormat:@"%@ > %@", configsController.currentConfig.name, actFullName];
}
- if ([target isKindOfClass:
[TargetKeyboard class]
]) {
+ if ([target isKindOfClass:
TargetKeyboard.class
]) {
[radioButtons selectCellAtRow:1 column:0];
keyInput.vk = [(TargetKeyboard*)target vk];
[radioButtons selectCellAtRow:1 column:0];
keyInput.vk = [(TargetKeyboard*)target vk];
- } else if ([target isKindOfClass:
[TargetConfig class]
]) {
+ } else if ([target isKindOfClass:
TargetConfig.class
]) {
[radioButtons selectCellAtRow:2 column:0];
NSUInteger idx = [configsController.configs
indexOfObject:[(TargetConfig *)target config]];
[radioButtons selectCellAtRow:2 column:0];
NSUInteger idx = [configsController.configs
indexOfObject:[(TargetConfig *)target config]];
@@
-183,19
+183,19
@@
} else
[configPopup selectItemAtIndex:idx];
}
} else
[configPopup selectItemAtIndex:idx];
}
- else if ([target isKindOfClass:
[TargetMouseMove class]
]) {
+ else if ([target isKindOfClass:
TargetMouseMove.class
]) {
[radioButtons selectCellAtRow:3 column:0];
[mouseDirSelect setSelectedSegment:[(TargetMouseMove *)target axis]];
}
[radioButtons selectCellAtRow:3 column:0];
[mouseDirSelect setSelectedSegment:[(TargetMouseMove *)target axis]];
}
- else if ([target isKindOfClass:
[TargetMouseBtn class]
]) {
+ else if ([target isKindOfClass:
TargetMouseBtn.class
]) {
[radioButtons selectCellAtRow:4 column:0];
mouseBtnSelect.selectedSegment = [(TargetMouseBtn *)target button] == kCGMouseButtonLeft ? 0 : 1;
}
[radioButtons selectCellAtRow:4 column:0];
mouseBtnSelect.selectedSegment = [(TargetMouseBtn *)target button] == kCGMouseButtonLeft ? 0 : 1;
}
- else if ([target isKindOfClass:
[TargetMouseScroll class]
]) {
+ else if ([target isKindOfClass:
TargetMouseScroll.class
]) {
[radioButtons selectCellAtRow:5 column:0];
scrollDirSelect.selectedSegment = [(TargetMouseScroll *)target amount] > 0;
}
[radioButtons selectCellAtRow:5 column:0];
scrollDirSelect.selectedSegment = [(TargetMouseScroll *)target amount] > 0;
}
- else if ([target isKindOfClass:
[TargetToggleMouseScope class]
]) {
+ else if ([target isKindOfClass:
TargetToggleMouseScope.class
]) {
[radioButtons selectCellAtRow:6 column:0];
} else {
[radioButtons selectCellAtRow:self.enabled ? 0 : -1 column:0];
[radioButtons selectCellAtRow:6 column:0];
} else {
[radioButtons selectCellAtRow:self.enabled ? 0 : -1 column:0];
@@
-204,7
+204,7
@@
}
- (void)loadCurrent {
}
- (void)loadCurrent {
- [self loadTarget:
[self currentTarget]
forAction:joystickController.selectedAction];
+ [self loadTarget:
self.currentTarget
forAction:joystickController.selectedAction];
}
- (void)focusKey {
}
- (void)focusKey {
diff --git
a/TargetMouseBtn.m
b/TargetMouseBtn.m
index
653014a
..
951715d
100644
(file)
--- a/
TargetMouseBtn.m
+++ b/
TargetMouseBtn.m
@@
-25,9
+25,8
@@
}
-(void) trigger {
}
-(void) trigger {
- NSRect screenRect = [[NSScreen mainScreen] frame];
- CGFloat height = screenRect.size.height;
- NSPoint mouseLoc = [NSEvent mouseLocation];
+ CGFloat height = NSScreen.mainScreen.frame.size.height;
+ NSPoint mouseLoc = NSEvent.mouseLocation;
CGEventType eventType = (_button == kCGMouseButtonLeft) ? kCGEventLeftMouseDown : kCGEventRightMouseDown;
CGEventRef click = CGEventCreateMouseEvent(NULL,
eventType,
CGEventType eventType = (_button == kCGMouseButtonLeft) ? kCGEventLeftMouseDown : kCGEventRightMouseDown;
CGEventRef click = CGEventCreateMouseEvent(NULL,
eventType,
@@
-38,9
+37,8
@@
}
-(void) untrigger {
}
-(void) untrigger {
- NSRect screenRect = [[NSScreen mainScreen] frame];
- CGFloat height = screenRect.size.height;
- NSPoint mouseLoc = [NSEvent mouseLocation];
+ CGFloat height = NSScreen.mainScreen.frame.size.height;
+ NSPoint mouseLoc = NSEvent.mouseLocation;
CGEventType eventType = (_button == kCGMouseButtonLeft) ? kCGEventLeftMouseUp : kCGEventRightMouseUp;
CGEventRef click = CGEventCreateMouseEvent(NULL,
eventType,
CGEventType eventType = (_button == kCGMouseButtonLeft) ? kCGEventLeftMouseUp : kCGEventRightMouseUp;
CGEventRef click = CGEventCreateMouseEvent(NULL,
eventType,
diff --git
a/TargetMouseMove.m
b/TargetMouseMove.m
index
9deabcc
..
3ec8f38
100644
(file)
--- a/
TargetMouseMove.m
+++ b/
TargetMouseMove.m
@@
-46,12
+46,11
@@
return NO;
}
return NO;
}
- NSRect screenRect = [[NSScreen mainScreen] frame];
- CGFloat height = screenRect.size.height;
+ CGFloat height = NSScreen.mainScreen.frame.size.height;
// TODO
float speed = 4.f;
// TODO
float speed = 4.f;
- if (
[jc frontWindowOnly]
)
+ if (
jc.frontWindowOnly
)
speed = 12.f;
float dx = 0.f, dy = 0.f;
if (_axis == 0)
speed = 12.f;
float dx = 0.f, dy = 0.f;
if (_axis == 0)
@@
-70,7
+69,7
@@
CGEventSetIntegerValueField(move, kCGMouseEventDeltaX, (int)dx);
CGEventSetIntegerValueField(move, kCGMouseEventDeltaY, (int)dy);
CGEventSetIntegerValueField(move, kCGMouseEventDeltaX, (int)dx);
CGEventSetIntegerValueField(move, kCGMouseEventDeltaY, (int)dy);
- if (
[jc frontWindowOnly]
) {
+ if (
jc.frontWindowOnly
) {
ProcessSerialNumber psn;
GetFrontProcess(&psn);
CGEventPostToPSN(&psn, move);
ProcessSerialNumber psn;
GetFrontProcess(&psn);
CGEventPostToPSN(&psn, move);
diff --git
a/TargetToggleMouseScope.m
b/TargetToggleMouseScope.m
index
2f03c2f
..
863a35f
100644
(file)
--- a/
TargetToggleMouseScope.m
+++ b/
TargetToggleMouseScope.m
@@
-28,9
+28,9
@@
- (void)trigger {
// FIXME: It's hacky to get at the controller this way, but it's
// also hacky to pass it. Shouldn't need to do either.
- (void)trigger {
// FIXME: It's hacky to get at the controller this way, but it's
// also hacky to pass it. Shouldn't need to do either.
- ApplicationController *ac =
[NSApplication sharedApplication]
.delegate;
+ ApplicationController *ac =
NSApplication.sharedApplication
.delegate;
JoystickController *jc = ac.jsController;
JoystickController *jc = ac.jsController;
-
[jc setFrontWindowOnly: ![jc frontWindowOnly]]
;
+
jc.frontWindowOnly = !jc.frontWindowOnly
;
}
@end
}
@end