Skip to content

Remember the splitter position in image compare - #39

Merged
sdottaka merged 1 commit into
WinMerge:masterfrom
Ikkoru:splitter-position
Aug 30, 2026
Merged

sdottaka merged 1 commit into
WinMerge:masterfrom
Ikkoru:splitter-position

Conversation

@Ikkoru

@Ikkoru Ikkoru commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Refs WinMerge/winmerge#3591

CalcChildImgWindowRect() rebuilds an equal split on every layout, so a dragged splitter is discarded on the next WM_SIZE. This stores the position in CImgMergeWindow and consults it when laying out two panes.

m_splitterPosition holds the size of whichever pane is smaller, signed: positive sizes the first pane from the near edge, negative sizes the second from the far edge. Anchoring the first pane unconditionally would preserve a narrow strip only on the left; a narrow right-hand pane would grow on resize.

CalcSplitterPosition() reproduces the bounds MoveSplitter() already enforces, so a restored layout equals the dragged one. The clamp is returned rather than written back, because the window is laid out once during creation before it has its final size. Windows too small to give both panes 32px fall back to the equal split.

SetHorizontalSplit() clears the value when the orientation changes, so a width is never applied as a height.

Two panes only; three-pane compare is unchanged.

GetSplitterPosition() / SetSplitterPosition() are appended to IImgMergeWindow, leaving the existing vtable order unchanged.

Alternatives, if you would prefer them: a fraction of the window instead of pixels; anchoring the first pane instead of the smaller one; a per-orientation pair of values instead of clearing on toggle; a position per splitter for three-pane.

Built and tested on Windows 11 x64, VS Build Tools 2026, Release, in both the standalone app and a WinMerge build carrying the matching options change. Position kept across resize, maximize/restore, reopening a comparison and restart, with the narrow pane on either side. Default centred layout is unchanged when the splitter has never been dragged. 32px minimum kept.

CalcChildImgWindowRect() rebuilt an equal split on every layout, so a
dragged splitter was lost on the next WM_SIZE. Store the position in
CImgMergeWindow and consult it when laying out two panes.

m_splitterPosition holds the size of whichever pane is smaller, signed:
positive anchors the first pane to the near edge, negative anchors the
second to the far edge. This keeps a narrow pane narrow on either side of
the splitter when the window is resized.

Expose it through IImgMergeWindow so a host can persist it. The new
methods are appended so the existing vtable order is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sdottaka

Copy link
Copy Markdown
Member

Thank you!

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