diff options
author | Nivesh Rajbhandari | 2012-04-16 16:06:24 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-04-16 16:06:24 -0700 |
commit | c253192a08b499ea7be46fa5438d273e51f7ec5a (patch) | |
tree | 18a1f0e3679c0eb993a9dedb537035d3861f49ac /js/ninja.reel/ninja.js | |
parent | e19376c54eedd1f1c457ba405b2f110be376a559 (diff) | |
parent | 4b900ea5cd6bb77eb30cec8c03b9ec9fa662c1e9 (diff) | |
download | ninja-c253192a08b499ea7be46fa5438d273e51f7ec5a.tar.gz |
Merge branch 'refs/heads/ninja-internal' into WebGLFixes
Diffstat (limited to 'js/ninja.reel/ninja.js')
-rwxr-xr-x | js/ninja.reel/ninja.js | 160 |
1 files changed, 158 insertions, 2 deletions
diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index 2a6e49f7..9b5081dd 100755 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js | |||
@@ -6,6 +6,7 @@ | |||
6 | 6 | ||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | Component = require("montage/ui/component").Component, | 8 | Component = require("montage/ui/component").Component, |
9 | UndoManager = require("montage/core/undo-manager").UndoManager, | ||
9 | AppData = require("js/data/appdata").AppData; | 10 | AppData = require("js/data/appdata").AppData; |
10 | 11 | ||
11 | var matrix = require("js/lib/math/matrix"); | 12 | var matrix = require("js/lib/math/matrix"); |
@@ -23,6 +24,113 @@ exports.Ninja = Montage.create(Component, { | |||
23 | value: null | 24 | value: null |
24 | }, | 25 | }, |
25 | 26 | ||
27 | _isResizing: { | ||
28 | value: null | ||
29 | }, | ||
30 | _resizedHeight : { | ||
31 | value: 0 | ||
32 | }, | ||
33 | _height: { | ||
34 | value: null | ||
35 | }, | ||
36 | |||
37 | height: { | ||
38 | get: function() { | ||
39 | if(this._height === null) { | ||
40 | var storedData = this.application.localStorage.getItem("timelinePanel"); | ||
41 | if(storedData && storedData.value) { | ||
42 | this._height = storedData.value; | ||
43 | } | ||
44 | } | ||
45 | return this._height; | ||
46 | }, | ||
47 | set: function(val) { | ||
48 | if(this._height != val) { | ||
49 | this._height = val; | ||
50 | this.application.localStorage.setItem("timelinePanel", {"version": this.version, "value": val}); | ||
51 | this.needsDraw = true; | ||
52 | } | ||
53 | |||
54 | } | ||
55 | }, | ||
56 | |||
57 | _resizedWidth : { | ||
58 | value: 0 | ||
59 | }, | ||
60 | _width: { | ||
61 | value: null | ||
62 | }, | ||
63 | |||
64 | width: { | ||
65 | get: function() { | ||
66 | if(this._width === null) { | ||
67 | var storedData = this.application.localStorage.getItem("rightPanelsContainer"); | ||
68 | if(storedData && storedData.value) { | ||
69 | this._width = storedData.value; | ||
70 | } | ||
71 | } | ||
72 | return this._width; | ||
73 | }, | ||
74 | set: function(val) { | ||
75 | if(this._width != val) { | ||
76 | this._width = val; | ||
77 | this.application.localStorage.setItem("rightPanelsContainer", {"version": this.version, "value": val}); | ||
78 | this.needsDraw = true; | ||
79 | } | ||
80 | |||
81 | } | ||
82 | }, | ||
83 | |||
84 | handleResizeStart: { | ||
85 | value:function(e) { | ||
86 | this.isResizing = true; | ||
87 | this.height = parseInt(this.timeline.element.offsetHeight); | ||
88 | this.width = parseInt(this.rightPanelContainer.offsetWidth); | ||
89 | this.rightPanelContainer.classList.add("disableTransition"); | ||
90 | this.timeline.element.classList.add("disableTransition"); | ||
91 | this.needsDraw = true; | ||
92 | } | ||
93 | }, | ||
94 | |||
95 | handleResizeMove: { | ||
96 | value:function(e) { | ||
97 | this._resizedHeight = e._event.dY; | ||
98 | this._resizedWidth = e._event.dX; | ||
99 | this.stage.resizeCanvases = true; | ||
100 | this.needsDraw = true; | ||
101 | } | ||
102 | }, | ||
103 | |||
104 | handleResizeEnd: { | ||
105 | value: function(e) { | ||
106 | // this.height -= this._resizedHeight; | ||
107 | // this.width -= this._resizedWidth; | ||
108 | this.stage.resizeCanvases = true; | ||
109 | this._resizedHeight = 0; | ||
110 | this._resizedWidth = 0; | ||
111 | this.isResizing = false; | ||
112 | this.needsDraw = true; | ||
113 | this.rightPanelContainer.classList.remove("disableTransition"); | ||
114 | this.timeline.element.classList.remove("disableTransition"); | ||
115 | this.height = this.timeline.element.offsetHeight; | ||
116 | this.width = this.rightPanelContainer.offsetWidth; | ||
117 | } | ||
118 | }, | ||
119 | |||
120 | handleResizeReset: { | ||
121 | value: function(e) { | ||
122 | this.width = 253; | ||
123 | this.height = 140; | ||
124 | this._resizedHeight = 0; | ||
125 | this._resizedWidth = 0; | ||
126 | this.timelineSplitter.collapsed = false; | ||
127 | this.panelSplitter.collapsed = false; | ||
128 | this.stage.resizeCanvases = true; | ||
129 | this.needsDraw = true; | ||
130 | } | ||
131 | }, | ||
132 | |||
133 | |||
26 | selectedElements: { | 134 | selectedElements: { |
27 | value: [] | 135 | value: [] |
28 | }, | 136 | }, |
@@ -34,7 +142,7 @@ exports.Ninja = Montage.create(Component, { | |||
34 | templateDidLoad: { | 142 | templateDidLoad: { |
35 | value: function() { | 143 | value: function() { |
36 | this.ninjaVersion = window.ninjaVersion.ninja.version; | 144 | this.ninjaVersion = window.ninjaVersion.ninja.version; |
37 | this.eventManager.addEventListener( "preloadFinish", this, false); | 145 | this.undoManager = document.application.undoManager = UndoManager.create(); |
38 | } | 146 | } |
39 | }, | 147 | }, |
40 | 148 | ||
@@ -53,7 +161,6 @@ exports.Ninja = Montage.create(Component, { | |||
53 | 161 | ||
54 | window.addEventListener("resize", this, false); | 162 | window.addEventListener("resize", this, false); |
55 | 163 | ||
56 | // this.eventManager.addEventListener( "appLoading", this, false); // Don't need this anymore | ||
57 | this.eventManager.addEventListener( "selectTool", this, false); | 164 | this.eventManager.addEventListener( "selectTool", this, false); |
58 | this.eventManager.addEventListener( "selectSubTool", this, false); | 165 | this.eventManager.addEventListener( "selectSubTool", this, false); |
59 | this.eventManager.addEventListener( "onOpenDocument", this, false); | 166 | this.eventManager.addEventListener( "onOpenDocument", this, false); |
@@ -78,12 +185,40 @@ exports.Ninja = Montage.create(Component, { | |||
78 | } | 185 | } |
79 | }, | 186 | }, |
80 | 187 | ||
188 | willDraw: { | ||
189 | value: function() { | ||
190 | |||
191 | } | ||
192 | }, | ||
193 | |||
194 | draw: { | ||
195 | value: function() { | ||
196 | if(this.isResizing) { | ||
197 | if (this.height - this._resizedHeight < 46) { | ||
198 | this.timelineSplitter.collapsed = true; | ||
199 | } else { | ||
200 | this.timelineSplitter.collapsed = false; | ||
201 | } | ||
202 | |||
203 | if (this.width - this._resizedWidth < 30) { | ||
204 | this.panelSplitter.collapsed = true; | ||
205 | } else { | ||
206 | this.panelSplitter.collapsed = false; | ||
207 | } | ||
208 | |||
209 | } | ||
210 | this.rightPanelContainer.style.width = (this.width - this._resizedWidth) + "px"; | ||
211 | this.timeline.element.style.height = (this.height - this._resizedHeight) + "px"; | ||
212 | } | ||
213 | }, | ||
214 | |||
81 | _didDraw: { | 215 | _didDraw: { |
82 | value: false | 216 | value: false |
83 | }, | 217 | }, |
84 | 218 | ||
85 | didDraw: { | 219 | didDraw: { |
86 | value: function() { | 220 | value: function() { |
221 | |||
87 | if(!this._didDraw) { | 222 | if(!this._didDraw) { |
88 | if (!this.application.ninja.coreIoApi.ioServiceDetected) { | 223 | if (!this.application.ninja.coreIoApi.ioServiceDetected) { |
89 | var check = this.application.ninja.coreIoApi.cloudAvailable(); | 224 | var check = this.application.ninja.coreIoApi.cloudAvailable(); |
@@ -166,6 +301,27 @@ exports.Ninja = Montage.create(Component, { | |||
166 | this.currentDocument.documentRoot.elementModel.controller.setProperty(this.currentDocument.documentRoot, "overflow", overflow); | 301 | this.currentDocument.documentRoot.elementModel.controller.setProperty(this.currentDocument.documentRoot, "overflow", overflow); |
167 | this.currentDocument.documentRoot.elementModel.controller.changeSelector(this.currentDocument.documentRoot, "transitionStopRule", transitionStopRule); | 302 | this.currentDocument.documentRoot.elementModel.controller.changeSelector(this.currentDocument.documentRoot, "transitionStopRule", transitionStopRule); |
168 | 303 | ||
304 | this._toggleWebGlAnimation(this.appModel.livePreview); | ||
305 | } | ||
306 | }, | ||
307 | |||
308 | // Turn on WebGL animation during preview | ||
309 | _toggleWebGlAnimation: { | ||
310 | value: function(inLivePreview) { | ||
311 | var glCanvases = this.currentDocument.iframe.contentWindow.document.querySelectorAll('[data-RDGE-id]'), | ||
312 | glShapeModel; | ||
313 | if(glCanvases) { | ||
314 | for(var i = 0, len = glCanvases.length; i<len; i++) { | ||
315 | glShapeModel = glCanvases[i].elementModel.shapeModel; | ||
316 | if(inLivePreview) { | ||
317 | glShapeModel.GLWorld._previewAnimation = true; | ||
318 | glShapeModel.GLWorld.restartRenderLoop(); | ||
319 | } else if (!glShapeModel.animate ) { | ||
320 | glShapeModel.GLWorld._previewAnimation = false; | ||
321 | glShapeModel.GLWorld._canvas.task.stop(); | ||
322 | } | ||
323 | } | ||
324 | } | ||
169 | } | 325 | } |
170 | }, | 326 | }, |
171 | 327 | ||