diff options
author | Nivesh Rajbhandari | 2012-06-27 14:21:27 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-06-27 14:21:27 -0700 |
commit | 978b9049d057d2a0995758275f68da8641193201 (patch) | |
tree | d26fadef6100d5eb87e871a68f8c71fac9ab27a6 /js/panels/Materials/materials-library-panel.reel/materials-library-panel.js | |
parent | 8351c3685a6db703d1940817abc71f92ef4e1bd4 (diff) | |
download | ninja-978b9049d057d2a0995758275f68da8641193201.tar.gz |
Integrating Materials UI changes. Squashed commit of the following:
commit 89ccb55130e67c4516e616ccc56d2a649a2b9160
Author: Nivesh Rajbhandari <mqg734@motorola.com>
Date: Wed Jun 27 14:20:01 2012 -0700
Position Materials Editor popup and change buttons' text color.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
commit 89bca82adc781f4913f8d302a49a8baa907631c5
Author: Nivesh Rajbhandari <mqg734@motorola.com>
Date: Wed Jun 27 12:00:51 2012 -0700
Support deleting and editing custom materials.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
commit 5be5160c4786beb70e8ad4d75562adb135718c6c
Merge: 1d9d9f6 2ebf3e3
Author: Nivesh Rajbhandari <mqg734@motorola.com>
Date: Wed Jun 27 11:11:37 2012 -0700
Merge branch 'refs/heads/ninja-internal' into WebGLMaterials
Conflicts:
js/data/panels-data.js
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
commit 1d9d9f6e66ea7585f07ed461cebba99e71f65de0
Author: Nivesh Rajbhandari <mqg734@motorola.com>
Date: Tue Jun 26 22:01:22 2012 -0700
"Save as" support to duplicate material with modified settings. Also removed Add button and disabled Reset button for now.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
commit bf1037508dbc686f2884765344832f906cbf06d0
Author: Nivesh Rajbhandari <mqg734@motorola.com>
Date: Tue Jun 26 17:23:31 2012 -0700
Added UI for duplicating and deleting materials in the Materials Library.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
commit 54930792f9c417df5f739831164aa1f96a41d67a
Author: Nivesh Rajbhandari <mqg734@motorola.com>
Date: Tue Jun 26 14:29:17 2012 -0700
Added preview of material in materials editor popup and fixed some styling.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/panels/Materials/materials-library-panel.reel/materials-library-panel.js')
-rwxr-xr-x | js/panels/Materials/materials-library-panel.reel/materials-library-panel.js | 109 |
1 files changed, 99 insertions, 10 deletions
diff --git a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js index cf0d4e93..cd933ea6 100755 --- a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js +++ b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js | |||
@@ -7,14 +7,36 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | Component = require("montage/ui/component").Component, | 8 | Component = require("montage/ui/component").Component, |
9 | MaterialsData = require("js/panels/Materials/materials-data.json"), | 9 | MaterialsData = require("js/panels/Materials/materials-data.json"), |
10 | Popup = require("montage/ui/popup/popup.reel").Popup; | 10 | Popup = require("montage/ui/popup/popup.reel").Popup, |
11 | MaterialsModel = require("js/models/materials-model").MaterialsModel, | ||
12 | LeafNode = require("js/components/treeview/ninja-leaf.reel").Leaf; | ||
11 | 13 | ||
12 | exports.MaterialsLibraryPanel = Montage.create(Component, { | 14 | exports.MaterialsLibraryPanel = Montage.create(Component, { |
13 | 15 | ||
16 | deleteButton: { | ||
17 | value: null | ||
18 | }, | ||
19 | |||
14 | materialsData: { | 20 | materialsData: { |
15 | value: null | 21 | value: null |
16 | }, | 22 | }, |
17 | 23 | ||
24 | materialId: { | ||
25 | value: null | ||
26 | }, | ||
27 | |||
28 | selectedMaterialNode: { | ||
29 | value: null | ||
30 | }, | ||
31 | |||
32 | customMaterialsBranch: { | ||
33 | value: null | ||
34 | }, | ||
35 | |||
36 | customMaterialsCounter: { | ||
37 | value: 2 | ||
38 | }, | ||
39 | |||
18 | _hasFocus: { | 40 | _hasFocus: { |
19 | enumerable: false, | 41 | enumerable: false, |
20 | value: false | 42 | value: false |
@@ -36,21 +58,32 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { | |||
36 | value:function(event) { | 58 | value:function(event) { |
37 | switch(event._currentTarget.label) | 59 | switch(event._currentTarget.label) |
38 | { | 60 | { |
39 | case "Add": | 61 | case "Duplicate": |
40 | console.log("Add new material"); | 62 | this.duplicateMaterial(); |
41 | break; | 63 | break; |
42 | case "Copy": | 64 | case "Edit": |
43 | console.log("Copy selected material"); | 65 | // console.log("Edit selected material"); |
66 | this._showMaterialPopup({ materialId: this.materialId }); | ||
44 | break; | 67 | break; |
45 | case "Delete": | 68 | case "Delete": |
46 | console.log("Delete selected material"); | 69 | this.deleteMaterial(); |
47 | break; | 70 | break; |
48 | } | 71 | } |
49 | } | 72 | } |
50 | }, | 73 | }, |
51 | 74 | ||
52 | handleNodeActivation: { | 75 | handleNodeActivation: { |
53 | value:function(obj) { | 76 | value: function(obj, event) { |
77 | this.selectedMaterialNode = event.currentTarget; | ||
78 | this.materialId = obj.id; | ||
79 | this.deleteButton.enabled = !!obj.canDelete; | ||
80 | } | ||
81 | }, | ||
82 | |||
83 | handleDblclick: { | ||
84 | value:function(obj, event) { | ||
85 | this.selectedMaterialNode = event.currentTarget; | ||
86 | this.materialId = obj.id; | ||
54 | this._showMaterialPopup({ materialId: obj.id }); | 87 | this._showMaterialPopup({ materialId: obj.id }); |
55 | } | 88 | } |
56 | }, | 89 | }, |
@@ -58,7 +91,6 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { | |||
58 | handleShowMaterialPopup: { | 91 | handleShowMaterialPopup: { |
59 | enumerable: false, | 92 | enumerable: false, |
60 | value: function (event) { | 93 | value: function (event) { |
61 | //this._showMaterialPopup(event.detail.materialId); | ||
62 | this._showMaterialPopup(event.detail); | 94 | this._showMaterialPopup(event.detail); |
63 | } | 95 | } |
64 | }, | 96 | }, |
@@ -80,15 +112,16 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { | |||
80 | if(!this._materialPopup) | 112 | if(!this._materialPopup) |
81 | { | 113 | { |
82 | this._materialPopup = Popup.create(); | 114 | this._materialPopup = Popup.create(); |
115 | this._materialInfo.materialsLibraryRef = this; | ||
83 | this._materialPopup.content = this._materialInfo; | 116 | this._materialPopup.content = this._materialInfo; |
117 | this._materialPopup.delegate = this; | ||
84 | this._materialPopup.modal = false; | 118 | this._materialPopup.modal = false; |
85 | this.eventManager.addEventListener("hideMaterialPopup", this, false); | 119 | this.eventManager.addEventListener("hideMaterialPopup", this, false); |
86 | this._materialPopup.addEventListener("show", this, false); | 120 | this._materialPopup.addEventListener("show", this, false); |
87 | } | 121 | } |
88 | this._materialPopup.show(); | 122 | this._materialPopup.show(); |
89 | 123 | ||
90 | materialID = materialObj.materialId; | 124 | this._materialInfo.loadMaterials(materialObj.materialId, materialObj.useSelection, materialObj.whichMaterial); |
91 | this._materialInfo.loadMaterials(materialID, materialObj.useSelection, materialObj.whichMaterial); | ||
92 | } | 125 | } |
93 | }, | 126 | }, |
94 | 127 | ||
@@ -99,5 +132,61 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { | |||
99 | this._materialPopup.hide(); | 132 | this._materialPopup.hide(); |
100 | } | 133 | } |
101 | } | 134 | } |
135 | }, | ||
136 | |||
137 | duplicateMaterial: { | ||
138 | enumerable: false, | ||
139 | value: function (matCopyName) { | ||
140 | // console.log("Duplicate selected material"); | ||
141 | var mat = MaterialsModel.getMaterial(this.materialId); | ||
142 | if(mat) { | ||
143 | var matCopy = mat.dup(); | ||
144 | if(!matCopyName) { | ||
145 | matCopyName = this.materialId + "_" + this.customMaterialsCounter++; | ||
146 | } | ||
147 | matCopy.setName(matCopyName); | ||
148 | MaterialsModel.addMaterial(matCopy); | ||
149 | |||
150 | var leaf = LeafNode.create(); | ||
151 | leaf.id = matCopyName; | ||
152 | leaf.label = matCopyName; | ||
153 | leaf.treeNodeType = "leaf"; | ||
154 | leaf.canDelete = true; | ||
155 | if(!this.customMaterialsBranch) { | ||
156 | this.customMaterialsBranch = this.materialsController.branchControllers[2]; | ||
157 | } | ||
158 | this.customMaterialsBranch.content.push(leaf); | ||
159 | } | ||
160 | } | ||
161 | }, | ||
162 | |||
163 | deleteMaterial: { | ||
164 | enumerable: false, | ||
165 | value: function () { | ||
166 | // console.log("Delete selected material"); | ||
167 | if(!this.customMaterialsBranch) { | ||
168 | this.customMaterialsBranch = this.materialsController.branchControllers[2]; | ||
169 | } | ||
170 | |||
171 | var mat = MaterialsModel.getMaterial(this.materialId); | ||
172 | if(mat) { | ||
173 | MaterialsModel.removeMaterial(this.materialId); | ||
174 | |||
175 | var index = this.customMaterialsBranch.selectedIndexes[0]; | ||
176 | this.customMaterialsBranch.content.splice(index, 1); | ||
177 | } | ||
178 | |||
179 | this.deleteButton.enabled = false; | ||
180 | } | ||
181 | }, | ||
182 | |||
183 | willPositionPopup: { | ||
184 | value: function(popup, defaultPosition) { | ||
185 | var content = popup.content.element, | ||
186 | contentHt = parseFloat(content.style.height) || content.offsetHeight || 0, | ||
187 | contentWd = parseFloat(content.style.width) || content.offsetWidth || 0, | ||
188 |