diff options
author | Valerio Virgillito | 2012-05-29 00:34:40 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-05-29 00:34:40 -0700 |
commit | 4c3aac5eabd93052b1554a03d78235215bb49db4 (patch) | |
tree | fe08f4f6d33d81d602f56daeaec845577fb9d8a5 /js/stage | |
parent | 9a66ccad0235484643ef6d821315b11b5be4a93e (diff) | |
download | ninja-4c3aac5eabd93052b1554a03d78235215bb49db4.tar.gz |
document bindings phase 1
- using array controller to bind the current document to all ninja components
- removed open document event
- removed references to the document controller
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/stage')
-rwxr-xr-x | js/stage/layout.js | 37 | ||||
-rwxr-xr-x | js/stage/stage-deps.js | 40 | ||||
-rwxr-xr-x | js/stage/stage.reel/stage.html | 18 | ||||
-rwxr-xr-x | js/stage/stage.reel/stage.js | 37 |
4 files changed, 87 insertions, 45 deletions
diff --git a/js/stage/layout.js b/js/stage/layout.js index 460c8b4a..8b66150d 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js | |||
@@ -23,6 +23,28 @@ exports.Layout = Montage.create(Component, { | |||
23 | drawFillColor: { value: 'rgba(255,255,255,1)' }, | 23 | drawFillColor: { value: 'rgba(255,255,255,1)' }, |
24 | ctxLineWidth: { value: 0.2 }, | 24 | ctxLineWidth: { value: 0.2 }, |
25 | 25 | ||
26 | _currentDocument: { | ||
27 | value : null, | ||
28 | enumerable : false | ||
29 | }, | ||
30 | |||
31 | currentDocument : { | ||
32 | get : function() { | ||
33 | return this._currentDocument; | ||
34 | }, | ||
35 | set : function(value) { | ||
36 | if (value === this._currentDocument || value.getProperty("currentView") !== "design") { | ||
37 | return; | ||
38 | } | ||
39 | |||
40 | this._currentDocument = value; | ||
41 | |||
42 | if(this._currentDocument) { | ||
43 | this.elementsToDraw = this._currentDocument.model.documentRoot.childNodes; | ||
44 | } | ||
45 | } | ||
46 | }, | ||
47 | |||
26 | _layoutView: { | 48 | _layoutView: { |
27 | value: "layoutAll" | 49 | value: "layoutAll" |
28 | }, | 50 | }, |
@@ -58,15 +80,6 @@ exports.Layout = Montage.create(Component, { | |||
58 | } | 80 | } |
59 | }, | 81 | }, |
60 | 82 | ||
61 | handleOpenDocument: { | ||
62 | value: function() { | ||
63 | // Initial elements to draw are the childrens of the root element | ||
64 | if(this.application.ninja.documentController.activeDocument.currentView === "design") { | ||
65 | this.elementsToDraw = this.application.ninja.documentController.activeDocument.model.documentRoot.childNodes; | ||
66 | } | ||
67 | } | ||
68 | }, | ||
69 | |||
70 | // Redraw stage only once after all deletion is completed | 83 | // Redraw stage only once after all deletion is completed |
71 | handleElementsRemoved: { | 84 | handleElementsRemoved: { |
72 | value: function(event) { | 85 | value: function(event) { |
@@ -79,11 +92,11 @@ exports.Layout = Montage.create(Component, { | |||
79 | value: function(event) { | 92 | value: function(event) { |
80 | var containerIndex; | 93 | var containerIndex; |
81 | 94 | ||
82 | if(this.application.ninja.documentController.activeDocument === null){ | 95 | if(this.currentDocument === null){ |
83 | return; | 96 | return; |
84 | } | 97 | } |
85 | 98 | ||
86 | if(this.application.ninja.documentController.activeDocument.currentView === "design"){ | 99 | if(this.currentDocument.currentView === "design"){ |
87 | // Make an array copy of the line node list which is not an array like object | 100 | // Make an array copy of the line node list which is not an array like object |
88 | this.domTree = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true); | 101 | this.domTree = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true); |
89 | // Index of the current container | 102 | // Index of the current container |
@@ -219,7 +232,7 @@ exports.Layout = Montage.create(Component, { | |||
219 | if(this.layoutView === "layoutAll") { | 232 | if(this.layoutView === "layoutAll") { |
220 | this.ctx.strokeStyle = 'rgba(0,0,0,1)'; // Black Stroke | 233 | this.ctx.strokeStyle = 'rgba(0,0,0,1)'; // Black Stroke |
221 | this.ctx.strokeRect(bounds3D[0][0]+5.5, bounds3D[0][1]-15.5, 70, 11); | 234 | this.ctx.strokeRect(bounds3D[0][0]+5.5, bounds3D[0][1]-15.5, 70, 11); |
222 | this.ctx.fillStyle = 'rgba(255,255,255,1)' // White Fill | 235 | this.ctx.fillStyle = 'rgba(255,255,255,1)'; // White Fill |
223 | this.ctx.fillRect(bounds3D[0][0]+6, bounds3D[0][1]-15, 69, 10); | 236 | this.ctx.fillRect(bounds3D[0][0]+6, bounds3D[0][1]-15, 69, 10); |
224 | 237 | ||
225 | this.ctx.fillStyle = 'rgba(0,0,0,1)'; | 238 | this.ctx.fillStyle = 'rgba(0,0,0,1)'; |
diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index 896d4a5b..756844fd 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js | |||
@@ -14,6 +14,34 @@ var Montage = require("montage/core/core").Montage, | |||
14 | VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; | 14 | VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; |
15 | 15 | ||
16 | exports.StageDeps = Montage.create(Component, { | 16 | exports.StageDeps = Montage.create(Component, { |
17 | |||
18 | _currentDocument: { | ||
19 | value : null, | ||
20 | enumerable : false | ||
21 | }, | ||
22 | |||
23 | currentDocument : { | ||
24 | get : function() { | ||
25 | return this._currentDocument; | ||
26 | }, | ||
27 | set : function(value) { | ||
28 | if (value === this._currentDocument || value.getProperty("currentView") !== "design") { | ||
29 | return; | ||
30 | } | ||
31 | |||
32 | this._currentDocument = value; | ||
33 | |||
34 | if(this._currentDocument) { | ||
35 | workingPlane = [0,0,1,0]; | ||
36 | |||
37 | snapManager._isCacheInvalid = true; | ||
38 | snapManager.setupDragPlaneFromPlane (workingPlane); | ||
39 | |||
40 | drawUtils.initializeFromDocument(); | ||
41 | } | ||
42 | } | ||
43 | }, | ||
44 | |||
17 | viewUtils: { | 45 | viewUtils: { |
18 | value: viewUtils | 46 | value: viewUtils |
19 | }, | 47 | }, |
@@ -59,18 +87,6 @@ exports.StageDeps = Montage.create(Component, { | |||
59 | } | 87 | } |
60 | }, | 88 | }, |
61 | 89 | ||
62 | handleOpenDocument: { | ||
63 | value: function() { | ||
64 | |||
65 | workingPlane = [0,0,1,0]; | ||
66 | |||
67 | snapManager._isCacheInvalid = true; | ||
68 | snapManager.setupDragPlaneFromPlane (workingPlane); | ||
69 | |||
70 | drawUtils.initializeFromDocument(); | ||
71 | } | ||
72 | }, | ||
73 | |||
74 | handleSwitchDocument: { | 90 | handleSwitchDocument: { |
75 | value: function(){ | 91 | value: function(){ |
76 | workingPlane = [0,0,1,0]; | 92 | workingPlane = [0,0,1,0]; |
diff --git a/js/stage/stage.reel/stage.html b/js/stage/stage.reel/stage.html index 30c3d231..89b674ab 100755 --- a/js/stage/stage.reel/stage.html +++ b/js/stage/stage.reel/stage.html | |||
@@ -18,25 +18,25 @@ | |||
18 | } | 18 | } |
19 | }, | 19 | }, |
20 | 20 | ||
21 | "StageDeps1": { | 21 | "stageDeps": { |
22 | "prototype": "js/stage/stage-deps", | 22 | "prototype": "js/stage/stage-deps", |
23 | "properties": { | 23 | "properties": { |
24 | "stage": {"@": "owner"} | 24 | "stage": {"@": "owner"} |
25 | }, | ||
26 | "bindings": { | ||
27 | "currentDocument": {"<-": "@owner.currentDocument"} | ||
25 | } | 28 | } |
26 | }, | 29 | }, |
27 | 30 | ||
28 | "layout1": { | 31 | "layout": { |
29 | "prototype": "js/stage/layout", | 32 | "prototype": "js/stage/layout", |
30 | "properties": { | 33 | "properties": { |
31 | "canvas": {"#": "layoutCanvas"}, | 34 | "canvas": {"#": "layoutCanvas"}, |
32 | "stage": {"@": "owner"} | 35 | "stage": {"@": "owner"} |
33 | }, | 36 | }, |
34 | "bindings": { | 37 | "bindings": { |
35 | "layoutView": { | 38 | "layoutView": {"<-": "@owner.appModel.layoutView"}, |
36 | "boundObject": {"@": "owner" }, | 39 | "currentDocument": {"<-": "@owner.currentDocument"} |
37 | "boundObjectPropertyPath": "appModel.layoutView", | ||
38 | "oneway": true | ||
39 | } | ||
40 | } | 40 | } |
41 | }, | 41 | }, |
42 | 42 | ||
@@ -59,8 +59,8 @@ | |||
59 | "_layoutCanvas": {"#": "layoutCanvas"}, | 59 | "_layoutCanvas": {"#": "layoutCanvas"}, |
60 | "_canvas": {"#": "stageCanvas"}, | 60 | "_canvas": {"#": "stageCanvas"}, |
61 | "_drawingCanvas": {"#": "drawingCanvas"}, | 61 | "_drawingCanvas": {"#": "drawingCanvas"}, |
62 | "stageDeps": {"@": "StageDeps1"}, | 62 | "stageDeps": {"@": "stageDeps"}, |
63 | "layout": {"@": "layout1"}, | 63 | "layout": {"@": "layout"}, |
64 | "stageView": {"@": "stageView"}, | 64 | "stageView": {"@": "stageView"}, |
65 | "textTool": {"@": "textTool"}, | 65 | "textTool": {"@": "textTool"}, |
66 | "focusManager": {"@": "focusManager"} | 66 | "focusManager": {"@": "focusManager"} |
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index c7afb95c..e00d2b54 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js | |||
@@ -155,25 +155,41 @@ exports.Stage = Montage.create(Component, { | |||
155 | set: function(value) { this._userContentBorder = value; } | 155 | set: function(value) { this._userContentBorder = value; } |
156 | }, | 156 | }, |
157 | 157 | ||
158 | _activeDocument : { | 158 | _currentDocument: { |
159 | value : null, | 159 | value : null, |
160 | enumerable : false | 160 | enumerable : false |
161 | }, | 161 | }, |
162 | 162 | ||
163 | activeDocument : { | 163 | currentDocument : { |
164 | get : function() { | 164 | get : function() { |
165 | return this._activeDocument; | 165 | return this._currentDocument; |
166 | }, | 166 | }, |
167 | set : function(document) { | 167 | set : function(value) { |
168 | ///// If the document is null set default stylesheets to null | 168 | // TODO: WRONG! Fails when going from design to code view |
169 | if (value === this._currentDocument || value.getProperty("currentView") !== "design") { | ||
170 | console.log("Stage - current document not set since the same value of " + this._currentDocument + " and value " + value); | ||
171 | return; | ||
172 | } | ||
169 | 173 | ||
170 | if(!document) { | 174 | if(!value) { |
171 | return false; | 175 | // Show the rulers |
176 | this.showRulers(); | ||
177 | // Show the canvas | ||
178 | this.hideCanvas(false); | ||
172 | } | 179 | } |
173 | 180 | ||
174 |