ENH: StaticGroup badge on macOS

Change-Id: Id446e12aec7780f46c341083a7ad8c81ccf4a4f0
Jira: STUDIO-10055
This commit is contained in:
chunmao.guo 2025-02-10 18:52:45 +08:00 committed by lane.wei
parent 52d6e2f46e
commit 5e6eacccf1
2 changed files with 39 additions and 1 deletions

View File

@ -7,17 +7,28 @@ StaticGroup::StaticGroup(wxWindow *parent, wxWindowID id, const wxString &label)
SetForegroundColour("#CECECE");
#ifdef __WXMSW__
Bind(wxEVT_PAINT, &StaticGroup::OnPaint, this);
#else
#endif
}
void StaticGroup::ShowBadge(bool show)
{
#ifdef __WXMSW__
if (show)
badge = ScalableBitmap(this, "badge", 18);
else
badge = ScalableBitmap{};
Refresh();
#endif
#ifdef __WXOSX__
if (show && badge == nullptr) {
badge = new ScalableButton(this, wxID_ANY, "badge", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, false, 18);
badge->SetSize(badge->GetBestSize());
badge->SetBackgroundColour("#F7F7F7");
LayoutBadge();
}
if (badge)
badge->Show(show);
#endif
}
#ifdef __WXMSW__
@ -59,3 +70,21 @@ void StaticGroup::PaintForeground(wxDC &dc, const struct tagRECT &rc)
}
#endif
#ifdef __WXOSX__
void StaticGroup::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
wxStaticBox::DoSetSize(x, y, width, height, sizeFlags);
if (badge)
LayoutBadge();
}
void StaticGroup::LayoutBadge()
{
auto size = GetSize();
auto size2 = size - badge->GetSize();
badge->SetPosition({size2.x - 6, 0});
}
#endif

View File

@ -18,9 +18,18 @@ private:
void OnPaint(wxPaintEvent &evt);
void PaintForeground(wxDC &dc, const struct tagRECT &rc) override;
#endif
#ifdef __WXOSX__
void DoSetSize(int x, int y, int width, int height, int sizeFlags) override;
void LayoutBadge();
#endif
private:
#ifdef __WXMSW__
ScalableBitmap badge;
#endif
#ifdef __WXOSX__
ScalableButton * badge { nullptr };
#endif
};
#endif // !slic3r_GUI_StaticGroup_hpp_