From 871679820681402d32c309fec8dba4ae160e7372 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 10 Feb 2020 11:37:22 +0100 Subject: [PATCH] Header upgraded --- Globals.js | 2 +- Spaces/TopSpace.js | 69 ++++++++++++++++++++++++++++++++++++++-------- SplashScreen.js | 2 +- 3 files changed, 60 insertions(+), 13 deletions(-) diff --git a/Globals.js b/Globals.js index 0a7a91072..a8204598e 100644 --- a/Globals.js +++ b/Globals.js @@ -178,7 +178,7 @@ maxDate.setDate(maxDate.getDate() + 365 * 1); // We might have charts that proj const MIN_PLOTABLE_DATE = new Date(2015, 0, 1, 0, 0, 0); const MAX_PLOTABLE_DATE = maxDate; -const TOP_SPACE_HEIGHT = 2 +const TOP_SPACE_HEIGHT = 40 const COCKPIT_SPACE_HEIGHT = 30; const BREAKPOINT_HEIGHT = 15; const SIDE_PANEL_WIDTH = 450 diff --git a/Spaces/TopSpace.js b/Spaces/TopSpace.js index a9295b91a..3fd2bc7de 100644 --- a/Spaces/TopSpace.js +++ b/Spaces/TopSpace.js @@ -7,27 +7,45 @@ function newTopSpace () { initialize: initialize } - let container = newContainer() - container.initialize() - thisObject.container = container + thisObject.container = newContainer() + thisObject.container.initialize() resize() - container.isDraggeable = false - + thisObject.container.isDraggeable = false + let backgroundImage + let logoImage return thisObject function initialize () { canvas.eventHandler.listenToEvent('Browser Resized', resize) + + backgroundImage = new Image() + logoImage = new Image() + + loadImage('superalgos-header-background', backgroundImage) + loadImage('superalgos-logo-for-color-background', logoImage) + + function loadImage (name, image) { + const PATH = 'Images/' + + image.onload = onImageLoad + image.fileName = name + + function onImageLoad () { + image.canDraw = true + } + image.src = window.canvasApp.urlPrefix + PATH + name + '.png' + } } function resize () { thisObject.container.frame.width = browserCanvas.width thisObject.container.frame.height = TOP_SPACE_HEIGHT - container.frame.position.x = 0 + thisObject.container.frame.position.x = 0 try { - container.frame.position.y = canvas.chartSpace.viewport.visibleArea.bottomLeft.y + thisObject.container.frame.position.y = canvas.chartSpace.viewport.visibleArea.bottomLeft.y } catch (e) { } } @@ -54,19 +72,48 @@ function newTopSpace () { } function drawBackground () { + /* Solid Color */ let opacity = 1 - browserCanvasContext.beginPath() - browserCanvasContext.rect(0, 0, thisObject.container.frame.width, thisObject.container.frame.height) if (areWeRecording === true) { browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', ' + opacity + ')' } else { browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.PATINATED_TURQUOISE + ', ' + opacity + ')' } - browserCanvasContext.closePath() - browserCanvasContext.fill() + + /* Background Image */ + if (backgroundImage !== undefined) { + if (backgroundImage.canDraw === true) { + let imagePosition = { + x: 0, + y: 0 + } + + browserCanvasContext.drawImage( + backgroundImage, imagePosition.x, + imagePosition.y, + browserCanvas.width, + TOP_SPACE_HEIGHT - 2) + } + } + + /* Logo Image */ + if (logoImage !== undefined) { + if (logoImage.canDraw === true) { + let imagePosition = { + x: 10, + y: 0 + } + + browserCanvasContext.drawImage( + logoImage, imagePosition.x, + imagePosition.y, + 150, + TOP_SPACE_HEIGHT - 2) + } + } } } diff --git a/SplashScreen.js b/SplashScreen.js index 9768aaa82..1fa6b751f 100644 --- a/SplashScreen.js +++ b/SplashScreen.js @@ -43,7 +43,7 @@ function newSplashScreen () { canDrawLogo = true } - logo.src = window.canvasApp.urlPrefix + 'Images/Superalgos-logo-horz-sm-t.png' + logo.src = window.canvasApp.urlPrefix + 'Images/superalgos-logo.png' canvas.eventHandler.listenToEvent('Browser Resized', resize) }