git ssb

16+

Dominic / patchbay



Commit 31a6b451195783f711ecd29057d9dc3ea60f92aa

Save window settings

Anders Rune Jensen committed on 8/31/2017, 7:26:13 PM
Parent: f1db11f663cc169035aa21d6ca1777e5530a739b

Files changed

app/html/app.jschanged
main.jschanged
package.jsonchanged
app/html/app.jsView
@@ -1,7 +1,8 @@
11 const nest = require('depnest')
22 const { h } = require('mutant')
33 const insertCss = require('insert-css')
4 +const electron = require('electron')
45
56 exports.gives = nest('app.html.app')
67
78 exports.needs = nest({
@@ -13,9 +14,11 @@
1314 'app.sync.addPage': 'first',
1415 'app.sync.catchKeyboardShortcut': 'first',
1516 'router.sync.router': 'first',
1617 'router.sync.normalise': 'first',
17- 'styles.css': 'reduce'
18 + 'styles.css': 'reduce',
19 + 'settings.sync.get': 'first',
20 + 'settings.sync.set': 'first'
1821 })
1922
2023 exports.create = function (api) {
2124 return nest('app.html.app', app)
@@ -55,8 +58,25 @@
5558
5659 addError(ev.error || ev)
5760 })
5861
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 +
5979 return App
6080 }
6181 }
6282
main.jsView
@@ -9,8 +9,9 @@
99 const bayGatherings = require('patchbay-gatherings')
1010 const patchbay = require('./')
1111 const patchContext = require('patch-context')
1212 const patchcore = require('patchcore')
13 +const patchSettings = require('patch-settings')
1314
1415 // polyfills
1516 require('setimmediate')
1617
@@ -22,9 +23,10 @@
2223 // gatherings,
2324 // bayGatherings, // TODO collect gatherings into this
2425 patchbay,
2526 patchContext,
26- patchcore
27 + patchcore,
28 + patchSettings
2729 )
2830
2931 const api = entry(sockets, nest('app.html.app', 'first'))
3032
package.jsonView
@@ -6,9 +6,9 @@
66 "scripts": {
77 "lint": "standard",
88 "setup": "npm install electron electro -g",
99 "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"
1111 },
1212 "browserify": {
1313 "transform": [
1414 "bulkify",
@@ -55,8 +55,9 @@
5555 "patch-gatherings": "^2.4.3",
5656 "patch-hub": "^1.1.0",
5757 "patchbay-gatherings": "^1.1.2",
5858 "patchcore": "^1.10.3",
59 + "patch-settings": "^1.0.0",
5960 "pull-abortable": "^4.1.1",
6061 "pull-cat": "^1.1.11",
6162 "pull-next": "1.0.0",
6263 "pull-scroll": "^1.0.7",

Built with git-ssb-web