Repository navigation
Expand file tree
/
Copy pathWDToolManager.m
More file actions
94 lines (75 loc) · 2.59 KB
/
Copy pathWDToolManager.m
File metadata and controls
94 lines (75 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//
// WDToolManager.m
// Inkpad
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2011-2013 Steve Sprang
//
#import "WDAddAnchorTool.h"
#import "WDEyedropperTool.h"
#import "WDEraserTool.h"
#import "WDFreehandTool.h"
#import "WDPenTool.h"
#import "WDRotateTool.h"
#import "WDScaleTool.h"
#import "WDScissorTool.h"
#import "WDSelectionTool.h"
#import "WDShapeTool.h"
#import "WDTextTool.h"
#import "WDToolManager.h"
NSString *WDActiveToolDidChange = @"WDActiveToolDidChange";
@implementation WDToolManager
@synthesize activeTool = activeTool_;
@synthesize tools = tools_;
+ (WDToolManager *) sharedInstance
{
static WDToolManager *toolManager_ = nil;
if (!toolManager_) {
toolManager_ = [[WDToolManager alloc] init];
toolManager_.activeTool = (toolManager_.tools)[0];
}
return toolManager_;
}
- (NSArray *) tools
{
if (!tools_) {
WDSelectionTool *groupSelect = (WDSelectionTool *) [WDSelectionTool tool];
groupSelect.groupSelect = YES;
WDShapeTool *oval = (WDShapeTool *) [WDShapeTool tool];
oval.shapeMode = WDShapeOval;
WDShapeTool *rect = (WDShapeTool *) [WDShapeTool tool];
rect.shapeMode = WDShapeRectangle;
WDShapeTool *star = (WDShapeTool *) [WDShapeTool tool];
star.shapeMode = WDShapeStar;
WDShapeTool *poly = (WDShapeTool *) [WDShapeTool tool];
poly.shapeMode = WDShapePolygon;
WDShapeTool *line = (WDShapeTool *) [WDShapeTool tool];
line.shapeMode = WDShapeLine;
WDShapeTool *spiral = (WDShapeTool *) [WDShapeTool tool];
spiral.shapeMode = WDShapeSpiral;
tools_ = @[[WDSelectionTool tool],
groupSelect,
[WDPenTool tool],
[WDAddAnchorTool tool],
[WDScissorTool tool],
[WDFreehandTool tool],
[WDEraserTool tool],
@[rect, oval, star, poly, spiral, line],
[WDTextTool tool],
[WDEyedropperTool tool],
[WDScaleTool tool],
[WDRotateTool tool]];
}
return tools_;
}
- (void) setActiveTool:(WDTool *)activeTool
{
[activeTool_ deactivated];
activeTool_ = activeTool;
[activeTool_ activated];
[[NSNotificationCenter defaultCenter] postNotificationName:WDActiveToolDidChange object:nil userInfo:nil];
}
@end