From aad41becbc41882abf1558c6b5aa38db6a9e99c8 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 19 Jun 2012 15:06:45 -0700 Subject: Fixing logic to close color panel popup This resolves closing the color panel popup when a user make a click outside the popup area or resizes the Ninja window. This should be tested prior to merging. --- js/panels/color/colorpopup-manager.js | 56 +++++++++++------------------------ 1 file changed, 17 insertions(+), 39 deletions(-) (limited to 'js') diff --git a/js/panels/color/colorpopup-manager.js b/js/panels/color/colorpopup-manager.js index 529ec1c8..4667f2b4 100755 --- a/js/panels/color/colorpopup-manager.js +++ b/js/panels/color/colorpopup-manager.js @@ -29,49 +29,27 @@ exports.ColorPopupManager = Montage.create(Component, { enumerable: false, value: function () { //////////////////////////////////////////////////////////// - //TODO: Improve logic on handling closing the popup - //////////////////////////////////////////////////////////// - //Hiding popup on any panel(s) actions - this.eventManager.addEventListener("panelOrderChanged", function (e) { - this.application.ninja.colorController.colorPopupManager.hideColorPopup(); - }.bind(this)); - // - this.eventManager.addEventListener("panelClose", function (e) { - this.application.ninja.colorController.colorPopupManager.hideColorPopup(); - }.bind(this)); - // - this.eventManager.addEventListener("panelCollapsed", function (e) { - this.application.ninja.colorController.colorPopupManager.hideColorPopup(); - }.bind(this)); - // - this.eventManager.addEventListener("panelSelected", function (e) { - this.application.ninja.colorController.colorPopupManager.hideColorPopup(); - }.bind(this)); - // - this.eventManager.addEventListener("togglePanel", function (e) { - this.application.ninja.colorController.colorPopupManager.hideColorPopup(); - }.bind(this)); - // - this.eventManager.addEventListener("panelResizing", function (e) { - this.application.ninja.colorController.colorPopupManager.hideColorPopup(); - }.bind(this)); - // - this.eventManager.addEventListener("panelResizedStart", function (e) { - this.application.ninja.colorController.colorPopupManager.hideColorPopup(); - }.bind(this)); - // - this.eventManager.addEventListener("panelResizedEnd", function (e) { - this.application.ninja.colorController.colorPopupManager.hideColorPopup(); - }.bind(this)); - // + //Closing popups on resize window.addEventListener('resize', function (e) { this.application.ninja.colorController.colorPopupManager.hideColorPopup(); }.bind(this)); - // + //Storing limits of popup + var top, bottom, left, right; + //Closing popups if outside limits document.addEventListener('mousedown', function (e) { - // - if (e._event.srcElement.getAttribute('data-montage-id') === 'stageCanvas' || e._event.srcElement.id === 'mainContainer' || e._event.srcElement.getAttribute('data-montage-id') === 'drawingCanvas') { - this.application.ninja.colorController.colorPopupManager.hideColorPopup(); + //Checking for popup to be opened otherwise nothing happens + if (this._popupPanel.opened && this._popupPanel.popup && this._popupPanel.popup.element && !e._event.srcElement.inputType) { + //Getting horizontal limits + left = parseInt(this._popupPanel.popup.element.style.left) + parseInt(this._popupPanel.popup.element.style.marginLeft); + right = left + parseInt(this._popupPanel.popup.element.offsetWidth); + //Getting vertical limits + top = parseInt(this._popupPanel.popup.element.style.top) + parseInt(this._popupPanel.popup.element.style.marginTop); + bottom = left + parseInt(this._popupPanel.popup.element.offsetHeight); + //Checking click position in relation to limits + if ((e._event.clientX < left || e._event.clientX > right) || (e._event.clientY < top || e._event.clientY > bottom)) { + //Hides popups since click is outside limits + this.application.ninja.colorController.colorPopupManager.hideColorPopup(); + } } }.bind(this)); //////////////////////////////////////////////////////////// -- cgit v1.2.3 From a0d18963d746e410511c29edd32bc1775d2d5851 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 19 Jun 2012 15:42:31 -0700 Subject: IKNINJA-1519 - Transform tool does not transform objects correctly in 3D space or in Top/Side view. Signed-off-by: Nivesh Rajbhandari --- js/tools/SelectionTool.js | 7 ++----- js/tools/ToolBase.js | 2 ++ js/tools/drawing-tool-base.js | 11 +++++++++-- js/tools/modifier-tool-base.js | 17 ++++++++--------- 4 files changed, 21 insertions(+), 16 deletions(-) (limited to 'js') diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 8b644d4a..9bd885a4 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -583,11 +583,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { this.mouseUpHitRec = DrawingToolBase.getUpdatedSnapPoint(point.x, point.y, do3DSnap, this.mouseDownHitRec); if (this._mouseDownHitRec && this._mouseUpHitRec) { - data = this.getDrawingData(event); - if(data) - { - this.modifyElements({pt0:data.mouseDownPos, pt1:data.mouseUpPos}, event); - } + this.modifyElements({pt0:this._mouseDownHitRec.calculateElementScreenPoint(), + pt1:this._mouseUpHitRec.calculateElementScreenPoint()}, event); } } } diff --git a/js/tools/ToolBase.js b/js/tools/ToolBase.js index f43b1b58..88333c74 100755 --- a/js/tools/ToolBase.js +++ b/js/tools/ToolBase.js @@ -35,6 +35,8 @@ exports.toolBase = Montage.create(Component, { _currentX: {value: 0, writable: true}, _currentY: {value: 0, writable: true}, + _dragPlane: { value: null }, + /** * This function is for specifying custom feedback routine * upon mouse over. diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index a752ad65..b5416a65 100755 --- a/js/tools/drawing-tool-base.js +++ b/js/tools/drawing-tool-base.js @@ -14,9 +14,16 @@ var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; exports.DrawingToolBase = Montage.create(Component, { - dragPlane: { - value: null + dragPlane: + { + get: function () { + return this.application.ninja.toolsData.selectedToolInstance._dragPlane; + }, + set: function (value) { + this.application.ninja.toolsData.selectedToolInstance._dragPlane = value; + } }, + /** * Used on the initial MouseDown for Drawing Tools * diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index 6c569f0a..14a7e619 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -21,7 +21,6 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { //------------------------------------------------------------------------- // Snapping-specific properties _canSnap: { value: true }, - _dragPlane: { value: null }, _snapParam: { value: null }, _snapIndex: { value: -1 }, _useQuadPt: { value: false }, @@ -163,15 +162,15 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { if(!this._dragPlane) { -// if( this._inLocalMode && (this._startMatArray.length === 1) ) -// { -// this._dragPlane = viewUtils.getUnprojectedElementPlane(this._clickedObject); -// snapManager.setupDragPlaneFromPlane(this._dragPlane); -// } -// else -// { + if((this._handleMode !== null) && (this.application.ninja.toolsData.selectedTool.action === "SelectionTool")) + { + this._dragPlane = viewUtils.getUnprojectedElementPlane(this.application.ninja.selectedElements[0]); + snapManager.setupDragPlaneFromPlane(this._dragPlane); + } + else + { this._dragPlane = snapManager.setupDragPlanes( hitRec, true ); -// } + } } // only do quadrant snapping if the 4 corners of the element are in the drag plane -- cgit v1.2.3