diff options
Diffstat (limited to 'js/stage/stage-deps.js')
-rwxr-xr-x | js/stage/stage-deps.js | 117 |
1 files changed, 11 insertions, 106 deletions
diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index a71b77be..896d4a5b 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js | |||
@@ -11,8 +11,7 @@ var Montage = require("montage/core/core").Montage, | |||
11 | drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, | 11 | drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, |
12 | ElementPlanes = require("js/helper-classes/3D/element-planes").ElementPlanes, | 12 | ElementPlanes = require("js/helper-classes/3D/element-planes").ElementPlanes, |
13 | MathUtilsClass = require("js/helper-classes/3D/math-utils").MathUtilsClass, | 13 | MathUtilsClass = require("js/helper-classes/3D/math-utils").MathUtilsClass, |
14 | VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, | 14 | VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; |
15 | DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase; | ||
16 | 15 | ||
17 | exports.StageDeps = Montage.create(Component, { | 16 | exports.StageDeps = Montage.create(Component, { |
18 | viewUtils: { | 17 | viewUtils: { |
@@ -27,55 +26,10 @@ exports.StageDeps = Montage.create(Component, { | |||
27 | value: drawUtils | 26 | value: drawUtils |
28 | }, | 27 | }, |
29 | 28 | ||
30 | currentStage: { | ||
31 | value: null | ||
32 | }, | ||
33 | |||
34 | _currentDocument: { | ||
35 | value: null | ||
36 | }, | ||
37 | |||
38 | currentDocument: { | ||
39 | get: function() { return this._currentDocument; }, | ||
40 | set: function(value) { | ||
41 | if(value) { | ||
42 | this._currentDocument = value; | ||
43 | this.currentStage = value.documentRoot; | ||
44 | } | ||
45 | } | ||
46 | }, | ||
47 | |||
48 | _userContentLeft: { | ||
49 | value: null | ||
50 | }, | ||
51 | |||
52 | userContentLeft: { | ||
53 | get: function() { return this._userContentLeft; }, | ||
54 | set: function(value) { | ||
55 | if(value) { | ||
56 | viewUtils.setUserContentLeft(value); | ||
57 | } | ||
58 | } | ||
59 | }, | ||
60 | |||
61 | _userContentTop: { | ||
62 | value: null | ||
63 | }, | ||
64 | |||
65 | userContentTop: { | ||
66 | get: function() { return this._userContentTop; }, | ||
67 | set: function(value) { | ||
68 | if(value) { | ||
69 | viewUtils.setUserContentTop(value); | ||
70 | } | ||
71 | } | ||
72 | }, | ||
73 | |||
74 | deserializedFromTemplate: { | 29 | deserializedFromTemplate: { |
75 | value: function() { | 30 | value: function() { |
76 | 31 | ||
77 | this.eventManager.addEventListener( "appLoaded", this, false); | 32 | this.eventManager.addEventListener("appLoaded", this, false); |
78 | this.eventManager.addEventListener( "openDocument", this, false); | ||
79 | 33 | ||
80 | // Initialize Deps | 34 | // Initialize Deps |
81 | // HACK | 35 | // HACK |
@@ -94,31 +48,14 @@ exports.StageDeps = Montage.create(Component, { | |||
94 | 48 | ||
95 | handleAppLoaded: { | 49 | handleAppLoaded: { |
96 | value: function() { | 50 | value: function() { |
97 | |||
98 | Object.defineBinding(this, "currentDocument", { | ||
99 | boundObject: this.application.ninja, | ||
100 | boundObjectPropertyPath: "currentDocument", | ||
101 | oneway: true | ||
102 | }); | ||
103 | |||
104 | Object.defineBinding(this, "userContentLeft", { | ||
105 | boundObject: this.stage, | ||
106 | boundObjectPropertyPath: "_userContentLeft", | ||
107 | oneway: true | ||
108 | }); | ||
109 | |||
110 | Object.defineBinding(this, "userContentTop", { | ||
111 | boundObject: this.stage, | ||
112 | boundObjectPropertyPath: "_userContentTop", | ||
113 | oneway: true | ||
114 | }); | ||
115 | |||
116 | // Setup the snap manager pointer to the app model | 51 | // Setup the snap manager pointer to the app model |
117 | snapManager.appModel = this.application.ninja.appModel; | 52 | snapManager.appModel = this.application.ninja.appModel; |
118 | // bind the snap properties to the snap manager | 53 | // bind the snap properties to the snap manager |
119 | snapManager.bindSnap(); | 54 | snapManager.bindSnap(); |
120 | 55 | ||
121 | 56 | drawUtils.viewUtils = viewUtils; | |
57 | drawUtils.snapManager = snapManager; | ||
58 | drawUtils.ElementPlanes = ElementPlanes; | ||
122 | } | 59 | } |
123 | }, | 60 | }, |
124 | 61 | ||
@@ -127,53 +64,21 @@ exports.StageDeps = Montage.create(Component, { | |||
127 | 64 | ||
128 | workingPlane = [0,0,1,0]; | 65 | workingPlane = [0,0,1,0]; |
129 | 66 | ||
130 | snapManager.setCurrentStage(this.currentStage); | 67 | snapManager._isCacheInvalid = true; |
131 | 68 | snapManager.setupDragPlaneFromPlane (workingPlane); | |
132 | viewUtils.setCurrentDocument(this.currentDocument); | ||
133 | viewUtils.setRootElement(this.currentStage.parentNode); | ||
134 | viewUtils.setStageElement(this.currentStage); | ||
135 | |||
136 | drawUtils.viewUtils = viewUtils; | ||
137 | drawUtils.snapManager = snapManager; | ||
138 | drawUtils.ElementPlanes = ElementPlanes; | ||
139 | |||
140 | snapManager._isCacheInvalid=true; | ||
141 | |||
142 | snapManager.setupDragPlaneFromPlane ( workingPlane ); | ||
143 | |||
144 | DrawingToolBase.stage = this.currentStage; | ||
145 | DrawingToolBase.stageComponent = this.stage; | ||
146 | 69 | ||
147 | drawUtils.initializeFromDocument(); | 70 | drawUtils.initializeFromDocument(); |
148 | } | 71 | } |
149 | }, | 72 | }, |
150 | 73 | ||
151 | reinitializeForSwitchDocument: { | 74 | handleSwitchDocument: { |
152 | value: function() { | 75 | value: function(){ |
153 | |||
154 | workingPlane = [0,0,1,0]; | 76 | workingPlane = [0,0,1,0]; |
155 | 77 | ||
156 | snapManager.setCurrentStage(this.currentStage); | 78 | snapManager._isCacheInvalid = true; |
157 | 79 | snapManager.setupDragPlaneFromPlane (workingPlane); | |
158 | viewUtils.setCurrentDocument(this.currentDocument); | ||
159 | viewUtils.setRootElement(this.currentStage.parentNode); | ||
160 | viewUtils.setStageElement(this.currentStage); | ||
161 | |||
162 | drawUtils.viewUtils = viewUtils; | ||
163 | drawUtils.snapManager = snapManager; | ||
164 | drawUtils.ElementPlanes = ElementPlanes; | ||
165 | |||
166 | snapManager._isCacheInvalid=true; | ||
167 | |||
168 | snapManager.setupDragPlaneFromPlane ( workingPlane ); | ||
169 | |||
170 | DrawingToolBase.stage = this.currentStage; | ||
171 | DrawingToolBase.stageComponent = this.stage; | ||
172 | 80 | ||
173 | drawUtils.initializeFromDocument(); | 81 | drawUtils.initializeFromDocument(); |
174 | } | 82 | } |
175 | } | 83 | } |
176 | |||
177 | |||
178 | |||
179 | }); \ No newline at end of file | 84 | }); \ No newline at end of file |