diff options
Diffstat (limited to 'js/components/tools-properties/shape-properties.reel/shape-properties.js')
-rwxr-xr-x | js/components/tools-properties/shape-properties.reel/shape-properties.js | 125 |
1 files changed, 104 insertions, 21 deletions
diff --git a/js/components/tools-properties/shape-properties.reel/shape-properties.js b/js/components/tools-properties/shape-properties.reel/shape-properties.js index 79567453..74875544 100755 --- a/js/components/tools-properties/shape-properties.reel/shape-properties.js +++ b/js/components/tools-properties/shape-properties.reel/shape-properties.js | |||
@@ -8,12 +8,75 @@ var Montage = require("montage/core/core").Montage, | |||
8 | ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, | 8 | ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, |
9 | ToolProperties = require("js/components/tools-properties/tool-properties").ToolProperties; | 9 | ToolProperties = require("js/components/tools-properties/tool-properties").ToolProperties; |
10 | 10 | ||
11 | exports.ShapeProperties = Montage.create(ToolProperties, { | 11 | var ShapeProperties = exports.ShapeProperties = Montage.create(ToolProperties, { |
12 | toolsData: { value: null }, | 12 | toolsData: { value: null }, |
13 | _use3D: { value: false }, | 13 | _use3D: { value: false }, |
14 | addedColorChips: { value: false }, | ||
15 | |||
16 | _fill: { | ||
17 | enumerable: false, | ||
18 | value: { colorMode: 'rgb', color: { r: 255, g: 255, b: 255, a: 1, css: 'rgb(255,255,255)', mode: 'rgb', wasSetByCode: true, type: 'change' }, webGlColor: [1, 1, 1, 1] } | ||
19 | //this._fillColorCtrl.color('nocolor', null); | ||
20 | }, | ||
21 | |||
22 | _stroke: { | ||
23 | enumerable: false, | ||
24 | value: { colorMode: 'rgb', color: { r: 0, g: 0, b: 0, a: 1, css: 'rgb(0,0,0)', mode: 'rgb', wasSetByCode: true, type: 'change' }, webGlColor: [0, 0, 0, 1] } | ||
25 | }, | ||
26 | |||
27 | stroke: { | ||
28 | enumerable: true, | ||
29 | get: function () { | ||
30 | return this._stroke; | ||
31 | }, | ||
32 | set: function (value) { | ||
33 | if (value !== this._stroke) { | ||
34 | this._stroke = value; | ||
35 | } | ||
36 | } | ||
37 | }, | ||
38 | |||
39 | fill: { | ||
40 | enumerable: true, | ||
41 | get: function () { | ||
42 | return this._fill; | ||
43 | }, | ||
44 | set: function (value) { | ||
45 | if (value !== this._fill) { | ||
46 | this._fill = value; | ||
47 | } | ||
48 | } | ||
49 | }, | ||
50 | |||
51 | draw: { | ||
52 | enumerable: false, | ||
53 | value: function () { | ||
54 | Object.getPrototypeOf(ShapeProperties).draw.call(this); | ||
55 | |||
56 | if (this.addedColorChips === false && this.application.ninja.colorController.colorPanelDrawn) { | ||
57 | // setup fill color | ||
58 | this._fillColorCtrl.props = { side: 'top', align: 'center', wheel: true, palette: true, gradient: false, image: false, nocolor: true, offset: -80 }; | ||
59 | this.application.ninja.colorController.addButton("chip", this._fillColorCtrl); | ||
60 | |||
61 | // setup stroke color | ||
62 | this._strokeColorCtrl.props = { side: 'top', align: 'center', wheel: true, palette: true, gradient: false, image: false, nocolor: true, offset: -80 }; | ||
63 | this.application.ninja.colorController.addButton("chip", this._strokeColorCtrl); | ||
64 | |||
65 | this._fillColorCtrl.addEventListener("change", this.handleFillColorChange.bind(this), false); | ||
66 | this._strokeColorCtrl.addEventListener("change", this.handleStrokeColorChange.bind(this), false); | ||
67 | |||
68 | this.addedColorChips = true; | ||
69 | } | ||
70 | |||
71 | if (this.addedColorChips) { | ||
72 | this._fillColorCtrl.color(this._fill.colorMode, this._fill.color); | ||
73 | this._strokeColorCtrl.color(this._stroke.colorMode, this._stroke.color); | ||
74 | } | ||
75 | } | ||
76 | }, | ||
14 | 77 | ||
15 | _subPrepare: { | 78 | _subPrepare: { |
16 | value: function() { | 79 | value: function () { |
17 | this.rectProperties.visible = true; | 80 | this.rectProperties.visible = true; |
18 | 81 | ||
19 | Object.defineBinding(this._strokeMaterial, "items", { | 82 | Object.defineBinding(this._strokeMaterial, "items", { |
@@ -33,21 +96,32 @@ exports.ShapeProperties = Montage.create(ToolProperties, { | |||
33 | } | 96 | } |
34 | }, | 97 | }, |
35 | 98 | ||
36 | _selectedSubTool: { value: null, enumerable: false}, | 99 | _selectedSubTool: { value: null, enumerable: false }, |
37 | 100 | ||
38 | selectedSubTool : { | 101 | selectedSubTool: { |
39 | get: function() { return this._selectedSubTool;}, | 102 | get: function () { return this._selectedSubTool; }, |
40 | set: function(value) { | 103 | set: function (value) { |
41 | if(value) { | 104 | if (value) { |
42 | 105 | ||
43 | this._selectedSubTool? this[this._selectedSubTool.properties].visible = false : this.rectProperties.visible = false; | 106 | this._selectedSubTool ? this[this._selectedSubTool.properties].visible = false : this.rectProperties.visible = false; |
44 | 107 | ||
45 | this._selectedSubTool = value; | 108 | this._selectedSubTool = value; |
46 | this[this._selectedSubTool.properties].visible = true; | 109 | this[this._selectedSubTool.properties].visible = true; |
47 | 110 | ||
48 | if(this._useWebGL.checked) | 111 | if (this._selectedSubTool.id === "LineTool") { |
49 | { | 112 | this._fillColorCtrl.style["display"] = "none"; |
50 | if(this._selectedSubTool.id === "LineTool") { | 113 | this._fillColorCtrl.visible = false; |
114 | this._fillColorCtrlIcon.style["display"] = "none"; | ||
115 | this._fillColorCtrlIcon.visible = false; | ||
116 | } else { | ||
117 | this._fillColorCtrl.style["display"] = ""; | ||
118 | this._fillColorCtrl.visible = true; | ||
119 | this._fillColorCtrlIcon.style["display"] = ""; | ||
120 | this._fillColorCtrlIcon.visible = true; | ||
121 | } | ||
122 | |||
123 | if (this._useWebGL.checked) { | ||
124 | if (this._selectedSubTool.id === "LineTool") { | ||
51 | this._fillIcon.style["display"] = "none"; | 125 | this._fillIcon.style["display"] = "none"; |
52 | this._fillMaterial.visible = false; | 126 | this._fillMaterial.visible = false; |
53 | } else { | 127 | } else { |
@@ -55,27 +129,23 @@ exports.ShapeProperties = Montage.create(ToolProperties, { | |||
55 | this._fillMaterial.visible = true; | 129 | this._fillMaterial.visible = true; |
56 | } | 130 | } |
57 | } | 131 | } |
58 | |||
59 | } | 132 | } |
60 | } | 133 | } |
61 | }, | 134 | }, |
62 | 135 | ||
63 | handleChange: { | 136 | handleChange: { |
64 | value: function(event) { | 137 | value: function (event) { |
65 | if(this._useWebGL.checked) | 138 | if (this._useWebGL.checked) { |
66 | { | ||
67 | this._use3D = true; | 139 | this._use3D = true; |
68 | this._materialLabel.style["display"] = ""; | 140 | this._materialLabel.style["display"] = ""; |
69 | this._strokeIcon.style["display"] = ""; | 141 | this._strokeIcon.style["display"] = ""; |
70 | this._strokeMaterial.visible = true; | 142 | this._strokeMaterial.visible = true; |
71 | if(this.selectedSubTool.id !== "LineTool") | 143 | if (this.selectedSubTool.id !== "LineTool") { |
72 | { | ||
73 | this._fillIcon.style["display"] = ""; | 144 | this._fillIcon.style["display"] = ""; |
74 | this._fillMaterial.visible = true; | 145 | this._fillMaterial.visible = true; |
75 | } | 146 | } |
76 | } | 147 | } |
77 | else | 148 | else { |
78 | { | ||
79 | this._use3D = false; | 149 | this._use3D = false; |
80 | this._materialLabel.style["display"] = "none"; | 150 | this._materialLabel.style["display"] = "none"; |
81 | this._strokeIcon.style["display"] = "none"; | 151 | this._strokeIcon.style["display"] = "none"; |
@@ -84,6 +154,19 @@ exports.ShapeProperties = Montage.create(ToolProperties, { | |||
84 | this._fillMaterial.visible = false; | 154 | this._fillMaterial.visible = false; |
85 | } | 155 | } |
86 | } | 156 | } |
87 | } | 157 | }, |
88 | 158 | ||
159 | handleFillColorChange: { | ||
160 | value: function (e) { | ||
161 | this.fill = e._event; | ||
162 | this.fill.webGlColor = this.application.ninja.colorController.colorModel.colorToWebGl(e._event.color); | ||
163 | } | ||
164 | }, | ||
165 | |||
166 | handleStrokeColorChange: { | ||
167 | value: function (e) { | ||
168 | this.stroke = e._event; | ||
169 | this.stroke.webGlColor = this.application.ninja.colorController.colorModel.colorToWebGl(e._event.color); | ||
170 | } | ||
171 | } | ||
89 | }); | 172 | }); |