MicroPad / MicroPad-Electron

The desktop app of https://github.com/MicroPad/MicroPad-Core
Mozilla Public License 2.0
64 stars 4 forks source link

Remember the last state of MicroPad window #42

Closed AndrewMD888 closed 1 year ago

AndrewMD888 commented 3 years ago

This is a small but helpful feature - it would be handy if the program opened to the same window size/position upon start up that it had from the previous execution.

zoepicone commented 2 years ago

I can try working on this - seems like window.js in electron-boilerplate would be able to deal with this pretty easily

NickGeek commented 2 years ago

@zoedelphi That works although by the looks of it, you could probably use the nodejs fs/promises package directly to store the setting as JSON or something. It looks small enough to implement that I think a whole lib might be overkill?

  1. If the file exists upon loading the app then parse it
  2. If error skip
  3. If it parses correctly then call the electron setSize function on BrowserWindow (https://www.electronjs.org/docs/latest/api/browser-window#winsetsizewidth-height-animate) to that value
  4. Add an event handler for the resize event to update and save that file asynchronously
zoepicone commented 2 years ago

@NickGeek I think the main issue would be dealing with resolution changes that could leave the window inaccessible due to being completely out of bounds - I was just thinking of using the single js file as nothing else in the lib is needed

NickGeek commented 2 years ago

@zoedelphi fair enough. As long as the licencing is okay with that file. You'll want to watch out for extra deps they pull in too. If you send in a PR I'll take a look.

NickGeek commented 1 year ago

Fixed in v4