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:
parent
e13b4f8833
commit
72f851f6f4
@ -154,13 +154,9 @@ public:
|
|||||||
// Get the bitmap size preferred by the majority of the elements of the
|
// 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.
|
// bundles at the given scale or the scale appropriate for the given window.
|
||||||
static wxSize
|
static wxSize
|
||||||
GetConsensusSizeFor(double scale,
|
GetConsensusSizeFor(double scale, const wxVector<wxBitmapBundle>& bundles);
|
||||||
const wxVector<wxBitmapBundle>& bundles,
|
|
||||||
const wxSize& sizeDefault);
|
|
||||||
static wxSize
|
static wxSize
|
||||||
GetConsensusSizeFor(wxWindow* win,
|
GetConsensusSizeFor(wxWindow* win, const wxVector<wxBitmapBundle>& bundles);
|
||||||
const wxVector<wxBitmapBundle>& bundles,
|
|
||||||
const wxSize& sizeDefault);
|
|
||||||
|
|
||||||
// Create wxImageList and fill it with the images from the given bundles in
|
// 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.
|
// the sizes appropriate for the DPI scaling used for the specified window.
|
||||||
|
@ -593,20 +593,16 @@ void RecordSizePref(SizePrefs& prefs, const wxSize& size)
|
|||||||
/* static */
|
/* static */
|
||||||
wxSize
|
wxSize
|
||||||
wxBitmapBundle::GetConsensusSizeFor(wxWindow* win,
|
wxBitmapBundle::GetConsensusSizeFor(wxWindow* win,
|
||||||
const wxVector<wxBitmapBundle>& bundles,
|
const wxVector<wxBitmapBundle>& bundles)
|
||||||
const wxSize& sizeDefault)
|
|
||||||
{
|
{
|
||||||
return GetConsensusSizeFor(win->GetDPIScaleFactor(), bundles, sizeDefault);
|
return GetConsensusSizeFor(win->GetDPIScaleFactor(), bundles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
wxSize
|
wxSize
|
||||||
wxBitmapBundle::GetConsensusSizeFor(double scale,
|
wxBitmapBundle::GetConsensusSizeFor(double scale,
|
||||||
const wxVector<wxBitmapBundle>& bundles,
|
const wxVector<wxBitmapBundle>& bundles)
|
||||||
const wxSize& sizeDefault)
|
|
||||||
{
|
{
|
||||||
const wxSize sizeIdeal = sizeDefault*scale;
|
|
||||||
|
|
||||||
// We want to use preferred bitmap size, but the preferred sizes can be
|
// We want to use preferred bitmap size, but the preferred sizes can be
|
||||||
// different for different bitmap bundles, so record all their preferences
|
// different for different bitmap bundles, so record all their preferences
|
||||||
// first.
|
// first.
|
||||||
@ -631,18 +627,8 @@ wxBitmapBundle::GetConsensusSizeFor(double scale,
|
|||||||
}
|
}
|
||||||
else if ( countThis == countMax )
|
else if ( countThis == countMax )
|
||||||
{
|
{
|
||||||
// We have a tie between different sizes, choose the one
|
// We have a tie between different sizes.
|
||||||
// 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
|
// Choose the larger one as like this some bitmaps will be
|
||||||
// downscaled, which should look better than upscaling some
|
// downscaled, which should look better than upscaling some
|
||||||
// (other) ones.
|
// (other) ones.
|
||||||
@ -650,8 +636,6 @@ wxBitmapBundle::GetConsensusSizeFor(double scale,
|
|||||||
sizePreferred = sizeThis;
|
sizePreferred = sizeThis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sizePreferred;
|
return sizePreferred;
|
||||||
}
|
}
|
||||||
@ -664,12 +648,7 @@ wxBitmapBundle::CreateImageList(wxWindow* win,
|
|||||||
wxCHECK_MSG( win, NULL, "must have a valid window" );
|
wxCHECK_MSG( win, NULL, "must have a valid window" );
|
||||||
wxCHECK_MSG( !bundles.empty(), NULL, "should have some images" );
|
wxCHECK_MSG( !bundles.empty(), NULL, "should have some images" );
|
||||||
|
|
||||||
// We arbitrarily choose the default size of the first bundle as the
|
wxSize size = GetConsensusSizeFor(win, bundles);
|
||||||
// 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());
|
|
||||||
|
|
||||||
// wxImageList wants the logical size for the platforms where logical and
|
// wxImageList wants the logical size for the platforms where logical and
|
||||||
// physical pixels are different.
|
// physical pixels are different.
|
||||||
|
@ -72,8 +72,7 @@ void wxBitmapComboBoxBase::UpdateInternals()
|
|||||||
m_usedImgSize = wxBitmapBundle::GetConsensusSizeFor
|
m_usedImgSize = wxBitmapBundle::GetConsensusSizeFor
|
||||||
(
|
(
|
||||||
GetControl(),
|
GetControl(),
|
||||||
m_bitmapbundles,
|
m_bitmapbundles
|
||||||
wxSize(0, 0)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -493,12 +493,8 @@ void wxToolBarBase::AdjustToolBitmapSize()
|
|||||||
}
|
}
|
||||||
else // Determine the best size to use from the bitmaps we have.
|
else // Determine the best size to use from the bitmaps we have.
|
||||||
{
|
{
|
||||||
wxSize sizePreferred = wxBitmapBundle::GetConsensusSizeFor
|
const wxSize
|
||||||
(
|
sizePreferred = wxBitmapBundle::GetConsensusSizeFor(this, bundles);
|
||||||
this,
|
|
||||||
bundles,
|
|
||||||
ToDIP(sizeOrig)
|
|
||||||
);
|
|
||||||
|
|
||||||
// GetConsensusSizeFor() returns physical size, but we want to operate
|
// GetConsensusSizeFor() returns physical size, but we want to operate
|
||||||
// with logical pixels as everything else is expressed in them.
|
// with logical pixels as everything else is expressed in them.
|
||||||
|
@ -475,7 +475,7 @@ TEST_CASE("BitmapBundle::GetConsensusSize", "[bmpbundle]")
|
|||||||
|
|
||||||
int GetConsensusSize(double scale) const
|
int GetConsensusSize(double scale) const
|
||||||
{
|
{
|
||||||
return wxBitmapBundle::GetConsensusSizeFor(scale, vec, wxSize()).y;
|
return wxBitmapBundle::GetConsensusSizeFor(scale, vec).y;
|
||||||
}
|
}
|
||||||
} bundles;
|
} bundles;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user