From d2f4d5e5f6742d53b6324d585a700566f73c992a Mon Sep 17 00:00:00 2001 From: mqg734 Date: Tue, 21 Feb 2012 16:49:11 -0800 Subject: Updated Materials Library and Materials Editor Popup to work with latest version of Montage. We had to change our css to not use id's. Also, updated the popup to use Montage's Popup component. It looks like bump material has a bug. So loading that material results in a runtime error. --- .../materials-library-panel.js | 121 +++++---------------- 1 file changed, 25 insertions(+), 96 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 f97e1a27..b16c4376 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,7 +7,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Tree = require("js/components/tree.reel").Tree, Button = require("js/components/button.reel").Button, MaterialsPopup = require("js/panels/Materials/materials-popup.reel").MaterialsPopup, - PopupMananger = require("js/components/popup-manager.reel").PopupMananger; + PopupMananger = require("js/components/popup-manager.reel").PopupMananger, + Popup = require("montage/ui/popup/popup.reel").Popup; exports.MaterialsLibraryPanel = (require("montage/core/core").Montage).create(require("montage/ui/component").Component, { @@ -92,20 +93,7 @@ exports.MaterialsLibraryPanel = (require("montage/core/core").Montage).create(re captureChange: { value:function(e) { var tNode = e._event.treeNode; - var left, top; - //TODO: Figure out if this is the best way to detect where user clicked - var mouseEvent = e._event.mouseEvent; - if (mouseEvent.clientX && mouseEvent.clientY) { - if (mouseEvent.clientX > (parseInt(document.width)/2)) { - left = mouseEvent.clientX - mouseEvent.offsetX-2; - top = mouseEvent.currentTarget.clientHeight/2+mouseEvent.clientY - mouseEvent.offsetY; - } else { - left = mouseEvent.clientX - mouseEvent.offsetX+parseInt(mouseEvent.currentTarget.clientWidth); - top = mouseEvent.clientY - mouseEvent.offsetY; - } - } - - this._showMaterialPopup(left + 'px', top + 'px', 'right', 'top', tNode.id); + this._showMaterialPopup(tNode.id); } }, @@ -113,93 +101,34 @@ exports.MaterialsLibraryPanel = (require("montage/core/core").Montage).create(re enumerable:true, value:null }, + + _materialInfo: { + enumerable:true + }, _showMaterialPopup: { enumerable: false, - value: function (x, y, side, align, materialID) { - if (this._materialPopup && this._materialPopup.opened) { - if (this._materialPopup.popup.position.x === x && this._materialPopup.popup.position.y === y) { - this._hideMaterialPopup(); - } else { - this._materialPopup.popup.position = {x: x, y: y}; - this._materialPopup.popup.tooltip = {side: side, align: align}; - this._materialPopup.popup.base.loadMaterials(materialID); - //TODO: Tooltip needs to be fixed to allow aligning to change on fly - //this._materialPopup.popup.drawTooltip(); - } - } else { - //////////////////////////////////////////////////// - //Creating popup from m-js component - var popup = document.createElement('div'); - var content = document.createElement('div'); - var popupBase = MaterialsPopup.create(); - - - //TODO: Check to see if this HACK is needed - //(elements needs to be on DOM to be drawn) - document.body.appendChild(popup); - popupBase.element = popup; - popupBase.needsDraw = true; - document.body.removeChild(popup); - //Adding drawn element to container - content.appendChild(popupBase.element); - - //Creating an instance of the popup and sending in created material popup content - this._materialPopup = {}; - this._materialPopup.popup = PopupMananger.createPopup(content, {x: x, y: y}, {side: side, align: align}); - this._materialPopup.popup.element.style.opacity = 0; - this._materialPopup.popup.base = popupBase; - popupBase._material = MaterialsLibrary.getMaterial( materialID ); - popupBase._materialName = materialID; - //TODO: Fix this animation/draw HACK (Move to didDraw callback) - setTimeout(function () { - this._materialPopup.popup.element.style.opacity = 1; - this._materialPopup.popup.base.loadMaterials(materialID); - }.bind(this), 150); - - - - //Popup was added, so it's opened - this._materialPopup.opened = true; - //TODO: Fix this HACK, it listens to this canvas to be clicked to close popup - document.getElementById('stageAndScenesContainer').addEventListener('click', this, false); - } - } - }, - //////////////////////////////////////////////////////////////////// - // - handleClick: { - enumerable: true, - value: function (e) { - //TODO: Fix this HACK - if (e._event.target.id === 'stageCanvas' && this._materialPopup.opened) { - this._handleDocumentClick(e); - } - } - }, - //////////////////////////////////////////////////////////////////// - // - _handleDocumentClick: { - enumerable: false, - value: function (e) { - this._hideMaterialPopup(); - //TODO: Fix this HACK - document.getElementById('stageAndScenesContainer').removeEventListener ('click', this, false); + value: function (materialID) { + + if(!this._materialPopup) + { + this._materialPopup = Popup.create(); + this._materialPopup.content = this._materialInfo; + this._materialPopup.modal = false; + this.eventManager.addEventListener("hideMaterialPopup", this, false); + this._materialPopup.addEventListener("show", this, false); + } + this._materialPopup.show(); + this._materialInfo.loadMaterials(materialID); } }, - //////////////////////////////////////////////////////////////////// - // - _hideMaterialPopup: { + + handleHideMaterialPopup: { enumerable: false, - value: function () { - if (this._materialPopup.opened) { - // - PopupMananger.removePopup(this._materialPopup.popup.element); - this._materialPopup.opened = false; - //TODO: Fix HACK of removing popup - this._materialPopup.popup.base.destroy(); - this._materialPopup.popup = null; - } + value: function (event) { + if(this._materialPopup){ + this._materialPopup.hide(); + } } } }); \ No newline at end of file -- cgit v1.2.3