From 3333356624cf2fd8d2ad1d89690c51d7a88076af Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 16 Oct 2021 20:05:51 +0200 Subject: [PATCH] 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. --- src/gtk/toolbar.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/gtk/toolbar.cpp b/src/gtk/toolbar.cpp index fdb45ed270..e2f1c121ae 100644 --- a/src/gtk/toolbar.cpp +++ b/src/gtk/toolbar.cpp @@ -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