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.
This commit is contained in:
Vadim Zeitlin 2022-06-05 02:02:56 +01:00
parent e13b4f8833
commit 72f851f6f4
5 changed files with 17 additions and 47 deletions

View File

@ -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<wxBitmapBundle>& bundles,
const wxSize& sizeDefault);
GetConsensusSizeFor(double scale, const wxVector<wxBitmapBundle>& bundles);
static wxSize
GetConsensusSizeFor(wxWindow* win,
const wxVector<wxBitmapBundle>& bundles,
const wxSize& sizeDefault);
GetConsensusSizeFor(wxWindow* win, const wxVector<wxBitmapBundle>& 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.

View File

@ -593,20 +593,16 @@ void RecordSizePref(SizePrefs& prefs, const wxSize& size)
/* static */
wxSize
wxBitmapBundle::GetConsensusSizeFor(wxWindow* win,
const wxVector<wxBitmapBundle>& bundles,
const wxSize& sizeDefault)
const wxVector<wxBitmapBundle>& bundles)
{
return GetConsensusSizeFor(win->GetDPIScaleFactor(), bundles, sizeDefault);
return GetConsensusSizeFor(win->GetDPIScaleFactor(), bundles);
}
/* static */
wxSize
wxBitmapBundle::GetConsensusSizeFor(double scale,
const wxVector<wxBitmapBundle>& bundles,
const wxSize& sizeDefault)
const wxVector<wxBitmapBundle>& 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.

View File

@ -72,8 +72,7 @@ void wxBitmapComboBoxBase::UpdateInternals()
m_usedImgSize = wxBitmapBundle::GetConsensusSizeFor
(
GetControl(),
m_bitmapbundles,
wxSize(0, 0)
m_bitmapbundles
);
}
}

View File

@ -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.

View File

@ -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;