Better safety if publish workflow crashes. Cleanup on Button

This commit is contained in:
Lam Wei Lun
2026-08-25 16:40:18 +08:00
parent 795514900d
commit 51b646efcf
5 changed files with 45 additions and 42 deletions
+6 -15
View File
@@ -80,7 +80,6 @@ bool Button::SetFont(const wxFont& font)
void Button::SetIcon(const wxString& icon)
{
custom_icon = wxNullBitmap;
auto tmpBitmap = ScalableBitmap(this, icon.ToStdString(), this->active_icon.px_cnt());
if (!icon.IsEmpty()) {
//BBS set button icon default size to 20
@@ -104,13 +103,6 @@ void Button::SetIcon(const wxBitmap& icon)
Refresh();
}
void Button::SetBitmap(const wxBitmap& bitmap)
{
custom_icon = bitmap;
messureSize();
Refresh();
}
void Button::SetMinSize(const wxSize& size)
{
minSize = size;
@@ -310,8 +302,7 @@ void Button::render(wxDC& dc)
}
}
auto szContent = textSize;
const bool has_custom_icon = custom_icon.IsOk();
if (has_custom_icon || icon.bmp().IsOk()) {
if (icon.bmp().IsOk()) {
if (szContent.y > 0) {
//BBS norrow size between text and icon
if (vertical)
@@ -319,7 +310,7 @@ void Button::render(wxDC& dc)
else
szContent.x += spacing;
}
szIcon = has_custom_icon ? custom_icon.GetSize() : icon.GetBmpSize();
szIcon = icon.GetBmpSize();
if (vertical) {
szContent.y += szIcon.y;
if (szIcon.x > szContent.x) szContent.x = szIcon.x;
@@ -342,12 +333,12 @@ void Button::render(wxDC& dc)
}
// start draw
wxPoint pt = rcContent.GetLeftTop();
if (has_custom_icon || icon.bmp().IsOk()) {
if (icon.bmp().IsOk()) {
if (vertical)
pt.x += (rcContent.width - szIcon.x) / 2;
else
pt.y += (rcContent.height - szIcon.y) / 2;
dc.DrawBitmap(has_custom_icon ? custom_icon : icon.bmp(), pt);
dc.DrawBitmap(icon.bmp(), pt);
//BBS norrow size between text and icon
if (vertical) {
pt.y += szIcon.y + spacing;
@@ -380,7 +371,7 @@ void Button::messureSize()
wxClientDC dc(this);
dc.GetTextExtent(GetLabel(), &textSize.width, &textSize.height, &textSize.x, &textSize.y);
wxSize szContent = textSize.GetSize();
if (custom_icon.IsOk() || this->active_icon.bmp().IsOk()) {
if (this->active_icon.bmp().IsOk()) {
if (szContent.y > 0) {
//BBS norrow size between text and icon
if (vertical)
@@ -388,7 +379,7 @@ void Button::messureSize()
else
szContent.x += 5;
}
wxSize szIcon = custom_icon.IsOk() ? custom_icon.GetSize() : this->active_icon.GetBmpSize();
wxSize szIcon = this->active_icon.GetBmpSize();
if (vertical) {
szContent.y += szIcon.y;
if (szIcon.x > szContent.x) szContent.x = szIcon.x;