Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zoom in-out #596

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/browser/actions/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,27 @@ function quitAndInstallUpdates() {
};
}

function zoomIn() {
return function (dispatch) {
return applicationControl.zoomIn().then(function () {
}).catch(error => dispatch(errorCaught(error)));
};
}

function zoomOut() {
return function (dispatch) {
return applicationControl.zoomOut().then(function () {
}).catch(error => dispatch(errorCaught(error)));
};
}

function zoomToDefault() {
return function (dispatch) {
return applicationControl.zoomToDefault().then(function () {
}).catch(error => dispatch(errorCaught(error)));
};
}

export function errorCaught(error) {
/* eslint no-console: 0 */
console.error(error);
Expand All @@ -75,5 +96,8 @@ export default {
showStartupWindow,
quit,
quitAndInstallUpdates,
toggleDevTools
toggleDevTools,
zoomIn,
zoomOut,
zoomToDefault
};
17 changes: 16 additions & 1 deletion src/browser/services/application-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ function showStartupWindow() {
return api.send('showStartupWindow');
}

function zoomIn() {
return api.send('zoomIn');
}

function zoomOut() {
return api.send('zoomOut');
}

function zoomToDefault() {
return api.send('zoomToDefault');
}

export default {
checkForUpdates,
createWindow,
Expand All @@ -110,5 +122,8 @@ export default {
surveyTabs,
toggleDevTools,
quitAndInstall,
quit
quit,
zoomIn,
zoomOut,
zoomToDefault
};
5 changes: 4 additions & 1 deletion src/browser/services/ipc-dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ const dispatchMap = {
FOCUS_ACTIVE_TERMINAL: () => freeTabGroupActions.focusFirstTabByType('document-terminal-viewer'),
FOCUS_NEWEST_PLOT: () => freeTabGroupActions.focusNewestPlot(),
TERMINAL_INTERRUPT: () => kernelActions.interrupt(),
TERMINAL_RESTART: () => kernelActions.restart()
TERMINAL_RESTART: () => kernelActions.restart(),
ZOOM_IN: () => applicationActions.zoomIn(),
ZOOM_OUT: () => applicationActions.zoomOut(),
ZOOM_TO_DEFAULT: () => applicationActions.zoomToDefault()
},
detectVariables = _.debounce(function (dispatch) {
dispatch(kernelActions.detectKernelVariables());
Expand Down
46 changes: 45 additions & 1 deletion src/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,47 @@ function onToggleFullScreen() {
});
}

/**
* Increases zoom
* @returns {Promise}
*/
function onZoomIn() {
const window = browserWindows.getFocusedWindow() || this;

return bluebird.try(function () {
window.webContents.getZoomLevel(function (zoomLevel){
window.webContents.setZoomLevel(zoomLevel + 1);
});
});
}

/**
* Decreases zoom
* @returns {Promise}
*/
function onZoomOut() {
const window = browserWindows.getFocusedWindow() || this;

return bluebird.try(function () {
window.webContents.getZoomLevel(function (zoomLevel){
window.webContents.setZoomLevel(zoomLevel - 1);
});
});
}

/**
* Zooms to the default level
* @returns {Promise}
*/
function onZoomToDefault() {
const window = browserWindows.getFocusedWindow() || this;

return bluebird.try(function () {
window.webContents.setZoomLevel(0);
});
}


/**
* @param {string} name
* @param {object} options
Expand Down Expand Up @@ -918,7 +959,10 @@ function attachIpcMainEvents() {
onSaveDialog,
onToggleDevTools,
onToggleFullScreen,
onKillKernelInstance
onKillKernelInstance,
onZoomIn,
onZoomOut,
onZoomToDefault
]);
}

Expand Down