From 76771d233b91e3b54ca77a1dbabc7e4f97370552 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Thu, 5 Mar 2020 00:27:15 +0800 Subject: [PATCH] zoom improvements #254 - ctrl/cmd+up/down hotkey to zoom - implement hotkey for comfort zoom --- src/App.jsx | 18 +++++++++++++++++- src/HelpSheet.jsx | 13 +++++++++---- src/LeftMenu.jsx | 14 +++++++------- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 3ad5fdb3e9f..bb75405aea3 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -332,6 +332,16 @@ const App = memo(() => { const zoomRel = useCallback((rel) => setZoom(z => Math.min(Math.max(z + rel, 1), zoomMax)), []); const frameRenderEnabled = !!(rotationPreviewRequested || dummyVideoPath); + const comfortZoom = duration ? (duration / 100) : undefined; + const toggleComfortZoom = useCallback(() => { + if (!comfortZoom) return; + + setZoom((prevZoom) => { + if (prevZoom === 1) return comfortZoom; + return 1; + }); + }, [comfortZoom]); + const getSegApparentEnd = useCallback((seg) => { const time = seg.end; if (time !== undefined) return time; @@ -1053,6 +1063,9 @@ const App = memo(() => { Mousetrap.bind('alt+right', () => seekClosestKeyframe(1)); Mousetrap.bind('up', () => jumpSeg(-1)); Mousetrap.bind('down', () => jumpSeg(1)); + Mousetrap.bind(['ctrl+up', 'command+up'], () => { zoomRel(1); return false; }); + Mousetrap.bind(['ctrl+down', 'command+down'], () => { zoomRel(-1); return false; }); + Mousetrap.bind('z', () => toggleComfortZoom()); Mousetrap.bind('.', () => shortStep(1)); Mousetrap.bind(',', () => shortStep(-1)); Mousetrap.bind('c', () => capture()); @@ -1077,6 +1090,9 @@ const App = memo(() => { Mousetrap.unbind('alt+right'); Mousetrap.unbind('up'); Mousetrap.unbind('down'); + Mousetrap.unbind(['ctrl+up', 'command+up']); + Mousetrap.unbind(['ctrl+down', 'command+down']); + Mousetrap.unbind('z'); Mousetrap.unbind('.'); Mousetrap.unbind(','); Mousetrap.unbind('c'); @@ -1091,7 +1107,7 @@ const App = memo(() => { }, [ addCutSegment, capture, changePlaybackRate, cutClick, playCommand, removeCutSegment, setCutEnd, setCutStart, seekRel, seekRelPercent, shortStep, deleteSource, jumpSeg, toggleHelp, - seekClosestKeyframe, + seekClosestKeyframe, zoomRel, toggleComfortZoom, ]); useEffect(() => { diff --git a/src/HelpSheet.jsx b/src/HelpSheet.jsx index 77bdb62497f..6525eaf1367 100644 --- a/src/HelpSheet.jsx +++ b/src/HelpSheet.jsx @@ -39,21 +39,26 @@ const HelpSheet = memo(({
CTRL / CMD + Seek backward 1% of timeline at current zoom
CTRL / CMD + Seek forward 1% of timeline at current zoom
+

Timeline/zoom operations

+
Z Toggle zoom between 1x and a calculated comfortable zoom level
+
CTRL / CMD + Zoom in timeline
+
CTRL / CMD + Zoom out timeline
+
Mouse scroll up/down/left/right - Pan timeline
+
CTRL + Mouse scroll up/down - Zoom in/out timeline
+

Segments and cut points

I Mark in / cut start point for current segment
O Mark out / cut end point for current segment
+ Add cut segment
BACKSPACE Remove current segment
+
Select previous segment
+
Select next segment

File system actions

E Export segment(s)
C Capture snapshot
D Delete source file
-

Mouse actions

-
Mouse scroll up/down/left/right - Seek / pan timeline
-
CTRL + Mouse scroll up/down - Zoom in/out timeline
-

Hover mouse over buttons in the main interface to see which function they have.

Last ffmpeg commands

diff --git a/src/LeftMenu.jsx b/src/LeftMenu.jsx index 6266bd28ef9..b68c273fe82 100644 --- a/src/LeftMenu.jsx +++ b/src/LeftMenu.jsx @@ -16,6 +16,8 @@ const LeftMenu = memo(({ zoom, setZoom, invertCutSegments, setInvertCutSegments }); } + const zoomOptions = Array(13).fill().map((unused, z) => 2 ** z); + return (
@@ -33,13 +35,11 @@ const LeftMenu = memo(({ zoom, setZoom, invertCutSegments, setInvertCutSegments
{Math.floor(zoom)}x
- setZoom(parseInt(e.target.value, 10)))}> + + {zoomOptions.map(val => ( + + ))}
);