Add wxBitmapBundle::GetPreferredLogicalSizeFor()

We often need the logical bitmap size when using it in size computations
involving window size, so add a function returning it directly to
wxBitmapBundle, similarly to wxBitmap::GetLogicalSize(), to avoid using
FromPhys() everywhere.

Also rename the existing wxBitmapBundle::GetPreferredSizeFor() to
GetPreferredBitmapSizeFor() to make it more clear that this is similar
to wxBitmap::GetSize() and so returns the size in physical units.

Closes #22056.
This commit is contained in:
Alexander Koshelev
2022-01-25 12:10:07 +03:00
committed by Vadim Zeitlin
parent dd185a0b27
commit b2629a97e5
20 changed files with 82 additions and 57 deletions

View File

@@ -49,7 +49,7 @@ TEST_CASE("BitmapBundle::FromBitmaps", "[bmpbundle]")
TEST_CASE("BitmapBundle::GetPreferredSize", "[bmpbundle]")
{
CHECK( wxBitmapBundle().GetPreferredSizeAtScale(1) == wxDefaultSize );
CHECK( wxBitmapBundle().GetPreferredBitmapSizeAtScale(1) == wxDefaultSize );
const wxSize normal(32, 32);
const wxSize bigger(64, 64);
@@ -59,18 +59,18 @@ TEST_CASE("BitmapBundle::GetPreferredSize", "[bmpbundle]")
// Check that the existing bitmaps are used without scaling for most of the
// typical scaling values.
CHECK( b.GetPreferredSizeAtScale(0 ) == normal );
CHECK( b.GetPreferredSizeAtScale(1 ) == normal );
CHECK( b.GetPreferredSizeAtScale(1.25) == normal );
CHECK( b.GetPreferredSizeAtScale(1.4 ) == normal );
CHECK( b.GetPreferredSizeAtScale(1.5 ) == bigger );
CHECK( b.GetPreferredSizeAtScale(1.75) == bigger );
CHECK( b.GetPreferredSizeAtScale(2 ) == bigger );
CHECK( b.GetPreferredSizeAtScale(2.5 ) == bigger );
CHECK( b.GetPreferredBitmapSizeAtScale(0 ) == normal );
CHECK( b.GetPreferredBitmapSizeAtScale(1 ) == normal );
CHECK( b.GetPreferredBitmapSizeAtScale(1.25) == normal );
CHECK( b.GetPreferredBitmapSizeAtScale(1.4 ) == normal );
CHECK( b.GetPreferredBitmapSizeAtScale(1.5 ) == bigger );
CHECK( b.GetPreferredBitmapSizeAtScale(1.75) == bigger );
CHECK( b.GetPreferredBitmapSizeAtScale(2 ) == bigger );
CHECK( b.GetPreferredBitmapSizeAtScale(2.5 ) == bigger );
// This scale is too big to use any of the existing bitmaps, so they will
// be scaled.
CHECK( b.GetPreferredSizeAtScale(3 ) == 3*normal );
CHECK( b.GetPreferredBitmapSizeAtScale(3 ) == 3*normal );
}
#ifdef wxHAS_DPI_INDEPENDENT_PIXELS