diff --git a/DesignSpace/Workspace/FunctionLibraries/NodeDeleter.js b/DesignSpace/Workspace/FunctionLibraries/NodeDeleter.js index 6287b01b8..0e498e572 100644 --- a/DesignSpace/Workspace/FunctionLibraries/NodeDeleter.js +++ b/DesignSpace/Workspace/FunctionLibraries/NodeDeleter.js @@ -24,6 +24,11 @@ function newNodeDeleter () { } function deleteUIObject (node, rootNodes) { + /* First we restore the reference parent to its default state */ + if (node.payload.referenceParent.payload !== undefined && node.payload.referenceParent.payload.uiObject !== undefined) { + node.payload.referenceParent.payload.uiObject.isShowing = false + } + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) if (nodeDefinition !== undefined) { /* Remove all of its own children nodes. */ diff --git a/DesignSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js b/DesignSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js index 68d2cf69f..643dd37ed 100644 --- a/DesignSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js +++ b/DesignSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js @@ -19,6 +19,10 @@ function newReferenceAttachDetach () { } function completeDetachment (node) { + if (node.payload.referenceParent.payload !== undefined && node.payload.referenceParent.payload.uiObject !== undefined) { + node.payload.referenceParent.payload.uiObject.isShowing = false + } + node.payload.referenceParent = undefined if (node.savedPayload !== undefined) { node.savedPayload.referenceParent = undefined diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index c9c08020b..5551c47a9 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -560,20 +560,32 @@ function newFloatingObject () { } function drawBackground () { - if (canvas.floatingSpace.isItFar(thisObject.payload)) { return } - if ((thisObject.isCollapsed === true && thisObject.collapsedManually === false) || thisObject.isParentCollapsed === true) { return } + if (canvas.floatingSpace.isItFar(thisObject.payload) && thisObject.payload.uiObject.isShowing === false) { return } + if ((thisObject.isCollapsed === true && thisObject.collapsedManually === false) || thisObject.isParentCollapsed === true) { + if (thisObject.payload.uiObject.isShowing !== true) { + return + } + } thisObject.payload.uiObject.drawBackground() } function drawMiddleground () { - if (canvas.floatingSpace.isItFar(thisObject.payload)) { return } - if ((thisObject.isCollapsed === true && thisObject.collapsedManually === false) || thisObject.isParentCollapsed === true) { return } + if (canvas.floatingSpace.isItFar(thisObject.payload) && thisObject.payload.uiObject.isShowing === false) { return } + if ((thisObject.isCollapsed === true && thisObject.collapsedManually === false) || thisObject.isParentCollapsed === true) { + if (thisObject.payload.uiObject.isShowing !== true) { + return + } + } thisObject.payload.uiObject.drawMiddleground() } function drawForeground () { - if (canvas.floatingSpace.isItFar(thisObject.payload)) { return } - if ((thisObject.isCollapsed === true && thisObject.collapsedManually === false) || thisObject.isParentCollapsed === true) { return } + if (canvas.floatingSpace.isItFar(thisObject.payload) && thisObject.payload.uiObject.isShowing === false) { return } + if ((thisObject.isCollapsed === true && thisObject.collapsedManually === false) || thisObject.isParentCollapsed === true) { + if (thisObject.payload.uiObject.isShowing !== true) { + return + } + } thisObject.payload.uiObject.drawForeground() } diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index ba8c9abdb..9958af61e 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -23,6 +23,7 @@ function newUiObject () { isExecuting: undefined, isRunning: undefined, shortcutKey: undefined, + isShowing: undefined, run: run, stop: stop, heartBeat: heartBeat, @@ -186,6 +187,7 @@ function newUiObject () { thisObject.uiObjectTitle = newUiObjectTitle() thisObject.uiObjectTitle.isVisibleFunction = thisObject.isVisibleFunction thisObject.uiObjectTitle.container.connectToParent(thisObject.container, false, false, true, true, false, false, true, true) + thisObject.uiObjectTitle.fitFunction = thisObject.fitFunction thisObject.uiObjectTitle.initialize(thisObject.payload) /* Load UI Object Image */ @@ -364,8 +366,10 @@ function newUiObject () { let totalRunning = 0 for (let j = 0; j < children.length; j++) { let child = children[j] - if (child.payload.uiObject.isRunning === true) { - totalRunning++ + if (child.payload !== undefined) { + if (child.payload.uiObject.isRunning === true) { + totalRunning++ + } } } if (totalRunning > 0) { @@ -870,6 +874,10 @@ function newUiObject () { function onFocus () { thisObject.isOnFocus = true + + if (thisObject.payload !== undefined && thisObject.isOnFocus === true && thisObject.payload.referenceParent !== undefined) { + thisObject.payload.referenceParent.payload.uiObject.isShowing = true + } } function onNotFocus () { @@ -886,6 +894,10 @@ function newUiObject () { if (thisObject.formulaEditor !== undefined) { thisObject.formulaEditor.deactivate() } + + if (thisObject.payload !== undefined && thisObject.isOnFocus === false && thisObject.payload.referenceParent !== undefined) { + thisObject.payload.referenceParent.payload.uiObject.isShowing = false + } } function onDisplace (event) { @@ -1132,6 +1144,10 @@ function newUiObject () { targetPoint = canvas.floatingSpace.container.frame.frameThisPoint(targetPoint) position = thisObject.container.frame.frameThisPoint(position) + if (thisObject.isOnFocus === true) { + targetPoint = thisObject.fitFunction(targetPoint) + } + if (canvas.floatingSpace.inMapMode === true) { position = canvas.floatingSpace.transformPointToMap(position) targetPoint = canvas.floatingSpace.transformPointToMap(targetPoint) @@ -1268,6 +1284,9 @@ function newUiObject () { function drawValue () { if (hasValue === false) { return } if (canvas.floatingSpace.inMapMode === true) { return } + if (thisObject.payload === undefined) { return } + if ((thisObject.payload.floatingObject.isCollapsed === true && thisObject.payload.floatingObject.collapsedManually === false) || thisObject.payload.floatingObject.isParentCollapsed === true) { return } + // if (currentValue === undefined || currentValue === '') { return } /* Text Follows */ @@ -1322,6 +1341,8 @@ function newUiObject () { function drawPercentage () { if (hasPercentage === false) { return } if (canvas.floatingSpace.inMapMode === true) { return } + if (thisObject.payload === undefined) { return } + if ((thisObject.payload.floatingObject.isCollapsed === true && thisObject.payload.floatingObject.collapsedManually === false) || thisObject.payload.floatingObject.isParentCollapsed === true) { return } let position = { x: 0, @@ -1475,6 +1496,10 @@ function newUiObject () { position = thisObject.container.frame.frameThisPoint(position) + if (thisObject.isShowing === true) { + position = thisObject.fitFunction(position) + } + if (canvas.floatingSpace.inMapMode === true) { position = canvas.floatingSpace.transformPointToMap(position) } @@ -1704,6 +1729,11 @@ function newUiObject () { } } } + + if (thisObject.isShowing === true) { + totalImageSize = 50 + } + browserCanvasContext.drawImage( icon, position.x - totalImageSize / 2, position.y - totalImageSize / 2, diff --git a/FloatingSpace/UiObjectTitle.js b/FloatingSpace/UiObjectTitle.js index cc3dd557a..e96b23eac 100644 --- a/FloatingSpace/UiObjectTitle.js +++ b/FloatingSpace/UiObjectTitle.js @@ -7,6 +7,7 @@ function newUiObjectTitle () { logger.fileName = MODULE_NAME let thisObject = { + fitFunction: undefined, isVisibleFunction: undefined, allwaysVisible: undefined, editMode: undefined, @@ -43,6 +44,7 @@ function newUiObjectTitle () { thisObject.container = undefined thisObject.payload = undefined thisObject.isVisibleFunction = undefined + thisObject.fitFunction = undefined } function initialize (payload) {