diff options
author | Nivesh Rajbhandari | 2012-06-13 10:03:53 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-06-13 10:03:53 -0700 |
commit | 1cfbfc91815b04dc2a5b090c5e05e300b9371eb7 (patch) | |
tree | 4cf6749de9fea6b90370e6f593146ae4a8690384 | |
parent | 509092ff335f74517a413cfb2deeb9d2de20f8e3 (diff) | |
parent | 5a7774f6769a7a682e21bafe0e57007668f16153 (diff) | |
download | ninja-1cfbfc91815b04dc2a5b090c5e05e300b9371eb7.tar.gz |
Merge branch 'refs/heads/ninja-internal' into PI_HotTextFixes
-rw-r--r-- | assets/canvas-runtime.js | 40 | ||||
-rw-r--r-- | js/components/prompt.reel/prompt.js | 73 | ||||
-rwxr-xr-x | js/document/document-html.js | 6 | ||||
-rwxr-xr-x | js/document/models/base.js | 66 | ||||
-rw-r--r-- | js/io/system/ninjalibrary.json | 2 | ||||
-rwxr-xr-x | js/lib/geom/brush-stroke.js | 5 | ||||
-rwxr-xr-x | js/models/element-model.js | 4 | ||||
-rwxr-xr-x | js/ninja.reel/ninja.js | 4 | ||||
-rwxr-xr-x | js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js | 66 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 49 |
10 files changed, 264 insertions, 51 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index fe5f839c..feb35187 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js | |||
@@ -2107,7 +2107,40 @@ NinjaCvsRt.RuntimeBrushStroke = Object.create(NinjaCvsRt.RuntimeGeomObj, { | |||
2107 | } | 2107 | } |
2108 | this._LocalPoints = newPoints.slice(0); | 2108 | this._LocalPoints = newPoints.slice(0); |
2109 | } | 2109 | } |
2110 | } | 2110 | |
2111 | // *** compute the bounding box ********* | ||
2112 | var BBoxMin = [Infinity, Infinity, Infinity]; | ||
2113 | var BBoxMax = [-Infinity, -Infinity, -Infinity]; | ||
2114 | if (numPoints === 0) { | ||
2115 | BBoxMin = [0, 0, 0]; | ||
2116 | BBoxMax = [0, 0, 0]; | ||
2117 | } else { | ||
2118 | for (var i=0;i<numPoints;i++){ | ||
2119 | var pt = this._LocalPoints[i]; | ||
2120 | for (var d = 0; d < 3; d++) { | ||
2121 | if (BBoxMin[d] > pt[d]) { | ||
2122 | BBoxMin[d] = pt[d]; | ||
2123 | } | ||
2124 | if (BBoxMax[d] < pt[d]) { | ||
2125 | BBoxMax[d] = pt[d]; | ||
2126 | } | ||
2127 | }//for every dimension d from 0 to 2 | ||
2128 | } | ||
2129 | } | ||
2130 | |||
2131 | //increase the bbox given the stroke width and the angle (in case of calligraphic brush) | ||
2132 | var bboxPadding = this._strokeWidth*0.5; | ||
2133 | for (var d = 0; d < 3; d++) { | ||
2134 | BBoxMin[d]-= bboxPadding; | ||
2135 | BBoxMax[d]+= bboxPadding; | ||
2136 | }//for every dimension d from 0 to 2 | ||
2137 | |||
2138 | //******* update the local coords so that the bbox min is at the origin ****** | ||
2139 | for (var i=0;i<numPoints;i++) { | ||
2140 | this._LocalPoints[i][0]-= BBoxMin[0]; | ||
2141 | this._LocalPoints[i][1]-= BBoxMin[1]; | ||
2142 | } | ||
2143 | }//if we need to do smoothing | ||
2111 | } | 2144 | } |
2112 | }, | 2145 | }, |
2113 | 2146 | ||
@@ -2231,7 +2264,10 @@ NinjaCvsRt.RuntimeBrushStroke = Object.create(NinjaCvsRt.RuntimeGeomObj, { | |||
2231 | var disp = [brushStamp[t][0], brushStamp[t][1]]; | 2264 | var disp = [brushStamp[t][0], brushStamp[t][1]]; |
2232 | var alphaVal = 1.0; | 2265 | var alphaVal = 1.0; |
2233 | var distFromOpaqueRegion = Math.abs(t-halfNumTraces) - opaqueRegionHalfWidth; | 2266 | var distFromOpaqueRegion = Math.abs(t-halfNumTraces) - opaqueRegionHalfWidth; |
2234 | if (distFromOpaqueRegion>0) { | 2267 | if (numTraces === 1){ |
2268 | distFromOpaqueRegion = 0; | ||
2269 | } | ||
2270 | else if (distFromOpaqueRegion>0) { | ||
2235 | var transparencyFactor = distFromOpaqueRegion/maxTransparentRegionHalfWidth; | 2271 | var transparencyFactor = distFromOpaqueRegion/maxTransparentRegionHalfWidth; |
2236 | alphaVal = 1.0 - transparencyFactor;//(transparencyFactor*transparencyFactor);//the square term produces nonlinearly varying alpha values | 2272 | alphaVal = 1.0 - transparencyFactor;//(transparencyFactor*transparencyFactor);//the square term produces nonlinearly varying alpha values |
2237 | alphaVal *= 0.5; //factor that accounts for lineWidth == 2 | 2273 | alphaVal *= 0.5; //factor that accounts for lineWidth == 2 |
diff --git a/js/components/prompt.reel/prompt.js b/js/components/prompt.reel/prompt.js new file mode 100644 index 00000000..652d7b7e --- /dev/null +++ b/js/components/prompt.reel/prompt.js | |||
@@ -0,0 +1,73 @@ | |||
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 | //////////////////////////////////////////////////////////////////////// | ||
8 | // | ||
9 | var Montage = require("montage/core/core").Montage, | ||
10 | Component = require("montage/ui/component").Component; | ||
11 | //////////////////////////////////////////////////////////////////////// | ||
12 | // | ||
13 | exports.NinjaPrompt = Montage.create(Component, { | ||
14 | //////////////////////////////////////////////////////////////////// | ||
15 | //TODO: This should have an UI template eventually | ||
16 | hasTemplate: { | ||
17 | value: false | ||
18 | }, | ||
19 | //////////////////////////////////////////////////////////////////// | ||
20 | //Type of prompt window (should be confirm, prompt, alert, or input) | ||
21 | _type: { | ||
22 | value: null | ||
23 | }, | ||
24 | //////////////////////////////////////////////////////////////////// | ||
25 | // | ||
26 | _params: { | ||
27 | value: null | ||
28 | }, | ||
29 | //////////////////////////////////////////////////////////////////// | ||
30 | // | ||
31 | _callback: { | ||
32 | value: null | ||
33 | }, | ||
34 | //////////////////////////////////////////////////////////////////// | ||
35 | // | ||
36 | initialize: { | ||
37 | value: function (type, params, callback) { | ||
38 | // | ||
39 | this._type = type.toLowerCase(); | ||
40 | this._params = params; | ||
41 | this._callback = callback; | ||
42 | } | ||
43 | }, | ||
44 | //////////////////////////////////////////////////////////////////// | ||
45 | // | ||
46 | show: { | ||
47 | value: function () { | ||
48 | // | ||
49 | var input; | ||
50 | // | ||
51 | switch (this._type) { | ||
52 | case 'confirm': | ||
53 | input = confirm(this._params.message); | ||
54 | if (this._callback) this._callback(input); | ||
55 | break; | ||
56 | default: | ||
57 | //TODO: Add support for other standard box types | ||
58 | break; | ||
59 | } | ||
60 | } | ||
61 | }, | ||
62 | //////////////////////////////////////////////////////////////////// | ||
63 | //This is for later, need to hide if need (overwrite) | ||
64 | hide: { | ||
65 | value: function () { | ||
66 | //TODO: Add support as real UI component | ||
67 | } | ||
68 | } | ||
69 | //////////////////////////////////////////////////////////////////// | ||
70 | //////////////////////////////////////////////////////////////////// | ||
71 | }); | ||
72 | //////////////////////////////////////////////////////////////////////// | ||
73 | //////////////////////////////////////////////////////////////////////// \ No newline at end of file | ||
diff --git a/js/document/document-html.js b/js/document/document-html.js index 15f88d09..aded9241 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js | |||
@@ -121,10 +121,8 @@ exports.HtmlDocument = Montage.create(Component, { | |||
121 | // | 121 | // |
122 | closeDocument: { | 122 | closeDocument: { |
123 | value: function (context, callback) { | 123 | value: function (context, callback) { |
124 | //Closing document and getting outcome | 124 | //Closing document (sending null to close all views) |
125 | var closed = this.model.close(null); | 125 | this.model.close(null, function () {if (callback) callback.call(context, this);}.bind(this)); |
126 | //Making callback if specified | ||
127 | if (callback) callback.call(context, this); | ||
128 | } | 126 | } |
129 | }, | 127 | }, |
130 | //////////////////////////////////////////////////////////////////// | 128 | //////////////////////////////////////////////////////////////////// |
diff --git a/js/document/models/base.js b/js/document/models/base.js index 1307e0c0..8ff52132 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js | |||
@@ -6,8 +6,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
6 | 6 | ||
7 | //////////////////////////////////////////////////////////////////////// | 7 | //////////////////////////////////////////////////////////////////////// |
8 | // | 8 | // |
9 | var Montage = require("montage/core/core").Montage, | 9 | var Montage = require("montage/core/core").Montage, |
10 | Component = require("montage/ui/component").Component; | 10 | Component = require("montage/ui/component").Component, |
11 | NinjaPrompt = require("js/components/prompt.reel").NinjaPrompt; | ||
11 | //////////////////////////////////////////////////////////////////////// | 12 | //////////////////////////////////////////////////////////////////////// |
12 | // | 13 | // |
13 | exports.BaseDocumentModel = Montage.create(Component, { | 14 | exports.BaseDocumentModel = Montage.create(Component, { |
@@ -267,30 +268,59 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
267 | if (this.callback) this.callback(result); | 268 | if (this.callback) this.callback(result); |
268 | } | 269 | } |
269 | }, | 270 | }, |
271 | //////////////////////////////////////////////////////////////////// | ||
272 | // | ||
273 | handleSavePrompt: { | ||
274 | value: function (continueToClose, callback) { | ||
275 | //TODO: Perhaps add logic to save the file is the user wants | ||
276 | if (continueToClose) { | ||
277 | if (callback) callback(); | ||
278 | } else { | ||
279 | //User canceled | ||
280 | //this.saveAll(null, callback); | ||
281 | } | ||
282 | } | ||
283 | }, | ||
270 | //////////////////////////////////////////////////////////////////// | 284 | //////////////////////////////////////////////////////////////////// |
271 | //TODO: Implement better logic to include different views on single document | 285 | //TODO: Implement better logic to include different views on single document |
272 | close: { | 286 | close: { |
273 | value: function (view, callback) { | 287 | value: function (view, callback) { |
274 | //Outcome of close (pending on save logic) | 288 | //Checking if files needs to be saved to avoid losing data |
275 | var success; | ||
276 | // | ||
277 | if (this.needsSave) { | 289 | if (this.needsSave) { |
278 | //TODO: Prompt user to save or lose data | 290 | //Creating prompt to ask user to save the file |
291 | var prompt = NinjaPrompt.create(); | ||
292 | prompt.initialize('confirm', {message: 'Do you want to save the changes you made in the document '+this.file.name+'?\n\nYour changes will be lost if you do not save them.'}, function (result){this.handleSavePrompt(result, callback);}.bind(this)); | ||
293 | //Showing the prompt, it will make callback with user input | ||
294 | prompt.show(); | ||
279 | } else { | 295 | } else { |
280 | //Close file | 296 | //TODO: Add support for other views |
281 | success = true; | 297 | if (!view || view === 'design') { |
282 | } | 298 | this.closeView('design'); |
283 | //Checking for view mode to close | 299 | } |
284 | if (this.views.design && (!view || view === 'design')) { | 300 |