UI: Ask linear child views to stay inside AT_MOST.

Fixes the DevMenu pop up in larger windows.
This commit is contained in:
Unknown W. Brackets 2017-03-19 16:36:21 -07:00
parent efbfdbb4a7
commit 9f3415f43f
2 changed files with 9 additions and 1 deletions

View File

@ -61,7 +61,7 @@ void DevMenu::CreatePopupContents(UI::ViewGroup *parent) {
I18NCategory *dev = GetI18NCategory("Developer");
I18NCategory *sy = GetI18NCategory("System");
ScrollView *scroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0f));
ScrollView *scroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
LinearLayout *items = new LinearLayout(ORIENT_VERTICAL);
#if !defined(MOBILE_DEVICE)

View File

@ -410,11 +410,19 @@ void LinearLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec v
if (v.type == UNSPECIFIED && measuredHeight_ != 0.0f)
v = MeasureSpec(AT_MOST, measuredHeight_);
view->Measure(dc, MeasureSpec(UNSPECIFIED, measuredWidth_), v - (float)margins.vert());
if (horiz.type == AT_MOST && view->GetMeasuredWidth() + margins.horiz() > horiz.size - weightZeroSum) {
// Try again, this time with AT_MOST.
view->Measure(dc, horiz, v - (float)margins.vert());
}
} else if (orientation_ == ORIENT_VERTICAL) {
MeasureSpec h = horiz;
if (h.type == UNSPECIFIED && measuredWidth_ != 0.0f)
h = MeasureSpec(AT_MOST, measuredWidth_);
view->Measure(dc, h - (float)margins.horiz(), MeasureSpec(UNSPECIFIED, measuredHeight_));
if (vert.type == AT_MOST && view->GetMeasuredHeight() + margins.vert() > vert.size - weightZeroSum) {
// Try again, this time with AT_MOST.
view->Measure(dc, h - (float)margins.horiz(), vert);
}
}
float amount;