Fixed issue #1074: PaintTree with poUnbuffered misplaces nodes under a mapping mode - #1384
Open
TetzkatLipHoka wants to merge 1 commit into
Open
Fixed issue #1074: PaintTree with poUnbuffered misplaces nodes under a mapping mode#1384TetzkatLipHoka wants to merge 1 commit into
TetzkatLipHoka wants to merge 1 commit into
Conversation
…nodes under a mapping mode SetCanvasOrigin() transformed its shift through LPtoDP before passing it to SetWindowOrgEx. SetWindowOrgEx however expects logical units - the same units the tree calculates with - so on a canvas with a mapping mode (the issue uses MM_ANISOTROPIC with a 2x viewport) the shift was scaled twice and every node was drawn at twice its offset: node contents, tree lines, buttons and grid lines all drifted apart, exactly as shown in the issue. With the default MM_TEXT mapping the transformation was a no-op, which is why the ordinary paint paths never showed the problem. Pass the shift to SetWindowOrgEx untransformed. Measured offscreen (2x MM_ANISOTROPIC): after the fix the unbuffered rendering places all grid lines and tree lines pixel-identical to the buffered rendering, and exactly at twice the unmapped positions; the MM_TEXT rendering is byte-identical to the one before the fix. New regression test Tests/VTPaintTreeIssue1074Tests.pas asserts both properties; without the fix both assertions fail. Test suite: 2 pre-existing failures (TestCopyHTML1/2, also failing on unmodified master), no new failures. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1074.
Cause
SetCanvasOrigin()in VirtualTrees.Utils.pas transformed its shift throughLPtoDPbefore passing it toSetWindowOrgEx:SetWindowOrgExhowever expects logical units — the same units the tree calculates with. On a canvas with a mapping mode (the issue usesMM_ANISOTROPICwith a 2x viewport) the shift therefore got scaled twice, so the unbuffered paint path drew every node at twice its offset: node contents, tree lines, buttons and grid lines all drift apart, exactly as shown in the issue's screenshot. With the defaultMM_TEXTmappingLPtoDPis the identity, which is why the ordinary paint paths never showed the problem.Fix
Pass the shift to
SetWindowOrgExuntransformed.Verification (all measured offscreen via pixel analysis)
MM_ANISOTROPICmapping, the unbuffered rendering now places all grid lines and tree lines pixel-identical to the buffered rendering, and exactly at twice the unmapped positions.MM_TEXTrendering is byte-identical to the one before the fix — no change for normal painting.TBaseVirtualTree.Printis unaffected: it renders into an unmapped bitmap and scales viaStretchBlt.Tests/VTPaintTreeIssue1074Tests.pasasserts both properties (unbuffered = buffered under mapping, mapped = 2x unmapped); without the fix both assertions fail. Full suite: no new failures (the twoTestCopyHTMLfailures also occur on unmodified master).🤖 Generated with Claude Code