mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-13 09:39:33 +01:00
Merge pull request #14779 from unknownbrackets/ui-ctrl-mapping
Tweak grid and scrollview handling
This commit is contained in:
4 files changed
+25
-5
No files matched your search
@@ -307,6 +307,7 @@ enum LayoutParamsType {
|
||||
LP_PLAIN = 0,
|
||||
LP_LINEAR = 1,
|
||||
LP_ANCHOR = 2,
|
||||
LP_GRID = 3,
|
||||
};
|
||||
|
||||
// Need a virtual destructor so vtables are created, otherwise RTTI can't work
|
||||
|
||||
@@ -765,10 +765,10 @@ void ScrollView::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec ver
|
||||
MeasureBySpec(layoutParams_->width, views_[0]->GetMeasuredWidth(), horiz, &measuredWidth_);
|
||||
}
|
||||
if (orientation_ == ORIENT_VERTICAL && vert.type != EXACTLY) {
|
||||
if (measuredHeight_ < views_[0]->GetMeasuredHeight()) {
|
||||
if (measuredHeight_ < views_[0]->GetMeasuredHeight() && layoutParams_->height < 0.0f) {
|
||||
measuredHeight_ = views_[0]->GetMeasuredHeight();
|
||||
}
|
||||
if (measuredHeight_ < views_[0]->GetBounds().h) {
|
||||
if (measuredHeight_ < views_[0]->GetBounds().h && layoutParams_->height < 0.0f) {
|
||||
measuredHeight_ = views_[0]->GetBounds().h;
|
||||
}
|
||||
if (vert.type == AT_MOST && measuredHeight_ > vert.size) {
|
||||
@@ -1246,7 +1246,9 @@ void GridLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec ver
|
||||
views_[i]->Measure(dc, MeasureSpec(measureType, settings_.columnWidth), MeasureSpec(measureType, settings_.rowHeight));
|
||||
}
|
||||
|
||||
MeasureBySpec(layoutParams_->width, 0.0f, horiz, &measuredWidth_);
|
||||
// Use the max possible width so AT_MOST gives us the full size.
|
||||
float maxWidth = (settings_.columnWidth + settings_.spacing) * views_.size() + settings_.spacing;
|
||||
MeasureBySpec(layoutParams_->width, maxWidth, horiz, &measuredWidth_);
|
||||
|
||||
// Okay, got the width we are supposed to adjust to. Now we can calculate the number of columns.
|
||||
numColumns_ = (measuredWidth_ - settings_.spacing) / (settings_.columnWidth + settings_.spacing);
|
||||
@@ -1263,7 +1265,9 @@ void GridLayout::Layout() {
|
||||
int x = 0;
|
||||
int count = 0;
|
||||
for (size_t i = 0; i < views_.size(); i++) {
|
||||
const GridLayoutParams *lp = views_[i]->GetLayoutParams()->As<GridLayoutParams>();
|
||||
Bounds itemBounds, innerBounds;
|
||||
Gravity grav = lp ? lp->gravity : G_CENTER;
|
||||
|
||||
itemBounds.x = bounds_.x + x;
|
||||
itemBounds.y = bounds_.y + y;
|
||||
@@ -1272,7 +1276,7 @@ void GridLayout::Layout() {
|
||||
|
||||
ApplyGravity(itemBounds, Margins(0.0f),
|
||||
views_[i]->GetMeasuredWidth(), views_[i]->GetMeasuredHeight(),
|
||||
G_HCENTER | G_VCENTER, innerBounds);
|
||||
grav, innerBounds);
|
||||
|
||||
views_[i]->SetBounds(innerBounds);
|
||||
views_[i]->Layout();
|
||||
|
||||
@@ -222,6 +222,21 @@ struct GridLayoutSettings {
|
||||
bool fillCells;
|
||||
};
|
||||
|
||||
class GridLayoutParams : public LayoutParams {
|
||||
public:
|
||||
GridLayoutParams()
|
||||
: LayoutParams(LP_GRID), gravity(G_CENTER) {}
|
||||
explicit GridLayoutParams(Gravity grav)
|
||||
: LayoutParams(LP_GRID), gravity(grav) {
|
||||
}
|
||||
|
||||
Gravity gravity;
|
||||
|
||||
static LayoutParamsType StaticType() {
|
||||
return LP_GRID;
|
||||
}
|
||||
};
|
||||
|
||||
class GridLayout : public ViewGroup {
|
||||
public:
|
||||
GridLayout(GridLayoutSettings settings, LayoutParams *layoutParams = 0);
|
||||
|
||||
+1
-1
@@ -1535,7 +1535,7 @@ void GridSettingsScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
auto di = GetI18NCategory("Dialog");
|
||||
auto sy = GetI18NCategory("System");
|
||||
|
||||
ScrollView *scroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, 50, 1.0f));
|
||||
ScrollView *scroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0f));
|
||||
LinearLayout *items = new LinearLayoutList(ORIENT_VERTICAL);
|
||||
|
||||
items->Add(new CheckBox(&g_Config.bGridView1, sy->T("Display Recent on a grid")));
|
||||
|
||||
Reference in new issue
Block a user