Side Panel Working
This commit is contained in:
1 parent
475ff0de3a
commit
72efde7021
5 files changed
+315
-19
No files matched your search
@@ -317,6 +317,10 @@ function newCanvas () {
|
||||
return
|
||||
}
|
||||
|
||||
if (container !== undefined && container.isDraggeable === false) {
|
||||
return
|
||||
}
|
||||
|
||||
/* We check if the mouse is over an element of the Top Space / */
|
||||
|
||||
container = thisObject.topSpace.getContainer(point)
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
function newSidePanel () {
|
||||
const MODULE_NAME = 'Side Panel'
|
||||
let thisObject = {
|
||||
sidePanelTab: undefined,
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
const SIDE_PANEL_WIDTH = 450
|
||||
const SIDE_PANEL_TAB_WIDTH = 400
|
||||
|
||||
let isInitialized = false
|
||||
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.name = MODULE_NAME
|
||||
thisObject.container.initialize()
|
||||
thisObject.container.isClickeable = true
|
||||
thisObject.container.isDraggeable = false
|
||||
|
||||
resize()
|
||||
return thisObject
|
||||
|
||||
function initialize () {
|
||||
thisObject.sidePanelTab = newSidePanelTab()
|
||||
thisObject.sidePanelTab.container.connectToParent(thisObject.container, false, false)
|
||||
thisObject.sidePanelTab.initialize()
|
||||
|
||||
window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize)
|
||||
isInitialized = true
|
||||
}
|
||||
|
||||
function resize () {
|
||||
thisObject.container.frame.width = SIDE_PANEL_WIDTH
|
||||
thisObject.container.frame.height = browserCanvas.height // - TOP_SPACE_HEIGHT
|
||||
thisObject.container.frame.position.x = -SIDE_PANEL_WIDTH
|
||||
thisObject.container.frame.position.y = 0 // TOP_SPACE_HEIGHT
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
let container
|
||||
|
||||
container = thisObject.sidePanelTab.getContainer(point)
|
||||
if (container !== undefined) { return container }
|
||||
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
return thisObject.container
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
function draw () {
|
||||
if (isInitialized === false) { return }
|
||||
borders()
|
||||
thisObject.sidePanelTab.draw()
|
||||
}
|
||||
|
||||
function borders () {
|
||||
let point1
|
||||
let point2
|
||||
let point3
|
||||
let point4
|
||||
|
||||
point1 = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: thisObject.container.frame.width,
|
||||
y: 0
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: thisObject.container.frame.width,
|
||||
y: thisObject.container.frame.height
|
||||
}
|
||||
|
||||
point4 = {
|
||||
x: 0,
|
||||
y: thisObject.container.frame.height
|
||||
}
|
||||
|
||||
point1 = thisObject.container.frame.frameThisPoint(point1)
|
||||
point2 = thisObject.container.frame.frameThisPoint(point2)
|
||||
point3 = thisObject.container.frame.frameThisPoint(point3)
|
||||
point4 = thisObject.container.frame.frameThisPoint(point4)
|
||||
|
||||
browserCanvasContext.setLineDash([0, 0])
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.moveTo(point1.x, point1.y)
|
||||
browserCanvasContext.lineTo(point2.x, point2.y)
|
||||
browserCanvasContext.lineTo(point3.x, point3.y)
|
||||
browserCanvasContext.lineTo(point4.x, point4.y)
|
||||
browserCanvasContext.lineTo(point1.x, point1.y)
|
||||
browserCanvasContext.closePath()
|
||||
|
||||
let opacity = 1
|
||||
|
||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.LIGHT + ', ' + opacity + ''
|
||||
browserCanvasContext.fill()
|
||||
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GREY + ', ' + opacity + ''
|
||||
browserCanvasContext.lineWidth = 0.3
|
||||
browserCanvasContext.stroke()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
function newSidePanelTab () {
|
||||
const MODULE_NAME = 'Side Panel Tab'
|
||||
let thisObject = {
|
||||
pointerDirection: 'left',
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
const TAB_WIDTH = 20
|
||||
const TAB_HEIGHT = 60
|
||||
|
||||
let isInitialized = false
|
||||
let animation = 'none'
|
||||
let ORIGINAL_PARENT_POSITON
|
||||
let xOffset = 0
|
||||
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.name = MODULE_NAME
|
||||
thisObject.container.initialize()
|
||||
thisObject.container.isClickeable = true
|
||||
thisObject.container.isDraggeable = false
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize () {
|
||||
thisObject.container.frame.width = TAB_WIDTH
|
||||
thisObject.container.frame.height = TAB_HEIGHT
|
||||
thisObject.container.frame.position.x = 0 + thisObject.container.parentContainer.frame.width
|
||||
thisObject.container.frame.position.y = 20
|
||||
|
||||
ORIGINAL_PARENT_POSITON = thisObject.container.parentContainer.frame.position.x
|
||||
|
||||
thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick)
|
||||
isInitialized = true
|
||||
}
|
||||
|
||||
function onMouseClick (event) {
|
||||
if (thisObject.pointerDirection === 'left') {
|
||||
animation = 'opening'
|
||||
} else {
|
||||
animation = 'closing'
|
||||
}
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
let container
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
return thisObject.container
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
function draw () {
|
||||
if (isInitialized === false) { return }
|
||||
animate()
|
||||
borders()
|
||||
arrow()
|
||||
}
|
||||
|
||||
function animate () {
|
||||
const STEP = 50
|
||||
|
||||
if (animation === 'opening') {
|
||||
xOffset = xOffset + STEP
|
||||
thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + xOffset
|
||||
if (xOffset > thisObject.container.parentContainer.frame.width) {
|
||||
animation = 'none'
|
||||
xOffset = thisObject.container.parentContainer.frame.width
|
||||
thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + xOffset
|
||||
thisObject.pointerDirection = 'right'
|
||||
}
|
||||
}
|
||||
|
||||
if (animation === 'closing') {
|
||||
xOffset = xOffset - STEP
|
||||
thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + xOffset
|
||||
if (xOffset < 0) {
|
||||
animation = 'none'
|
||||
xOffset = 0
|
||||
thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON
|
||||
thisObject.pointerDirection = 'left'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function arrow () {
|
||||
let point1
|
||||
let point2
|
||||
let point3
|
||||
|
||||
if (thisObject.pointerDirection === 'left') {
|
||||
point1 = {
|
||||
x: TAB_WIDTH * 1 / 5,
|
||||
y: TAB_HEIGHT * 12 / 30
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: TAB_WIDTH * 3 / 5,
|
||||
y: TAB_HEIGHT * 15 / 30
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: TAB_WIDTH * 1 / 5,
|
||||
y: TAB_HEIGHT * 18 / 30
|
||||
}
|
||||
} else {
|
||||
point1 = {
|
||||
x: TAB_WIDTH * 3 / 5,
|
||||
y: TAB_HEIGHT * 12 / 30
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: TAB_WIDTH * 1 / 5,
|
||||
y: TAB_HEIGHT * 15 / 30
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: TAB_WIDTH * 3 / 5,
|
||||
y: TAB_HEIGHT * 18 / 30
|
||||
}
|
||||
}
|
||||
|
||||
point1 = thisObject.container.frame.frameThisPoint(point1)
|
||||
point2 = thisObject.container.frame.frameThisPoint(point2)
|
||||
point3 = thisObject.container.frame.frameThisPoint(point3)
|
||||
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.moveTo(point1.x, point1.y)
|
||||
browserCanvasContext.lineTo(point2.x, point2.y)
|
||||
browserCanvasContext.lineTo(point3.x, point3.y)
|
||||
browserCanvasContext.closePath()
|
||||
|
||||
let opacity = 1
|
||||
|
||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.GREY + ', ' + opacity + ''
|
||||
browserCanvasContext.fill()
|
||||
}
|
||||
|
||||
function borders () {
|
||||
let point1
|
||||
let point2
|
||||
let point3
|
||||
let point4
|
||||
|
||||
point1 = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: TAB_WIDTH,
|
||||
y: 0
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: TAB_WIDTH,
|
||||
y: TAB_HEIGHT
|
||||
}
|
||||
|
||||
point4 = {
|
||||
x: 0,
|
||||
y: TAB_HEIGHT
|
||||
}
|
||||
|
||||
point1 = thisObject.container.frame.frameThisPoint(point1)
|
||||
point2 = thisObject.container.frame.frameThisPoint(point2)
|
||||
point3 = thisObject.container.frame.frameThisPoint(point3)
|
||||
point4 = thisObject.container.frame.frameThisPoint(point4)
|
||||
|
||||
browserCanvasContext.setLineDash([0, 0])
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.moveTo(point1.x, point1.y)
|
||||
browserCanvasContext.lineTo(point2.x, point2.y)
|
||||
browserCanvasContext.lineTo(point3.x, point3.y)
|
||||
browserCanvasContext.lineTo(point4.x, point4.y)
|
||||
browserCanvasContext.lineTo(point1.x, point1.y)
|
||||
browserCanvasContext.closePath()
|
||||
|
||||
let opacity = 1
|
||||
|
||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + opacity + ''
|
||||
browserCanvasContext.fill()
|
||||
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GREY + ', ' + opacity + ''
|
||||
browserCanvasContext.lineWidth = 0.3
|
||||
browserCanvasContext.stroke()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ const DEFAULT_MARKET = {
|
||||
|
||||
UI_COLOR = {
|
||||
DARK: "48, 48, 54",
|
||||
GREY: "150, 150, 150",
|
||||
LIGHT: "234, 226, 222",
|
||||
WHITE: "255, 255, 255",
|
||||
GOLDEN_ORANGE: "240, 162, 2",
|
||||
|
||||
+9
-19
@@ -1,9 +1,11 @@
|
||||
|
||||
function newStrategySpace () {
|
||||
const MODULE_NAME = 'Strategy Space'
|
||||
let thisObject = {
|
||||
sidePanel: undefined,
|
||||
strategyCollection: undefined,
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
strategyCollection: undefined,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize
|
||||
}
|
||||
@@ -12,8 +14,6 @@ function newStrategySpace () {
|
||||
container.initialize()
|
||||
thisObject.container = container
|
||||
|
||||
resize()
|
||||
|
||||
container.isDraggeable = false
|
||||
|
||||
return thisObject
|
||||
@@ -22,15 +22,8 @@ function newStrategySpace () {
|
||||
thisObject.strategyCollection = newStrategyCollection()
|
||||
await thisObject.strategyCollection.initialize()
|
||||
|
||||
window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize)
|
||||
}
|
||||
|
||||
function resize () {
|
||||
thisObject.container.frame.width = viewPort.visibleArea.topRight.x - viewPort.visibleArea.topLeft.x
|
||||
thisObject.container.frame.height = viewPort.visibleArea.topLeft.y - viewPort.visibleArea.bottomLeft.y
|
||||
|
||||
container.frame.position.x = viewPort.visibleArea.topLeft.x
|
||||
container.frame.position.y = viewPort.visibleArea.topLeft.y
|
||||
thisObject.sidePanel = newSidePanel()
|
||||
thisObject.sidePanel.initialize()
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
@@ -39,16 +32,13 @@ function newStrategySpace () {
|
||||
container = thisObject.strategyCollection.getContainer(point)
|
||||
if (container !== undefined) { return container }
|
||||
|
||||
/* The point does not belong to any inner container, so we return the current container. */
|
||||
container = thisObject.sidePanel.getContainer(point)
|
||||
if (container !== undefined) { return container }
|
||||
|
||||
return thisObject.container
|
||||
return
|
||||
}
|
||||
|
||||
function draw () {
|
||||
drawBackground()
|
||||
}
|
||||
|
||||
function drawBackground () {
|
||||
|
||||
thisObject.sidePanel.draw()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user