@@ -61,6 +61,12 @@ class SimpleAxisLayout::Impl {
61
61
std::optional<float > m_maxRelativeScale = 2 .f;
62
62
SimpleAxisLayout* m_layout = nullptr ;
63
63
64
+ std::optional<float > m_minMainAxis;
65
+ std::optional<float > m_minCrossAxis;
66
+ // max sizes are currently unused, max layout size is planned
67
+ std::optional<float > m_maxMainAxis;
68
+ std::optional<float > m_maxCrossAxis;
69
+
64
70
std::unordered_map<CCNode*, float > m_originalScalesPerNode;
65
71
std::unordered_map<CCNode*, float > m_relativeScalesPerNode;
66
72
@@ -227,8 +233,9 @@ std::unordered_map<CCNode*, float> SimpleAxisLayout::Impl::calculateCrossScaling
227
233
228
234
switch (m_crossAxisScaling) {
229
235
case AxisScaling::Grow:
236
+ if (m_minCrossAxis == std::nullopt) m_minCrossAxis = layoutWidth;
230
237
// grow the layout to fit the widest node
231
- if (maxWidth > layoutWidth) layoutWidth = maxWidth;
238
+ layoutWidth = std::min (m_minCrossAxis. value (), maxWidth) ;
232
239
break ;
233
240
case AxisScaling::Fit:
234
241
// fit the layout to the widest node
@@ -286,8 +293,9 @@ std::unordered_map<CCNode*, float> SimpleAxisLayout::Impl::calculateMainScaling(
286
293
287
294
switch (m_mainAxisScaling) {
288
295
case AxisScaling::Grow:
296
+ if (m_minMainAxis == std::nullopt) m_minMainAxis = layoutHeight;
289
297
// grow the layout to fit all the nodes
290
- if (totalHeight > layoutHeight) layoutHeight = totalHeight;
298
+ layoutHeight = std::min (m_minMainAxis. value (), totalHeight) ;
291
299
break ;
292
300
case AxisScaling::Fit:
293
301
// fit the layout to all the nodes
@@ -503,7 +511,8 @@ void SimpleAxisLayout::Impl::applyCrossPositioning(CCNode* layout, std::vector<C
503
511
// reapply grow/fit since main scaling may have changed the max width
504
512
switch (m_crossAxisScaling) {
505
513
case AxisScaling::Grow:
506
- if (maxWidth > layoutWidth) layoutWidth = maxWidth;
514
+ if (m_minCrossAxis == std::nullopt) m_minCrossAxis = layoutWidth;
515
+ layoutWidth = std::min (m_minCrossAxis.value (), maxWidth);
507
516
break ;
508
517
case AxisScaling::Fit:
509
518
layoutWidth = maxWidth;
0 commit comments