From 3378a5a88f3c0698090add280a1c1b0573ba8ccd Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Sat, 29 Feb 2020 10:50:25 +0800 Subject: [PATCH] add ui buttons for keyframe seek --- src/TimelineControls.jsx | 27 +++++++++++++++++++++------ src/renderer.jsx | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/TimelineControls.jsx b/src/TimelineControls.jsx index c1c183ba..db520848 100644 --- a/src/TimelineControls.jsx +++ b/src/TimelineControls.jsx @@ -1,6 +1,7 @@ import React, { Fragment, memo } from 'react'; import { FaHandPointLeft, FaHandPointRight, FaStepBackward, FaStepForward, FaCaretLeft, FaCaretRight, FaPause, FaPlay, FaImages, FaKey } from 'react-icons/fa'; import { GiSoundWaves } from 'react-icons/gi'; +import { IoMdKey } from 'react-icons/io'; // import useTraceUpdate from 'use-trace-update'; import { getSegColors, parseDuration, formatDuration } from './util'; @@ -12,7 +13,7 @@ const TimelineControls = memo(({ setCurrentSegIndex, cutStartTimeManual, setCutStartTimeManual, cutEndTimeManual, setCutEndTimeManual, duration, jumpCutEnd, jumpCutStart, startTimeOffset, setCutTime, currentApparentCutSeg, playing, shortStep, playCommand, setTimelineMode, hasAudio, hasVideo, timelineMode, - keyframesEnabled, setKeyframesEnabled, + keyframesEnabled, setKeyframesEnabled, seekClosestKeyframe, }) => { const { segActiveBgColor: currentSegActiveBgColor, @@ -61,14 +62,15 @@ const TimelineControls = memo(({ } function renderCutTimeInput(type) { - const cutTimeManual = type === 'start' ? cutStartTimeManual : cutEndTimeManual; + const isStart = type === 'start'; + const cutTimeManual = type === isStart ? cutStartTimeManual : cutEndTimeManual; const cutTimeInputStyle = { - background: 'white', borderRadius: 5, color: 'rgba(0, 0, 0, 0.7)', fontSize: 13, padding: '3px 5px', margin: '0 3px', border: 'none', boxSizing: 'border-box', fontFamily: 'inherit', width: 90, textAlign: type === 'start' ? 'right' : 'left', + background: 'white', borderRadius: 5, color: 'rgba(0, 0, 0, 0.7)', fontSize: 13, textAlign: 'center', padding: '3px 5px', marginTop: 0, marginBottom: 0, marginLeft: isStart ? 3 : 5, marginRight: isStart ? 5 : 3, border: 'none', boxSizing: 'border-box', fontFamily: 'inherit', width: 90, }; const isCutTimeManualSet = () => cutTimeManual !== undefined; - const set = type === 'start' ? setCutStartTimeManual : setCutEndTimeManual; + const set = isStart ? setCutStartTimeManual : setCutEndTimeManual; const handleCutTimeInput = (text) => { // Allow the user to erase @@ -94,13 +96,13 @@ const TimelineControls = memo(({ seekAbs(rel); }; - const cutTime = type === 'start' ? currentApparentCutSeg.start : currentApparentCutSeg.end; + const cutTime = isStart ? currentApparentCutSeg.start : currentApparentCutSeg.end; return ( handleCutTimeInput(e.target.value)} value={isCutTimeManualSet() ? cutTimeManual @@ -163,6 +165,13 @@ const TimelineControls = memo(({ {renderCutTimeInput('start')} + seekClosestKeyframe(-1)} + /> shortStep(1)} /> + seekClosestKeyframe(1)} + /> {renderCutTimeInput('end')} diff --git a/src/renderer.jsx b/src/renderer.jsx index bd906aea..e265c3e6 100644 --- a/src/renderer.jsx +++ b/src/renderer.jsx @@ -1675,6 +1675,7 @@ const App = memo(() => { currentApparentCutSeg={currentApparentCutSeg} playing={playing} shortStep={shortStep} + seekClosestKeyframe={seekClosestKeyframe} playCommand={playCommand} setTimelineMode={setTimelineMode} timelineMode={timelineMode}