From 3c3eecc8478747e3cb632021ed80d3415d9adb0d Mon Sep 17 00:00:00 2001 From: Murilo Polese Date: Tue, 23 Apr 2024 10:41:48 +0200 Subject: [PATCH 1/3] Splash screen --- index.js | 30 +++++++++++++++++++++++------- ui/arduino/splash.html | 21 +++++++++++++++++++++ 2 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 ui/arduino/splash.html diff --git a/index.js b/index.js index 3f01633..e2130c6 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,8 @@ const registerIPCHandlers = require('./backend/ipc.js') const registerMenu = require('./backend/menu.js') let win = null // main window +let splash = null +let splashTimeout = null // START APP function createWindow () { @@ -17,11 +19,30 @@ function createWindow () { nodeIntegration: false, webSecurity: true, enableRemoteModule: false, - preload: path.join(__dirname, "preload.js") + preload: path.join(__dirname, "preload.js"), + show: false } }) // and load the index.html of the app. win.loadFile('ui/arduino/index.html') + // If the app takes a while to open, show splash screen + splashTimeout = setTimeout(() => { + // Create the splash screen + splash = new BrowserWindow({ + width: 560, + height: 180, + transparent: true, + frame: false, + alwaysOnTop: true + }); + splash.loadFile('ui/arduino/splash.html') + }, 250) + + win.once('ready-to-show', () => { + clearTimeout(splashTimeout) + if (splash) splash.destroy() + win.show() + }) registerIPCHandlers(win, ipcMain, app) registerMenu(win) @@ -29,11 +50,6 @@ function createWindow () { app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) createWindow() }) - // app.on('window-all-closed', () => { - // if (process.platform !== 'darwin') app.quit() - // }) } - -// TODO: Loading splash screen -app.whenReady().then(createWindow) +app.on('ready', createWindow) diff --git a/ui/arduino/splash.html b/ui/arduino/splash.html new file mode 100644 index 0000000..6d7e2e1 --- /dev/null +++ b/ui/arduino/splash.html @@ -0,0 +1,21 @@ + + + + + Arduino Lab for MicroPython + + + + Arduino Lab For MicroPython Logo + + From 4aadc2935fd9500aae826e38652da32021d420fa Mon Sep 17 00:00:00 2001 From: Murilo Polese Date: Tue, 23 Apr 2024 11:40:43 +0200 Subject: [PATCH 2/3] Encoding image as base64 to load faster --- ui/arduino/splash.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/arduino/splash.html b/ui/arduino/splash.html index 6d7e2e1..15ae0b4 100644 --- a/ui/arduino/splash.html +++ b/ui/arduino/splash.html @@ -16,6 +16,6 @@ - Arduino Lab For MicroPython Logo + Arduino Lab For MicroPython Logo From 2b36cfabf2552dcb7dc416943740e0c06bfb6703 Mon Sep 17 00:00:00 2001 From: Murilo Polese Date: Tue, 23 Apr 2024 11:44:30 +0200 Subject: [PATCH 3/3] Always show the splash screen for a brief time --- index.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/index.js b/index.js index e2130c6..b38f989 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ const registerMenu = require('./backend/menu.js') let win = null // main window let splash = null -let splashTimeout = null +let splashTimestamp = null // START APP function createWindow () { @@ -25,22 +25,27 @@ function createWindow () { }) // and load the index.html of the app. win.loadFile('ui/arduino/index.html') + // If the app takes a while to open, show splash screen - splashTimeout = setTimeout(() => { - // Create the splash screen - splash = new BrowserWindow({ - width: 560, - height: 180, - transparent: true, - frame: false, - alwaysOnTop: true - }); - splash.loadFile('ui/arduino/splash.html') - }, 250) + // Create the splash screen + splash = new BrowserWindow({ + width: 450, + height: 140, + transparent: true, + frame: false, + alwaysOnTop: true + }); + splash.loadFile('ui/arduino/splash.html') + splashTimestamp = Date.now() win.once('ready-to-show', () => { - clearTimeout(splashTimeout) - if (splash) splash.destroy() + if (Date.now()-splashTimestamp > 1000) { + splash.destroy() + } else { + setTimeout(() => { + splash.destroy() + }, 500) + } win.show() }) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy