feat: support tab icons

This commit is contained in:
Ian Chua
2026-07-29 19:37:17 +08:00
parent e00906a833
commit 3145f28bb7
15 changed files with 260 additions and 104 deletions
+5 -15
View File
@@ -95,14 +95,11 @@ void Button::SetIcon(const wxString& icon)
}
}
void Button::SetInactiveIcon(const wxString &icon)
void Button::SetIcon(const wxBitmap& icon)
{
if (!icon.IsEmpty()) {
// BBS set button icon default size to 20
this->inactive_icon = ScalableBitmap(this, icon.ToStdString(), this->active_icon.px_cnt());
} else {
this->inactive_icon = ScalableBitmap();
}
this->active_icon = ScalableBitmap();
this->active_icon.bmp() = icon;
messureSize();
Refresh();
}
@@ -260,9 +257,6 @@ void Button::Rescale()
if (this->active_icon.bmp().IsOk())
this->active_icon.msw_rescale();
if (this->inactive_icon.bmp().IsOk())
this->inactive_icon.msw_rescale();
messureSize();
if(m_has_style)
@@ -293,11 +287,7 @@ void Button::render(wxDC& dc)
wxSize szIcon;
wxSize textSize = this->textSize.GetSize();
ScalableBitmap icon;
if (m_selected || ((states & (int)StateColor::State::Hovered) != 0))
icon = active_icon;
else
icon = inactive_icon;
ScalableBitmap icon = active_icon;
wxSize padding = this->paddingSize;
int spacing = 5;
// Wrap text
+1 -6
View File
@@ -34,12 +34,10 @@ class Button : public StaticBox
wxSize minSize; // set by outer
wxSize paddingSize;
ScalableBitmap active_icon;
ScalableBitmap inactive_icon;
StateColor text_color;
bool pressedDown = false;
bool m_selected = true;
bool canFocus = true;
bool isCenter = true;
bool vertical = false;
@@ -61,8 +59,7 @@ public:
bool SetFont(const wxFont& font) override;
void SetIcon(const wxString& icon);
void SetInactiveIcon(const wxString& icon);
void SetIcon(const wxBitmap& icon);
void SetMinSize(const wxSize& size) override;
void SetMaxSize(const wxSize& size) override;
@@ -75,8 +72,6 @@ public:
void SetTextColorNormal(wxColor const &color);
void SetSelected(bool selected = true) { m_selected = selected; }
bool Enable(bool enable = true) override;
void EnableTooltipEvenDisabled();// The tip will be shown even if the button is disabled