diff options
author | hwc487 | 2012-07-09 16:08:02 -0700 |
---|---|---|
committer | hwc487 | 2012-07-09 16:08:02 -0700 |
commit | 5085d0f67df89a21715308956004164597a6ba79 (patch) | |
tree | 2c896163143a66331205a39b0a3b1b45d51bf12a /js/panels/Materials/materials-library-panel.reel/materials-library-panel.js | |
parent | 51f1691f792dbda9b740ded8aa0457c9406db156 (diff) | |
parent | 84b3327bd92faafab7954b5eb64c7abe24a3fe13 (diff) | |
download | ninja-5085d0f67df89a21715308956004164597a6ba79.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into GridFixes
Conflicts:
js/helper-classes/3D/StageLine.js
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 | 131 |
1 files changed, 111 insertions, 20 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 b5d6bb96..873184dc 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 | |||
@@ -31,17 +31,39 @@ POSSIBILITY OF SUCH DAMAGE. | |||
31 | var Montage = require("montage/core/core").Montage, | 31 | var Montage = require("montage/core/core").Montage, |
32 | Component = require("montage/ui/component").Component, | 32 | Component = require("montage/ui/component").Component, |
33 | MaterialsData = require("js/panels/Materials/materials-data.json"), | 33 | MaterialsData = require("js/panels/Materials/materials-data.json"), |
34 | Popup = require("montage/ui/popup/popup.reel").Popup; | 34 | Popup = require("montage/ui/popup/popup.reel").Popup, |
35 | MaterialsModel = require("js/models/materials-model").MaterialsModel, | ||
36 | LeafNode = require("js/components/treeview/ninja-leaf.reel").Leaf; | ||
35 | 37 | ||
36 | exports.MaterialsLibraryPanel = Montage.create(Component, { | 38 | exports.MaterialsLibraryPanel = Montage.create(Component, { |
37 | 39 | ||
40 | deleteButton: { | ||
41 | value: null | ||
42 | }, | ||
43 | |||
38 | materialsData: { | 44 | materialsData: { |
39 | value: null | 45 | value: null |
40 | }, | 46 | }, |
41 | 47 | ||
48 | materialId: { | ||
49 | value: null | ||
50 | }, | ||
51 | |||
52 | selectedMaterialNode: { | ||
53 | value: null | ||
54 | }, | ||
55 | |||
56 | customMaterialsBranch: { | ||
57 | value: null | ||
58 | }, | ||
59 | |||
60 | customMaterialsCounter: { | ||
61 | value: 2 | ||
62 | }, | ||
63 | |||
42 | _hasFocus: { | 64 | _hasFocus: { |
43 | enumerable: false, | 65 | enumerable: false, |
44 | value: false | 66 | value: false |
45 | }, | 67 | }, |
46 | 68 | ||
47 | didCreate: { | 69 | didCreate: { |
@@ -60,21 +82,32 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { | |||
60 | value:function(event) { | 82 | value:function(event) { |
61 | switch(event._currentTarget.label) | 83 | switch(event._currentTarget.label) |
62 | { | 84 | { |
63 | case "Add": | 85 | case "Duplicate": |
64 | console.log("Add new material"); | 86 | this.duplicateMaterial(); |
65 | break; | 87 | break; |
66 | case "Copy": | 88 | case "Edit": |
67 | console.log("Copy selected material"); | 89 | // console.log("Edit selected material"); |
90 | this._showMaterialPopup({ materialId: this.materialId }); | ||
68 | break; | 91 | break; |
69 | case "Delete": | 92 | case "Delete": |
70 | console.log("Delete selected material"); | 93 | this.deleteMaterial(); |
71 | break; | 94 | break; |
72 | } | 95 | } |
73 | } | 96 | } |
74 | }, | 97 | }, |
75 | 98 | ||
76 | handleNodeActivation: { | 99 | handleNodeActivation: { |
77 | value:function(obj) { | 100 | value: function(obj, event) { |
101 | this.selectedMaterialNode = event.currentTarget; | ||
102 | this.materialId = obj.id; | ||
103 | this.deleteButton.enabled = !!obj.canDelete; | ||
104 | } | ||
105 | }, | ||
106 | |||
107 | handleDblclick: { | ||
108 | value:function(obj, event) { | ||
109 | this.selectedMaterialNode = event.currentTarget; | ||
110 | this.materialId = obj.id; | ||
78 | this._showMaterialPopup({ materialId: obj.id }); | 111 | this._showMaterialPopup({ materialId: obj.id }); |
79 | } | 112 | } |
80 | }, | 113 | }, |
@@ -82,7 +115,6 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { | |||
82 | handleShowMaterialPopup: { | 115 | handleShowMaterialPopup: { |
83 | enumerable: false, | 116 | enumerable: false, |
84 | value: function (event) { | 117 | value: function (event) { |
85 | //this._showMaterialPopup(event.detail.materialId); | ||
86 | this._showMaterialPopup(event.detail); | 118 | this._showMaterialPopup(event.detail); |
87 | } | 119 | } |
88 | }, | 120 | }, |
@@ -96,32 +128,91 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { | |||
96 | enumerable:true, | 128 | enumerable:true, |
97 | serializable: true | 129 | serializable: true |
98 | }, | 130 | }, |
99 | 131 | ||
100 | _showMaterialPopup: { | 132 | _showMaterialPopup: { |
101 | enumerable: false, | 133 | enumerable: false, |
102 | value: function (materialObj) { | 134 | value: function (materialObj) { |
103 | 135 | ||
104 | if(!this._materialPopup) | 136 | if(!this._materialPopup) |
105 | { | 137 | { |
106 | this._materialPopup = Popup.create(); | 138 | this._materialPopup = Popup.create(); |
139 | this._materialInfo.materialsLibraryRef = this; | ||
107 | this._materialPopup.content = this._materialInfo; | 140 | this._materialPopup.content = this._materialInfo; |
141 | this._materialPopup.delegate = this; | ||
108 | this._materialPopup.modal = false; | 142 | this._materialPopup.modal = false; |
109 | this.eventManager.addEventListener("hideMaterialPopup", this, false); | 143 | this.eventManager.addEventListener("hideMaterialPopup", this, false); |
110 | this._materialPopup.addEventListener("show", this, false); | 144 | this._materialPopup.addEventListener("show", this, false); |
111 | } | 145 | } |
112 | this._materialPopup.show(); | 146 | this._materialPopup.show(); |
113 | 147 | ||
114 | materialID = materialObj.materialId; | 148 | this._materialInfo.loadMaterials(materialObj.materialId, materialObj.useSelection, materialObj.whichMaterial); |
115 | this._materialInfo.loadMaterials(materialID, materialObj.useSelection, materialObj.whichMaterial); | 149 | } |
116 | } | ||
117 | }, | 150 | }, |
118 | 151 | ||
119 | handleHideMaterialPopup: { | 152 | handleHideMaterialPopup: { |
120 | enumerable: false, | 153 | enumerable: false, |
121 | value: function (event) { | 154 | value: function (event) { |
122 | if(this._materialPopup){ | 155 | if(this._materialPopup){ |
156 | // console.log("hiding material popup"); | ||
157 | this._materialInfo.destroy(); | ||
123 | this._materialPopup.hide(); | 158 | this._materialPopup.hide(); |
124 | } | 159 | } |
125 | } | 160 | } |
161 | }, | ||
162 | |||
163 | duplicateMaterial: { | ||
164 | enumerable: false, | ||
165 | value: function (matCopyName) { | ||
166 | // console.log("Duplicate selected material"); | ||
167 | var mat = MaterialsModel.getMaterial(this.materialId); | ||
168 | if(mat) { | ||
169 | var matCopy = mat.dup(); | ||
170 | if(!matCopyName) { | ||
171 | matCopyName = this.materialId + "_" + this.customMaterialsCounter++; | ||
172 | } | ||
173 | matCopy.setName(matCopyName); | ||
174 | MaterialsModel.addMaterial(matCopy); | ||
175 | |||
176 | var leaf = LeafNode.create(); | ||
177 | leaf.id = matCopyName; | ||
178 | leaf.label = matCopyName; | ||
179 | leaf.treeNodeType = "leaf"; | ||
180 | leaf.canDelete = true; | ||
181 | if(!this.customMaterialsBranch) { | ||
182 | this.customMaterialsBranch = this.materialsController.branchControllers[2]; | ||
183 | } | ||
184 | this.customMaterialsBranch.content.push(leaf); | ||
185 | } | ||
186 | } | ||
187 | }, | ||
188 | |||
189 | deleteMaterial: { | ||
190 | enumerable: false, | ||
191 | value: function () { | ||
192 | // console.log("Delete selected material"); | ||
193 | if(!this.customMaterialsBranch) { | ||
194 | this.customMaterialsBranch = this.materialsController.branchControllers[2]; | ||