Skip to content

Commit 8f420df

Browse files
committed
Add reset zoom shortcut, closes #1224
1 parent d989420 commit 8f420df

6 files changed

Lines changed: 94 additions & 191 deletions

File tree

app/lib/actions/shortcuts.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ extension ShortcutDefinitionLocalization on ShortcutDefinition {
8888
changePathShortcut => loc.changePathShortcut,
8989
zoomInShortcut => loc.zoomIn,
9090
zoomOutShortcut => loc.zoomOut,
91+
resetZoomShortcut => loc.resetZoom,
9192
rotateLeftShortcut => loc.rotateLeft,
9293
rotateRightShortcut => loc.rotateRight,
9394
fullScreenShortcut => loc.fullScreenShortcut,
@@ -134,6 +135,7 @@ final keybinder = Keybinder(
134135
packsShortcut,
135136
zoomInShortcut,
136137
zoomOutShortcut,
138+
resetZoomShortcut,
137139
rotateLeftShortcut,
138140
rotateRightShortcut,
139141
pasteShortcut,

app/lib/actions/zoom.dart

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import 'package:keybinder/keybinder.dart';
77

88
class ZoomIntent extends Intent {
99
final bool reverse;
10+
final bool reset;
1011

11-
const ZoomIntent({this.reverse = false});
12+
const ZoomIntent({this.reverse = false, this.reset = false});
1213
}
1314

1415
const zoomInShortcut = ShortcutDefinition(
@@ -23,6 +24,16 @@ const zoomOutShortcut = ShortcutDefinition(
2324
defaultActivator: SingleActivator(LogicalKeyboardKey.minus, control: true),
2425
);
2526

27+
const resetZoomShortcut = ShortcutDefinition(
28+
id: 'reset_zoom',
29+
intent: ZoomIntent(reset: true),
30+
defaultActivator: SingleActivator(
31+
LogicalKeyboardKey.digit0,
32+
control: true,
33+
shift: true,
34+
),
35+
);
36+
2637
class ZoomAction extends Action<ZoomIntent> {
2738
final BuildContext context;
2839

@@ -41,7 +52,9 @@ class ZoomAction extends Action<ZoomIntent> {
4152
final transformCubit = cubit.transformCubit;
4253
final step = ZoomAction.step(cubit.settingsCubit.state);
4354
cubit.transformCubit.sizeConstrained(
44-
transformCubit.state.size + (intent.reverse ? -step : step),
55+
intent.reset
56+
? 1
57+
: transformCubit.state.size + (intent.reverse ? -step : step),
4558
cursor: center,
4659
runtime: cubit,
4760
);

app/lib/settings/pages/inputs.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ final _keyboardSettingsPage = SettingsLeapPage<ButterflySettings>(
428428
changePathShortcut,
429429
zoomInShortcut,
430430
zoomOutShortcut,
431+
resetZoomShortcut,
431432
rotateLeftShortcut,
432433
rotateRightShortcut,
433434
fullScreenShortcut,
@@ -835,6 +836,7 @@ final _projectInputShortcuts = [
835836
changePathShortcut,
836837
zoomInShortcut,
837838
zoomOutShortcut,
839+
resetZoomShortcut,
838840
rotateLeftShortcut,
839841
rotateRightShortcut,
840842
fullScreenShortcut,

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@phosphor-icons/react": "^2.1.10",
1919
"@types/react": "^19.2.18",
2020
"@types/react-dom": "^19.2.4",
21-
"astro": "^7.1.6",
21+
"astro": "^7.2.0",
2222
"katex": "^0.18.1",
2323
"react": "^19.2.8",
2424
"react-dom": "^19.2.8",

0 commit comments

Comments
 (0)