diff --git a/Canvas.js b/Canvas.js index e9bcd1e96..5ed30c33b 100644 --- a/Canvas.js +++ b/Canvas.js @@ -235,7 +235,18 @@ function newCanvas() { let container; - /* We check first if the mouse is over a panel/ */ + /* We check if the mouse is over an element of the Top Space / */ + + container = thisObject.topSpace.getContainer(point); + + if (container !== undefined && container.isDraggeable === true) { + + containerBeingDragged = container; + containerDragStarted = true; + return; + } + + /* We check if the mouse is over a panel/ */ container = thisObject.panelsSpace.getContainer(point); @@ -246,7 +257,7 @@ function newCanvas() { return; } - /* We check first if the mouse is over a floatingObject/ */ + /* We check if the mouse is over a floatingObject/ */ floatingObjectBeingDragged = thisObject.floatingSpace.floatingLayer.isInside(event.pageX, event.pageY); @@ -280,7 +291,17 @@ function newCanvas() { let container; - /* We check first if the mouse is over a panel/ */ + /* We check if the mouse is over an element of the Top Space / */ + + container = thisObject.topSpace.getContainer(point); + + if (container !== undefined && container.isClickeable === true) { + + container.eventHandler.raiseEvent('onMouseClick', event); + return; + } + + /* We check if the mouse is over a panel/ */ container = thisObject.panelsSpace.getContainer(point); @@ -290,7 +311,7 @@ function newCanvas() { return; } - /* We check first if the mouse is over a floatingObject/ */ + /* We check if the mouse is over a floatingObject/ */ let floatingObjectBeingClicked = thisObject.floatingSpace.floatingLayer.isInside(event.pageX, event.pageY); diff --git a/Panels/TimeControlPanel.js b/Panels/TimeControlPanel.js index b00aba1cc..ea7fcf630 100644 --- a/Panels/TimeControlPanel.js +++ b/Panels/TimeControlPanel.js @@ -219,6 +219,7 @@ function newTimeControlPanel() { beginDatetime: thisObject.datetimeDisplay.currentDatetime, endDatetime: undefined, timePeriod: PLAY_STEP, + startMode: window.CURRENT_START_MODE, eventHandler: thisObject.container.eventHandler }; diff --git a/Spaces/TopSpace.js b/Spaces/TopSpace.js index 9af654f36..31fd88d01 100644 --- a/Spaces/TopSpace.js +++ b/Spaces/TopSpace.js @@ -54,17 +54,20 @@ function newTopSpace() { let container; - for (let i = 0; i < thisObject.panels.length; i++) { + container = endUser.getContainer(point); + if (container !== undefined) { return container; } - container = thisObject.panels[i].getContainer(point); + container = devTeam.getContainer(point); + if (container !== undefined) { return container; } - if (container !== undefined) { + container = currentBot.getContainer(point); + if (container !== undefined) { return container; } - /* We found an inner container which has the point. We return it. */ + container = currentProcess.getContainer(point); + if (container !== undefined) { return container; } - return container; - } - } + container = currentStartMode.getContainer(point); + if (container !== undefined) { return container; } /* The point does not belong to any inner container, so we return the current container. */ diff --git a/TopSpace/CurrentBot.js b/TopSpace/CurrentBot.js index 63c9bcfb6..3d35c8cb7 100644 --- a/TopSpace/CurrentBot.js +++ b/TopSpace/CurrentBot.js @@ -35,22 +35,19 @@ function newCurrentBot() { let container; - for (let i = 0; i < thisObject.panels.length; i++) { + /* First we check if this point is inside this object UI. */ - container = thisObject.panels[i].getContainer(point); + if (thisObject.container.frame.isThisPointHere(point, true) === true) { - if (container !== undefined) { + return this.container; - /* We found an inner container which has the point. We return it. */ + } else { - return container; - } + /* This point does not belong to this space. */ + + return undefined; } - /* The point does not belong to any inner container, so we return the current container. */ - - return thisObject.container; - } function draw() { diff --git a/TopSpace/CurrentProcess.js b/TopSpace/CurrentProcess.js index e205e8938..a58d96944 100644 --- a/TopSpace/CurrentProcess.js +++ b/TopSpace/CurrentProcess.js @@ -35,22 +35,19 @@ function newCurrentProcess() { let container; - for (let i = 0; i < thisObject.panels.length; i++) { + /* First we check if this point is inside this object UI. */ - container = thisObject.panels[i].getContainer(point); + if (thisObject.container.frame.isThisPointHere(point, true) === true) { - if (container !== undefined) { + return this.container; - /* We found an inner container which has the point. We return it. */ + } else { - return container; - } + /* This point does not belong to this space. */ + + return undefined; } - /* The point does not belong to any inner container, so we return the current container. */ - - return thisObject.container; - } function draw() { diff --git a/TopSpace/CurrentStartMode.js b/TopSpace/CurrentStartMode.js index b7c949ba8..4a376e0a8 100644 --- a/TopSpace/CurrentStartMode.js +++ b/TopSpace/CurrentStartMode.js @@ -19,6 +19,7 @@ function newCurrentStartMode() { container.frame.position.y = 0; container.isDraggeable = false; + container.isClickeable = true; return thisObject; @@ -27,7 +28,28 @@ function newCurrentStartMode() { window.CURRENT_START_MODE = window.localStorage.getItem("currentStartMode"); if (window.CURRENT_START_MODE === null) { - window.CURRENT_START_MODE = ""; + window.CURRENT_START_MODE = "Backtest"; + } + + thisObject.container.eventHandler.listenToEvent("onMouseClick", onClick); + } + + function onClick() { + + switch (window.CURRENT_START_MODE) { + + case "Backtest": { + window.CURRENT_START_MODE = "Live"; + break; + } + case "Live": { + window.CURRENT_START_MODE = "Competition"; + break; + } + case "Competition": { + window.CURRENT_START_MODE = "Backtest"; + break; + } } } @@ -35,22 +57,19 @@ function newCurrentStartMode() { let container; - for (let i = 0; i < thisObject.panels.length; i++) { + /* First we check if this point is inside this object UI. */ - container = thisObject.panels[i].getContainer(point); + if (thisObject.container.frame.isThisPointHere(point, true) === true) { - if (container !== undefined) { + return this.container; - /* We found an inner container which has the point. We return it. */ + } else { - return container; - } + /* This point does not belong to this space. */ + + return undefined; } - /* The point does not belong to any inner container, so we return the current container. */ - - return thisObject.container; - } function draw() { diff --git a/TopSpace/DevTeam.js b/TopSpace/DevTeam.js index 2d895ba71..960f45674 100644 --- a/TopSpace/DevTeam.js +++ b/TopSpace/DevTeam.js @@ -35,22 +35,19 @@ function newDevTeam() { let container; - for (let i = 0; i < thisObject.panels.length; i++) { + /* First we check if this point is inside this object UI. */ - container = thisObject.panels[i].getContainer(point); + if (thisObject.container.frame.isThisPointHere(point, true) === true) { - if (container !== undefined) { + return this.container; - /* We found an inner container which has the point. We return it. */ + } else { - return container; - } + /* This point does not belong to this space. */ + + return undefined; } - /* The point does not belong to any inner container, so we return the current container. */ - - return thisObject.container; - } function draw() { diff --git a/TopSpace/EndUser.js b/TopSpace/EndUser.js index 72747adc6..b0d11d444 100644 --- a/TopSpace/EndUser.js +++ b/TopSpace/EndUser.js @@ -35,22 +35,19 @@ function newEndUser() { let container; - for (let i = 0; i < thisObject.panels.length; i++) { + /* First we check if this point is inside this object UI. */ - container = thisObject.panels[i].getContainer(point); + if (thisObject.container.frame.isThisPointHere(point, true) === true) { - if (container !== undefined) { + return this.container; - /* We found an inner container which has the point. We return it. */ + } else { - return container; - } + /* This point does not belong to this space. */ + + return undefined; } - /* The point does not belong to any inner container, so we return the current container. */ - - return thisObject.container; - } function draw() {