Fix switch button color

This commit is contained in:
Noisyfox 2025-10-05 14:26:19 +08:00
parent e5bd736def
commit 24fe8a9fa7
2 changed files with 21 additions and 5 deletions

View file

@ -38,22 +38,26 @@ void SwitchButton::SetLabels(wxString const& lbl_on, wxString const& lbl_off)
void SwitchButton::SetTextColor(StateColor const& color)
{
text_color = color;
text_color = color;
Rescale();
}
void SwitchButton::SetTextColor2(StateColor const &color)
{
text_color2 = color;
text_color2 = color;
Rescale();
}
void SwitchButton::SetTrackColor(StateColor const& color)
{
track_color = color;
track_color = color;
Rescale();
}
void SwitchButton::SetThumbColor(StateColor const& color)
{
thumb_color = color;
thumb_color = color;
Rescale();
}
void SwitchButton::SetValue(bool value)
@ -63,6 +67,16 @@ void SwitchButton::SetValue(bool value)
update();
}
bool SwitchButton::SetBackgroundColour(const wxColour& colour)
{
if (wxBitmapToggleButton::SetBackgroundColour(colour)) {
Rescale();
return true;
}
return false;
}
void SwitchButton::Rescale()
{
if (labels[0].IsEmpty()) {
@ -70,7 +84,7 @@ void SwitchButton::Rescale()
m_off.msw_rescale();
}
else {
SetBackgroundColour(StaticBox::GetParentBackgroundColor(GetParent()));
wxBitmapToggleButton::SetBackgroundColour(StaticBox::GetParentBackgroundColor(GetParent()));
#ifdef __WXOSX__
auto scale = Slic3r::GUI::mac_max_scaling_factor();
int BS = (int) scale;

View file

@ -30,6 +30,8 @@ public:
void Rescale();
bool SetBackgroundColour(const wxColour& colour) override;
private:
void update();