aboutsummaryrefslogtreecommitdiff
path: root/js/stage
diff options
context:
space:
mode:
authorPushkar Joshi2012-05-31 12:20:03 -0700
committerPushkar Joshi2012-05-31 12:20:03 -0700
commit4bc52365b1f81a386c3c59fd7c6ad874bb387cb5 (patch)
treec5b17297aba04bd54a59cf6214d29486e089031b /js/stage
parent75a862d305bc4502e22bc5aa65fa271143b8cf6c (diff)
parent6042bdc5f2aada4412912fd01602d32c9088dc26 (diff)
downloadninja-4bc52365b1f81a386c3c59fd7c6ad874bb387cb5.tar.gz
Merge branch 'master' into pentool
Diffstat (limited to 'js/stage')
-rwxr-xr-xjs/stage/layout.js14
-rwxr-xr-xjs/stage/stage-deps.js117
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.js170
-rwxr-xr-xjs/stage/stage.reel/stage.js255
-rwxr-xr-xjs/stage/tool-handle.js4
5 files changed, 190 insertions, 370 deletions
diff --git a/js/stage/layout.js b/js/stage/layout.js
index 0a76dbe5..460c8b4a 100755
--- a/js/stage/layout.js
+++ b/js/stage/layout.js
@@ -62,12 +62,8 @@ exports.Layout = Montage.create(Component, {
62 value: function() { 62 value: function() {
63 // Initial elements to draw are the childrens of the root element 63 // Initial elements to draw are the childrens of the root element
64 if(this.application.ninja.documentController.activeDocument.currentView === "design") { 64 if(this.application.ninja.documentController.activeDocument.currentView === "design") {
65 this.elementsToDraw = this.application.ninja.documentController.activeDocument.documentRoot.childNodes; 65 this.elementsToDraw = this.application.ninja.documentController.activeDocument.model.documentRoot.childNodes;
66 } 66 }
67
68 // Draw the elements and the 3d info
69 this.draw();
70 this.draw3DInfo(false);
71 } 67 }
72 }, 68 },
73 69
@@ -89,7 +85,7 @@ exports.Layout = Montage.create(Component, {
89 85
90 if(this.application.ninja.documentController.activeDocument.currentView === "design"){ 86 if(this.application.ninja.documentController.activeDocument.currentView === "design"){
91 // Make an array copy of the line node list which is not an array like object 87 // Make an array copy of the line node list which is not an array like object
92 this.domTree = Array.prototype.slice.call(this.application.ninja.documentController.activeDocument._liveNodeList, 0); 88 this.domTree = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true);
93 // Index of the current container 89 // Index of the current container
94 containerIndex = this.domTree.indexOf(this.application.ninja.currentSelectedContainer); 90 containerIndex = this.domTree.indexOf(this.application.ninja.currentSelectedContainer);
95 91
@@ -156,7 +152,7 @@ exports.Layout = Montage.create(Component, {
156 drawTagOutline: { 152 drawTagOutline: {
157 value: function (item) { 153 value: function (item) {
158 154
159 if(!item || (item.nodeType !== 1)) return; 155 if(!item || !this.application.ninja.selectionController.isNodeTraversable(item)) return;
160 156
161 // TODO Bind the layoutview mode to the current document 157 // TODO Bind the layoutview mode to the current document
162 // var mode = this.application.ninja.currentDocument.layoutMode; 158 // var mode = this.application.ninja.currentDocument.layoutMode;
@@ -241,7 +237,7 @@ exports.Layout = Montage.create(Component, {
241 value: function() { 237 value: function() {
242 if(this.application.ninja.currentDocument) { 238 if(this.application.ninja.currentDocument) {
243 this.clearCanvas(); 239 this.clearCanvas();
244 this.WalkDOM(this.application.ninja.currentDocument.documentRoot); 240 this.WalkDOM(this.application.ninja.currentDocument.model.documentRoot);
245 241
246 //drawUtils.updatePlanes(); 242 //drawUtils.updatePlanes();
247 //if(this.application.ninja.currentDocument.draw3DGrid) drawUtils.drawWorkingPlane(); 243 //if(this.application.ninja.currentDocument.draw3DGrid) drawUtils.drawWorkingPlane();
@@ -253,7 +249,7 @@ exports.Layout = Montage.create(Component, {
253 drawElementsOutline: { 249 drawElementsOutline: {
254 value: function(elements) { 250 value: function(elements) {
255 this.clearCanvas(); 251 this.clearCanvas();
256 this.WalkDOM(this.application.ninja.currentDocument.documentRoot, elements); 252 this.WalkDOM(this.application.ninja.currentDocument.model.documentRoot, elements);
257 } 253 }
258 }, 254 },
259 255
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
17exports.StageDeps = Montage.create(Component, { 16exports.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