From e4159f8cea57077c755030a421c091b28c7a8ecc Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 19 Mar 2012 17:06:20 -0700 Subject: Use new tree control in Materials panel. Signed-off-by: Nivesh Rajbhandari --- js/panels/Materials/materials-data.json | 43 ++++++++++++++++++++++ .../materials-library-panel.html | 43 ++++++++++++++++++---- .../materials-library-panel.js | 34 ++++++++--------- .../materials-popup.reel/materials-popup.js | 6 ++- 4 files changed, 99 insertions(+), 27 deletions(-) create mode 100644 js/panels/Materials/materials-data.json (limited to 'js/panels/Materials') diff --git a/js/panels/Materials/materials-data.json b/js/panels/Materials/materials-data.json new file mode 100644 index 00000000..f06ab6c8 --- /dev/null +++ b/js/panels/Materials/materials-data.json @@ -0,0 +1,43 @@ +{ + "label": "materials", + "children": [ + { + "label": "Ninja Materials", + "children": [ + { + "label": "Uber", + "id" : "UberMaterial" + }, + { + "label": "Bump Metal", + "id" : "BumpMetalMaterial" + }, + { + "label": "Linear Gradient", + "id" : "LinearGradientMaterial" + }, + { + "label": "Radial Gradient", + "id" : "RadialGradientMaterial" + }, + { + "label": "Flat", + "id" : "FlatMaterial" + } + ] + }, + { + "label": "Custom Materials", + "children": [ + { + "label": "Checker Board", + "id" : "CheckerBoard" + }, + { + "label": "Shiny Metal", + "id" : "ShinyMetal" + } + ] + } + ] +} \ No newline at end of file diff --git a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.html b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.html index fe17d0f8..4e41512f 100755 --- a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.html +++ b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.html @@ -46,10 +46,39 @@ } ] }, - "materialInfo": { - "module": "js/panels/Materials/materials-popup.reel", - "name": "MaterialsPopup" - }, + "materialInfo": { + "module": "js/panels/Materials/materials-popup.reel", + "name": "MaterialsPopup" + }, + "materialsController" : { + "module": "js/controllers/tree-controller", + "name": "TreeController", + "properties" : { + "branchKey" : "children", + "labelKey" : "label", + "delegate": {"@": "owner" } + }, + "bindings": { + "content": { + "boundObject": {"@": "owner"}, + "boundObjectPropertyPath": "materialsData" + } + } + }, + "materialsContainer" : { + "module" : "js/components/treeview/treeview.reel", + "name" : "Treeview", + "properties" : { + "element" : {"#": "materials_library_tree"}, + "branchComponent" : {"@": "branch" }, + "contentController": {"@": "materialsController"}, + "showRoot": false + } + }, + "branch" : { + "module" : "js/components/treeview/ninja-branch.reel", + "name" : "Branch" + }, "owner": { "module": "js/panels/Materials/materials-library-panel.reel", "name": "MaterialsLibraryPanels", @@ -65,9 +94,9 @@
-
-
    -
    +
    +
    +

    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 bb550598..5fd86d00 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 @@ -4,29 +4,26 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var Tree = require("js/components/tree.reel").Tree, - MaterialsPopup = require("js/panels/Materials/materials-popup.reel").MaterialsPopup, - PopupMananger = require("js/components/popup-manager.reel").PopupMananger, +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; -exports.MaterialsLibraryPanel = (require("montage/core/core").Montage).create(require("montage/ui/component").Component, { +exports.MaterialsLibraryPanel = Montage.create(Component, { + + materialsData: { + value: null + }, _hasFocus: { enumerable: false, value: false }, - - prepareForDraw: { - enumerable: false, - value: function() { - var treeHolderDiv = document.getElementById("materials_library_tree"); - var materialsTree = Tree.create(); - materialsTree.element = treeHolderDiv; - materialsTree.dataProvider = this._loadXMLDoc("js/panels/Materials/Materials.xml"); - materialsTree.needsDraw = true; - materialsTree.addEventListener("change", this, true); - } + didCreate: { + value: function() { + this.materialsData = MaterialsData; + } }, willDraw: { @@ -71,10 +68,9 @@ exports.MaterialsLibraryPanel = (require("montage/core/core").Montage).create(re } }, - captureChange: { - value:function(e) { - var tNode = e._event.treeNode; - this._showMaterialPopup(tNode.id); + handleNodeActivation: { + value:function(obj) { + this._showMaterialPopup(obj.id); } }, diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.js b/js/panels/Materials/materials-popup.reel/materials-popup.js index 193e72b7..b44761bc 100755 --- a/js/panels/Materials/materials-popup.reel/materials-popup.js +++ b/js/panels/Materials/materials-popup.reel/materials-popup.js @@ -214,7 +214,11 @@ exports.MaterialsPopup = Montage.create(Component, { enumerable: true, value: function(materialID) { - this._materialName = materialID; + // Note that setting Array.length = 0 will empty arrays, + // which is fine if you use getMaterialData to get a new array, but not for the + // dummyData arrays. + this._materialsData.length = 0; + this._materialName = materialID; if( (materialID === "UberMaterial") || (materialID === "FlatMaterial") || -- cgit v1.2.3 From e1c4f30a4c13d747fa69d78598e0961286bbe571 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 20 Mar 2012 10:59:05 -0700 Subject: Support button control in Properties Panel and use them for edit fill and stroke material. Signed-off-by: Nivesh Rajbhandari --- .../materials-library-panel.js | 32 +++++++--------------- 1 file changed, 10 insertions(+), 22 deletions(-) (limited to 'js/panels/Materials') 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 5fd86d00..2176c6d5 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 @@ -26,28 +26,9 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { } }, - willDraw: { - enumerable: false, - value: function() { - - } - }, - - draw: { - enumerable: false, - value: function() { - - } - }, - - _loadXMLDoc: { - value:function(dname) { - if (window.XMLHttpRequest) { - xhttp = new XMLHttpRequest(); - } - xhttp.open("GET", dname, false); - xhttp.send(); - return xhttp.responseXML; + prepareForDraw: { + value : function() { + this.eventManager.addEventListener("showMaterialPopup", this, false); } }, @@ -74,6 +55,13 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { } }, + handleShowMaterialPopup: { + enumerable: false, + value: function (event) { + this._showMaterialPopup(event.detail.materialId); + } + }, + _materialPopup: { enumerable:true, value:null -- cgit v1.2.3 From 17cf4470b54cc6014f23f982d1a644a045cccb04 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 20 Mar 2012 11:17:46 -0700 Subject: Deleting unused Materials.xml file since we converted to JSON. Signed-off-by: Nivesh Rajbhandari --- js/panels/Materials/Materials.xml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100755 js/panels/Materials/Materials.xml (limited to 'js/panels/Materials') diff --git a/js/panels/Materials/Materials.xml b/js/panels/Materials/Materials.xml deleted file mode 100755 index a958575e..00000000 --- a/js/panels/Materials/Materials.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file -- cgit v1.2.3