FIX: StaticGroup constriant layout badge on macOS
Change-Id: Ia93c91b990ec3f5fef3eae57d48ca71b4a0841e6 Jira: STUDIO-10383
This commit is contained in:
parent
af880399a5
commit
88521a06d1
|
@ -10,6 +10,8 @@ StaticGroup::StaticGroup(wxWindow *parent, wxWindowID id, const wxString &label)
|
|||
#endif
|
||||
}
|
||||
|
||||
void StaticGroup_layoutBadge(void * group, void * badge);
|
||||
|
||||
void StaticGroup::ShowBadge(bool show)
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
|
@ -24,7 +26,7 @@ void StaticGroup::ShowBadge(bool show)
|
|||
badge = new ScalableButton(this, wxID_ANY, "badge", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, false, 18);
|
||||
badge->SetSize(badge->GetBestSize());
|
||||
badge->SetBackgroundColour("#F7F7F7");
|
||||
LayoutBadge();
|
||||
StaticGroup_layoutBadge(GetHandle(), badge->GetHandle());
|
||||
}
|
||||
if (badge && badge->IsShown() != show)
|
||||
badge->Show(show);
|
||||
|
@ -70,22 +72,3 @@ 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)
|
||||
{
|
||||
auto size = GetSize();
|
||||
wxStaticBox::DoSetSize(x, y, width, height, sizeFlags);
|
||||
if (badge && size != GetSize())
|
||||
LayoutBadge();
|
||||
}
|
||||
|
||||
void StaticGroup::LayoutBadge()
|
||||
{
|
||||
auto size = GetSize();
|
||||
auto size2 = size - badge->GetSize();
|
||||
badge->SetPosition({size2.x - 6, 0});
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,10 +18,6 @@ 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__
|
||||
|
|
|
@ -16,6 +16,7 @@ void set_tag_when_enter_full_screen(bool isfullscreen);
|
|||
void set_title_colour_after_set_title(void * window);
|
||||
void initGestures(void * view, wxEvtHandler * handler);
|
||||
void openFolderForFile(wxString const & file);
|
||||
void StaticGroup_layoutBadge(void * group, void * badge);
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -416,3 +416,12 @@ void initGestures(void * view, wxEvtHandler * handler)
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
void StaticGroup_layoutBadge(void * group, void * badge)
|
||||
{
|
||||
NSView * vg = (NSView *)group;
|
||||
NSView * vb = (NSView *)badge;
|
||||
vb.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[vg addConstraint: [NSLayoutConstraint constraintWithItem:vb attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:vg attribute:NSLayoutAttributeTop multiplier:1.0 constant:15]];
|
||||
[vg addConstraint: [NSLayoutConstraint constraintWithItem:vb attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:vg attribute:NSLayoutAttributeRight multiplier:1.0 constant:-1]];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue