mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2025-02-01 05:21:40 +01:00
Add new "Snap to Scene Change" shortcuts
This commit is contained in:
parent
64451e3570
commit
ec28d9bbe4
@ -2033,6 +2033,10 @@ can edit in same subtitle file (collaboration)</Information>
|
||||
<AdjustSetEndAndOffsetTheRest>Set end, offset the rest</AdjustSetEndAndOffsetTheRest>
|
||||
<AdjustSetEndAndOffsetTheRestAndGoToNext>Set end, offset the rest and go to next</AdjustSetEndAndOffsetTheRestAndGoToNext>
|
||||
<AdjustExtendCurrentSubtitle>Extend current line to next subtitle or max duration</AdjustExtendCurrentSubtitle>
|
||||
<AdjustSnapStartToNextSceneChange>Snap selected lines start to next scene change</AdjustSnapStartToNextSceneChange>
|
||||
<AdjustSnapStartToNextSceneChangeWithGap>Snap selected lines start to next scene change with min. gap</AdjustSnapStartToNextSceneChangeWithGap>
|
||||
<AdjustSnapEndToPreviousSceneChange>Snap selected lines end to previous scene change</AdjustSnapEndToPreviousSceneChange>
|
||||
<AdjustSnapEndToPreviousSceneChangeWithGap>Snap selected lines end to previous scene change with min. gap</AdjustSnapEndToPreviousSceneChangeWithGap>
|
||||
<AdjustExtendToNextSceneChange>Extend selected lines to next scene change (or next subtitle)</AdjustExtendToNextSceneChange>
|
||||
<AdjustExtendToNextSceneChangeWithGap>Extend selected lines to next scene change with min. gap (or next subtitle)</AdjustExtendToNextSceneChangeWithGap>
|
||||
<AdjustExtendToPreviousSceneChange>Extend selected lines to previous scene change (or previous subtitle)</AdjustExtendToPreviousSceneChange>
|
||||
|
@ -2327,6 +2327,10 @@ can edit in same subtitle file (collaboration)",
|
||||
AdjustSetEndAndOffsetTheRest = "Set end, offset the rest",
|
||||
AdjustSetEndAndOffsetTheRestAndGoToNext = "Set end, offset the rest and go to next",
|
||||
AdjustExtendCurrentSubtitle = "Extend current line to next subtitle or max duration",
|
||||
AdjustSnapStartToNextSceneChange = "Snap selected lines start to next scene change",
|
||||
AdjustSnapStartToNextSceneChangeWithGap = "Snap selected lines start to next scene change with min. gap",
|
||||
AdjustSnapEndToPreviousSceneChange = "Snap selected lines end to previous scene change",
|
||||
AdjustSnapEndToPreviousSceneChangeWithGap = "Snap selected lines end to previous scene change with min. gap",
|
||||
AdjustExtendToNextSceneChange = "Extend selected lines to next scene change (or next subtitle)",
|
||||
AdjustExtendToNextSceneChangeWithGap = "Extend selected lines to next scene change with min. gap (or next subtitle)",
|
||||
AdjustExtendToPreviousSceneChange = "Extend selected lines to previous scene change (or previous subtitle)",
|
||||
|
@ -5521,6 +5521,18 @@ namespace Nikse.SubtitleEdit.Core
|
||||
case "Settings/AdjustExtendCurrentSubtitle":
|
||||
language.Settings.AdjustExtendCurrentSubtitle = reader.Value;
|
||||
break;
|
||||
case "Settings/AdjustSnapStartToNextSceneChange":
|
||||
language.Settings.AdjustSnapStartToNextSceneChange = reader.Value;
|
||||
break;
|
||||
case "Settings/AdjustSnapStartToNextSceneChangeWithGap":
|
||||
language.Settings.AdjustSnapStartToNextSceneChangeWithGap = reader.Value;
|
||||
break;
|
||||
case "Settings/AdjustSnapEndToPreviousSceneChange":
|
||||
language.Settings.AdjustSnapEndToPreviousSceneChange = reader.Value;
|
||||
break;
|
||||
case "Settings/AdjustSnapEndToPreviousSceneChangeWithGap":
|
||||
language.Settings.AdjustSnapEndToPreviousSceneChangeWithGap = reader.Value;
|
||||
break;
|
||||
case "Settings/AdjustExtendToNextSceneChange":
|
||||
language.Settings.AdjustExtendToNextSceneChange = reader.Value;
|
||||
break;
|
||||
|
@ -2199,6 +2199,10 @@
|
||||
public string AdjustSetEndAndOffsetTheRest { get; set; }
|
||||
public string AdjustSetEndAndOffsetTheRestAndGoToNext { get; set; }
|
||||
public string AdjustExtendCurrentSubtitle { get; set; }
|
||||
public string AdjustSnapStartToNextSceneChange { get; set; }
|
||||
public string AdjustSnapStartToNextSceneChangeWithGap { get; set; }
|
||||
public string AdjustSnapEndToPreviousSceneChange { get; set; }
|
||||
public string AdjustSnapEndToPreviousSceneChangeWithGap { get; set; }
|
||||
public string AdjustExtendToNextSceneChange { get; set; }
|
||||
public string AdjustExtendToNextSceneChangeWithGap { get; set; }
|
||||
public string AdjustExtendToPreviousSceneChange { get; set; }
|
||||
|
@ -15,6 +15,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
// ...but the built-in serialization is too slow - so a custom (de-)serialization has been used!
|
||||
|
||||
public class RecentFileEntry
|
||||
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
public string OriginalFileName { get; set; }
|
||||
@ -1914,6 +1915,10 @@ $HorzAlign = Center
|
||||
public string MoveStartOneFrameForwardKeepGapPrev { get; set; }
|
||||
public string MoveEndOneFrameBackKeepGapNext { get; set; }
|
||||
public string MoveEndOneFrameForwardKeepGapNext { get; set; }
|
||||
public string MainAdjustSnapStartToNextSceneChange { get; set; }
|
||||
public string MainAdjustSnapStartToNextSceneChangeWithGap { get; set; }
|
||||
public string MainAdjustSnapEndToPreviousSceneChange { get; set; }
|
||||
public string MainAdjustSnapEndToPreviousSceneChangeWithGap { get; set; }
|
||||
public string MainAdjustExtendToNextSceneChange { get; set; }
|
||||
public string MainAdjustExtendToNextSceneChangeWithGap { get; set; }
|
||||
public string MainAdjustExtendToPreviousSceneChange { get; set; }
|
||||
@ -2076,6 +2081,10 @@ $HorzAlign = Center
|
||||
Waveform1000MsLeft = "Left";
|
||||
Waveform1000MsRight = "Right";
|
||||
MainTranslateGoogleTranslate = "Control+Shift+G";
|
||||
MainAdjustSnapStartToNextSceneChange = string.Empty;
|
||||
MainAdjustSnapStartToNextSceneChangeWithGap = string.Empty;
|
||||
MainAdjustSnapEndToPreviousSceneChange = string.Empty;
|
||||
MainAdjustSnapEndToPreviousSceneChangeWithGap = string.Empty;
|
||||
MainAdjustExtendToNextSceneChange = string.Empty;
|
||||
MainAdjustExtendToNextSceneChangeWithGap = string.Empty;
|
||||
MainAdjustExtendToPreviousSceneChange = string.Empty;
|
||||
@ -6903,6 +6912,30 @@ $HorzAlign = Center
|
||||
settings.Shortcuts.MoveEndOneFrameForwardKeepGapNext = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainAdjustSnapStartToNextSceneChange");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.Shortcuts.MainAdjustSnapStartToNextSceneChange = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainAdjustSnapStartToNextSceneChangeWithGap");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.Shortcuts.MainAdjustSnapStartToNextSceneChangeWithGap = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainAdjustSnapEndToPreviousSceneChange");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.Shortcuts.MainAdjustSnapEndToPreviousSceneChange = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainAdjustSnapEndToPreviousSceneChangeWithGap");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.Shortcuts.MainAdjustSnapEndToPreviousSceneChangeWithGap = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainAdjustExtendToNextSceneChange");
|
||||
if (subNode != null)
|
||||
{
|
||||
@ -8181,6 +8214,10 @@ $HorzAlign = Center
|
||||
textWriter.WriteElementString("MoveStartOneFrameForwardKeepGapPrev", settings.Shortcuts.MoveStartOneFrameForwardKeepGapPrev);
|
||||
textWriter.WriteElementString("MoveEndOneFrameBackKeepGapNext", settings.Shortcuts.MoveEndOneFrameBackKeepGapNext);
|
||||
textWriter.WriteElementString("MoveEndOneFrameForwardKeepGapNext", settings.Shortcuts.MoveEndOneFrameForwardKeepGapNext);
|
||||
textWriter.WriteElementString("MainAdjustSnapStartToNextSceneChange", settings.Shortcuts.MainAdjustSnapStartToNextSceneChange);
|
||||
textWriter.WriteElementString("MainAdjustSnapStartToNextSceneChangeWithGap", settings.Shortcuts.MainAdjustSnapStartToNextSceneChangeWithGap);
|
||||
textWriter.WriteElementString("MainAdjustSnapEndToPreviousSceneChange", settings.Shortcuts.MainAdjustSnapEndToPreviousSceneChange);
|
||||
textWriter.WriteElementString("MainAdjustSnapEndToPreviousSceneChangeWithGap", settings.Shortcuts.MainAdjustSnapEndToPreviousSceneChangeWithGap);
|
||||
textWriter.WriteElementString("MainAdjustExtendToNextSceneChange", settings.Shortcuts.MainAdjustExtendToNextSceneChange);
|
||||
textWriter.WriteElementString("MainAdjustExtendToNextSceneChangeWithGap", settings.Shortcuts.MainAdjustExtendToNextSceneChangeWithGap);
|
||||
textWriter.WriteElementString("MainAdjustExtendToPreviousSceneChange", settings.Shortcuts.MainAdjustExtendToPreviousSceneChange);
|
||||
|
@ -14749,6 +14749,26 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
ExtendSelectedLinesToPreviousLine();
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (_shortcuts.MainAdjustSnapStartToNextSceneChange == e.KeyData)
|
||||
{
|
||||
SnapSelectedLinesStartToNextSceneChange();
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (_shortcuts.MainAdjustSnapStartToNextSceneChangeWithGap == e.KeyData)
|
||||
{
|
||||
SnapSelectedLinesStartToNextSceneChange(true);
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (_shortcuts.MainAdjustSnapEndToPreviousSceneChange == e.KeyData)
|
||||
{
|
||||
SnapSelectedLinesEndToPreviousSceneChange();
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (_shortcuts.MainAdjustSnapEndToPreviousSceneChangeWithGap == e.KeyData)
|
||||
{
|
||||
SnapSelectedLinesEndToPreviousSceneChange(true);
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (_shortcuts.MainAdjustExtendToNextSceneChange == e.KeyData)
|
||||
{
|
||||
ExtendSelectedLinesToNextSceneChange();
|
||||
@ -15123,6 +15143,140 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void SnapSelectedLinesStartToNextSceneChange(bool withGap = false)
|
||||
{
|
||||
var historyAdded = false;
|
||||
foreach (ListViewItem selectedItem in SubtitleListview1.SelectedItems)
|
||||
{
|
||||
var idx = selectedItem.Index;
|
||||
var p = _subtitle.Paragraphs[idx];
|
||||
List<double> nextSceneChanges = audioVisualizer.SceneChanges.Count > 0 ? audioVisualizer.SceneChanges.Where(x => x > p.StartTime.TotalSeconds + 0.01).ToList() : new List<double>();
|
||||
if (nextSceneChanges.Count > 0)
|
||||
{
|
||||
double nearestSceneChange = nextSceneChanges.Aggregate((x, y) => Math.Abs(x - p.StartTime.TotalSeconds) < Math.Abs(y - p.StartTime.TotalSeconds) ? x : y);
|
||||
|
||||
if (!historyAdded)
|
||||
{
|
||||
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustSnapStartToNextSceneChange));
|
||||
historyAdded = true;
|
||||
}
|
||||
|
||||
if (!withGap)
|
||||
{
|
||||
if (nearestSceneChange * 1000 < p.EndTime.TotalMilliseconds)
|
||||
{
|
||||
p.StartTime.TotalMilliseconds = nearestSceneChange * 1000;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nearestSceneChange * 1000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines < p.EndTime.TotalMilliseconds)
|
||||
{
|
||||
p.StartTime.TotalMilliseconds = nearestSceneChange * 1000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
}
|
||||
}
|
||||
|
||||
if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle)
|
||||
{
|
||||
var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs);
|
||||
if (original != null)
|
||||
{
|
||||
if (!historyAdded)
|
||||
{
|
||||
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustSnapStartToNextSceneChange));
|
||||
historyAdded = true;
|
||||
}
|
||||
|
||||
if (!withGap)
|
||||
{
|
||||
if (nearestSceneChange * 1000 < p.EndTime.TotalMilliseconds)
|
||||
{
|
||||
original.StartTime.TotalMilliseconds = nearestSceneChange * 1000;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nearestSceneChange * 1000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines < p.EndTime.TotalMilliseconds)
|
||||
{
|
||||
original.StartTime.TotalMilliseconds = nearestSceneChange * 1000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RefreshSelectedParagraphs();
|
||||
}
|
||||
}
|
||||
|
||||
private void SnapSelectedLinesEndToPreviousSceneChange(bool withGap = false)
|
||||
{
|
||||
var historyAdded = false;
|
||||
foreach (ListViewItem selectedItem in SubtitleListview1.SelectedItems)
|
||||
{
|
||||
var idx = selectedItem.Index;
|
||||
var p = _subtitle.Paragraphs[idx];
|
||||
List<double> previousSceneChanges = audioVisualizer.SceneChanges.Count > 0 ? audioVisualizer.SceneChanges.Where(x => x < p.EndTime.TotalSeconds + 0.01).ToList() : new List<double>();
|
||||
if (previousSceneChanges.Count > 0)
|
||||
{
|
||||
double nearestSceneChange = previousSceneChanges.Aggregate((x, y) => Math.Abs(x - p.EndTime.TotalSeconds) < Math.Abs(y - p.EndTime.TotalSeconds) ? x : y);
|
||||
|
||||
if (!historyAdded)
|
||||
{
|
||||
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustSnapEndToPreviousSceneChange));
|
||||
historyAdded = true;
|
||||
}
|
||||
|
||||
if (!withGap)
|
||||
{
|
||||
if (nearestSceneChange * 1000 > p.StartTime.TotalMilliseconds)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = nearestSceneChange * 1000;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nearestSceneChange * 1000 - Configuration.Settings.General.MinimumMillisecondsBetweenLines > p.StartTime.TotalMilliseconds)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = nearestSceneChange * 1000 - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
}
|
||||
}
|
||||
|
||||
if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle)
|
||||
{
|
||||
var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs);
|
||||
if (original != null)
|
||||
{
|
||||
if (!historyAdded)
|
||||
{
|
||||
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustSnapEndToPreviousSceneChange));
|
||||
historyAdded = true;
|
||||
}
|
||||
|
||||
if (!withGap)
|
||||
{
|
||||
if (nearestSceneChange * 1000 > p.StartTime.TotalMilliseconds)
|
||||
{
|
||||
original.EndTime.TotalMilliseconds = nearestSceneChange * 1000;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nearestSceneChange * 1000 - Configuration.Settings.General.MinimumMillisecondsBetweenLines > p.StartTime.TotalMilliseconds)
|
||||
{
|
||||
original.EndTime.TotalMilliseconds = nearestSceneChange * 1000 - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RefreshSelectedParagraphs();
|
||||
}
|
||||
}
|
||||
|
||||
private void ExtendSelectedLinesToNextSceneChange(bool withGap = false)
|
||||
{
|
||||
var historyAdded = false;
|
||||
|
@ -1365,6 +1365,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
AddNode(createAndAdjustNode, language.AdjustEndOneFrameBackKeepGapNext, nameof(Configuration.Settings.Shortcuts.MoveEndOneFrameBackKeepGapNext));
|
||||
AddNode(createAndAdjustNode, language.AdjustEndOneFrameForwardKeepGapNext, nameof(Configuration.Settings.Shortcuts.MoveEndOneFrameForwardKeepGapNext));
|
||||
AddNode(createAndAdjustNode, language.RecalculateDurationOfCurrentSubtitle, nameof(Configuration.Settings.Shortcuts.GeneralAutoCalcCurrentDuration));
|
||||
AddNode(createAndAdjustNode, language.AdjustSnapStartToNextSceneChange, nameof(Configuration.Settings.Shortcuts.MainAdjustSnapStartToNextSceneChange));
|
||||
AddNode(createAndAdjustNode, language.AdjustSnapStartToNextSceneChangeWithGap, nameof(Configuration.Settings.Shortcuts.MainAdjustSnapStartToNextSceneChangeWithGap));
|
||||
AddNode(createAndAdjustNode, language.AdjustSnapEndToPreviousSceneChange, nameof(Configuration.Settings.Shortcuts.MainAdjustSnapEndToPreviousSceneChange));
|
||||
AddNode(createAndAdjustNode, language.AdjustSnapEndToPreviousSceneChangeWithGap, nameof(Configuration.Settings.Shortcuts.MainAdjustSnapEndToPreviousSceneChangeWithGap));
|
||||
AddNode(createAndAdjustNode, language.AdjustExtendToNextSceneChange, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToNextSceneChange));
|
||||
AddNode(createAndAdjustNode, language.AdjustExtendToNextSceneChangeWithGap, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToNextSceneChangeWithGap));
|
||||
AddNode(createAndAdjustNode, language.AdjustExtendToPreviousSceneChange, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToPreviousSceneChange));
|
||||
|
@ -114,6 +114,10 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public Keys MainAdjustMoveStartOneFrameForwardKeepGapPrev { get; set; }
|
||||
public Keys MainAdjustMoveEndOneFrameBackKeepGapNext { get; set; }
|
||||
public Keys MainAdjustMoveEndOneFrameForwardKeepGapNext { get; set; }
|
||||
public Keys MainAdjustSnapStartToNextSceneChange { get; set; }
|
||||
public Keys MainAdjustSnapStartToNextSceneChangeWithGap { get; set; }
|
||||
public Keys MainAdjustSnapEndToPreviousSceneChange { get; set; }
|
||||
public Keys MainAdjustSnapEndToPreviousSceneChangeWithGap { get; set; }
|
||||
public Keys MainAdjustExtendToNextSceneChange { get; set; }
|
||||
public Keys MainAdjustExtendToNextSceneChangeWithGap { get; set; }
|
||||
public Keys MainAdjustExtendToPreviousSceneChange { get; set; }
|
||||
@ -298,6 +302,10 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
MainAdjustMoveStartOneFrameForwardKeepGapPrev = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MoveStartOneFrameForwardKeepGapPrev);
|
||||
MainAdjustMoveEndOneFrameBackKeepGapNext = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MoveEndOneFrameBackKeepGapNext);
|
||||
MainAdjustMoveEndOneFrameForwardKeepGapNext = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MoveEndOneFrameForwardKeepGapNext);
|
||||
MainAdjustSnapStartToNextSceneChange = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainAdjustSnapStartToNextSceneChange);
|
||||
MainAdjustSnapStartToNextSceneChangeWithGap = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainAdjustSnapStartToNextSceneChangeWithGap);
|
||||
MainAdjustSnapEndToPreviousSceneChange = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainAdjustSnapEndToPreviousSceneChange);
|
||||
MainAdjustSnapEndToPreviousSceneChangeWithGap = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainAdjustSnapEndToPreviousSceneChangeWithGap);
|
||||
MainAdjustExtendToNextSceneChange = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainAdjustExtendToNextSceneChange);
|
||||
MainAdjustExtendToNextSceneChangeWithGap = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainAdjustExtendToNextSceneChangeWithGap);
|
||||
MainAdjustExtendToPreviousSceneChange = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainAdjustExtendToPreviousSceneChange);
|
||||
|
Loading…
x
Reference in New Issue
Block a user