Commit 31a6b451195783f711ecd29057d9dc3ea60f92aa
Save window settings
Anders Rune Jensen committed on 8/31/2017, 7:26:13 PMParent: f1db11f663cc169035aa21d6ca1777e5530a739b
Files changed
app/html/app.js | changed |
main.js | changed |
package.json | changed |
app/html/app.js | ||
---|---|---|
@@ -1,7 +1,8 @@ | ||
1 | 1 … | const nest = require('depnest') |
2 | 2 … | const { h } = require('mutant') |
3 | 3 … | const insertCss = require('insert-css') |
4 … | +const electron = require('electron') | |
4 | 5 … | |
5 | 6 … | exports.gives = nest('app.html.app') |
6 | 7 … | |
7 | 8 … | exports.needs = nest({ |
@@ -13,9 +14,11 @@ | ||
13 | 14 … | 'app.sync.addPage': 'first', |
14 | 15 … | 'app.sync.catchKeyboardShortcut': 'first', |
15 | 16 … | 'router.sync.router': 'first', |
16 | 17 … | 'router.sync.normalise': 'first', |
17 | - 'styles.css': 'reduce' | |
18 … | + 'styles.css': 'reduce', | |
19 … | + 'settings.sync.get': 'first', | |
20 … | + 'settings.sync.set': 'first' | |
18 | 21 … | }) |
19 | 22 … | |
20 | 23 … | exports.create = function (api) { |
21 | 24 … | return nest('app.html.app', app) |
@@ -55,8 +58,25 @@ | ||
55 | 58 … | |
56 | 59 … | addError(ev.error || ev) |
57 | 60 … | }) |
58 | 61 … | |
62 … | + window.addEventListener('resize', function(e){ | |
63 … | + var wc = electron.remote.getCurrentWebContents() | |
64 … | + wc && wc.getZoomFactor((zf) => { | |
65 … | + api.settings.sync.set({ | |
66 … | + zoomFactor: zf, | |
67 … | + bounds: electron.remote.getCurrentWindow().getBounds() | |
68 … | + }) | |
69 … | + }) | |
70 … | + }) | |
71 … | + | |
72 … | + var zoomFactor = api.settings.sync.get('zoom') | |
73 … | + if (zoomFactor) | |
74 … | + electron.remote.getCurrentWebContents().setZoomFactor(zoomFactor) | |
75 … | + var bounds = api.settings.sync.get('bounds') | |
76 … | + if (bounds) | |
77 … | + electron.remote.getCurrentWindow().setBounds(bounds) | |
78 … | + | |
59 | 79 … | return App |
60 | 80 … | } |
61 | 81 … | } |
62 | 82 … |
main.js | |||
---|---|---|---|
@@ -9,8 +9,9 @@ | |||
9 | 9 … | const bayGatherings = require('patchbay-gatherings') | |
10 | 10 … | const patchbay = require('./') | |
11 | 11 … | const patchContext = require('patch-context') | |
12 | 12 … | const patchcore = require('patchcore') | |
13 … | +const patchSettings = require('patch-settings') | ||
13 | 14 … | ||
14 | 15 … | // polyfills | |
15 | 16 … | require('setimmediate') | |
16 | 17 … | ||
@@ -22,9 +23,10 @@ | |||
22 | 23 … | // gatherings, | |
23 | 24 … | // bayGatherings, // TODO collect gatherings into this | |
24 | 25 … | patchbay, | |
25 | 26 … | patchContext, | |
26 | - patchcore | ||
27 … | + patchcore, | ||
28 … | + patchSettings | ||
27 | 29 … | ) | |
28 | 30 … | ||
29 | 31 … | const api = entry(sockets, nest('app.html.app', 'first')) | |
30 | 32 … |
package.json | ||
---|---|---|
@@ -6,9 +6,9 @@ | ||
6 | 6 … | "scripts": { |
7 | 7 … | "lint": "standard", |
8 | 8 … | "setup": "npm install electron electro -g", |
9 | 9 … | "rebuild": "npm rebuild --runtime=electron --target=$(electron -v) --abi=$(electron --abi) --disturl=https://atom.io/download/atom-shell", |
10 | - "start": "electro main.js" | |
10 … | + "start": "electro main.js -- --title patchbay" | |
11 | 11 … | }, |
12 | 12 … | "browserify": { |
13 | 13 … | "transform": [ |
14 | 14 … | "bulkify", |
@@ -55,8 +55,9 @@ | ||
55 | 55 … | "patch-gatherings": "^2.4.3", |
56 | 56 … | "patch-hub": "^1.1.0", |
57 | 57 … | "patchbay-gatherings": "^1.1.2", |
58 | 58 … | "patchcore": "^1.10.3", |
59 … | + "patch-settings": "^1.0.0", | |
59 | 60 … | "pull-abortable": "^4.1.1", |
60 | 61 … | "pull-cat": "^1.1.11", |
61 | 62 … | "pull-next": "1.0.0", |
62 | 63 … | "pull-scroll": "^1.0.7", |
Built with git-ssb-web