From 6076c7d4b252326709578f10d670cb25dadca100 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 16 Mar 2020 08:11:48 +0100 Subject: [PATCH] Refactoring --- Panels/LayersPanel.js | 26 +++++++++---------- Panels/PlotterPanel.js | 20 +++++++------- Panels/{PanelTabButton.js => UpDownButton.js} | 4 +-- Spaces/PanelsSpace.js | 4 +-- 4 files changed, 27 insertions(+), 27 deletions(-) rename Panels/{PanelTabButton.js => UpDownButton.js} (99%) diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 3498f8765..6d37195da 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -6,7 +6,7 @@ function newLayersPanel () { layers: [], payload: undefined, isVisible: true, - panelTabButton: undefined, + upDownButton: undefined, physics: physics, draw: draw, getContainer: getContainer, @@ -43,8 +43,8 @@ function newLayersPanel () { function finalize () { thisObject.container.eventHandler.stopListening(onMouseWheelEventSuscriptionId) - thisObject.panelTabButton.finalize() - thisObject.panelTabButton = undefined + thisObject.upDownButton.finalize() + thisObject.upDownButton = undefined layersMap = undefined visibleLayers = undefined @@ -69,11 +69,11 @@ function newLayersPanel () { thisObject.container.frame.position = position loadFrame(thisObject.payload, thisObject.container.frame) - thisObject.panelTabButton = newPanelTabButton() - thisObject.panelTabButton.parentContainer = thisObject.container - thisObject.panelTabButton.container.frame.parentFrame = thisObject.container.frame - thisObject.panelTabButton.fitFunction = thisObject.fitFunction - thisObject.panelTabButton.initialize() + thisObject.upDownButton = newUpDownButton() + thisObject.upDownButton.parentContainer = thisObject.container + thisObject.upDownButton.container.frame.parentFrame = thisObject.container.frame + thisObject.upDownButton.fitFunction = thisObject.fitFunction + thisObject.upDownButton.initialize() onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) @@ -87,7 +87,7 @@ function newLayersPanel () { } function saveObjectStatePanelLocation () { - savePropertyAtNodeConfig(thisObject.payload, 'panelLocation', thisObject.panelTabButton.status) + savePropertyAtNodeConfig(thisObject.payload, 'panelLocation', thisObject.upDownButton.status) } function readObjectState () { @@ -123,7 +123,7 @@ function newLayersPanel () { saveObjectStatePanelLocation() // this overrides any invalid value at the config. return } - thisObject.panelTabButton.setStatus(storedValue) + thisObject.upDownButton.setStatus(storedValue) saveObjectStatePanelLocation() } } @@ -247,7 +247,7 @@ function newLayersPanel () { if (isInitialized === false || thisObject.visible === false || thisObject.isHidden === true) { return } let container - container = thisObject.panelTabButton.getContainer(point) + container = thisObject.upDownButton.getContainer(point) if (container !== undefined) { return container } /* First we check if thisObject point is inside thisObject space. */ @@ -301,7 +301,7 @@ function newLayersPanel () { if (isInitialized === false) { return } if (thisObject.payload.node === undefined) { return } - thisObject.panelTabButton.physics() + thisObject.upDownButton.physics() saveFrame(thisObject.payload, thisObject.container.frame) syncWithConfigPhysics() @@ -387,7 +387,7 @@ function newLayersPanel () { visibleLayers[i].draw() } drawScrollBar() - thisObject.panelTabButton.draw() + thisObject.upDownButton.draw() } function drawHeader () { diff --git a/Panels/PlotterPanel.js b/Panels/PlotterPanel.js index 24ef4f91f..783657718 100644 --- a/Panels/PlotterPanel.js +++ b/Panels/PlotterPanel.js @@ -22,7 +22,7 @@ function newPlotterPanel () { let heightFactor = 1 let currentRecord - let panelTabButton + let upDownButton let panelNode return thisObject @@ -35,8 +35,8 @@ function newPlotterPanel () { heightFactor = undefined currentRecord = undefined - panelTabButton.finalize() - panelTabButton = undefined + upDownButton.finalize() + upDownButton = undefined panelNode = undefined } @@ -50,18 +50,18 @@ function newPlotterPanel () { thisObject.container.frame.position.x = canvas.chartingSpace.viewport.visibleArea.topRight.x - thisObject.container.frame.width - thisObject.container.frame.width * Math.random() * 8 thisObject.container.frame.position.y = canvas.chartingSpace.viewport.visibleArea.bottomLeft.y - thisObject.container.frame.height - thisObject.container.frame.height * Math.random() * 1.5 - panelTabButton = newPanelTabButton() - panelTabButton.parentContainer = thisObject.container - panelTabButton.container.frame.parentFrame = thisObject.container.frame - panelTabButton.fitFunction = thisObject.fitFunction - panelTabButton.initialize() + upDownButton = newUpDownButton() + upDownButton.parentContainer = thisObject.container + upDownButton.container.frame.parentFrame = thisObject.container.frame + upDownButton.fitFunction = thisObject.fitFunction + upDownButton.initialize() } function getContainer (point) { if (thisObject.isVisible !== true) { return } let container - container = panelTabButton.getContainer(point) + container = upDownButton.getContainer(point) if (container !== undefined) { return container } if (thisObject.container.frame.isThisPointHere(point, true) === true) { @@ -87,7 +87,7 @@ function newPlotterPanel () { thisObject.container.frame.draw(false, false, true, thisObject.fitFunction) plotCurrentRecordData() - panelTabButton.draw() + upDownButton.draw() } function plotCurrentRecordData () { diff --git a/Panels/PanelTabButton.js b/Panels/UpDownButton.js similarity index 99% rename from Panels/PanelTabButton.js rename to Panels/UpDownButton.js index 38de1b23c..e68e9fdf1 100644 --- a/Panels/PanelTabButton.js +++ b/Panels/UpDownButton.js @@ -1,4 +1,4 @@ -function newPanelTabButton () { +function newUpDownButton () { let thisObject = { container: undefined, fitFunction: undefined, @@ -48,7 +48,7 @@ function newPanelTabButton () { thisObject.container.frame.width = 10 thisObject.container.frame.height = 10 - var position = { + let position = { x: thisObject.parentContainer.frame.width - 14, y: 1 } diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index 831f8fa50..45f154f31 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -165,8 +165,8 @@ function newPanelsSpace () { let verticalLine = (canvas.chartingSpace.viewport.visibleArea.topRight.x - canvas.chartingSpace.viewport.visibleArea.topLeft.x) / 2 + canvas.chartingSpace.viewport.visibleArea.topLeft.x let horizontalLine = (canvas.chartingSpace.viewport.visibleArea.bottomRight.y - canvas.chartingSpace.viewport.visibleArea.topRight.y) / 2 + canvas.chartingSpace.viewport.visibleArea.topRight.y - if (panel.panelTabButton !== undefined) { - if (panel.panelTabButton.status === 'up') { + if (panel.upDownButton !== undefined) { + if (panel.upDownButton.status === 'up') { if (centerPoint.x < verticalLine) { panel.gravitatesTowards = 'topLeft' } else {