[Bug 59602] New: Nested `UserControl` is not properly rescaled on font change
http://bugs.winehq.org/show_bug.cgi?id=59602 Bug ID: 59602 Summary: Nested `UserControl` is not properly rescaled on font change Product: Framework Mono Version: 6.12.0 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: System.Windows.Forms Assignee: wine-bugs@list.winehq.org Reporter: matthias.klaey@gmx.ch CC: madewokherd@gmail.com Distribution: --- Created attachment 80671 --> http://bugs.winehq.org/attachment.cgi?id=80671 Screenshots + Logs [Windows 11 Textscale 125% = all fine], [Mono Debian WSL = user control not properly scaled], Simplified situation: TestForm
TestButton TestControl > SubControl > SubButton
(see attached screenshots for complete sitation) When applying a new font to the form, e.g. `Font = SystemFonts.IconTitleFont`, form and controls are expected to get rescaled, as the form is set to `AutoScaleMode.Font`. Rescaling does happen, and works fine for e.g the `TestButton` (button_Form_SizeChanged to {Width=390, Height=32}), as well as for `TestButton` (TestControl_SizeChanged to {Width=390, Height=32}), but `SubControl` does not get scaled in respect to Size! It only gets scaled in respect to Location! The attached .zip contains screenshots demonstrating the issue: - Windows 11 .NET Framework 4.8 text scaled to 125% => all fine. - Debian 12 with Mono 6.12.0 => user control not properly scaled. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59602 --- Comment #1 from matthias.klaey@gmx.ch <matthias.klaey@gmx.ch> --- I think the root cause is `else if (IsContainerAutoScaling (this.Parent))` at https://gitlab.winehq.org/mono/mono/-/blob/main/mcs/class/System.Windows.For...: The container of `TestControl` is `TestForm`, which is about auto-scaling (https://gitlab.winehq.org/mono/mono/-/blob/main/mcs/class/System.Windows.For...) when the above piece of code is being called. Consequently, `TestControl` will not perform scaling in respect to the size (https://gitlab.winehq.org/mono/mono/-/blob/main/mcs/class/System.Windows.For...). If this analysis is correct, the implementation will have to be refined such it performs scaling children even with nested controls. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59602 --- Comment #2 from matthias.klaey@gmx.ch <matthias.klaey@gmx.ch> --- Note that issue also applies to MDI child forms, i.e. forms that have a parent. Depending on `Dock`, controls of an MDI child form may not get scaled for the reason described earlier. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59602 --- Comment #3 from matthias.klaey@gmx.ch <matthias.klaey@gmx.ch> --- Workaround good enough to handle composite/nested controls: ``` /// <remarks> /// Works around https://bugs.winehq.org/show_bug.cgi?id=59602 by scaling nested children /// in case of <see cref="BoundsSpecified.Location"/>, rather than skipping: /// https://gitlab.winehq.org/mono/mono/-/blob/main/mcs/class/System.Windows.For... /// </remarks> [Conditional("MONO")] public static void ApplyMonoScaleChildrenWorkaround(Control.ControlCollection controls, SizeF factor, BoundsSpecified specified, bool scaleChildren) { if ((specified == BoundsSpecified.Location) && scaleChildren) { foreach (Control c in controls) c.Scale(factor); } } ``` Workaround has to be applied to the top-level composite control: ``` #if (MONO) protected override void ScaleControl(SizeF factor, BoundsSpecified specified) { base.ScaleControl(factor, specified); SuspendLayout(); ControlEx.ApplyMonoScaleChildrenWorkaround(Controls, factor, specified, ScaleChildren); ResumeLayout(); } #endif ``` The workaround does not work for forms, e.g. MDI child forms. For such, call `Scale()` on all composite controls: ``` #if (MONO) protected override void ScaleControl(SizeF factor, BoundsSpecified specified) { base.ScaleControl(factor, specified); SuspendLayout(); someControl.Scale(factor); ResumeLayout(); } #endif ``` -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (1)
-
WineHQ Bugzilla