Really support wxBitmapBundle in wxGTK wxToolBar

Use the appropriately sized bitmap instead of always using the (scaled
version of the) default one, as was the case since 97f6c85d9b (Add first
version of wxBitmapBundle and use it in wxToolBar, 2021-09-24).

With this change, toolbar bitmaps work correctly in 100% and 200% DPI
scaling.
This commit is contained in:
Vadim Zeitlin
2021-10-16 20:05:51 +02:00
parent 0f5c2851f4
commit 3333356624

View File

@@ -190,29 +190,27 @@ double BitmapProvider::GetScale() const
wxBitmap BitmapProvider::Get() const
{
#ifdef __WXGTK3__
wxBitmap bitmap(m_tool->GetNormalBitmap());
if (m_tool->IsEnabled())
if (!m_tool->IsEnabled())
{
if (bitmap.IsOk() && bitmap.GetScaleFactor() <= 1)
bitmap.UnRef();
}
else
{
wxBitmap disabled(m_tool->GetDisabledBitmap());
wxBitmap disabled(GetAtScale(m_tool->GetDisabledBitmapBundle()));
// if no disabled bitmap and normal bitmap is scaled
if (!disabled.IsOk() && bitmap.IsOk() && bitmap.GetScaleFactor() > 1)
if (!disabled.IsOk() && IsScaled())
{
// make scaled disabled bitmap from normal one
disabled = bitmap.CreateDisabled();
wxBitmap bitmap(GetAtScale(m_tool->GetNormalBitmapBundle()));
if (bitmap.IsOk())
disabled = bitmap.CreateDisabled();
}
bitmap = disabled;
return disabled;
}
if (IsScaled())
return GetAtScale(m_tool->GetNormalBitmapBundle());
#else
wxBitmap bitmap;
if (!m_tool->IsEnabled())
bitmap = m_tool->GetDisabledBitmap();
return m_tool->GetDisabledBitmap();
#endif
return bitmap;
return wxBitmap();
}
} // namespace