diff --git a/ipc.js b/ipc.js index 080f0b6..0098aaa 100644 --- a/ipc.js +++ b/ipc.js @@ -4,12 +4,12 @@ const fs = require('fs'); module.exports = function(win) { ipcMain.on('toggle_fullscreen', function(event, arg) { - console.log('toggle_fullscreen'); + console.log('Event received: toggle_fullscreen'); win.setFullScreen(!win.isFullScreen()); }); ipcMain.on('toggle_devtools', function(event, arg) { - console.log('toggle_devtools'); + console.log('Event received: toggle_devtools'); win.toggleDevTools(); }); diff --git a/main.js b/main.js index 8178daf..d9c1823 100644 --- a/main.js +++ b/main.js @@ -8,5 +8,18 @@ let win; app.on('ready', function() { win = window('index.html'); + win.on('closed', function() { + console.log('Window closed'); + win = null; + }); ipc_setup(win); + console.log('Application started'); +}); + +app.on('window-all-closed', function() { + console.log('Application windows closed'); + if(process.platform !== 'darwin') { + console.log('Application exited'); + app.quit(); + } }); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 0d37582..5f40b85 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "corkboard", - "version": "1.0.0", + "version": "1.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 3535d1e..7978781 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "corkboard", "productName": "Corkboard", - "version": "1.1.0", + "version": "1.2.0", "description": "Sticky Notes & Pictures", "main": "main.js", "scripts": { diff --git a/state/action_types.js b/state/action_types.js index 5a0f3c4..d5682e4 100644 --- a/state/action_types.js +++ b/state/action_types.js @@ -4,6 +4,9 @@ export const A_LOAD_STATE = 'load_state'; // App export const A_APP_OBSERVE_Z = 'app_observe_z'; export const A_APP_TOGGLE_GODMODE = 'app_toggle_godmode'; +export const A_APP_ZOOM_RESET = 'app_zoom_reset'; +export const A_APP_ZOOM_IN = 'app_zoom_in'; +export const A_APP_ZOOM_OUT = 'app_zoom_out'; // Sticky Store export const A_STICKY_EDIT_CONTENT = 'sticky_edit_content'; diff --git a/state/app/actions.js b/state/app/actions.js index 3ebeb46..5a3794f 100644 --- a/state/app/actions.js +++ b/state/app/actions.js @@ -1,11 +1,15 @@ import { A_APP_OBSERVE_Z, - A_APP_TOGGLE_GODMODE + A_APP_TOGGLE_GODMODE, + A_APP_ZOOM_IN, + A_APP_ZOOM_OUT, + A_APP_ZOOM_RESET } from '../action_types'; import { M_APP_OBSERVE_Z, - M_APP_TOGGLE_GODMODE + M_APP_TOGGLE_GODMODE, + M_APP_ZOOM_SET } from '../mutation_types'; export default { @@ -14,5 +18,14 @@ export default { }, [A_APP_OBSERVE_Z]: function(context, z) { context.commit(M_APP_OBSERVE_Z, z); + }, + [A_APP_ZOOM_IN]: function(context) { + context.commit(M_APP_ZOOM_SET, context.getters.zoom_factor + 0.1); + }, + [A_APP_ZOOM_OUT]: function(context) { + context.commit(M_APP_ZOOM_SET, context.getters.zoom_factor - 0.1); + }, + [A_APP_ZOOM_RESET]: function(context) { + context.commit(M_APP_ZOOM_SET, 1); } } \ No newline at end of file diff --git a/state/app/getters.js b/state/app/getters.js index 408d516..965166b 100644 --- a/state/app/getters.js +++ b/state/app/getters.js @@ -1,5 +1,8 @@ export default { maxZ: function(state) { return state.maxZ; + }, + zoom_factor: function(state) { + return state.zoom_factor; } } \ No newline at end of file diff --git a/state/app/mutations.js b/state/app/mutations.js index 2bd4a94..a0941da 100644 --- a/state/app/mutations.js +++ b/state/app/mutations.js @@ -1,6 +1,9 @@ +var { webFrame } = require('electron'); + import { M_APP_OBSERVE_Z, - M_APP_TOGGLE_GODMODE + M_APP_TOGGLE_GODMODE, + M_APP_ZOOM_SET } from '../mutation_types'; export default { @@ -9,5 +12,12 @@ export default { }, [M_APP_OBSERVE_Z]: function(state, z) { state.maxZ = Math.max(state.maxZ, z); + }, + [M_APP_ZOOM_SET]: function(state, f) { + f = Math.min(f, 2); + f = Math.max(f, 0.5); + state.zoom_factor = f; + webFrame.setZoomFactor(f); + localStorage.setItem('zoom_factor', f); } } \ No newline at end of file diff --git a/state/app/state.js b/state/app/state.js index 1f80666..92eb62a 100644 --- a/state/app/state.js +++ b/state/app/state.js @@ -1,4 +1,10 @@ +const { webFrame } = require('electron'); + +var f = +localStorage.getItem('zoom_factor') || 1; +webFrame.setZoomFactor(f); + export default { godmode: false, - maxZ: 0 + maxZ: 0, + zoom_factor: f } \ No newline at end of file diff --git a/state/mutation_types.js b/state/mutation_types.js index cc614ed..2a8647c 100644 --- a/state/mutation_types.js +++ b/state/mutation_types.js @@ -1,6 +1,7 @@ // App export const M_APP_OBSERVE_Z = 'app_observe_z'; export const M_APP_TOGGLE_GODMODE = 'app_toggle_godmode'; +export const M_APP_ZOOM_SET = 'app_zoom_set'; // Sticky Store export const M_STICKY_LOAD = 'sticky_load'; diff --git a/view/corkboard.vue b/view/corkboard.vue index b932572..848eb06 100644 --- a/view/corkboard.vue +++ b/view/corkboard.vue @@ -1,5 +1,5 @@ @@ -96,12 +94,10 @@ export default { img { background: #eeeeee; - border-bottom: 0px; - border-top: 0px; border: 1px solid #dddddd; flex: 0 0 auto; margin: 0rem 1.5rem; - max-height: 14rem; + height: 14rem; max-width: 14rem; object-fit: contain; }