Fix GTK negative content width warnings for bitmap toggle buttons

On Linux/GTK, CheckBox, RadioBox, and SwitchButton set their size to
exactly the bitmap size (18x18 or 16x16), but GTK's internal CSS padding
requires additional space, resulting in negative content width warnings.
Use GetBestSize() on GTK to account for theme padding.
This commit is contained in:
SoftFever
2026-03-26 16:05:58 +08:00
parent 52e53053e1
commit b09bade560
3 changed files with 42 additions and 5 deletions

View File

@@ -180,8 +180,15 @@ void SwitchButton::Rescale()
(i == 0 ? m_off : m_on).bmp() = bmp;
}
}
SetSize(m_on.GetBmpSize());
update();
#ifdef __WXGTK__
wxSize bestSize = GetBestSize();
bestSize.IncTo(m_on.GetBmpSize());
SetSize(bestSize);
SetMinSize(bestSize);
#else
SetSize(m_on.GetBmpSize());
#endif
}
void SwitchButton::update()