From c33cca3166612493106180ca720151881ca94cb8 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 4 Feb 2020 11:32:15 +0100 Subject: [PATCH] Multiple isTensed Values --- .../FunctionLibraries/NodeCloning.js | 2 +- .../FunctionLibraries/ProtocolNode.js | 2 +- FloatingSpace/CircularMenu.js | 1 + FloatingSpace/CircularMenuItem.js | 11 ++++++-- FloatingSpace/FloatingObject.js | 27 +++++++++++++------ FloatingSpace/UiObject.js | 2 +- FloatingSpace/UiObjectConstructor.js | 12 +++------ Globals.js | 8 ++++++ 8 files changed, 44 insertions(+), 21 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js b/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js index ab81e42a6..a0cb778ae 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js @@ -145,7 +145,7 @@ function newNodeCloning () { isPinned: node.payload.floatingObject.isPinned, isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually), isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually), - isTensed: (node.payload.floatingObject.isTensed && node.payload.floatingObject.tensedManually) + isTensed: (node.payload.floatingObject.isTensed) }, uiObject: { isRunning: node.payload.uiObject.isRunning, diff --git a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js index dc5ef92de..9dc8afba4 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -148,7 +148,7 @@ function newProtocolNode () { isPinned: node.payload.floatingObject.isPinned, isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually), isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually), - isTensed: (node.payload.floatingObject.isTensed && node.payload.floatingObject.tensedManually) + isTensed: (node.payload.floatingObject.isTensed) }, uiObject: { isRunning: node.payload.uiObject.isRunning, diff --git a/FloatingSpace/CircularMenu.js b/FloatingSpace/CircularMenu.js index ab9b5a958..0e81863c4 100644 --- a/FloatingSpace/CircularMenu.js +++ b/FloatingSpace/CircularMenu.js @@ -83,6 +83,7 @@ function newCircularMenu () { menuItem.disableIfPropertyIsDefined = menuItemInitialValue.disableIfPropertyIsDefined menuItem.propertyToCheckFor = menuItemInitialValue.propertyToCheckFor menuItem.ring = menuItemInitialValue.ring + menuItem.icons = menuItemInitialValue.icons if (menuItem.label === undefined) { menuItem.type = 'Icon Only' diff --git a/FloatingSpace/CircularMenuItem.js b/FloatingSpace/CircularMenuItem.js index f377c8c45..d088385e6 100644 --- a/FloatingSpace/CircularMenuItem.js +++ b/FloatingSpace/CircularMenuItem.js @@ -9,6 +9,7 @@ function newCircularMenuItem () { confirmationLabel: undefined, iconOn: undefined, iconOff: undefined, + icons: undefined, currentIcon: undefined, disableIfPropertyIsDefined: undefined, propertyToCheckFor: undefined, @@ -92,6 +93,7 @@ function newCircularMenuItem () { thisObject.container = undefined thisObject.iconOn = undefined thisObject.iconOff = undefined + thisObject.icons = undefined thisObject.currentIcon = undefined thisObject.payload = undefined thisObject.actionFunction = undefined @@ -208,8 +210,13 @@ function newCircularMenuItem () { thisObject.iconOn = canvas.designerSpace.iconByUiObjectType.get(thisObject.relatedUiObject) thisObject.iconOff = canvas.designerSpace.iconByUiObjectType.get(thisObject.relatedUiObject) } else { - thisObject.iconOn = canvas.designerSpace.iconCollection.get(thisObject.iconPathOn) - thisObject.iconOff = canvas.designerSpace.iconCollection.get(thisObject.iconPathOff) + if (thisObject.iconPathOn !== undefined && thisObject.iconPathOff !== undefined) { + thisObject.iconOn = canvas.designerSpace.iconCollection.get(thisObject.iconPathOn) + thisObject.iconOff = canvas.designerSpace.iconCollection.get(thisObject.iconPathOff) + } else { + thisObject.iconOn = canvas.designerSpace.iconCollection.get(thisObject.icons[thisObject.actionStatus()]) + thisObject.iconOff = canvas.designerSpace.iconCollection.get(thisObject.icons[thisObject.actionStatus()]) + } } } diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index 95da8d8f8..885ae9ca7 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -22,7 +22,7 @@ function newFloatingObject () { targetRadius: 0, // This is the target radius of the floating object with zoom applied. It should be animated until reaching this value. isPinned: false, isFrozen: false, - isTensed: false, + isTensed: TENSION_LEVEL.NO_TENSION, isCollapsed: false, isParentCollapsed: false, frozenManually: false, @@ -165,13 +165,24 @@ function newFloatingObject () { } function tensionToggle () { - if (thisObject.isTensed !== true) { - thisObject.isTensed = true - thisObject.tensedManually = true - } else { - thisObject.isTensed = false - thisObject.tensedManually = false + switch (thisObject.isTensed) { + case TENSION_LEVEL.NO_TENSION: + thisObject.isTensed = TENSION_LEVEL.LEVEL_360 + break + case TENSION_LEVEL.LEVEL_360: + thisObject.isTensed = TENSION_LEVEL.LEVEL_180 + break + case TENSION_LEVEL.LEVEL_180: + thisObject.isTensed = TENSION_LEVEL.LEVEL_90 + break + case TENSION_LEVEL.LEVEL_90: + thisObject.isTensed = TENSION_LEVEL.LEVEL_45 + break + case TENSION_LEVEL.LEVEL_45: + thisObject.isTensed = TENSION_LEVEL.NO_TENSION + break } + return thisObject.isTensed } @@ -212,7 +223,7 @@ function newFloatingObject () { function tensionPhysics () { /* Tension Effect */ - if (thisObject.isTensed === true) { + if (thisObject.isTensed !== TENSION_LEVEL.NO_TENSION) { let parent = thisObject.payload.chainParent if (parent === undefined) { return } if (parent.payload === undefined) { return } diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 1950f6b5e..5a20e5464 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -864,7 +864,7 @@ function newUiObject () { /* Target Line */ let LINE_STYLE = UI_COLOR.TITANIUM_YELLOW - if (thisObject.payload.floatingObject.isTensed === true) { + if (thisObject.payload.floatingObject.isTensed !== TENSION_LEVEL.NO_TENSION) { LINE_STYLE = UI_COLOR.GOLDEN_ORANGE } if (thisObject.payload.floatingObject.isFrozen === true) { diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index 110015794..1eed3a137 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -57,16 +57,12 @@ function newUiObjectConstructor () { if (payload.node.savedPayload.floatingObject.isCollapsed === true) { floatingObject.collapseToggle() } - if (payload.node.savedPayload.floatingObject.isTensed === true) { - floatingObject.tensionToggle() - } + floatingObject.isTensed = payload.node.savedPayload.floatingObject.isTensed } /* For brand new objects being created directly by the user, we will make them inherit some properties from their parents. */ if (userAddingNew === true) { - if (payload.parentNode.payload.floatingObject.isTensed === true) { - floatingObject.tensionToggle() - } + floatingObject.isTensed = payload.parentNode.payload.floatingObject.isTensed } let uiObject = newUiObject() @@ -146,8 +142,7 @@ function newUiObjectConstructor () { currentStatus: true, label: undefined, visible: true, - iconPathOn: 'menu-tensor-fixed-angles', - iconPathOff: 'menu-tensor-free-angles', + icons: ['menu-tensor-free-angles', 'menu-tensor-fixed-angles', 'menu-share', 'compass', 'broken-link'], rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -315,6 +310,7 @@ function newUiObjectConstructor () { switch (payload.node.type) { case 'Workspace': { level_0() + floatingObject.isTensed = TENSION_LEVEL.LEVEL_360 break } diff --git a/Globals.js b/Globals.js index 60d77a30e..92d054bd2 100644 --- a/Globals.js +++ b/Globals.js @@ -51,6 +51,14 @@ const GET_CONTAINER_PURPOSE = { DRAGGING: 4 } +const TENSION_LEVEL = { + NO_TENSION: 0, + LEVEL_360: 1, + LEVEL_180: 2, + LEVEL_90: 3, + LEVEL_45: 4 +} + /* User Interface Panels */ UI_PANEL = {