[Linux] Fix Black borders on checkbox and switch button (#13362)

init
This commit is contained in:
yw4z
2026-05-04 15:54:17 +08:00
committed by GitHub
parent 1d4c7c56a2
commit 988b500f33
4 changed files with 81 additions and 17 deletions
+10 -17
View File
@@ -2,6 +2,10 @@
#include "../wxExtensions.hpp"
#ifdef __WXGTK3__
#include "../GUI_Utils.hpp"
#endif
CheckBox::CheckBox(wxWindow *parent, int id)
: wxBitmapToggleButton(parent, id, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE)
, m_on(this, "check_on", 18)
@@ -24,16 +28,12 @@ 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());
#ifdef __WXGTK3__
Slic3r::GUI::RemoveButtonBorder(this);
#endif
Rescale();
}
void CheckBox::SetValue(bool value)
@@ -61,16 +61,9 @@ 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());
SetMinSize(m_on.GetBmpSize());
#endif
update();
}
void CheckBox::update()
+9
View File
@@ -11,6 +11,10 @@
#include "libslic3r/MacUtils.hpp"
#endif
#ifdef __WXGTK3__
#include "../GUI_Utils.hpp"
#endif
#include <wx/dcmemory.h>
#include <wx/dcclient.h>
#include <wx/dcgraph.h>
@@ -28,6 +32,11 @@ SwitchButton::SwitchButton(wxWindow* parent, wxWindowID id)
SetBackgroundColour(StaticBox::GetParentBackgroundColor(parent));
Bind(wxEVT_TOGGLEBUTTON, [this](auto& e) { update(); e.Skip(); });
SetFont(Label::Body_12);
#ifdef __WXGTK3__
Slic3r::GUI::RemoveButtonBorder(this);
#endif
Rescale();
}