Skip to content

Commit

Permalink
feat: zoom in tauri at reduced capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
abose committed Nov 1, 2023
1 parent ffddf23 commit 16b91ae
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/command/DefaultMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,13 @@ define(function (require, exports, module) {
let subMenu = menu.addSubMenu(Strings.CMD_ZOOM_UI, Commands.VIEW_ZOOM_SUBMENU);
subMenu.addMenuItem(Commands.VIEW_ZOOM_IN);
subMenu.addMenuItem(Commands.VIEW_ZOOM_OUT);
subMenu.addMenuItem(Commands.VIEW_INCREASE_FONT_SIZE);
subMenu.addMenuItem(Commands.VIEW_DECREASE_FONT_SIZE);
if(!Phoenix.browser.isTauri) {
// tauri doesnt support zoomin/out and the document.body.style.zoom = 1.5 trick didnt work
// as code mirror doesnt support css transform styles. so we just show increase and decrease
// font size as zoom. so we wont register redundant VIEW_INCREASE_FONT_SIZE commands in tauri
subMenu.addMenuItem(Commands.VIEW_INCREASE_FONT_SIZE);
subMenu.addMenuItem(Commands.VIEW_DECREASE_FONT_SIZE);
}
subMenu.addMenuItem(Commands.VIEW_RESTORE_FONT_SIZE);
menu.addMenuDivider();
menu.addMenuItem(Commands.TOGGLE_ACTIVE_LINE);
Expand Down
12 changes: 10 additions & 2 deletions src/view/ViewCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,16 @@ define(function (require, exports, module) {
// Register command handlers
CommandManager.register(Strings.CMD_INCREASE_FONT_SIZE, Commands.VIEW_INCREASE_FONT_SIZE, _handleIncreaseFontSize);
CommandManager.register(Strings.CMD_DECREASE_FONT_SIZE, Commands.VIEW_DECREASE_FONT_SIZE, _handleDecreaseFontSize);
CommandManager.register(Strings.CMD_ZOOM_IN, Commands.VIEW_ZOOM_IN, _handleZoom, {eventSource: true});
CommandManager.register(Strings.CMD_ZOOM_OUT, Commands.VIEW_ZOOM_OUT, _handleZoom, {eventSource: true});
if(Phoenix.browser.isTauri){
// tauri doesnt support zoomin/out and the document.body.style.zoom = 1.5 trick didnt work
// as code mirror doesnt support css transform styles. so we just show increase and decrease
// font size as zoom.
CommandManager.register(Strings.CMD_ZOOM_IN, Commands.VIEW_ZOOM_IN, _handleIncreaseFontSize, {eventSource: true});
CommandManager.register(Strings.CMD_ZOOM_OUT, Commands.VIEW_ZOOM_OUT, _handleDecreaseFontSize, {eventSource: true});
} else {
CommandManager.register(Strings.CMD_ZOOM_IN, Commands.VIEW_ZOOM_IN, _handleZoom, {eventSource: true});
CommandManager.register(Strings.CMD_ZOOM_OUT, Commands.VIEW_ZOOM_OUT, _handleZoom, {eventSource: true});
}
CommandManager.register(Strings.CMD_RESTORE_FONT_SIZE, Commands.VIEW_RESTORE_FONT_SIZE, _handleRestoreFontSize);
CommandManager.register(Strings.CMD_SCROLL_LINE_UP, Commands.VIEW_SCROLL_LINE_UP, _handleScrollLineUp);
CommandManager.register(Strings.CMD_SCROLL_LINE_DOWN, Commands.VIEW_SCROLL_LINE_DOWN, _handleScrollLineDown);
Expand Down
21 changes: 20 additions & 1 deletion src/view/fontrules/font-based-rules.less
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,35 @@
@defaultmenuwidth: 300px/@defaultfontsize;

@lineheight: @fontsize + @fontsize * @lineheightoffset;
@menuFontSize: @fontsize + 2;
@titleFontSize: @fontsize + 6;

.CodeMirror {
font-size: @fontsize !important;
}

.codehint-menu .dropdown-menu li a, .inlinemenu-menu .dropdown-menu li a {
.codehint-menu .dropdown-menu li a, .inlinemenu-menu .dropdown-menu li a{
font-size: @fontsize !important;
line-height: @lineheight !important;
}

.modal-bar{
font-size: @menuFontSize !important;
}

.context-menu .dropdown-menu li a , .toolbar .nav .dropdown-menu li a{
font-size: @menuFontSize !important;
line-height: @lineheight !important;
}

.toolbar .title {
font-size: @titleFontSize !important;
}

#titlebar {
font-size: @menuFontSize !important;
}

span.brackets-js-hints-with-type-details {
width: @defaultmenuwidth * @fontsize !important;
}
Expand Down

0 comments on commit 16b91ae

Please sign in to comment.