From b5819e7a146d5644c07740feb667ab04891d8e51 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 11 Mar 2021 17:13:56 +0100 Subject: [PATCH] detachUsingMouse implemented at Space Settings so that users don't detach by mistake nodes --- Projects/Superalgos/Schemas/AppSchema.json | 2 +- Projects/Superalgos/Schemas/Docs-Nodes/space-settings.json | 4 ++++ Projects/Superalgos/UI/Spaces/Floating-Space/FloatingSpace.js | 4 ++++ Projects/Superalgos/UI/Spaces/Floating-Space/UiObject.js | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Projects/Superalgos/Schemas/AppSchema.json b/Projects/Superalgos/Schemas/AppSchema.json index dfc67b42c..d329c4b5c 100644 --- a/Projects/Superalgos/Schemas/AppSchema.json +++ b/Projects/Superalgos/Schemas/AppSchema.json @@ -15936,7 +15936,7 @@ "config": true }, "initialValues": { - "config": "{\"node\":{\"distancePercentage\":60,\"radiusPercentage\":85,\"massPercentage\":100,\"animationSteps\":2,\"menuItem\":{\"widthPercentage\":100,\"heightPercentage\":60,\"radiusPercentage\":90}},\"physics\":false}" + "config": "{\"node\":{\"distancePercentage\":60,\"radiusPercentage\":85,\"massPercentage\":100,\"animationSteps\":2,\"menuItem\":{\"widthPercentage\":100,\"heightPercentage\":60,\"radiusPercentage\":90}},\"physics\":false,\"detachUsingMouse\":false }" }, "menuItems": [ { diff --git a/Projects/Superalgos/Schemas/Docs-Nodes/space-settings.json b/Projects/Superalgos/Schemas/Docs-Nodes/space-settings.json index 163254323..704cea2c2 100644 --- a/Projects/Superalgos/Schemas/Docs-Nodes/space-settings.json +++ b/Projects/Superalgos/Schemas/Docs-Nodes/space-settings.json @@ -55,6 +55,10 @@ { "style": "List", "text": "physics determines wether the environment is static (false) or dynamic (true). When physics is set to true, nodes in the design space are affected by th gravitational pull and repulsion of other nodes." + }, + { + "style": "List", + "text": "detachUsingMouse defines if you can detach nodes from it's parent or reference parents only using the mouse (when true) or if you can not use the mouse for that and can only do it using the detach buttons on the icon's menu (when false)." } ] } \ No newline at end of file diff --git a/Projects/Superalgos/UI/Spaces/Floating-Space/FloatingSpace.js b/Projects/Superalgos/UI/Spaces/Floating-Space/FloatingSpace.js index ba8292de5..4131368d7 100644 --- a/Projects/Superalgos/UI/Spaces/Floating-Space/FloatingSpace.js +++ b/Projects/Superalgos/UI/Spaces/Floating-Space/FloatingSpace.js @@ -100,6 +100,7 @@ function newSuperalgosFloatingSpace() { } }, physics: true, + detachUsingMouse: false } return thisObject @@ -536,6 +537,9 @@ function newSuperalgosFloatingSpace() { if (configSettings.physics !== undefined) { thisObject.settings.physics = configSettings.physics } + if (configSettings.detachUsingMouse !== undefined) { + thisObject.settings.detachUsingMouse = configSettings.detachUsingMouse + } } function positionContraintsPhysics() { diff --git a/Projects/Superalgos/UI/Spaces/Floating-Space/UiObject.js b/Projects/Superalgos/UI/Spaces/Floating-Space/UiObject.js index 7d5910a89..80380a401 100644 --- a/Projects/Superalgos/UI/Spaces/Floating-Space/UiObject.js +++ b/Projects/Superalgos/UI/Spaces/Floating-Space/UiObject.js @@ -560,6 +560,7 @@ function newUiObject() { function chainDetachingPhysics() { if (isDragging !== true) { return } if (rightDragging === false) { return } + if (UI.projects.superalgos.spaces.floatingSpace.settings.detachUsingMouse !== true) {return} let distanceToChainParent = Math.sqrt(Math.pow(thisObject.payload.position.x - thisObject.payload.targetPosition.x, 2) + Math.pow(thisObject.payload.position.y - thisObject.payload.targetPosition.y, 2)) let ratio = distanceToChainParent / previousDistanceToChainParent @@ -665,6 +666,7 @@ function newUiObject() { if (thisObject.payload === undefined) { return } if (thisObject.payload.floatingObject.isFrozen === true) { return } if (rightDragging === false) { return } + if (UI.projects.superalgos.spaces.floatingSpace.settings.detachUsingMouse !== true) {return} if (thisObject.payload.referenceParent === undefined) { return }