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/stage | |
parent | e19376c54eedd1f1c457ba405b2f110be376a559 (diff) | |
parent | 4b900ea5cd6bb77eb30cec8c03b9ec9fa662c1e9 (diff) | |
download | ninja-c253192a08b499ea7be46fa5438d273e51f7ec5a.tar.gz |
Merge branch 'refs/heads/ninja-internal' into WebGLFixes
Diffstat (limited to 'js/stage')
-rwxr-xr-x | js/stage/layout.js | 61 | ||||
-rwxr-xr-x | js/stage/stage-view.reel/stage-view.js | 12 | ||||
-rwxr-xr-x | js/stage/stage.reel/stage.html | 7 | ||||
-rwxr-xr-x | js/stage/stage.reel/stage.js | 51 | ||||
-rwxr-xr-x | js/stage/tool-handle.js | 7 |
5 files changed, 94 insertions, 44 deletions
diff --git a/js/stage/layout.js b/js/stage/layout.js index 8a53a08b..a096848e 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js | |||
@@ -53,44 +53,26 @@ exports.Layout = Montage.create(Component, { | |||
53 | this.ctx.lineWidth = this.ctxLineWidth; | 53 | this.ctx.lineWidth = this.ctxLineWidth; |
54 | this.ctx.fillStyle = this.drawFillColor; | 54 | this.ctx.fillStyle = this.drawFillColor; |
55 | 55 | ||
56 | // this.eventManager.addEventListener("elementAdded", this, false); | ||
57 | this.eventManager.addEventListener("elementDeleted", this, false); | ||
58 | |||
59 | this.eventManager.addEventListener("selectionChange", this, false); | 56 | this.eventManager.addEventListener("selectionChange", this, false); |
60 | 57 | this.eventManager.addEventListener("elementsRemoved", this, false); | |
61 | this.eventManager.addEventListener("deleteSelection", this, false); | ||
62 | } | 58 | } |
63 | }, | 59 | }, |
64 | 60 | ||
65 | handleOpenDocument: { | 61 | handleOpenDocument: { |
66 | value: function() { | 62 | value: function() { |
67 | // Initial elements to draw is the entire node list | 63 | // Initial elements to draw are the childrens of the root element |
68 | if(this.application.ninja.documentController.activeDocument.currentView === "design"){//only for designer view | 64 | if(this.application.ninja.documentController.activeDocument.currentView === "design") { |
69 | this.elementsToDraw = this.application.ninja.documentController.activeDocument._liveNodeList; | 65 | this.elementsToDraw = this.application.ninja.documentController.activeDocument.documentRoot.childNodes; |
70 | } | 66 | } |
67 | |||
71 | // Draw the elements and the 3d info | 68 | // Draw the elements and the 3d info |
72 | this.draw(); | 69 | this.draw(); |
73 | this.draw3DInfo(false); | 70 | this.draw3DInfo(false); |
74 | } | 71 | } |
75 | }, | 72 | }, |
76 | 73 | ||
77 | // No need to keep track of the added elements. We now have a live node list of the dom | ||
78 | handleElementAdded: { | ||
79 | value: function(event) { | ||
80 | // this.domTree.push(event.detail); | ||
81 | // this.draw(); | ||
82 | // this.draw3DInfo(false); | ||
83 | } | ||
84 | }, | ||
85 | |||
86 | handleElementDeleted: { | ||
87 | value: function(event) { | ||
88 | //this.domTree.splice(this.domTree.indexOf(event.detail), 1); | ||
89 | } | ||
90 | }, | ||
91 | |||
92 | // Redraw stage only once after all deletion is completed | 74 | // Redraw stage only once after all deletion is completed |
93 | handleDeleteSelection: { | 75 | handleElementsRemoved: { |
94 | value: function(event) { | 76 | value: function(event) { |
95 | this.draw(); | 77 | this.draw(); |
96 | this.draw3DInfo(false); | 78 | this.draw3DInfo(false); |
@@ -99,30 +81,39 @@ exports.Layout = Montage.create(Component, { | |||
99 | 81 | ||
100 | handleSelectionChange: { | 82 | handleSelectionChange: { |
101 | value: function(event) { | 83 | value: function(event) { |
84 | var containerIndex; | ||
102 | 85 | ||
103 | if(this.application.ninja.documentController.activeDocument === null){ | 86 | if(this.application.ninja.documentController.activeDocument === null){ |
104 | return; | 87 | return; |
105 | } | 88 | } |
106 | 89 | ||
107 | // Make an array copy of the line node list which is not an array like object | 90 | if(this.application.ninja.documentController.activeDocument.currentView === "design"){ |
108 | if(this.application.ninja.documentController.activeDocument.currentView === "design"){//only for designer view | 91 | // Make an array copy of the line node list which is not an array like object |
109 | this.domTree = Array.prototype.slice.call(this.application.ninja.documentController.activeDocument._liveNodeList, 0); | 92 | this.domTree = Array.prototype.slice.call(this.application.ninja.documentController.activeDocument._liveNodeList, 0); |
93 | // Index of the current container | ||
94 | containerIndex = this.domTree.indexOf(this.application.ninja.currentSelectedContainer); | ||
95 | |||
96 | if(containerIndex < 0) { | ||
97 | // Stage is the container. | ||
98 | this.domTree = Array.prototype.slice.call(this.application.ninja.currentSelectedContainer.childNodes, 0); | ||
99 | } else { | ||
100 | // Child nodes of the container | ||
101 | this.domTree = Array.prototype.slice.call(this.domTree[containerIndex].childNodes, 0); | ||
102 | } | ||
110 | } | 103 | } |
111 | // Clear the elements to draw | 104 | // Clear the elements to draw |
112 | this.elementsToDraw.length = 0; | 105 | this.elementsToDraw.length = 0; |
113 | 106 | ||
114 | // Draw the non selected elements | 107 | // Draw the non selected elements |
115 | if(!event.detail.isDocument) { | 108 | if(!event.detail.isDocument) { |
116 | var tmp = event.detail.elements.map(function(element){ return element._element}); | ||
117 | |||
118 | this.elementsToDraw = this.domTree.filter(function(value) { | 109 | this.elementsToDraw = this.domTree.filter(function(value) { |
119 | return (tmp.indexOf(value) === -1); | 110 | return (event.detail.elements.indexOf(value) === -1); |
120 | }); | 111 | }); |
121 | } else { | 112 | } else { |
122 | this.elementsToDraw = this.domTree; | 113 | this.elementsToDraw = Array.prototype.slice.call(this.domTree, 0); |
123 | } | 114 | } |
124 | 115 | ||
125 | this.draw(); // Not a reel yet :) | 116 | this.draw(); // Not a reel yet |
126 | this.draw3DInfo(false); | 117 | this.draw3DInfo(false); |
127 | 118 | ||
128 | // Clear the domTree copy | 119 | // Clear the domTree copy |
@@ -165,7 +156,7 @@ exports.Layout = Montage.create(Component, { | |||
165 | drawTagOutline: { | 156 | drawTagOutline: { |
166 | value: function (item) { | 157 | value: function (item) { |
167 | 158 | ||
168 | if(!item) return; | 159 | if(!item || (item.nodeType !== 1)) return; |
169 | 160 | ||
170 | // TODO Bind the layoutview mode to the current document | 161 | // TODO Bind the layoutview mode to the current document |
171 | // var mode = this.application.ninja.currentDocument.layoutMode; | 162 | // var mode = this.application.ninja.currentDocument.layoutMode; |
@@ -348,7 +339,11 @@ exports.Layout = Montage.create(Component, { | |||
348 | 339 | ||
349 | _elementName: { | 340 | _elementName: { |
350 | value: function(item) { | 341 | value: function(item) { |
351 | return this.application.ninja.elementMediator.getNJProperty(item, "selection"); | 342 | if(item.elementModel && item.elementModel.hasOwnProperty("selection")) { |
343 | return item.elementModel['selection']; | ||
344 | } else { | ||
345 | return ""; | ||
346 | } | ||
352 | } | 347 | } |
353 | } | 348 | } |
354 | 349 | ||
diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index ad67cada..1f471431 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js | |||
@@ -200,14 +200,18 @@ exports.StageView = Montage.create(Component, { | |||
200 | }, | 200 | }, |
201 | showRulers:{ | 201 | showRulers:{ |
202 | value:function(){ | 202 | value:function(){ |
203 | this.application.ninja.rulerTop.style.background = "url('../images/temp/ruler-top.png')"; | 203 | this.application.ninja.rulerTop.style.display = "block"; |
204 | this.application.ninja.rulerLeft.style.background = "url('../images/temp/ruler-left.png')"; | 204 | this.application.ninja.rulerLeft.style.display = "block"; |
205 | // this.application.ninja.rulerTop.style.background = "url('../images/temp/ruler-top.png')"; | ||
206 | // this.application.ninja.rulerLeft.style.background = "url('../images/temp/ruler-left.png')"; | ||
205 | } | 207 | } |
206 | }, | 208 | }, |
207 | hideRulers:{ | 209 | hideRulers:{ |
208 | value:function(){ | 210 | value:function(){ |
209 | this.application.ninja.rulerTop.style.background = "rgb(128,128,128)"; | 211 | this.application.ninja.rulerTop.style.display = "none"; |
210 | this.application.ninja.rulerLeft.style.background = "rgb(128,128,128)"; | 212 | this.application.ninja.rulerLeft.style.display = "none"; |
213 | // this.application.ninja.rulerTop.style.background = "rgb(128,128,128)"; | ||
214 | // this.application.ninja.rulerLeft.style.background = "rgb(128,128,128)"; | ||
211 | } | 215 | } |
212 | }, | 216 | }, |
213 | 217 | ||
diff --git a/js/stage/stage.reel/stage.html b/js/stage/stage.reel/stage.html index 812e3d55..f796303c 100755 --- a/js/stage/stage.reel/stage.html +++ b/js/stage/stage.reel/stage.html | |||
@@ -50,6 +50,10 @@ | |||
50 | "element" : {"#": "textToolObject"} | 50 | "element" : {"#": "textToolObject"} |
51 | } | 51 | } |
52 | }, | 52 | }, |
53 | |||
54 | "focusManager": { | ||
55 | "object": "js/components/focus-manager.reel" | ||
56 | }, | ||
53 | 57 | ||
54 | "owner": { | 58 | "owner": { |
55 | "module": "js/stage/stage.reel", | 59 | "module": "js/stage/stage.reel", |
@@ -63,7 +67,8 @@ | |||
63 | "stageDeps": {"@": "StageDeps1"}, | 67 | "stageDeps": {"@": "StageDeps1"}, |
64 | "layout": {"@": "layout1"}, | 68 | "layout": {"@": "layout1"}, |
65 | "stageView": {"@": "stageView"}, | 69 | "stageView": {"@": "stageView"}, |
66 | "textTool": {"@": "textTool"} | 70 | "textTool": {"@": "textTool"}, |
71 | "focusManager": {"@": "focusManager"} | ||
67 | }, | 72 | }, |
68 | "bindings": { | 73 | "bindings": { |
69 | "currentDocumentStageView": { | 74 | "currentDocumentStageView": { |
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 4c1d046b..ec8c0e55 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js | |||
@@ -170,8 +170,7 @@ exports.Stage = Montage.create(Component, { | |||
170 | 170 | ||
171 | // Hack for now until a full component | 171 | // Hack for now until a full component |
172 | this.layout.draw(); | 172 | this.layout.draw(); |
173 | } | 173 | } else if(this.updatedStage) { |
174 | else if(this.updatedStage) { | ||
175 | this.layout.draw(); | 174 | this.layout.draw(); |
176 | this.layout.draw3DInfo(true); | 175 | this.layout.draw3DInfo(true); |
177 | } | 176 | } |
@@ -235,6 +234,10 @@ exports.Stage = Montage.create(Component, { | |||
235 | 234 | ||
236 | this.hideCanvas(false); | 235 | this.hideCanvas(false); |
237 | 236 | ||
237 | // Recalculate the canvas sizes because of splitter resizing | ||
238 | this._canvas.width = this._layoutCanvas.width = this._drawingCanvas.width = this.element.offsetWidth - 11 ; | ||
239 | this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this.element.offsetHeight - 11; | ||