The first line shows the system-handled scaling. We can see the UI structure and relative proportions at 96 DPI for reference.
The 3rd line shows the program-handled high DPI scaling. We can see that the icon sizes in the toolbar are correct relative to the font size, but the icons appear crowded on the toolbar. It's easy to guess that the padding isn't scaling with DPI.
The 2nd line shows program-handled high DPI scaling with the modified wxWidgets. I tried having a LLM write code to make the padding scale with DPI. We can see that the height is correct this time, and the spacing between buttons is also correct. However, the spacing between buttons and separators still isn't scaling with DPI. Testing revealed that the separator width isn't scaling with DPI.
I couldn't find a suitable way to scale the separator width while ensuring it's centered. Directly modifying the iBitmap member adds all the new width to the right side of the separator line, causing it to not be centered on the buttons on either side.
I would appreciate it if you could improve high DPI support for MSW wxToolBar in 3.2 and 3.3. It would be great if this bug could be fixed by default (without requiring developers to explicitly call SetToolPacking()); however, if it cannot be fixed due to compatibility requirements, I would at least like sufficient guidance in the documentation so that developers can improve their own programs.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Yes, it would be nice to fix this, although I think the effect is particularly bad here because the icons are so small.
How exactly did you modify wx to achieve the result in (2)?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
The minimum usable code for me is
diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index 253d379af6..294e9d271a 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -442,6 +442,8 @@ bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size) // Retrieve packing value if it hasn't been yet set with SetToolPacking. DWORD padding = ::SendMessage(GetHwnd(), TB_GETPADDING, 0, 0); m_toolPacking = IsVertical() ? HIWORD(padding) : LOWORD(padding); + DWORD scaledPadding = MAKELPARAM(FromDIP(LOWORD(padding)), FromDIP(HIWORD(padding))); + ::SendMessage(GetHwnd(), TB_SETPADDING, 0, scaledPadding); } else { @@ -571,7 +573,7 @@ wxSize wxToolBar::MSWGetFittingtSizeForControl(wxToolBarTool* tool) const // This is arbitrary, but we want to leave at least 1px around the control // vertically, otherwise it really looks too cramped. - size.y += 2*1; + size.y += FromDIP(2*1); // Account for the label, if any. if ( wxStaticText * const staticText = tool->GetStaticText() ) @@ -584,7 +586,7 @@ wxSize wxToolBar::MSWGetFittingtSizeForControl(wxToolBarTool* tool) const size.x = sizeLabel.x; size.y += sizeLabel.y; - size.y += MARGIN_CONTROL_LABEL; + size.y += FromDIP(MARGIN_CONTROL_LABEL); } } @@ -592,7 +594,7 @@ wxSize wxToolBar::MSWGetFittingtSizeForControl(wxToolBarTool* tool) const // half of it to each tool, as the total amount of packing is the sum of // the right margin of the previous tool and the left margin of the next // one. - size.x += m_toolPacking / 2; + size.x += FromDIP(m_toolPacking) / 2; return size; }
Pure proof-of-concept. I haven't tested other types of toolbar items at all, nor have I considered how to handle explicit padding specified by the user.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()