Skip to content

Add frame-based min-gap setting (#11084)#11099

Merged
niksedk merged 3 commits into
mainfrom
min-gap-frames-11084
May 22, 2026
Merged

Add frame-based min-gap setting (#11084)#11099
niksedk merged 3 commits into
mainfrom
min-gap-frames-11084

Conversation

@niksedk
Copy link
Copy Markdown
Member

@niksedk niksedk commented May 22, 2026

Summary

  • Adds a frame value alongside the existing ms value for the minimum gap between lines, stored together in a new MsOrFramesValue wrapper on SeGeneral.
  • When UseFrameMode is on, the Settings UI shows a frames input (with the ms equivalent rendered next to it at lower opacity); when off, the existing ms input is shown. The row label swaps to match.
  • All consumers of the old MinimumMillisecondsBetweenLines (~30 sites across MainViewModel, BinaryEdit, AudioVisualizer, InsertService, etc.) now go through MinimumBetweenLines.GetMilliseconds() so frame mode actually takes effect, and the two libse-sync sites push the effective ms through too.

Closes #11084.

Test plan

  • Toggle Use frame mode in Settings → General; confirm the Min gap row label changes between "Min gap (ms)" and "Min gap (frames)" and that the right control + the "= N ms" hint appears.
  • In frame mode, set Min gap to 2 frames at 23.976 fps and verify the hint shows 83 ms.
  • Switch the project frame rate; confirm the hint updates and that gap enforcement (e.g. paste from clipboard, apply min gaps) uses the new ms value.
  • Settings load/save round-trip preserves both Milliseconds and Frames.

⚠️ Settings.json migration: the old top-level MinimumMillisecondsBetweenLines key is no longer mapped, so users with a customized value will reset to the default (24 ms / 2 frames). Happy to add a setter-only legacy property if you want to preserve it.

🤖 Generated with Claude Code

niksedk and others added 2 commits May 22, 2026 10:34
Wraps the min-gap between lines in an MsOrFramesValue that stores both
a millisecond and a frame value. When UseFrameMode is on, the frame
value is converted to ms via the current frame rate; otherwise the ms
value is used directly. The Settings UI swaps label and control based
on the mode, and shows the ms equivalent next to the frame input.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a frame-based alternative for the “minimum gap between lines” setting, so gap enforcement can respect Use frame mode while still preserving a millisecond value for non-frame workflows.

Changes:

  • Introduces MsOrFramesValue and replaces MinimumMillisecondsBetweenLines with MinimumBetweenLines in general settings.
  • Updates many min-gap consumers to use MinimumBetweenLines.GetMilliseconds() so frame mode affects enforcement.
  • Extends Settings UI/localization to show a frames input + ms equivalent hint when frame mode is enabled.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/ui/Logic/UiUtil.cs Adds generic WithBindIsVisible helpers used by the Settings UI.
src/ui/Logic/SubtitleGridCopyPasteHelper.cs Uses effective min-gap ms when pasting to compute insert timing.
src/ui/Logic/ISplitManager.cs Uses effective min-gap ms when splitting subtitles.
src/ui/Logic/InsertService.cs Uses effective min-gap ms when inserting before/after.
src/ui/Logic/Config/SeGeneral.cs Replaces min-gap ms setting with MsOrFramesValue wrapper and default.
src/ui/Logic/Config/MsOrFramesValue.cs New wrapper storing ms+frames and computing effective ms in frame mode.
src/ui/Logic/Config/Language/Options/LanguageSettings.cs Adds localized label for “Min gap (frames)”.
src/ui/Features/Video/CutVideo/CutVideoViewModel.cs Uses effective min-gap ms for cut navigation constraints.
src/ui/Features/Tools/FixCommonErrors/FixCommonErrorsViewModel.cs Pushes effective min-gap ms into libse settings for tools.
src/ui/Features/Tools/ApplyMinGap/ApplyMinGapViewModel.cs Loads min-gap value in frames vs ms depending on frame mode.
src/ui/Features/Tools/ApplyDurationLimits/ApplyDurationLimitsViewModel.cs Uses effective min-gap ms when capping end times.
src/ui/Features/Shared/BinaryEdit/BinaryEditViewModel.cs Uses effective min-gap ms when adjusting binary subtitle timings.
src/ui/Features/Options/Settings/SettingsViewModel.cs Adds frame-mode min-gap fields, label swap, and ms-equivalent hint.
src/ui/Features/Options/Settings/SettingsPage.cs Updates Settings UI row to swap ms/frames inputs and show hint in frame mode.
src/ui/Features/Options/Settings/SettingsItem.cs Adds optional label text binding support for dynamic labels.
src/ui/Features/Options/Settings/ProfileDisplay.cs Maps profile min-gap to the ms slot of the new wrapper.
src/ui/Features/Main/SubtitleLineViewModel.cs Uses effective min-gap ms for gap warnings/errors.
src/ui/Features/Main/MainViewModel.cs Pushes effective min-gap ms into libse and updates various enforcement sites.
src/ui/Features/Main/MainHelpers/PasteFromClipboardHelper.cs Uses effective min-gap ms when generating timings from plain text paste.
src/ui/Features/Main/Layout/InitWaveform.cs Uses effective min-gap ms to configure waveform min-gap display.
src/ui/Features/Files/ImportPlainText/ScriptSyncService.cs Uses effective min-gap ms for script sync constraints.
src/ui/Features/Files/ImportPlainText/ImportPlainTextViewModel.cs Uses effective min-gap ms for import defaults.
src/ui/Controls/AudioVisualizerControl/AudioVisualizer.cs Uses effective min-gap ms when generating timecodes.

Comment on lines 5128 to 5133
Se.Settings.General.SubtitleLineMaximumLength = p.SubtitleLineMaximumLength;
Se.Settings.General.SubtitleMaximumCharactersPerSeconds = (double)p.SubtitleMaximumCharactersPerSeconds;
Se.Settings.General.SubtitleOptimalCharactersPerSeconds = (double)p.SubtitleOptimalCharactersPerSeconds;
Se.Settings.General.SubtitleMaximumWordsPerMinute = (double)p.SubtitleMaximumWordsPerMinute;
Se.Settings.General.MinimumMillisecondsBetweenLines = p.MinimumMillisecondsBetweenLines;
Se.Settings.General.MinimumBetweenLines.Milliseconds = p.MinimumMillisecondsBetweenLines;
Se.Settings.General.MaxNumberOfLines = p.MaxNumberOfLines;
Comment on lines +58 to +70
public string MinGapFramesAsMs
{
get
{
if (!MinGapFrames.HasValue)
{
return string.Empty;
}

var fps = Configuration.Settings.General.CurrentFrameRate;
var ms = SubtitleFormat.FramesToMilliseconds(MinGapFrames.Value, fps);
return $"= {ms} ms (at {fps.ToString("0.###", CultureInfo.InvariantCulture)} fps)";
}
Comment thread src/ui/Logic/UiUtil.cs
Comment on lines +1197 to +1214
public static T WithBindIsVisible<T>(this T control, string isVisiblePropertyPath) where T : Control
{
control.Bind(Visual.IsVisibleProperty, new Binding
{
Path = isVisiblePropertyPath,
Mode = BindingMode.TwoWay,
});

return control;
}

public static T WithBindIsVisible<T>(this T control, object source, string isVisiblePropertyPath) where T : Control
{
control.Bind(Visual.IsVisibleProperty, new Binding(isVisiblePropertyPath)
{
Source = source,
Mode = BindingMode.TwoWay,
});
Comment on lines +35 to +41
public SettingsItem(string label, object labelBindingSource, string labelBindingPath, Func<Control> controlFactory)
{
_label = label;
_controlFactory = controlFactory;
_labelBindingSource = labelBindingSource;
_labelBindingPath = labelBindingPath;
}
- Profile selection now updates both Milliseconds and Frames so
  frame-mode users see profile-driven min-gap changes too.
- OneWay binding for the new generic WithBindIsVisible helpers
  (IsVisible is sink-only — TwoWay caused write-back errors on
  computed properties like IsMsMode).
- Include both unit variants of the min-gap label in the filter
  string so search matches whether the user sees "ms" or "frames".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@niksedk niksedk merged commit 149efb5 into main May 22, 2026
1 of 3 checks passed
@niksedk niksedk deleted the min-gap-frames-11084 branch May 22, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[suggestion] Option to use frames instead of milliseconds in all settings

2 participants