Hello,
I am using wxAuiToolBar with bitmaps loaded from SVG files. This works fine. I then started to fine tune the code for dark mode by providing a specific disabled bitmap, based on the theme.
I am doing that using this code:
... // toolbar -> wxAuiToolBar // tool -> wxAuiToolBarItem auto normal_bmp = tool->GetBitmapFor(toolbar); wxBitmap disable_bmp = normal_bmp; if (DrawingUtils::IsThemeDark()) { disable_bmp = disable_bmp.ConvertToDisabled(0); } else { disable_bmp = disable_bmp.ConvertToDisabled(255); } tool->SetDisabledBitmap(disable_bmp);
I would expect that the disabled bitmap will have the same size characteristics as the normal one, however, this is what I am getting:
bad-toolbar.png (view on web)To workaround it, I wrote a helper function that changes the original bitmap before it is added to the toolbar - which works:
void AddTool(wxAuiToolBar* toolbar, int toolId, const wxString& label, const wxBitmap& bitmap, const wxString& shortHelpString, wxItemKind item_kind) { size_t brightness = DrawingUtils::IsThemeDark() ? 0 : 255; auto disabled_bmp = bitmap.ConvertToDisabled(brightness); wxBitmap::Rescale(disabled_bmp, wxSize(16, 16)); wxString help_string = shortHelpString.empty() ? label : shortHelpString; toolbar->AddTool(toolId, label, bitmap, disabled_bmp, item_kind, help_string, help_string, nullptr); } `` The way I see it, we have 2 issues here: - The automatic creation of disabled bitmaps does not take into consideration the dark mode (i.e. wxAuiToolBar should provide a default **proper** disabled bitmaps and it should not assume 255 brightness) - `ConvertToDisabled` return a bitmap with wrong size (or maybe it is the `GetBitmapFor(..)` Thanks.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()