From 17c2fb59d07fb8241f3209452357376563c13b73 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 6 May 2019 08:53:59 +0200 Subject: [PATCH] low level BUG in Frame fixed --- FloatingSpace/CircularMenuItem.js | 13 ++----- Frame.js | 60 +++++++++++++++++++++++++------ 2 files changed, 53 insertions(+), 20 deletions(-) diff --git a/FloatingSpace/CircularMenuItem.js b/FloatingSpace/CircularMenuItem.js index d04fa8ee5..f02a8ab08 100644 --- a/FloatingSpace/CircularMenuItem.js +++ b/FloatingSpace/CircularMenuItem.js @@ -24,8 +24,9 @@ function newCircularMenuItem () { thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) - thisObject.container.isClickeable = false + thisObject.container.isClickeable = true thisObject.container.isDraggeable = false + thisObject.container.detectMouseOver = true thisObject.container.frame.radius = 0 thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 @@ -96,18 +97,11 @@ function newCircularMenuItem () { } function onMouseClick (event) { - + console.log('Menu item clicked') } function drawBackground () { if (thisObject.container.frame.position.x > 0 && thisObject.isDeployed === true && thisObject.currentRadius >= thisObject.targetRadius) { - let position = { - x: 0, - y: 0 - } - - position = thisObject.container.frame.frameThisPoint(position) - let params = { cornerRadius: 3, lineWidth: 0.1, @@ -160,4 +154,3 @@ function newCircularMenuItem () { } } } - diff --git a/Frame.js b/Frame.js index f46f70630..24eab5872 100644 --- a/Frame.js +++ b/Frame.js @@ -65,25 +65,65 @@ function newFrame () { } function frameThisPoint (point) { - if (thisObject.parentFrame !== undefined) { - point = thisObject.parentFrame.frameThisPoint(point) + /* We need not to modify the point received, so me make a copy of it. */ + + let checkPoint = { + x: point.x, + y: point.y } - point.x = point.x + thisObject.position.x - point.y = point.y + thisObject.position.y + let parentPoint = { + x: 0, + y: 0 + } - return point + let returnPoint = { + x: 0, + y: 0 + } + + if (thisObject.parentFrame !== undefined) { + parentPoint = thisObject.parentFrame.frameThisPoint(checkPoint) + + returnPoint.x = parentPoint.x + thisObject.position.x + returnPoint.y = parentPoint.y + thisObject.position.y + } else { + returnPoint.x = checkPoint.x + thisObject.position.x + returnPoint.y = checkPoint.y + thisObject.position.y + } + + return returnPoint } function unframeThisPoint (point) { - if (thisObject.parentFrame !== undefined) { - point = thisObject.parentFrame.unframeThisPoint(point) + /* We need not to modify the point received, so me make a copy of it. */ + + let checkPoint = { + x: point.x, + y: point.y } - point.x = point.x - thisObject.position.x - point.y = point.y - thisObject.position.y + let parentPoint = { + x: 0, + y: 0 + } - return point + let returnPoint = { + x: 0, + y: 0 + } + + if (thisObject.parentFrame !== undefined) { + parentPoint = thisObject.parentFrame.unframeThisPoint(checkPoint) + + returnPoint.x = parentPoint.x - thisObject.position.x + returnPoint.y = parentPoint.y - thisObject.position.y + } else { + returnPoint.x = checkPoint.x - thisObject.position.x + returnPoint.y = checkPoint.y - thisObject.position.y + } + + return returnPoint } function canYouMoveHere (tempDisplacement) {