mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-04-06 00:32:05 +02:00
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:
@@ -24,9 +24,16 @@ CheckBox::CheckBox(wxWindow *parent, int id)
|
||||
Bind(wxEVT_ENTER_WINDOW, &CheckBox::updateBitmap, this);
|
||||
Bind(wxEVT_LEAVE_WINDOW, &CheckBox::updateBitmap, this);
|
||||
#endif
|
||||
update();
|
||||
#ifdef __WXGTK__
|
||||
wxSize bestSize = GetBestSize();
|
||||
bestSize.IncTo(m_on.GetBmpSize());
|
||||
SetSize(bestSize);
|
||||
SetMinSize(bestSize);
|
||||
#else
|
||||
SetSize(m_on.GetBmpSize());
|
||||
SetMinSize(m_on.GetBmpSize());
|
||||
update();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CheckBox::SetValue(bool value)
|
||||
@@ -54,8 +61,16 @@ void CheckBox::Rescale()
|
||||
m_on_focused.msw_rescale();
|
||||
m_half_focused.msw_rescale();
|
||||
m_off_focused.msw_rescale();
|
||||
update();
|
||||
#ifdef __WXGTK__
|
||||
wxSize bestSize = GetBestSize();
|
||||
bestSize.IncTo(m_on.GetBmpSize());
|
||||
SetSize(bestSize);
|
||||
SetMinSize(bestSize);
|
||||
#else
|
||||
SetSize(m_on.GetBmpSize());
|
||||
update();
|
||||
SetMinSize(m_on.GetBmpSize());
|
||||
#endif
|
||||
}
|
||||
|
||||
void CheckBox::update()
|
||||
|
||||
@@ -13,9 +13,16 @@ RadioBox::RadioBox(wxWindow *parent)
|
||||
// SetBackgroundStyle(wxBG_STYLE_TRANSPARENT);
|
||||
if (parent) SetBackgroundColour(parent->GetBackgroundColour());
|
||||
// Bind(wxEVT_TOGGLEBUTTON, [this](auto& e) { update(); e.Skip(); });
|
||||
update();
|
||||
#ifdef __WXGTK__
|
||||
wxSize bestSize = GetBestSize();
|
||||
bestSize.IncTo(m_on.GetBmpSize());
|
||||
SetSize(bestSize);
|
||||
SetMinSize(bestSize);
|
||||
#else
|
||||
SetSize(m_on.GetBmpSize());
|
||||
SetMinSize(m_on.GetBmpSize());
|
||||
update();
|
||||
#endif
|
||||
}
|
||||
|
||||
void RadioBox::SetValue(bool value)
|
||||
@@ -34,8 +41,16 @@ void RadioBox::Rescale()
|
||||
{
|
||||
m_on.msw_rescale();
|
||||
m_off.msw_rescale();
|
||||
SetSize(m_on.GetBmpSize());
|
||||
update();
|
||||
#ifdef __WXGTK__
|
||||
wxSize bestSize = GetBestSize();
|
||||
bestSize.IncTo(m_on.GetBmpSize());
|
||||
SetSize(bestSize);
|
||||
SetMinSize(bestSize);
|
||||
#else
|
||||
SetSize(m_on.GetBmpSize());
|
||||
SetMinSize(m_on.GetBmpSize());
|
||||
#endif
|
||||
}
|
||||
|
||||
void RadioBox::update() {
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user