From 72f851f6f46b10dbd1ee0da3e48d39689135d2da Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 5 Jun 2022 02:02:56 +0100 Subject: [PATCH] Remove the size parameter of wxBitmapBundle::GetConsensusSizeFor() It doesn't seem to be useful and wasn't really specified in 2 out of 3 existing calls to this function and was probably wrongly specified in the remaining one, so just remove it for now, it can always be added later if we decide what exactly should it do. --- include/wx/bmpbndl.h | 8 ++----- src/common/bmpbndl.cpp | 43 +++++++++--------------------------- src/common/bmpcboxcmn.cpp | 3 +-- src/common/tbarbase.cpp | 8 ++----- tests/graphics/bmpbundle.cpp | 2 +- 5 files changed, 17 insertions(+), 47 deletions(-) diff --git a/include/wx/bmpbndl.h b/include/wx/bmpbndl.h index ddcba2930d..dabbfa8d2d 100644 --- a/include/wx/bmpbndl.h +++ b/include/wx/bmpbndl.h @@ -154,13 +154,9 @@ public: // Get the bitmap size preferred by the majority of the elements of the // bundles at the given scale or the scale appropriate for the given window. static wxSize - GetConsensusSizeFor(double scale, - const wxVector& bundles, - const wxSize& sizeDefault); + GetConsensusSizeFor(double scale, const wxVector& bundles); static wxSize - GetConsensusSizeFor(wxWindow* win, - const wxVector& bundles, - const wxSize& sizeDefault); + GetConsensusSizeFor(wxWindow* win, const wxVector& bundles); // Create wxImageList and fill it with the images from the given bundles in // the sizes appropriate for the DPI scaling used for the specified window. diff --git a/src/common/bmpbndl.cpp b/src/common/bmpbndl.cpp index fb02842521..a15b004b65 100644 --- a/src/common/bmpbndl.cpp +++ b/src/common/bmpbndl.cpp @@ -593,20 +593,16 @@ void RecordSizePref(SizePrefs& prefs, const wxSize& size) /* static */ wxSize wxBitmapBundle::GetConsensusSizeFor(wxWindow* win, - const wxVector& bundles, - const wxSize& sizeDefault) + const wxVector& bundles) { - return GetConsensusSizeFor(win->GetDPIScaleFactor(), bundles, sizeDefault); + return GetConsensusSizeFor(win->GetDPIScaleFactor(), bundles); } /* static */ wxSize wxBitmapBundle::GetConsensusSizeFor(double scale, - const wxVector& bundles, - const wxSize& sizeDefault) + const wxVector& bundles) { - const wxSize sizeIdeal = sizeDefault*scale; - // We want to use preferred bitmap size, but the preferred sizes can be // different for different bitmap bundles, so record all their preferences // first. @@ -631,25 +627,13 @@ wxBitmapBundle::GetConsensusSizeFor(double scale, } else if ( countThis == countMax ) { - // We have a tie between different sizes, choose the one - // corresponding to the current scale factor, if possible, as this - // is the ideal bitmap size that should be consistent with all the - // other bitmaps. - if ( sizePreferred != sizeIdeal ) - { - if ( sizeThis == sizeIdeal ) - { - sizePreferred = sizeThis; - } - else // Neither of the sizes is the ideal one. - { - // Choose the larger one as like this some bitmaps will be - // downscaled, which should look better than upscaling some - // (other) ones. - if ( sizeThis.y > sizePreferred.y ) - sizePreferred = sizeThis; - } - } + // We have a tie between different sizes. + + // Choose the larger one as like this some bitmaps will be + // downscaled, which should look better than upscaling some + // (other) ones. + if ( sizeThis.y > sizePreferred.y ) + sizePreferred = sizeThis; } } @@ -664,12 +648,7 @@ wxBitmapBundle::CreateImageList(wxWindow* win, wxCHECK_MSG( win, NULL, "must have a valid window" ); wxCHECK_MSG( !bundles.empty(), NULL, "should have some images" ); - // We arbitrarily choose the default size of the first bundle as the - // default size for the image list too, as it's not clear what else could - // we do here. Note that this size is only used to break the tie in case - // the same number of bundles prefer two different sizes, so it's not going - // to matter at all in most cases. - wxSize size = GetConsensusSizeFor(win, bundles, bundles[0].GetDefaultSize()); + wxSize size = GetConsensusSizeFor(win, bundles); // wxImageList wants the logical size for the platforms where logical and // physical pixels are different. diff --git a/src/common/bmpcboxcmn.cpp b/src/common/bmpcboxcmn.cpp index db4e608e7d..73023ddd79 100644 --- a/src/common/bmpcboxcmn.cpp +++ b/src/common/bmpcboxcmn.cpp @@ -72,8 +72,7 @@ void wxBitmapComboBoxBase::UpdateInternals() m_usedImgSize = wxBitmapBundle::GetConsensusSizeFor ( GetControl(), - m_bitmapbundles, - wxSize(0, 0) + m_bitmapbundles ); } } diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index 673022012a..72b022812c 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -493,12 +493,8 @@ void wxToolBarBase::AdjustToolBitmapSize() } else // Determine the best size to use from the bitmaps we have. { - wxSize sizePreferred = wxBitmapBundle::GetConsensusSizeFor - ( - this, - bundles, - ToDIP(sizeOrig) - ); + const wxSize + sizePreferred = wxBitmapBundle::GetConsensusSizeFor(this, bundles); // GetConsensusSizeFor() returns physical size, but we want to operate // with logical pixels as everything else is expressed in them. diff --git a/tests/graphics/bmpbundle.cpp b/tests/graphics/bmpbundle.cpp index dbb2e9a50e..810ed9f61d 100644 --- a/tests/graphics/bmpbundle.cpp +++ b/tests/graphics/bmpbundle.cpp @@ -475,7 +475,7 @@ TEST_CASE("BitmapBundle::GetConsensusSize", "[bmpbundle]") int GetConsensusSize(double scale) const { - return wxBitmapBundle::GetConsensusSizeFor(scale, vec, wxSize()).y; + return wxBitmapBundle::GetConsensusSizeFor(scale, vec).y; } } bundles;