diff options
author | Ananya Sen | 2012-07-23 17:01:14 -0700 |
---|---|---|
committer | Ananya Sen | 2012-07-23 17:01:14 -0700 |
commit | 48d9ed19573a07c68da305d14ca6ab3a04d31d64 (patch) | |
tree | b4bf6c48c7fdade2cf531d84cac3359489d38405 /js/stage | |
parent | c07a7a9d11bc8299fa9686544b18840cc8e640c2 (diff) | |
parent | afc7ad4f240fdf7890a79c2d4d7f8eb2e7c30a34 (diff) | |
download | ninja-48d9ed19573a07c68da305d14ca6ab3a04d31d64.tar.gz |
Merge branch 'refs/heads/Jose-Document' into Document
Diffstat (limited to 'js/stage')
-rwxr-xr-x | js/stage/binding-view.reel/binding-view.js | 2 | ||||
-rwxr-xr-x | js/stage/layout.js | 58 | ||||
-rwxr-xr-x | js/stage/stage.reel/stage.js | 356 |
3 files changed, 221 insertions, 195 deletions
diff --git a/js/stage/binding-view.reel/binding-view.js b/js/stage/binding-view.reel/binding-view.js index 3e83281e..b207cc3d 100755 --- a/js/stage/binding-view.reel/binding-view.js +++ b/js/stage/binding-view.reel/binding-view.js | |||
@@ -365,7 +365,7 @@ exports.BindingView = Montage.create(Component, { | |||
365 | this.mouseOverHud = overHud; | 365 | this.mouseOverHud = overHud; |
366 | if(this._isDrawingConnection && !overHud) { | 366 | if(this._isDrawingConnection && !overHud) { |
367 | //NOTE : Continue This content. mouse over select | 367 | //NOTE : Continue This content. mouse over select |
368 | var obj = this.application.ninja.stage.getElement(event, true); | 368 | var obj = this.application.ninja.stage.getElement(e, true); |
369 | if (obj && obj !== this.selectedElement) | 369 | if (obj && obj !== this.selectedElement) |
370 | { | 370 | { |
371 | if (!obj.controller || obj === null) | 371 | if (!obj.controller || obj === null) |
diff --git a/js/stage/layout.js b/js/stage/layout.js index d133f100..5cc8dbea 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js | |||
@@ -67,19 +67,11 @@ exports.Layout = Montage.create(Component, { | |||
67 | return this._currentDocument; | 67 | return this._currentDocument; |
68 | }, | 68 | }, |
69 | set : function(value) { | 69 | set : function(value) { |
70 | if (value === this._currentDocument) {// || value.getProperty("currentView") !== "design") { | 70 | if (value !== this._currentDocument) { |
71 | return; | 71 | this._currentDocument = value; |
72 | } | 72 | if(this._currentDocument && this._currentDocument.currentView === "design") { |
73 | 73 | this.elementsToDraw = Array.prototype.slice.call(this._currentDocument.model.documentRoot.childNodes, 0); | |
74 | drawUtils._eltArray.length = 0; | 74 | } |
75 | drawUtils._planesArray.length = 0; | ||
76 | |||
77 | this._currentDocument = value; | ||
78 | |||
79 | if(!value) { | ||
80 | |||
81 | } else if(this._currentDocument.currentView === "design") { | ||
82 | this.elementsToDraw = this._currentDocument.model.documentRoot.childNodes; | ||
83 | } | 75 | } |
84 | } | 76 | } |
85 | }, | 77 | }, |
@@ -113,17 +105,6 @@ exports.Layout = Montage.create(Component, { | |||
113 | this.ctx = this.canvas.getContext("2d"); | 105 | this.ctx = this.canvas.getContext("2d"); |
114 | this.ctx.lineWidth = this.ctxLineWidth; | 106 | this.ctx.lineWidth = this.ctxLineWidth; |
115 | this.ctx.fillStyle = this.drawFillColor; | 107 | this.ctx.fillStyle = this.drawFillColor; |
116 | |||
117 | this.eventManager.addEventListener("selectionChange", this, false); | ||
118 | this.eventManager.addEventListener("elementsRemoved", this, false); | ||
119 | } | ||
120 | }, | ||
121 | |||
122 | // Redraw stage only once after all deletion is completed | ||
123 | handleElementsRemoved: { | ||
124 | value: function(event) { | ||
125 | this.draw(); | ||
126 | this.draw3DInfo(false); | ||
127 | } | 108 | } |
128 | }, | 109 | }, |
129 | 110 | ||
@@ -131,13 +112,16 @@ exports.Layout = Montage.create(Component, { | |||
131 | value: function(event) { | 112 | value: function(event) { |
132 | var containerIndex; | 113 | var containerIndex; |
133 | 114 | ||
115 | // Clear the elements to draw | ||
116 | this.elementsToDraw.length = 0; | ||
117 | |||
134 | if(this.currentDocument === null){ | 118 | if(this.currentDocument === null){ |
135 | return; | 119 | return; |
136 | } | 120 | } |
137 | 121 | ||
138 | if(this.currentDocument.currentView === "design"){ | 122 | if(this.currentDocument.currentView === "design"){ |
139 | // Make an array copy of the line node list which is not an array like object | 123 | // Make an array copy of the live node list which is not an array like object |
140 | this.domTree = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true); | 124 | this.domTree = this.currentDocument.model.views.design.getLiveNodeList(true); |
141 | // Index of the current container | 125 | // Index of the current container |
142 | containerIndex = this.domTree.indexOf(this.currentDocument.model.domContainer); | 126 | containerIndex = this.domTree.indexOf(this.currentDocument.model.domContainer); |
143 | 127 | ||
@@ -149,8 +133,6 @@ exports.Layout = Montage.create(Component, { | |||
149 | this.domTree = Array.prototype.slice.call(this.domTree[containerIndex].childNodes, 0); | 133 | this.domTree = Array.prototype.slice.call(this.domTree[containerIndex].childNodes, 0); |
150 | } | 134 | } |
151 | } | 135 | } |
152 | // Clear the elements to draw | ||
153 | this.elementsToDraw.length = 0; | ||
154 | 136 | ||
155 | // Draw the non selected elements | 137 | // Draw the non selected elements |
156 | if(!event.detail.isDocument) { | 138 | if(!event.detail.isDocument) { |
@@ -161,9 +143,6 @@ exports.Layout = Montage.create(Component, { | |||
161 | this.elementsToDraw = Array.prototype.slice.call(this.domTree, 0); | 143 | this.elementsToDraw = Array.prototype.slice.call(this.domTree, 0); |
162 | } | 144 | } |
163 | 145 | ||
164 | this.draw(); // Not a reel yet | ||
165 | this.draw3DInfo(false); | ||
166 | |||
167 | // Clear the domTree copy | 146 | // Clear the domTree copy |
168 | this.domTree.length = 0; | 147 | this.domTree.length = 0; |
169 | } | 148 | } |
@@ -171,8 +150,6 @@ exports.Layout = Montage.create(Component, { | |||
171 | 150 | ||
172 | draw: { | 151 | draw: { |
173 | value: function() { | 152 | value: function() { |
174 | this.clearCanvas(); | ||
175 | |||
176 | // TODO Bind the layoutview mode to the current document | 153 | // TODO Bind the layoutview mode to the current document |
177 | // var mode = this.application.ninja.currentDocument.layoutMode; | 154 | // var mode = this.application.ninja.currentDocument.layoutMode; |
178 | if(this.layoutView === "layoutOff") return; | 155 | if(this.layoutView === "layoutOff") return; |
@@ -184,21 +161,6 @@ exports.Layout = Montage.create(Component, { | |||
184 | } | 161 | } |
185 | }, | 162 | }, |
186 | 163 | ||
187 | draw3DInfo: { | ||
188 | value: function(updatePlanes) { | ||
189 | if(updatePlanes) { | ||
190 | drawUtils.updatePlanes(); | ||
191 | this.application.ninja.stage.stageDeps.snapManager._isCacheInvalid = true; | ||
192 | } | ||
193 | |||
194 | if(this.stage.appModel.show3dGrid) { | ||
195 | this.application.ninja.stage.stageDeps.snapManager.updateWorkingPlaneFromView(); | ||
196 | } | ||
197 | drawUtils.drawWorkingPlane(); | ||
198 | drawUtils.draw3DCompass(); | ||
199 | } | ||
200 | }, | ||
201 | |||
202 | clearCanvas: { | 164 | clearCanvas: { |
203 | value: function() { | 165 | value: function() { |
204 | this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); | 166 | this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); |
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 7c587989..817220d4 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js | |||
@@ -29,10 +29,10 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |||
29 | POSSIBILITY OF SUCH DAMAGE. | 29 | POSSIBILITY OF SUCH DAMAGE. |
30 | </copyright> */ | 30 | </copyright> */ |
31 | 31 | ||
32 | var Montage = require("montage/core/core").Montage, | 32 | var Montage = require("montage/core/core").Montage, |
33 | Component = require("montage/ui/component").Component, | 33 | Component = require("montage/ui/component").Component, |
34 | drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, | 34 | drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, |
35 | vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; | 35 | vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; |
36 | 36 | ||
37 | exports.Stage = Montage.create(Component, { | 37 | exports.Stage = Montage.create(Component, { |
38 | 38 | ||
@@ -46,8 +46,20 @@ exports.Stage = Montage.create(Component, { | |||
46 | drawNow: { value : false }, | 46 | drawNow: { value : false }, |
47 | switchedFromCodeDoc: { value : false }, | 47 | switchedFromCodeDoc: { value : false }, |
48 | 48 | ||
49 | drawLayout: { value : false }, | ||
50 | updatePlanes: { value : false }, | ||
51 | draw3DInfo: { value : false }, | ||
52 | |||
49 | // TO REVIEW | 53 | // TO REVIEW |
50 | zoomFactor: {value : 1 }, | 54 | zoomFactor: { |
55 | get: function() { | ||
56 | if (this._viewport && this._viewport.style && this._viewport.style.zoom) { | ||
57 | return Number(this._viewport.style.zoom); | ||
58 | } else { | ||
59 | return 1; | ||
60 | } | ||
61 | } | ||
62 | }, | ||
51 | 63 | ||
52 | _canvasSelectionPrefs: { value: { "thickness" : 1.0, "color" : "#46a1ff" } }, | 64 | _canvasSelectionPrefs: { value: { "thickness" : 1.0, "color" : "#46a1ff" } }, |
53 | _canvasDrawingPrefs: { value: { "thickness" : 1.0, "color" : "#000" } }, | 65 | _canvasDrawingPrefs: { value: { "thickness" : 1.0, "color" : "#000" } }, |
@@ -85,7 +97,21 @@ exports.Stage = Montage.create(Component, { | |||
85 | set: function(value) { | 97 | set: function(value) { |
86 | this._resizeCanvases = value; | 98 | this._resizeCanvases = value; |
87 | if(value) { | 99 | if(value) { |
88 | this.needsDraw = true; | 100 | // TODO GET THE SCROLL SIZE FROM THE CSS -- 11 px |
101 | this._canvas.width = this._layoutCanvas.width = this._drawingCanvas.width = this._gridCanvas.width = this.bindingView.width = this.element.offsetWidth - 11; | ||
102 | this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this._gridCanvas.height = this.bindingView.height = this.element.offsetHeight - 11;// - 26 - 26; | ||
103 | |||
104 | if(this.currentDocument) { | ||
105 | if(this.currentDocument.currentView === "design") { | ||
106 | this.drawLayout = true; | ||
107 | this.updatePlanes = true; | ||
108 | this.draw3DInfo = true; | ||
109 | this.needsDrawSelection = true; | ||
110 | } | ||
111 | if(this.currentDocument.model && this.currentDocument.model.documentRoot) { | ||
112 | this.currentDocument.model.documentRoot.elementModel.setProperty("offsetCache", false); | ||
113 | } | ||
114 | } | ||
89 | } | 115 | } |
90 | } | 116 | } |
91 | }, | 117 | }, |
@@ -99,6 +125,44 @@ exports.Stage = Montage.create(Component, { | |||
99 | set: function(value) { | 125 | set: function(value) { |
100 | this._updatedStage = value; | 126 | this._updatedStage = value; |
101 | if(value) { | 127 | if(value) { |
128 | if(this.currentDocument) { | ||
129 | if(this.currentDocument.currentView === "design") { | ||
130 | this.drawLayout = true; | ||
131 | this.updatePlanes = true; | ||
132 | this.draw3DInfo = true; | ||
133 | this.needsDrawSelection = true; | ||
134 | } | ||
135 | if(this.currentDocument.model && this.currentDocument.model.documentRoot) { | ||
136 | this.currentDocument.model.documentRoot.elementModel.setProperty("offsetCache", false); | ||
137 | } | ||
138 | } | ||
139 | } | ||
140 | } | ||
141 | }, | ||
142 | |||
143 | _needsDr |