diff options
-rwxr-xr-x | js/controllers/selection-controller.js | 4 | ||||
-rwxr-xr-x | js/controllers/styles-controller.js | 2 | ||||
-rwxr-xr-x | js/lib/geom/line.js | 13 | ||||
-rwxr-xr-x | js/panels/Panel.reel/Panel.js | 13 | ||||
-rwxr-xr-x | js/stage/layout.js | 2 | ||||
-rwxr-xr-x | js/tools/LineTool.js | 56 | ||||
-rw-r--r-- | manifest.json | 2 |
7 files changed, 59 insertions, 33 deletions
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 7a26ed3b..4b031d70 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js | |||
@@ -58,13 +58,13 @@ exports.SelectionController = Montage.create(Component, { | |||
58 | return; | 58 | return; |
59 | } | 59 | } |
60 | 60 | ||
61 | if(this._currentDocument && this._currentDocument.currentView === "design") { | 61 | if(this._currentDocument && (this._currentDocument.currentView === "design" || this._currentDocument.model.currentView.identifier !== "code")) { |
62 | this._currentDocument.model._selection = this.application.ninja.selectedElements; | 62 | this._currentDocument.model._selection = this.application.ninja.selectedElements; |
63 | } | 63 | } |
64 | 64 | ||
65 | this._currentDocument = value; | 65 | this._currentDocument = value; |
66 | 66 | ||
67 | if(this._currentDocument && this._currentDocument.currentView === "design") { | 67 | if(this._currentDocument && (this._currentDocument.currentView === "design" || this._currentDocument.model.currentView.identifier !== "code")) { |
68 | this.selectedElements = this._currentDocument.model.selection; | 68 | this.selectedElements = this._currentDocument.model.selection; |
69 | } | 69 | } |
70 | /* | 70 | /* |
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index e95c6614..68d031fb 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js | |||
@@ -87,7 +87,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
87 | set : function(document) { | 87 | set : function(document) { |
88 | ///// If the document is null set default stylesheets to null | 88 | ///// If the document is null set default stylesheets to null |
89 | 89 | ||
90 | if(!document || document.currentView === "code") { | 90 | if(!document || (document.currentView === "code" && document.model.currentView.identifier !== "design-code")) { |
91 | this._currentDocument = null; | 91 | this._currentDocument = null; |
92 | this._stageStylesheet = null; | 92 | this._stageStylesheet = null; |
93 | this.defaultStylesheet = null; | 93 | this.defaultStylesheet = null; |
diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js index eec4f6d9..df65ee86 100755 --- a/js/lib/geom/line.js +++ b/js/lib/geom/line.js | |||
@@ -537,6 +537,15 @@ exports.Line = Object.create(GeomObj, { | |||
537 | ctx.strokeStyle = c; | 537 | ctx.strokeStyle = c; |
538 | } | 538 | } |
539 | 539 | ||
540 | var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils; | ||
541 | viewUtils.pushViewportObj( world.getCanvas() ); | ||
542 | var cop = viewUtils.getCenterOfProjection(); | ||
543 | viewUtils.popViewportObj(); | ||
544 | var xCtr = cop[0] + this._xOffset, yCtr = cop[1] - this._yOffset; | ||
545 | var xLeft = xCtr - 0.5*this.getWidth(), yTop = yCtr - 0.5*this.getHeight(); | ||
546 | var xDist = cop[0] - xLeft, yDist = cop[1] - yTop; | ||
547 | var xOff = 0.5*world.getViewportWidth() - xDist, yOff = 0.5*world.getViewportHeight() - yDist; | ||
548 | |||
540 | // get the points | 549 | // get the points |
541 | var p0, p1; | 550 | var p0, p1; |
542 | if(this._slope === "vertical") { | 551 | if(this._slope === "vertical") { |
@@ -554,8 +563,8 @@ exports.Line = Object.create(GeomObj, { | |||
554 | } | 563 | } |
555 | 564 | ||
556 | // draw the line | 565 | // draw the line |
557 | ctx.moveTo( p0[0], p0[1] ); | 566 | ctx.moveTo( p0[0]+xOff, p0[1]+yOff ); |
558 | ctx.lineTo( p1[0], p1[1] ); | 567 | ctx.lineTo( p1[0]+xOff, p1[1]+yOff ); |
559 | ctx.stroke(); | 568 | ctx.stroke(); |
560 | } | 569 | } |
561 | } | 570 | } |
diff --git a/js/panels/Panel.reel/Panel.js b/js/panels/Panel.reel/Panel.js index 988088e3..586636e1 100755 --- a/js/panels/Panel.reel/Panel.js +++ b/js/panels/Panel.reel/Panel.js | |||
@@ -159,11 +159,24 @@ exports.Panel = Montage.create(Component, { | |||
159 | this.disabled = true; | 159 | this.disabled = true; |
160 | } else { | 160 | } else { |
161 | this.disabled = this._currentDocument.currentView !== "design"; | 161 | this.disabled = this._currentDocument.currentView !== "design"; |
162 | this._currentDocument.addPropertyChangeListener("model.currentViewIdentifier", this, false); | ||
162 | } | 163 | } |
163 | 164 | ||
164 | } | 165 | } |
165 | }, | 166 | }, |
166 | 167 | ||
168 | handleChange: { | ||
169 | value: function(notification) { | ||
170 | if(notification.currentPropertyPath === "model.currentViewIdentifier") { | ||
171 | if(this.currentDocument.model.currentView.identifier === "design-code") { | ||
172 | this.disabled = true; | ||
173 | } else { | ||
174 | this.disabled = false; | ||
175 | } | ||
176 | } | ||
177 | } | ||
178 | }, | ||
179 | |||
167 | handleBtnCollapseAction: { | 180 | handleBtnCollapseAction: { |
168 | value: function() { | 181 | value: function() { |
169 | this.collapsed = !this.collapsed; | 182 | this.collapsed = !this.collapsed; |
diff --git a/js/stage/layout.js b/js/stage/layout.js index 5cc8dbea..5e6e8152 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js | |||
@@ -69,7 +69,7 @@ exports.Layout = Montage.create(Component, { | |||
69 | set : function(value) { | 69 | set : function(value) { |
70 | if (value !== this._currentDocument) { | 70 | if (value !== this._currentDocument) { |
71 | this._currentDocument = value; | 71 | this._currentDocument = value; |
72 | if(this._currentDocument && this._currentDocument.currentView === "design") { | 72 | if(this._currentDocument && (this._currentDocument.currentView === "design" || this._currentDocument.model.currentView.identifier !== "code")) { |
73 | this.elementsToDraw = Array.prototype.slice.call(this._currentDocument.model.documentRoot.childNodes, 0); | 73 | this.elementsToDraw = Array.prototype.slice.call(this._currentDocument.model.documentRoot.childNodes, 0); |
74 | } | 74 | } |
75 | } | 75 | } |
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index f0d96c3c..4ec327b5 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js | |||
@@ -97,34 +97,38 @@ exports.LineTool = Montage.create(ShapeTool, { | |||
97 | if(this.drawData) { | 97 | if(this.drawData) { |
98 | w = Math.floor(this.drawData.width); | 98 | w = Math.floor(this.drawData.width); |
99 | h = Math.floor(this.drawData.height); | 99 | h = Math.floor(this.drawData.height); |
100 | // set the dimensions | ||
101 | if(slope === "horizontal") { | ||
102 | h = Math.max(this._strokeSize, 1); | ||
103 | w = Math.max(w, 1); | ||
104 | } else if(slope === "vertical") { | ||
105 | w = Math.max(this._strokeSize, 1); | ||
106 | h = Math.max(h, 1); | ||
107 | } else { | ||
108 | // else make the line's stroke fit inside the canvas by growing the canvas | ||
109 | var theta = Math.atan(slope); | ||
110 | xAdj = Math.abs((this._strokeSize/2)*Math.sin(theta)); | ||
111 | yAdj = Math.abs((this._strokeSize/2)*Math.cos(theta)); | ||
112 | |||
113 | w += ~~(xAdj*2); | ||
114 | h += ~~(yAdj*2); | ||
115 | } | ||
116 | |||
100 | if(!this._useExistingCanvas()) { | 117 | if(!this._useExistingCanvas()) { |
101 | // set the dimensions | 118 | |
102 | if(slope === "horizontal") { | 119 | canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); |
103 | h = Math.max(this._strokeSize, 1); | 120 | |
104 | w = Math.max(w, 1); | 121 | var styles = document.application.njUtils.stylesFromDraw(canvas, w, h, this.drawData); |
105 | } else if(slope === "vertical") { | 122 | this.application.ninja.elementMediator.addElements(canvas, styles); |
106 | w = Math.max(this._strokeSize, 1); | 123 | } else { |
107 | h = Math.max(h, 1); | 124 | canvas = this._targetedElement; |
108 | } else { | 125 | if (!canvas.getAttribute( "data-RDGE-id" )) |
109 | // else make the line's stroke fit inside the canvas by growing the canvas | 126 | canvas.setAttribute( "data-RDGE-id", NJUtils.generateRandom() ); |
110 | var theta = Math.atan(slope); | 127 | canvas.elementModel.controller = ShapesController; |
111 | xAdj = Math.abs((this._strokeSize/2)*Math.sin(theta)); | 128 | if(!canvas.elementModel.shapeModel) { |
112 | yAdj = Math.abs((this._strokeSize/2)*Math.cos(theta)); | 129 | canvas.elementModel.shapeModel = Montage.create(ShapeModel); |
113 | |||
114 | w += ~~(xAdj*2); | ||
115 | h += ~~(yAdj*2); | ||
116 | } | ||
117 | |||
118 | canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); | ||
119 | |||
120 | var styles = document.application.njUtils.stylesFromDraw(canvas, w, h, this.drawData); | ||
121 | this.application.ninja.elementMediator.addElements(canvas, styles); | ||
122 | } else { | ||
123 | canvas = this._targetedElement; | ||
124 | canvas.elementModel.controller = ShapesController; | ||
125 | if(!canvas.elementModel.shapeModel) { | ||
126 | canvas.elementModel.shapeModel = Montage.create(ShapeModel); | ||
127 | } | 130 | } |
131 | this.RenderShape(w, h, this.drawData.planeMat, this.drawData.midPt, canvas, slope, xAdj, yAdj); | ||
128 | } | 132 | } |
129 | } | 133 | } |
130 | } | 134 | } |
diff --git a/manifest.json b/manifest.json index 14d8b239..46b444c3 100644 --- a/manifest.json +++ b/manifest.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "name": "Ninja Authoring Tool Preview", | 2 | "name": "Ninja Authoring Tool Preview", |
3 | "description": "Ninja HTML5 Authoring Tool Preview", | 3 | "description": "Ninja HTML5 Authoring Tool Preview", |
4 | "version": "0.8.0.0", | 4 | "version": "0.7.2.0", |
5 | "app": { | 5 | "app": { |
6 | "launch": { | 6 | "launch": { |
7 | "local_path": "index.html" | 7 | "local_path": "index.html" |