Skip to content

Fix Merge two subtitles: keep ASSA styles and split tracks by layer#11257

Merged
niksedk merged 1 commit into
mainfrom
fix/merge-two-subtitles-assa-styles
May 29, 2026
Merged

Fix Merge two subtitles: keep ASSA styles and split tracks by layer#11257
niksedk merged 1 commit into
mainfrom
fix/merge-two-subtitles-assa-styles

Conversation

@niksedk
Copy link
Copy Markdown
Member

@niksedk niksedk commented May 29, 2026

@

Problem

When using Tools → Merge two subtitles with the Advanced SubStation Alpha output, the merged result lost its styling after being loaded into the main grid: only a single style appeared and no paragraph carried a style, so top/bottom positioning could not work.

Root cause

In MainViewModel.ShowToolsMergeTwoSubtitles:

  1. Styles dropped from paragraphs — the ASSA format was selected after SetSubtitles built the row view models. SubtitleLineViewModel only copies the style (Extra) into its Style property when the active format is AdvancedSubStationAlpha, so the rows ended up with an empty Style and ToParagraph wrote no style on save.
  2. Header dropped — the merged header (containing Style1/Style2) was never transferred to _subtitle, so only the default header style survived. The other merge tools already do _subtitle.Header = result.ResultSubtitle.Header; this one did not.

The merge logic itself (MergeTwoSubtitlesViewModel.BuildAssaMerge) was verified to produce correct output (two styles with an8/an2 alignment, events referencing the right style) — the loss happened only on consumption.

Fix

  • Select the output format before building the rows, so the style is copied into each row.
  • Carry the merged header over to _subtitle.
  • Put each merged track on its own layer (0 and 1) so the two streams do not collide/stack against each other when shown at the same time. Vertical placement still comes from the per-style alignment (an8 top / an2 bottom).

Testing

  • Verified the libse serialization produces both styles with correct alignment and per-event layers.
  • UI project builds clean (0 warnings, 0 errors).

🤖 Generated with Claude Code
@

When merging two subtitles to Advanced SubStation Alpha, the result lost
its styling: the grid showed only a single style and no paragraph carried
a style.

Two causes in MainViewModel.ShowToolsMergeTwoSubtitles:
- The ASSA format was selected after SetSubtitles built the row view
  models, so SubtitleLineViewModel never copied the style (Extra) into
  Style (it only does so for AdvancedSubStationAlpha). Set the format
  before building the rows.
- The merged header (Style1/Style2) was never transferred to _subtitle,
  so only the default header style survived. Carry the header over, like
  the other tools do.

Also put each merged track on its own layer (0 and 1) so the two streams
do not collide/stack against each other when shown at the same time. The
top/bottom positioning still comes from the per-style alignment (an8/an2).

Co-Authored-By: Claude Opus 4.8 (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

Fixes ASSA style/header loss when using Tools → Merge two subtitles. The output format is now selected before building row view models so per-paragraph styles are copied, the merged header (with Style1/Style2) is propagated to _subtitle, and each track is placed on its own layer to prevent visual collision.

Changes:

  • Reorder SetSubtitleFormat/SetSubtitles and copy ResultSubtitle.Header to _subtitle in ShowToolsMergeTwoSubtitles.
  • Assign distinct layers (0 and 1) to merged paragraphs in BuildAssaMerge.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/ui/Features/Main/MainViewModel.cs Set format before building rows; carry merged header to _subtitle.
src/ui/Features/Tools/MergeTwoSubtitles/MergeTwoSubtitlesViewModel.cs Assign per-track layers (0/1) to avoid overlap.

@niksedk niksedk merged commit 8cfaf31 into main May 29, 2026
4 checks passed
@niksedk niksedk deleted the fix/merge-two-subtitles-assa-styles branch May 29, 2026 16:55
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.

2 participants