Allow using alignment with wxEXPAND and wxSHAPED in wxBoxSizer
Don't assert in wxBoxSizer when both alignment flags and wxEXPAND are used together if wxSHAPED is also used, as such flag combinations may make sense and so shouldn't be forbidden. Add a unit test checking that this is allowed.
This commit is contained in:
parent
20db193332
commit
999d78a3bc
@ -2071,7 +2071,10 @@ wxSizerItem *wxBoxSizer::DoInsert(size_t index, wxSizerItem *item)
|
||||
);
|
||||
}
|
||||
|
||||
if ( flags & wxEXPAND )
|
||||
// Note that using alignment with wxEXPAND can make sense if wxSHAPED
|
||||
// is also used, as the item doesn't necessarily fully expand in the
|
||||
// other direction in this case.
|
||||
if ( (flags & wxEXPAND) && !(flags & wxSHAPED) )
|
||||
{
|
||||
wxASSERT_MSG
|
||||
(
|
||||
@ -2097,7 +2100,7 @@ wxSizerItem *wxBoxSizer::DoInsert(size_t index, wxSizerItem *item)
|
||||
);
|
||||
}
|
||||
|
||||
if ( flags & wxEXPAND )
|
||||
if ( (flags & wxEXPAND) && !(flags & wxSHAPED) )
|
||||
{
|
||||
wxASSERT_MSG(
|
||||
!(flags & (wxALIGN_BOTTOM | wxALIGN_CENTRE_VERTICAL)),
|
||||
|
@ -398,6 +398,15 @@ TEST_CASE_METHOD(BoxSizerTestCase, "BoxSizer::IncompatibleFlags", "[sizer]")
|
||||
ASSERT_SIZER_INCOMPATIBLE_FLAGS(wxEXPAND, wxALIGN_CENTRE_VERTICAL);
|
||||
ASSERT_SIZER_INCOMPATIBLE_FLAGS(wxEXPAND, wxALIGN_BOTTOM);
|
||||
|
||||
// But combining it with these flags and wxSHAPED does make sense and so
|
||||
// shouldn't result in an assert.
|
||||
CHECK_NOTHROW(
|
||||
sizer->Add(10, 10, 0, wxEXPAND | wxSHAPED | wxALIGN_CENTRE_VERTICAL)
|
||||
);
|
||||
CHECK_NOTHROW(
|
||||
sizer->Add(10, 10, 0, wxEXPAND | wxSHAPED | wxALIGN_TOP)
|
||||
);
|
||||
|
||||
|
||||
// And now exactly the same thing in the other direction.
|
||||
sizer = new wxBoxSizer(wxVERTICAL);
|
||||
@ -419,6 +428,13 @@ TEST_CASE_METHOD(BoxSizerTestCase, "BoxSizer::IncompatibleFlags", "[sizer]")
|
||||
ASSERT_SIZER_INCOMPATIBLE_FLAGS(wxEXPAND, wxALIGN_CENTRE_HORIZONTAL);
|
||||
ASSERT_SIZER_INCOMPATIBLE_FLAGS(wxEXPAND, wxALIGN_RIGHT);
|
||||
|
||||
CHECK_NOTHROW(
|
||||
sizer->Add(10, 10, 0, wxEXPAND | wxSHAPED | wxALIGN_CENTRE_HORIZONTAL)
|
||||
);
|
||||
CHECK_NOTHROW(
|
||||
sizer->Add(10, 10, 0, wxEXPAND | wxSHAPED | wxALIGN_RIGHT)
|
||||
);
|
||||
|
||||
#undef ASSERT_SIZER_INCOMPATIBLE_FLAGS
|
||||
#undef ASSERT_SIZER_INVALID_FLAGS
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user