diff options
author | Pierre Frisch | 2011-12-22 07:25:50 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-01-27 11:18:17 -0800 |
commit | b89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch) | |
tree | 0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /js/stage/stage-deps.js | |
parent | 2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff) | |
download | ninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz |
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'js/stage/stage-deps.js')
-rw-r--r-- | js/stage/stage-deps.js | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js new file mode 100644 index 00000000..7c6d58b4 --- /dev/null +++ b/js/stage/stage-deps.js | |||
@@ -0,0 +1,150 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | var Montage = require("montage/core/core").Montage, | ||
8 | Component = require("montage/ui/component").Component; | ||
9 | |||
10 | var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; | ||
11 | var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils; | ||
12 | var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; | ||
13 | var ElementPlanes = require("js/helper-classes/3D/element-planes").ElementPlanes; | ||
14 | var MathUtilsClass = require("js/helper-classes/3D/math-utils").MathUtilsClass; | ||
15 | var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; | ||
16 | |||
17 | //TODO : This dependency needs to be reworked | ||
18 | var DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase; | ||
19 | |||
20 | exports.StageDeps = Montage.create(Component, { | ||
21 | viewUtils: { | ||
22 | value: viewUtils | ||
23 | }, | ||
24 | |||
25 | snapManager: { | ||
26 | value: snapManager | ||
27 | }, | ||
28 | |||
29 | currentStage: { | ||
30 | value: null | ||
31 | }, | ||
32 | |||
33 | _currentDocument: { | ||
34 | value: null | ||
35 | }, | ||
36 | |||
37 | currentDocument: { | ||
38 | get: function() { return this._currentDocument; }, | ||
39 | set: function(value) { | ||
40 | if(value) { | ||
41 | this._currentDocument = value; | ||
42 | this.currentStage = value.documentRoot; | ||
43 | } | ||
44 | } | ||
45 | }, | ||
46 | |||
47 | _userContentLeft: { | ||
48 | value: null | ||
49 | }, | ||
50 | |||
51 | userContentLeft: { | ||
52 | get: function() { return this._userContentLeft; }, | ||
53 | set: function(value) { | ||
54 | if(value) { | ||
55 | viewUtils.setUserContentLeft(value); | ||
56 | } | ||
57 | } | ||
58 | }, | ||
59 | |||
60 | _userContentTop: { | ||
61 | value: null | ||
62 | }, | ||
63 | |||
64 | userContentTop: { | ||
65 | get: function() { return this._userContentTop; }, | ||
66 | set: function(value) { | ||
67 | if(value) { | ||
68 | viewUtils.setUserContentTop(value); | ||
69 | } | ||
70 | } | ||
71 | }, | ||
72 | |||
73 | deserializedFromTemplate: { | ||
74 | value: function() { | ||
75 | |||
76 | this.eventManager.addEventListener( "appLoaded", this, false); | ||
77 | this.eventManager.addEventListener( "openDocument", this, false); | ||
78 | |||
79 | // Initialize Deps | ||
80 | // HACK | ||
81 | // TODO Rework | ||
82 | window.MathUtils = MathUtilsClass; | ||
83 | window.VecUtils = VecUtils; | ||
84 | |||
85 | snapManager.drawingCanvas = this.stage.drawingCanvas; | ||
86 | |||
87 | // Setup the listeners for the draw-util and snapmanager when removing elements | ||
88 | // TODO Revisit when supporting multiple documents | ||
89 | drawUtils.initialize(); | ||
90 | snapManager.initialize(); | ||
91 | } | ||
92 | }, | ||
93 | |||
94 | handleAppLoaded: { | ||
95 | value: function() { | ||
96 | |||
97 | Object.defineBinding(this, "currentDocument", { | ||
98 | boundObject: this.application.ninja, | ||
99 | boundObjectPropertyPath: "currentDocument", | ||
100 | oneway: true | ||
101 | }); | ||
102 | |||
103 | Object.defineBinding(this, "userContentLeft", { | ||
104 | boundObject: this.stage, | ||
105 | boundObjectPropertyPath: "_userContentLeft", | ||
106 | oneway: true | ||
107 | }); | ||
108 | |||
109 | Object.defineBinding(this, "userContentTop", { | ||
110 | boundObject: this.stage, | ||
111 | boundObjectPropertyPath: "_userContentTop", | ||
112 | oneway: true | ||
113 | }); | ||
114 | |||
115 | // Setup the snap manager pointer to the app model | ||
116 | snapManager.appModel = this.application.ninja.appModel; | ||
117 | // bind the snap properties to the snap manager | ||
118 | snapManager.bindSnap(); | ||
119 | |||
120 | |||
121 | } | ||
122 | }, | ||
123 | |||
124 | handleOpenDocument: { | ||
125 | value: function() { | ||
126 | |||
127 | workingPlane = Vector.create( [0,0,1,0] ); | ||
128 | |||
129 | snapManager.setCurrentStage(this.currentStage); | ||
130 | |||
131 | viewUtils.setCurrentDocument(this.currentDocument); | ||
132 | viewUtils.setRootElement(this.currentStage.parentNode); | ||
133 | viewUtils.setStageElement(this.currentStage); | ||
134 | |||
135 | drawUtils.setDrawingSurfaceElement(this.stage.canvas); | ||
136 | drawUtils.setSourceSpaceElement( this.currentStage ); | ||
137 | drawUtils.setWorkingPlane( workingPlane ); | ||
138 | drawUtils.viewUtils = viewUtils; | ||
139 | drawUtils.snapManager = snapManager; | ||
140 | drawUtils.ElementPlanes = ElementPlanes; | ||
141 | |||
142 | snapManager.setupDragPlaneFromPlane ( workingPlane ); | ||
143 | |||
144 | DrawingToolBase.stage = this.currentStage; | ||
145 | DrawingToolBase.stageComponent = this.stage; | ||
146 | |||
147 | } | ||
148 | } | ||
149 | |||
150 | }); \ No newline at end of file | ||