improve invert cut segments

fixes #1078
pull/1089/head
Mikael Finstad 2022-03-17 23:28:37 +08:00
rodzic b79bd490d5
commit 7799107299
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 25AB36E3E81CBC26
4 zmienionych plików z 13 dodań i 14 usunięć

Wyświetl plik

@ -728,8 +728,10 @@ const App = memo(() => {
const toggleSimpleMode = useCallback(() => setSimpleMode((v) => {
if (!hideAllNotifications) toast.fire({ text: v ? i18n.t('Advanced view has been enabled. You will now also see non-essential buttons and functions') : i18n.t('Advanced view disabled. You will now see only the most essential buttons and functions') });
return !v;
}), [hideAllNotifications, setSimpleMode]);
const newValue = !v;
if (newValue) setInvertCutSegments(false);
return newValue;
}), [hideAllNotifications, setInvertCutSegments, setSimpleMode]);
const effectiveExportMode = useMemo(() => {
if (segmentsToChaptersOnly) return 'sesgments_to_chapters';
@ -1371,18 +1373,13 @@ const App = memo(() => {
}, [numStreamsToCopy, setWorking, segmentsToChaptersOnly, selectedSegments, outSegTemplateOrDefault, generateOutSegFileNames, segmentsToExport, getOutSegError, cutMultiple, outputDir, customOutDir, fileFormat, duration, isRotationSet, effectiveRotation, copyFileStreams, allFilesMeta, keyframeCut, shortestFlag, ffmpegExperimental, preserveMovData, preserveMetadataOnMerge, movFastStart, avoidNegativeTs, customTagsByFile, customTagsByStreamId, dispositionByStreamId, detectedFps, enableSmartCut, willMerge, mainFileFormatData, mainStreams, exportExtraStreams, hideAllNotifications, segmentsToChapters, invertCutSegments, autoConcatCutSegments, isCustomFormatSelected, autoDeleteMergedSegments, filePath, nonCopiedExtraStreams, handleCutFailed]);
const onExportPress = useCallback(async () => {
if (!filePath || workingRef.current) return;
if (!filePath || workingRef.current || segmentsToExport.length < 1) return;
if (haveInvalidSegs) {
errorToast(i18n.t('Start time must be before end time'));
return;
}
if (segmentsToExport.length < 1) {
errorToast(i18n.t('No segments to export'));
return;
}
if (exportConfirmEnabled) setExportConfirmVisible(true);
else await onExportConfirm();
}, [filePath, haveInvalidSegs, segmentsToExport, exportConfirmEnabled, onExportConfirm]);

Wyświetl plik

@ -299,6 +299,7 @@ const BottomBar = memo(({
size={24}
role="button"
title={invertCutSegments ? t('Discard selected segments') : t('Keep selected segments')}
style={{ color: invertCutSegments ? primaryTextColor : undefined }}
onClick={onYinYangClick}
/>
</motion.div>

Wyświetl plik

@ -1,5 +1,5 @@
import React, { memo, useMemo, useRef, useCallback } from 'react';
import { FaSave, FaPlus, FaMinus, FaTag, FaSortNumericDown, FaAngleRight, FaRegCheckCircle, FaRegCircle } from 'react-icons/fa';
import { FaYinYang, FaSave, FaPlus, FaMinus, FaTag, FaSortNumericDown, FaAngleRight, FaRegCheckCircle, FaRegCircle } from 'react-icons/fa';
import { AiOutlineSplitCells } from 'react-icons/ai';
import { motion } from 'framer-motion';
import Swal from 'sweetalert2';
@ -158,10 +158,10 @@ const SegmentList = memo(({
updateSegOrders(newList.map((list) => list.id));
}, [segments, updateSegOrders]);
let headerText = t('Segments to export:');
let header = t('Segments to export:');
if (segments.length === 0) {
if (invertCutSegments) headerText = t('Make sure you have no overlapping segments.');
else headerText = t('No segments to export.');
if (invertCutSegments) header = <Trans>You have enabled the &quot;invert segments&quot; mode <FaYinYang style={{ verticalAlign: 'middle' }} /> which will cut away selected segments instead of keeping them. But there is no space between any segments, or at least two segments are overlapping. This would not produce any output. Either make room between segments or click the Yinyang <FaYinYang style={{ verticalAlign: 'middle' }} /> symbol below to disable this mode.</Trans>;
else header = t('No segments to export.');
}
async function onReorderSegs(index) {
@ -264,7 +264,7 @@ const SegmentList = memo(({
onClick={toggleSegmentsList}
/>
{headerText}
{header}
</div>
<ReactSortable list={sortableList} setList={setSortableList} sort={!invertCutSegments}>

Wyświetl plik

@ -46,7 +46,8 @@ export function hasAnySegmentOverlap(sortedSegments) {
return sortedSegments.some((cutSegment, i) => {
if (i === 0) return false;
return sortedSegments[i - 1].end > cutSegment.start;
const previousSeg = sortedSegments[i - 1];
return previousSeg.end > cutSegment.start;
});
}