Don't change orthogonal alignment in wxSizerFlags::CenterXXX()

It was unexpected that using wxSizerFlags().Right().CentreVertical()
didn't right-align the item because CentreVertical() reset the alignment
in the horizontal direction rather than just setting it in the vertical
one, so change this, document the new behaviour explicitly and add a new
unit test checking for it.

Closes #18989.
This commit is contained in:
Vadim Zeitlin
2021-01-25 12:58:04 +01:00
parent caf5a62fd9
commit 9130f8bfc6
3 changed files with 45 additions and 4 deletions

View File

@@ -69,14 +69,26 @@ public:
return *this;
}
// some shortcuts for Align()
// this is just a shortcut for Align()
wxSizerFlags& Centre() { return Align(wxALIGN_CENTRE); }
wxSizerFlags& Center() { return Centre(); }
wxSizerFlags& CentreVertical() { return Align(wxALIGN_CENTRE_VERTICAL); }
// but all the remaining methods turn on the corresponding alignment flag
// without affecting the existing ones
wxSizerFlags& CentreVertical()
{
m_flags = (m_flags & ~wxALIGN_BOTTOM) | wxALIGN_CENTRE_VERTICAL;
return *this;
}
wxSizerFlags& CenterVertical() { return CentreVertical(); }
wxSizerFlags& CentreHorizontal() { return Align(wxALIGN_CENTRE_HORIZONTAL); }
wxSizerFlags& CentreHorizontal()
{
m_flags = (m_flags & ~wxALIGN_RIGHT) | wxALIGN_CENTRE_HORIZONTAL;
return *this;
}
wxSizerFlags& CenterHorizontal() { return CentreHorizontal(); }
wxSizerFlags& Top()