From 89cc588714ecdfa876042e4f154f80b40405be19 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Mon, 28 Jan 2019 14:31:30 +0100 Subject: [PATCH] =?UTF-8?q?improve=20cut=20section=20rendering=20?= =?UTF-8?q?=F0=9F=92=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.css | 25 ++++++----- src/renderer.jsx | 113 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 92 insertions(+), 46 deletions(-) diff --git a/src/main.css b/src/main.css index ce6126bd..47dd40c8 100644 --- a/src/main.css +++ b/src/main.css @@ -84,7 +84,7 @@ input, button, textarea, :focus { #current-time-display { text-align: center; - color: rgba(255, 255, 255, 0.3); + color: rgba(255, 255, 255, 0.8); padding: .5em; } @@ -94,22 +94,25 @@ input, button, textarea, :focus { background-color: #444; } -.timeline-wrapper .current-time, .timeline-wrapper .cut-start-time { +.timeline-wrapper .current-time, .timeline-wrapper .cut-section, .timeline-wrapper .cut-time-marker { position: absolute; bottom: 0; top: 0; - width: 1px; } -.timeline-wrapper .current-time { - background-color: red; - z-index: 2; -} -.timeline-wrapper .cut-start-time { - background-color: rgba(0, 0, 0, 0.3); - border-left: 1px solid black; - border-right: 1px solid black; +.timeline-wrapper .cut-section { z-index: 1; + background-color: rgba(0, 255, 149, 0.5); +} +.timeline-wrapper .cut-time-marker { + z-index: 2; + box-sizing: border-box; + background: rgba(0, 255, 149, 0.5); +} +.timeline-wrapper .current-time { + z-index: 3; + background-color: rgba(255, 255, 255, 1); + width: 1px; } #drag-drop-field { diff --git a/src/renderer.jsx b/src/renderer.jsx index 7d3bdaf5..1e2b35f9 100644 --- a/src/renderer.jsx +++ b/src/renderer.jsx @@ -68,7 +68,7 @@ const localState = { playing: false, currentTime: undefined, duration: undefined, - cutStartTime: 0, + cutStartTime: undefined, cutStartTimeManual: undefined, cutEndTime: undefined, cutEndTimeManual: undefined, @@ -274,6 +274,11 @@ class App extends React.Component { return `${this.getRotation()}°`; } + getApparentCutStartTime() { + if (this.state.cutStartTime !== undefined) return this.state.cutStartTime; + return 0; + } + getApparentCutEndTime() { if (this.state.cutEndTime !== undefined) return this.state.cutEndTime; if (this.state.duration !== undefined) return this.state.duration; @@ -302,7 +307,7 @@ class App extends React.Component { toggleKeyframeCut = () => this.setState(({ keyframeCut }) => ({ keyframeCut: !keyframeCut })); jumpCutStart = () => { - seekAbs(this.state.cutStartTime); + seekAbs(this.getApparentCutStartTime()); } jumpCutEnd = () => { @@ -314,7 +319,7 @@ class App extends React.Component { const $target = $('.timeline-wrapper'); const parentOffset = $target.offset(); const relX = e.srcEvent.pageX - parentOffset.left; - setCursor((relX / $target[0].offsetWidth) * this.state.duration); + setCursor((relX / $target[0].offsetWidth) * (this.state.duration || 0)); }, 200); /* eslint-enable react/sort-comp */ @@ -351,13 +356,13 @@ class App extends React.Component { } const { - cutStartTime, cutEndTime, filePath, customOutDir, fileFormat, duration, includeAllStreams, + cutEndTime, cutStartTime, filePath, customOutDir, fileFormat, duration, includeAllStreams, stripAudio, keyframeCut, } = this.state; const rotation = this.isRotationSet() ? this.getRotation() : undefined; - if (!this.isCutRangeValid()) { + if (!(this.isCutRangeValid() || cutEndTime === undefined || cutStartTime === undefined)) { errorToast('Start time must be before end time'); return; } @@ -368,7 +373,7 @@ class App extends React.Component { customOutDir, filePath, format: fileFormat, - cutFrom: cutStartTime, + cutFrom: this.getApparentCutStartTime(), cutTo: cutEndTime, cutToApparent: this.getApparentCutEndTime(), videoDuration: duration, @@ -430,7 +435,7 @@ class App extends React.Component { } isCutRangeValid() { - return this.state.cutStartTime < this.getApparentCutEndTime(); + return this.getApparentCutStartTime() < this.getApparentCutEndTime(); } toggleHelp() { @@ -463,7 +468,7 @@ class App extends React.Component { })); }; - const cutTime = type === 'start' ? this.state.cutStartTime : this.getApparentCutEndTime(); + const cutTime = type === 'start' ? this.getApparentCutStartTime() : this.getApparentCutEndTime(); return ( - {!this.state.filePath && ( + {!filePath && (
DROP VIDEO
PRESS H FOR HELP
)} - {this.state.working && ( + {working && (
- {this.state.cutProgress != null && ( + {cutProgress != null && ( - {`${Math.floor(this.state.cutProgress * 100)} %`} + {`${Math.floor(cutProgress * 100)} %`} )}
@@ -528,18 +569,20 @@ class App extends React.Component { options={{ recognizers: {} }} >
-
+ {currentTimePos !== undefined &&
} - {this.isCutRangeValid() && ( -
- ) - } + {cutStartTime !== undefined &&
} + {isCutRangeValid && (cutStartTime !== undefined || cutEndTime !== undefined) && ( +
+ )} + {cutEndTime !== undefined &&
}
{formatDuration(this.getOffsetCurrentTime())}
@@ -571,7 +614,7 @@ class App extends React.Component { />