From 599e48062ff71549e92557c706848565836d1ada Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 14 May 2020 15:56:30 +0200 Subject: [PATCH] Mouse over working --- Canvas.js | 2 +- SideSpace/ListItem.js | 29 +++++++++++++++++++++++++++-- SideSpace/ListView.js | 15 --------------- Spaces/SideSpace.js | 6 +++--- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/Canvas.js b/Canvas.js index 8a2cfaa4f..db6104f40 100644 --- a/Canvas.js +++ b/Canvas.js @@ -854,7 +854,7 @@ function newCanvas () { /* We check if the mouse is over an element of the Designe Space / */ if (thisObject.sideSpace !== undefined) { - container = thisObject.sideSpace.getContainer(point) + container = thisObject.sideSpace.getContainer(point, GET_CONTAINER_PURPOSE.MOUSE_OVER) if (container !== undefined && container.detectMouseOver === true) { containerFound() diff --git a/SideSpace/ListItem.js b/SideSpace/ListItem.js index 98af0384e..d1aefc3dc 100644 --- a/SideSpace/ListItem.js +++ b/SideSpace/ListItem.js @@ -25,9 +25,16 @@ function newListItem () { let name let type + let onMouseOverEventSubscriptionId + let onMouseNotOverEventSubscriptionId + + let isMouseOver = false return thisObject function finalize () { + thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId) + thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId) + thisObject.container.finalize() thisObject.container = undefined thisObject.fitFunction = undefined @@ -36,6 +43,9 @@ function newListItem () { function initialize (pName, pType) { name = pName type = pType + + onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) + onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) } function getContainer (point) { @@ -44,6 +54,14 @@ function newListItem () { } } + function onMouseOver (event) { + isMouseOver = true + } + + function onMouseNotOver () { + isMouseOver = false + } + function onMouseClick (event) { } @@ -55,6 +73,7 @@ function newListItem () { function draw () { let icon = canvas.designSpace.iconByUiObjectType.get(type) let backgroundColor = UI_COLOR.BLACK + let labelColor const RED_LINE_HIGHT = 4 const OPACITY = 1 @@ -69,10 +88,16 @@ function newListItem () { opacity: OPACITY } + if (isMouseOver === false) { + labelColor = UI_COLOR.WHITE + } else { + labelColor = UI_COLOR.TITANIUM_YELLOW + } + roundedCornersBackground(params) - drawLabel(name, 1 / 2, 3.0 / 10, -5, 0, 15, thisObject.container) - drawLabel(type, 1 / 2, 7.2 / 10, -5, 0, 15, thisObject.container) + drawLabel(name, 1 / 2, 3.0 / 10, -5, 0, 15, thisObject.container, labelColor) + drawLabel(type, 1 / 2, 7.2 / 10, -5, 0, 15, thisObject.container, labelColor) drawIcon(icon, 1 / 2, 1 / 2, 0, 0, 80, thisObject.container) } } diff --git a/SideSpace/ListView.js b/SideSpace/ListView.js index aed070f7c..e066f7b73 100644 --- a/SideSpace/ListView.js +++ b/SideSpace/ListView.js @@ -41,16 +41,11 @@ function newListView () { let itemSeparation let onMouseWheelEventSuscriptionId - let onMouseOverEventSubscriptionId - let onMouseNotOverEventSubscriptionId - let isMouseOver return thisObject function finalize () { thisObject.container.eventHandler.stopListening(onMouseWheelEventSuscriptionId) - thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId) - thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId) listItemsMap = undefined visibleListItems = undefined @@ -75,8 +70,6 @@ function newListView () { thisObject.container.frame.position = position onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) - onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) - onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) resize() turnOn() @@ -125,14 +118,6 @@ function newListView () { thisObject.isVisible = false } - function onMouseOver (event) { - isMouseOver = true - } - - function onMouseNotOver () { - isMouseOver = false - } - function onMouseWheel (event) { delta = event.wheelDelta if (delta > 0) { diff --git a/Spaces/SideSpace.js b/Spaces/SideSpace.js index 99e80feca..a950c9b7c 100644 --- a/Spaces/SideSpace.js +++ b/Spaces/SideSpace.js @@ -69,13 +69,13 @@ function newSideSpace () { } } - function getContainer (point) { + function getContainer (point, purpose) { let container - container = thisObject.sidePanelTab.getContainer(point) + container = thisObject.sidePanelTab.getContainer(point, purpose) if (container !== undefined) { return container } - container = listView.getContainer(point) + container = listView.getContainer(point, purpose) if (container !== undefined) { return container } if (thisObject.container.frame.isThisPointHere(point, true) === true) {