aboutsummaryrefslogtreecommitdiff
path: root/js/stage
diff options
context:
space:
mode:
authorValerio Virgillito2012-06-04 10:20:57 -0700
committerValerio Virgillito2012-06-04 10:20:57 -0700
commitc1ec69879028220b0c3f11ad6e24035bf527802c (patch)
tree043bfe4ec9e08f4f598a4845ae5fbcddacc7c8fb /js/stage
parent3abba04025dbc0daadb08184833a2558c442b8e1 (diff)
parent266460e52831c5b3a3473be420756fd88bb8aced (diff)
downloadninja-c1ec69879028220b0c3f11ad6e24035bf527802c.tar.gz
Merge pull request #264 from mencio/document-bindings-fix
Document bindings fix - Changing the documents architecture to use bindings instead of events
Diffstat (limited to 'js/stage')
-rwxr-xr-xjs/stage/layout.js52
-rwxr-xr-xjs/stage/stage-deps.js27
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.css50
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.html30
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.js62
-rwxr-xr-xjs/stage/stage.reel/stage.css47
-rwxr-xr-xjs/stage/stage.reel/stage.html27
-rwxr-xr-xjs/stage/stage.reel/stage.js175
8 files changed, 194 insertions, 276 deletions
diff --git a/js/stage/layout.js b/js/stage/layout.js
index 460c8b4a..71296405 100755
--- a/js/stage/layout.js
+++ b/js/stage/layout.js
@@ -23,6 +23,30 @@ 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(!value) {
43
44 } else if(this._currentDocument.currentView === "design") {
45 this.elementsToDraw = this._currentDocument.model.documentRoot.childNodes;
46 }
47 }
48 },
49
26 _layoutView: { 50 _layoutView: {
27 value: "layoutAll" 51 value: "layoutAll"
28 }, 52 },
@@ -58,15 +82,6 @@ exports.Layout = Montage.create(Component, {
58 } 82 }
59 }, 83 },
60 84
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 85 // Redraw stage only once after all deletion is completed
71 handleElementsRemoved: { 86 handleElementsRemoved: {
72 value: function(event) { 87 value: function(event) {
@@ -79,11 +94,11 @@ exports.Layout = Montage.create(Component, {
79 value: function(event) { 94 value: function(event) {
80 var containerIndex; 95 var containerIndex;
81 96
82 if(this.application.ninja.documentController.activeDocument === null){ 97 if(this.currentDocument === null){
83 return; 98 return;
84 } 99 }
85 100
86 if(this.application.ninja.documentController.activeDocument.currentView === "design"){ 101 if(this.currentDocument.currentView === "design"){
87 // Make an array copy of the line node list which is not an array like object 102 // 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); 103 this.domTree = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true);
89 // Index of the current container 104 // Index of the current container
@@ -121,6 +136,10 @@ exports.Layout = Montage.create(Component, {
121 value: function() { 136 value: function() {
122 this.clearCanvas(); 137 this.clearCanvas();
123 138
139 // TODO Bind the layoutview mode to the current document
140 // var mode = this.application.ninja.currentDocument.layoutMode;
141 if(this.layoutView === "layoutOff") return;
142
124 var els = this.elementsToDraw.length; 143 var els = this.elementsToDraw.length;
125 for(var i = 0, el; i < els; i++){ 144 for(var i = 0, el; i < els; i++){
126 this.drawTagOutline(this.elementsToDraw[i]); 145 this.drawTagOutline(this.elementsToDraw[i]);
@@ -132,13 +151,13 @@ exports.Layout = Montage.create(Component, {
132 value: function(updatePlanes) { 151 value: function(updatePlanes) {
133 if(updatePlanes) { 152 if(updatePlanes) {
134 drawUtils.updatePlanes(); 153 drawUtils.updatePlanes();
154 this.application.ninja.stage.stageDeps.snapManager._isCacheInvalid = true;
135 } 155 }
136 156
137 if(this.stage.appModel.show3dGrid) { 157 if(this.stage.appModel.show3dGrid) {
138 this.application.ninja.stage.stageDeps.snapManager.updateWorkingPlaneFromView(); 158 this.application.ninja.stage.stageDeps.snapManager.updateWorkingPlaneFromView();
139 drawUtils.drawWorkingPlane();
140 } 159 }
141 160 drawUtils.drawWorkingPlane();
142 drawUtils.draw3DCompass(); 161 drawUtils.draw3DCompass();
143 } 162 }
144 }, 163 },
@@ -154,11 +173,6 @@ exports.Layout = Montage.create(Component, {
154 173
155 if(!item || !this.application.ninja.selectionController.isNodeTraversable(item)) return; 174 if(!item || !this.application.ninja.selectionController.isNodeTraversable(item)) return;
156 175
157 // TODO Bind the layoutview mode to the current document
158 // var mode = this.application.ninja.currentDocument.layoutMode;
159
160 if(this.layoutView === "layoutOff") return;
161
162 // Don't draw outlines for shapes. 176 // Don't draw outlines for shapes.
163 // TODO Use the element mediator/controller/model to see if its a shape 177 // TODO Use the element mediator/controller/model to see if its a shape
164 // if (utilsModule.utils.isElementAShape(item)) return; 178 // if (utilsModule.utils.isElementAShape(item)) return;
@@ -219,7 +233,7 @@ exports.Layout = Montage.create(Component, {
219 if(this.layoutView === "layoutAll") { 233 if(this.layoutView === "layoutAll") {
220 this.ctx.strokeStyle = 'rgba(0,0,0,1)'; // Black Stroke 234 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); 235 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 236 this.ctx.fillStyle = 'rgba(255,255,255,1)'; // White Fill
223 this.ctx.fillRect(bounds3D[0][0]+6, bounds3D[0][1]-15, 69, 10); 237 this.ctx.fillRect(bounds3D[0][0]+6, bounds3D[0][1]-15, 69, 10);
224 238
225 this.ctx.fillStyle = 'rgba(0,0,0,1)'; 239 this.ctx.fillStyle = 'rgba(0,0,0,1)';
diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js
index 896d4a5b..762c2529 100755
--- a/js/stage/stage-deps.js
+++ b/js/stage/stage-deps.js
@@ -14,6 +14,7 @@ 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
16exports.StageDeps = Montage.create(Component, { 16exports.StageDeps = Montage.create(Component, {
17
17 viewUtils: { 18 viewUtils: {
18 value: viewUtils 19 value: viewUtils
19 }, 20 },
@@ -37,8 +38,6 @@ exports.StageDeps = Montage.create(Component, {
37 window.MathUtils = MathUtilsClass; 38 window.MathUtils = MathUtilsClass;
38 window.VecUtils = VecUtils; 39 window.VecUtils = VecUtils;
39 40
40 snapManager.drawingCanvas = this.stage.drawingCanvas;
41
42 // Setup the listeners for the draw-util and snapmanager when removing elements 41 // Setup the listeners for the draw-util and snapmanager when removing elements
43 // TODO Revisit when supporting multiple documents 42 // TODO Revisit when supporting multiple documents
44 drawUtils.initialize(); 43 drawUtils.initialize();
@@ -57,28 +56,6 @@ exports.StageDeps = Montage.create(Component, {
57 drawUtils.snapManager = snapManager; 56 drawUtils.snapManager = snapManager;
58 drawUtils.ElementPlanes = ElementPlanes; 57 drawUtils.ElementPlanes = ElementPlanes;
59 } 58 }
60 },
61
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: {
75 value: function(){
76 workingPlane = [0,0,1,0];
77
78 snapManager._isCacheInvalid = true;
79 snapManager.setupDragPlaneFromPlane (workingPlane);
80
81 drawUtils.initializeFromDocument();
82 }
83 } 59 }
60
84}); \ No newline at end of file 61}); \ No newline at end of file
diff --git a/js/stage/stage-view.reel/stage-view.css b/js/stage/stage-view.reel/stage-view.css
deleted file mode 100755
index 8afb52a2..00000000
--- a/js/stage/stage-view.reel/stage-view.css
+++ /dev/null
@@ -1,50 +0,0 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6
7.codeViewContainer {
8 position: absolute;
9 top: 0px;
10 left: 0px;
11 margin: 0px;
12 padding: 0px;
13 background-color: #ffffff;
14 width: 100%;
15 height: 100%;
16 overflow:auto;
17 cursor:text;
18}
19
20.codeViewContainer .CodeMirror {
21 width: 100%;
22 height: 100%;
23 background: white;
24}
25
26.codeViewContainer .CodeMirror-scroll {
27 height: 100%;
28 overflow: auto;
29}
30
31.codeViewContainer>div{
32 width:2500px;/*to prevent scrolling of editor container in the middle of the page for short files*/
33}
34
35span.CodeMirror-matchhighlight { background: #e9e9e9 }
36.CodeMirror-focused span.CodeMirror-matchhighlight { background: #e7e4ff; !important }
37div.CodeMirror span.CodeMirror-matchingbracket {color: #000 !important;background-color: #ffd500;}
38.CodeMirror-completions select {background-color:#e8f2ff;border:1px solid #c1c1c1;box-shadow: 8px 8px 8px rgba(0, 0, 0, 0.8);}
39.CodeMirror-completions {z-index:6001 !important;}
40
41.cm-s-default .activeline {background: #e8f2ff; !important}