From 978b9049d057d2a0995758275f68da8641193201 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 27 Jun 2012 14:21:27 -0700 Subject: Integrating Materials UI changes. Squashed commit of the following: commit 89ccb55130e67c4516e616ccc56d2a649a2b9160 Author: Nivesh Rajbhandari Date: Wed Jun 27 14:20:01 2012 -0700 Position Materials Editor popup and change buttons' text color. Signed-off-by: Nivesh Rajbhandari commit 89bca82adc781f4913f8d302a49a8baa907631c5 Author: Nivesh Rajbhandari Date: Wed Jun 27 12:00:51 2012 -0700 Support deleting and editing custom materials. Signed-off-by: Nivesh Rajbhandari commit 5be5160c4786beb70e8ad4d75562adb135718c6c Merge: 1d9d9f6 2ebf3e3 Author: Nivesh Rajbhandari 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 commit 1d9d9f6e66ea7585f07ed461cebba99e71f65de0 Author: Nivesh Rajbhandari 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 commit bf1037508dbc686f2884765344832f906cbf06d0 Author: Nivesh Rajbhandari 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 commit 54930792f9c417df5f739831164aa1f96a41d67a Author: Nivesh Rajbhandari 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 Signed-off-by: Nivesh Rajbhandari --- .../materials-library-panel.js | 109 +++++++++++++++++++-- 1 file changed, 99 insertions(+), 10 deletions(-) (limited to 'js/panels/Materials/materials-library-panel.reel/materials-library-panel.js') 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 var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component, MaterialsData = require("js/panels/Materials/materials-data.json"), - Popup = require("montage/ui/popup/popup.reel").Popup; + Popup = require("montage/ui/popup/popup.reel").Popup, + MaterialsModel = require("js/models/materials-model").MaterialsModel, + LeafNode = require("js/components/treeview/ninja-leaf.reel").Leaf; exports.MaterialsLibraryPanel = Montage.create(Component, { + deleteButton: { + value: null + }, + materialsData: { value: null }, + materialId: { + value: null + }, + + selectedMaterialNode: { + value: null + }, + + customMaterialsBranch: { + value: null + }, + + customMaterialsCounter: { + value: 2 + }, + _hasFocus: { enumerable: false, value: false @@ -36,21 +58,32 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { value:function(event) { switch(event._currentTarget.label) { - case "Add": - console.log("Add new material"); + case "Duplicate": + this.duplicateMaterial(); break; - case "Copy": - console.log("Copy selected material"); + case "Edit": +// console.log("Edit selected material"); + this._showMaterialPopup({ materialId: this.materialId }); break; case "Delete": - console.log("Delete selected material"); + this.deleteMaterial(); break; } } }, handleNodeActivation: { - value:function(obj) { + value: function(obj, event) { + this.selectedMaterialNode = event.currentTarget; + this.materialId = obj.id; + this.deleteButton.enabled = !!obj.canDelete; + } + }, + + handleDblclick: { + value:function(obj, event) { + this.selectedMaterialNode = event.currentTarget; + this.materialId = obj.id; this._showMaterialPopup({ materialId: obj.id }); } }, @@ -58,7 +91,6 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { handleShowMaterialPopup: { enumerable: false, value: function (event) { - //this._showMaterialPopup(event.detail.materialId); this._showMaterialPopup(event.detail); } }, @@ -80,15 +112,16 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { if(!this._materialPopup) { this._materialPopup = Popup.create(); + this._materialInfo.materialsLibraryRef = this; this._materialPopup.content = this._materialInfo; + this._materialPopup.delegate = this; this._materialPopup.modal = false; this.eventManager.addEventListener("hideMaterialPopup", this, false); this._materialPopup.addEventListener("show", this, false); } this._materialPopup.show(); - materialID = materialObj.materialId; - this._materialInfo.loadMaterials(materialID, materialObj.useSelection, materialObj.whichMaterial); + this._materialInfo.loadMaterials(materialObj.materialId, materialObj.useSelection, materialObj.whichMaterial); } }, @@ -99,5 +132,61 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { this._materialPopup.hide(); } } + }, + + duplicateMaterial: { + enumerable: false, + value: function (matCopyName) { +// console.log("Duplicate selected material"); + var mat = MaterialsModel.getMaterial(this.materialId); + if(mat) { + var matCopy = mat.dup(); + if(!matCopyName) { + matCopyName = this.materialId + "_" + this.customMaterialsCounter++; + } + matCopy.setName(matCopyName); + MaterialsModel.addMaterial(matCopy); + + var leaf = LeafNode.create(); + leaf.id = matCopyName; + leaf.label = matCopyName; + leaf.treeNodeType = "leaf"; + leaf.canDelete = true; + if(!this.customMaterialsBranch) { + this.customMaterialsBranch = this.materialsController.branchControllers[2]; + } + this.customMaterialsBranch.content.push(leaf); + } + } + }, + + deleteMaterial: { + enumerable: false, + value: function () { +// console.log("Delete selected material"); + if(!this.customMaterialsBranch) { + this.customMaterialsBranch = this.materialsController.branchControllers[2]; + } + + var mat = MaterialsModel.getMaterial(this.materialId); + if(mat) { + MaterialsModel.removeMaterial(this.materialId); + + var index = this.customMaterialsBranch.selectedIndexes[0]; + this.customMaterialsBranch.content.splice(index, 1); + } + + this.deleteButton.enabled = false; + } + }, + + willPositionPopup: { + value: function(popup, defaultPosition) { + var content = popup.content.element, + contentHt = parseFloat(content.style.height) || content.offsetHeight || 0, + contentWd = parseFloat(content.style.width) || content.offsetWidth || 0, + pt = webkitConvertPointFromNodeToPage(this.selectedMaterialNode, new WebKitPoint(0, 0)); + return {top: pt.y - contentHt + 10, left: pt.x - contentWd + 10}; + } } }); \ No newline at end of file -- cgit v1.2.3 From 2da05a4c71bfe9b136384d9e94fbfbef19f24550 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 27 Jun 2012 17:28:06 -0700 Subject: Performance fix for WebGL materials playing even when the dialog/file is no longer in view. Also pausing videos when switching documents. Signed-off-by: Nivesh Rajbhandari --- .../Materials/materials-library-panel.reel/materials-library-panel.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/panels/Materials/materials-library-panel.reel/materials-library-panel.js') 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 cd933ea6..8c1aa1dc 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 @@ -129,6 +129,8 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { enumerable: false, value: function (event) { if(this._materialPopup){ +// console.log("hiding material popup"); + this._materialInfo.destroy(); this._materialPopup.hide(); } } -- cgit v1.2.3 From 648ee61ae84216d0236e0dbc211addc13b2cfa3a Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:52:06 -0700 Subject: Expand tabs --- .../materials-library-panel.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'js/panels/Materials/materials-library-panel.reel/materials-library-panel.js') 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..1cf3cec7 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 @@ -40,8 +40,8 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { }, _hasFocus: { - enumerable: false, - value: false + enumerable: false, + value: false }, didCreate: { @@ -98,10 +98,10 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { }, _showMaterialPopup: { - enumerable: false, - value: function (materialObj) { + enumerable: false, + value: function (materialObj) { - if(!this._materialPopup) + if(!this._materialPopup) { this._materialPopup = Popup.create(); this._materialPopup.content = this._materialInfo; @@ -113,15 +113,15 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { materialID = materialObj.materialId; this._materialInfo.loadMaterials(materialID, materialObj.useSelection, materialObj.whichMaterial); - } + } }, handleHideMaterialPopup: { - enumerable: false, - value: function (event) { + enumerable: false, + value: function (event) { if(this._materialPopup){ this._materialPopup.hide(); } - } + } } }); -- cgit v1.2.3 From 04343eda8c2f870b0da55cfdc8003c99fe1cc4de Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:53:10 -0700 Subject: Remove trailing spaces --- .../Materials/materials-library-panel.reel/materials-library-panel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/panels/Materials/materials-library-panel.reel/materials-library-panel.js') 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 1cf3cec7..98a87b07 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 @@ -96,7 +96,7 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { enumerable:true, serializable: true }, - + _showMaterialPopup: { enumerable: false, value: function (materialObj) { -- cgit v1.2.3 From fdbec324dad4ab33d97282ab021d2c1661bc097c Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Mon, 9 Jul 2012 16:27:52 -0700 Subject: BSD License --- .../materials-library-panel.js | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'js/panels/Materials/materials-library-panel.reel/materials-library-panel.js') 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 873184dc..aef48230 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 @@ -1,24 +1,25 @@ /* -Copyright (c) 2012, Motorola Mobility, Inc +Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved. -BSD License. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of Motorola Mobility nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of Motorola Mobility LLC nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- cgit v1.2.3