Fix wxFLEX_GROWMODE_ALL in wxFlexGridSizer with proportions
Setting wxFLEX_GROWMODE_ALL for the non-flexible direction broke handling of proportions in the flexible direction which were unexpectedly not taken into account at all any more due to not passing them to DoAdjustForGrowables(). Fix this by still respecting the proportions in this case and add a test case to ensure this doesn't get broken again. See #23251, #23253. (cherry picked from commit 6bfabd7afe16ed734565635228d540cb47b16970)
This commit is contained in:
parent
17d7cf3a5a
commit
4b57475e58
@ -239,6 +239,10 @@ All:
|
|||||||
|
|
||||||
- Add move ctor and assignment to wxString (Pavel Tyunin, #23224).
|
- Add move ctor and assignment to wxString (Pavel Tyunin, #23224).
|
||||||
|
|
||||||
|
All (GUI):
|
||||||
|
|
||||||
|
- Fix wxFLEX_GROWMODE_ALL in wxFlexGridSizer with proportions (#23253).
|
||||||
|
|
||||||
wxOSX:
|
wxOSX:
|
||||||
|
|
||||||
- Respect composition mode when drawing bitmaps (#23240).
|
- Respect composition mode when drawing bitmaps (#23240).
|
||||||
|
@ -2111,16 +2111,23 @@ void wxFlexGridSizer::AdjustForGrowables(const wxSize& sz, const wxSize& origina
|
|||||||
}
|
}
|
||||||
#endif // wxDEBUG_LEVEL
|
#endif // wxDEBUG_LEVEL
|
||||||
|
|
||||||
|
// Use growable columns proportions if we are flexible in this direction.
|
||||||
|
const wxArrayInt* const growableColsProportions =
|
||||||
|
(m_flexDirection & wxHORIZONTAL) || (m_growMode == wxFLEX_GROWMODE_SPECIFIED)
|
||||||
|
? &m_growableColsProportions
|
||||||
|
: NULL;
|
||||||
|
|
||||||
if ( (m_flexDirection & wxHORIZONTAL) || (m_growMode != wxFLEX_GROWMODE_NONE) )
|
// And do anything at all with the columns if we're either flexible or must
|
||||||
|
// resize all columns uniformly (otherwise we use wxFLEX_GROWMODE_NONE and
|
||||||
|
// there is nothing to do).
|
||||||
|
if ( growableColsProportions || (m_growMode == wxFLEX_GROWMODE_ALL) )
|
||||||
{
|
{
|
||||||
DoAdjustForGrowables
|
DoAdjustForGrowables
|
||||||
(
|
(
|
||||||
sz.x - minSize.x,
|
sz.x - minSize.x,
|
||||||
m_growableCols,
|
m_growableCols,
|
||||||
m_colWidths,
|
m_colWidths,
|
||||||
m_growMode == wxFLEX_GROWMODE_SPECIFIED ? &m_growableColsProportions
|
growableColsProportions
|
||||||
: NULL
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// This gives nested objects that benefit from knowing one size
|
// This gives nested objects that benefit from knowing one size
|
||||||
@ -2148,13 +2155,18 @@ void wxFlexGridSizer::AdjustForGrowables(const wxSize& sz, const wxSize& origina
|
|||||||
sz.x - minSize.x,
|
sz.x - minSize.x,
|
||||||
m_growableCols,
|
m_growableCols,
|
||||||
m_colWidths,
|
m_colWidths,
|
||||||
m_growMode == wxFLEX_GROWMODE_SPECIFIED ? &m_growableColsProportions
|
growableColsProportions
|
||||||
: NULL
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (m_flexDirection & wxVERTICAL) || (m_growMode != wxFLEX_GROWMODE_NONE) )
|
// Same as above but for the rows.
|
||||||
|
const wxArrayInt* const growableRowsProportions =
|
||||||
|
(m_flexDirection & wxVERTICAL) || (m_growMode == wxFLEX_GROWMODE_SPECIFIED)
|
||||||
|
? &m_growableRowsProportions
|
||||||
|
: NULL;
|
||||||
|
|
||||||
|
if ( growableRowsProportions || (m_growMode == wxFLEX_GROWMODE_ALL) )
|
||||||
{
|
{
|
||||||
// pass NULL instead of proportions if the grow mode is ALL as we
|
// pass NULL instead of proportions if the grow mode is ALL as we
|
||||||
// should treat all rows as having proportion of 1 then
|
// should treat all rows as having proportion of 1 then
|
||||||
@ -2163,8 +2175,7 @@ void wxFlexGridSizer::AdjustForGrowables(const wxSize& sz, const wxSize& origina
|
|||||||
sz.y - minSize.y,
|
sz.y - minSize.y,
|
||||||
m_growableRows,
|
m_growableRows,
|
||||||
m_rowHeights,
|
m_rowHeights,
|
||||||
m_growMode == wxFLEX_GROWMODE_SPECIFIED ? &m_growableRowsProportions
|
growableRowsProportions
|
||||||
: NULL
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,3 +179,37 @@ TEST_CASE_METHOD(GridSizerTestCase,
|
|||||||
m_sizer->Add(10, 10, wxSizerFlags().Expand().Centre())
|
m_sizer->Add(10, 10, wxSizerFlags().Expand().Centre())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE_METHOD(GridSizerTestCase,
|
||||||
|
"wxGridSizer::GrowMode",
|
||||||
|
"[grid-sizer][sizer]")
|
||||||
|
{
|
||||||
|
wxVector<wxWindow*> children;
|
||||||
|
for ( int n = 0; n < 4; n++ )
|
||||||
|
{
|
||||||
|
children.push_back(new wxWindow(m_win, wxID_ANY));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Proportions of growable columns should be respected.
|
||||||
|
m_sizer->AddGrowableCol(0, 1);
|
||||||
|
m_sizer->AddGrowableCol(1, 4);
|
||||||
|
|
||||||
|
// However proportions of growable rows should not because we use
|
||||||
|
// wxFLEX_GROWMODE_ALL which tells the sizer to grow all rows uniformly.
|
||||||
|
m_sizer->AddGrowableRow(0, 1);
|
||||||
|
m_sizer->AddGrowableRow(1, 4);
|
||||||
|
|
||||||
|
m_sizer->SetFlexibleDirection(wxHORIZONTAL);
|
||||||
|
m_sizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_ALL);
|
||||||
|
|
||||||
|
// Make both dimensions divisible by 5 to avoid dealing with extra pixels.
|
||||||
|
m_win->SetClientSize(100, 100);
|
||||||
|
|
||||||
|
SetChildren(children, wxSizerFlags().Expand());
|
||||||
|
|
||||||
|
// Check that we have different widths but same heights for all children.
|
||||||
|
CHECK( children[0]->GetSize() == wxSize(20, 50) );
|
||||||
|
CHECK( children[1]->GetSize() == wxSize(80, 50) );
|
||||||
|
CHECK( children[2]->GetSize() == wxSize(20, 50) );
|
||||||
|
CHECK( children[3]->GetSize() == wxSize(80, 50) );
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user