Repository navigation
feat(app): zoom the desktop app with Ctrl/⌘ + = and − - #647
Merged
Merged
Conversation
Zoom in (⌘=, Ctrl+= on Windows and Linux) and Zoom out (⌘−, Ctrl+-) step through the zoom levels Settings offers, from a zoom between them too, and stop at the smallest and largest. Like browsers, Zoom in also takes ⌘+ with Shift, the + key of layouts that have one and the keypad's + and −; those alternates run the command without showing in menus, tooltips or the shortcut sheet. Actual size goes back to 100 % and has no chord, as ⌘0 shows Devices. The main and Settings windows run the chords before their content, so zoom works in both and while a field has focus. On macOS both windows' View menus list the three items, disabled where they would change nothing, and own ⌘= and ⌘−; the windows leave those keys to the menus so each press zooms once. The palette and the shortcut sheet list the commands; phones and the web app do not offer them.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
# Conflicts: # app/desktop/src/main/kotlin/com/linroid/ketch/app/desktop/DesktopMenuBar.kt # app/desktop/src/main/kotlin/com/linroid/ketch/app/desktop/main.kt
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows #643 (Settings → General → Zoom) for #600. Browsers and Electron apps zoom with Ctrl/⌘ +
=and−; Ketch had no such shortcut, so Windows users, who have no menu bar, could only zoom from Settings.What changes
⌘=,Ctrl+=) and Zoom out (⌘−,Ctrl+-) step through the levels Settings offers (90, 100, 110, 125, 150, 175, 200 %). They also step from a zoom between levels (115 → 125 or 110) and stop at the smallest and largest. A hand-written 50 % or 300 % steps back inside and never further out.⌘+with Shift, the+key of layouts that have one (German, Nordic) and the keypad's+(Zoom out: the keypad's−). These are a newKetchCommand.alternates: the matcher binds them (boundChords), but menus, tooltips and the shortcut sheet show only the main chord.⌘0already shows Devices.onPreviewKeyEvent, so zoom works in both windows and while a text field has focus.⌘=and⌘−. AWT hands a key equivalent to both the window and the menu, so the windows skip the keys their menus own (menuKeys), and each press zooms once.ShellCommands.bindscheckszoomSupported, so phones and the web app don't offer them. In the palette the three commands also match the Zoom setting's name, so "zoom" finds Actual size, and in languages that call the commands something else (Vergrößern, Масштаб…) the setting's name finds them too.ZoomLevelsmoved fromGeneralSettingstostate/ZoomLevels.kt.AppSettingsControllergainszoomIn,zoomOut,resetZoom,canZoomInandcanZoomOut.Snapshots
The macOS menu bar is native and isn't covered by the snapshot harness.
Tests
AppSettingsControllerTest: stepping through every level in both directions, stopping at the ends, from between two levels, from 50 % and 300 %, and reset.KetchCommandsTest(uniqueness, never hiding global chords, printable labels, no Ctrl with primary) now covers bound chords, so the alternates are checked too. New label and alternates tests.ShortcutMatcherTest,ShortcutSheetTest,PaletteProvidersTest,DesktopTrayModelTest(View menu items, enabled states,menuKeys),DesktopCommandsTestandHostShortcutsTest../gradlew :app:shared:jvmTest :app:desktop:testpass, and:app:shared:compileKotlinWasmJs :app:shared:compileAndroidMaincompile.Not checked by hand: pressing the keys in a running desktop app on macOS or Windows. The key paths are covered only by the matcher and menu tests above.