From 453a52b942fa27c8f412716c8290dbcb6172d0e4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 6 Feb 2023 15:30:43 +0100 Subject: [PATCH] Fix return value of wxToolBar::GetToolBitmapSize() under GTK/Mac Fix another pixel units confusion in wxToolBar code and ensure that "sizeNeeded" is expressed in logical units when a fixed bitmap size is set, to make it consistent with the case when it is not set, and also because bitmap size is supposed to be expressed in logical pixels, in both SetToolBitmapSize() and, for consistency, GetToolBitmapSize() too. Also explicitly mention the latter in the documentation. See #23228. Closes #23222. --- interface/wx/toolbar.h | 5 +++++ src/common/tbarbase.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/interface/wx/toolbar.h b/interface/wx/toolbar.h index 5630aca98f..79449c8638 100644 --- a/interface/wx/toolbar.h +++ b/interface/wx/toolbar.h @@ -594,6 +594,11 @@ public: usually unnecessary to call either this function or SetToolBitmapSize() at all. + This function returns the size in logical pixels, for consistency with + SetToolBitmapSize() which takes size in logical pixels. See @ref + overview_high_dpi for more information about the different pixel types + and how to convert between them. + @remarks Note that this is the size of the bitmap you pass to AddTool(), and not the eventual size of the tool button. diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index 1ef80ae35d..04c8057b9c 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -486,7 +486,7 @@ void wxToolBarBase::AdjustToolBitmapSize() // We want to round 1.5 down to 1, but 1.75 up to 2. int scaleFactorRoundedDown = static_cast(ceil(2*GetDPIScaleFactor())) / 2; - sizeNeeded = m_requestedBitmapSize*scaleFactorRoundedDown; + sizeNeeded = FromPhys(m_requestedBitmapSize*scaleFactorRoundedDown); } else // Determine the best size to use from the bitmaps we have. {