From 64e154d165a36a148c5bdef2e9682421cd65644f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 13 Jul 2019 14:18:56 +0200 Subject: [PATCH] Collapsing implemented at Trading System only --- FloatingSpace/FloatingObject.js | 29 ++++++++++++++++++++++++ FloatingSpace/StrategyPart.js | 7 +++++- FloatingSpace/StrategyPartConstructor.js | 16 ++++++++++++- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index cca996732..48a35269b 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -23,14 +23,18 @@ function newFloatingObject () { isPinned: false, isFrozen: false, isTensed: false, + isCollapsed: false, frozenManually: false, + collapsedManually: false, getPinStatus: getPinStatus, getFreezeStatus: getFreezeStatus, + getCollapseStatus: getCollapseStatus, getTensionStatus: getTensionStatus, nearbyFloatingObjects: [], setPosition: setPosition, pinToggle: pinToggle, freezeToggle: freezeToggle, + collapseToggle: collapseToggle, tensionToggle: tensionToggle, physics: physics, initializeMass: initializeMass, @@ -128,6 +132,10 @@ function newFloatingObject () { return thisObject.isFrozen } + function getCollapseStatus () { + return thisObject.isCollapsed + } + function getTensionStatus () { return thisObject.isTensed } @@ -143,6 +151,17 @@ function newFloatingObject () { return thisObject.isFrozen } + function collapseToggle () { + if (thisObject.isCollapsed !== true) { + thisObject.isCollapsed = true + thisObject.collapsedManually = true + } else { + thisObject.isCollapsed = false + thisObject.collapsedManually = false + } + return thisObject.isCollapsed + } + function tensionToggle () { if (thisObject.isTensed !== true) { thisObject.isTensed = true @@ -158,6 +177,7 @@ function newFloatingObject () { thisObjectPhysics() thisObject.payload.uiObject.physics() frozenPhysics() + collapsePhysics() tensionPhysics() } @@ -170,6 +190,15 @@ function newFloatingObject () { } } + function collapsePhysics () { + if (thisObject.collapsedManually === false) { + let parent = thisObject.payload.chainParent + if (parent !== undefined) { + thisObject.isCollapsed = parent.payload.floatingObject.isCollapsed + } + } + } + function tensionPhysics () { /* Tension Effect */ if (thisObject.isTensed === true) { diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/StrategyPart.js index 5b42a748b..304464f3d 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/StrategyPart.js @@ -137,6 +137,8 @@ function newStrategyPart () { } function getContainer (point) { + if (thisObject.payload.floatingObject.isCollapsed === true && thisObject.payload.floatingObject.collapsedManually === false) { return } + let container if (isDragging === false && thisObject.isOnFocus === true) { @@ -379,7 +381,7 @@ function newStrategyPart () { function detachingPhysics () { if (isDragging !== true) { return } - if (thisObject.isFrozen === true) { return } + if (thisObject.payload.floatingObject.isFrozen === true) { return } if (rightDragging === false) { 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)) @@ -520,6 +522,7 @@ function newStrategyPart () { } function drawBackground () { + if (thisObject.payload.floatingObject.isCollapsed === true && thisObject.payload.floatingObject.collapsedManually === false) { return } if (thisObject.isOnFocus === false) { drawConnectingLine() @@ -530,6 +533,7 @@ function newStrategyPart () { } function drawMiddleground () { + if (thisObject.payload.floatingObject.isCollapsed === true && thisObject.payload.floatingObject.collapsedManually === false) { return } if (thisObject.isOnFocus === false) { drawValue() drawText() @@ -538,6 +542,7 @@ function newStrategyPart () { } function drawForeground () { + if (thisObject.payload.floatingObject.isCollapsed === true && thisObject.payload.floatingObject.collapsedManually === false) { return } if (thisObject.isOnFocus === false) { drawBodyAndPicture() if (isDragging === false) { diff --git a/FloatingSpace/StrategyPartConstructor.js b/FloatingSpace/StrategyPartConstructor.js index a998a8b1c..c255a6166 100644 --- a/FloatingSpace/StrategyPartConstructor.js +++ b/FloatingSpace/StrategyPartConstructor.js @@ -145,7 +145,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 180 + angle: -165 }, { action: 'Freeze / Unfreeze', @@ -159,6 +159,20 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, + angle: 165 + }, + { + action: 'Collapse / Uncollapse', + actionFunction: floatingObject.collapseToggle, + actionStatus: floatingObject.getCollapeseStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'tap', + iconPathOff: 'layout', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, angle: 135 }, {