[#12795] Fix logic statements rendering oversized for one frame after creation
自动翻译暂时不可用
本帖暂时展示 GitHub 原始内容。
Fixes #12757
Problem
Newly created logic statements render oversized for a single frame, then snap back to their correct size. Reproducible every time: open a processor's logic editor and create any wrapping statement (e.g. set, op).
Cause
Statements whose content uses a wrapping table (LStatement#useWrapping()) get their preferred height computed by WrapTable before its width is known. With no prior layout, WrapTable#computeSize() assumes rows wrap at the widest single cell, so the content table reports a much larger height than its final laid-out height (e.g. ~109 units instead of ~44 for a set statement). DragLayout sizes the new StatementElem from that stale value on the first frame; WrapTable corrects itself once laid out at the real width, and the canvas snaps to the correct size on the next frame.
Fix
Pre-lay out the content table at its final width in the StatementElem constructor, so its preferred height is correct the first time DragLayout measures it. Only applies to wrapping tables; regular tables are unaffected.
Verification
Reproduced on a local build before the change: logging element size on the first two draw calls showed h=160 then h=95 for a set statement. After the change, the first frame size matches the final size (h=95 on both frames, same for op statements), confirmed by the same logging and visually in game on Windows.
Note: this fix was developed with AI assistance (root cause analysis and patch), as allowed and disclosed per the AI policy in CONTRIBUTING. The change was built and tested locally as described above.
由 MDT GitHub 同步机器人自动同步。