From 080a236a014368d8cab135cde0796402b85d884d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 20 Nov 2021 21:36:08 +0100 Subject: [PATCH] Keep toolbar bitmap size in logical, not physical, pixels As SetToolBitmapSize() takes logical pixels, GetToolBitmapSize() should also return them for consistency. Closes #19323. --- src/common/tbarbase.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index a73b79b954..1a285f4152 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -458,12 +458,22 @@ void wxToolBarBase::AdjustToolBitmapSize() if ( !bundles.empty() ) { - const wxSize sizePreferred = wxBitmapBundle::GetConsensusSizeFor - ( - this, - bundles, - sizeOrig - ); + wxSize sizePreferred = wxBitmapBundle::GetConsensusSizeFor + ( + this, + bundles, + sizeOrig + ); + + // This size is supposed to be in logical units for the platforms where + // they differ from physical ones, so convert it. + // + // Note that this could introduce rounding problems but, in fact, + // neither wxGTK nor wxOSX (that are the only ports where contents + // scale factor may be different from 1) use this size at all + // currently, so it shouldn't matter. But if/when they are modified to + // use the size computed here, this would need to be revisited. + sizePreferred /= GetContentScaleFactor(); if ( sizePreferred != sizeOrig ) SetToolBitmapSize(sizePreferred);