mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-05 04:56:31 +00:00
Add a simple grid-based layout manager.
This commit is contained in:
parent
7ebbe20904
commit
f45b5d6094
46
ui/ui.h
46
ui/ui.h
@ -81,6 +81,52 @@ private:
|
||||
float spacing_;
|
||||
};
|
||||
|
||||
class HGrid : public LayoutManager {
|
||||
public:
|
||||
HGrid(float x, float y, float xMax, float xSpacing = 2.0f, float ySpacing = 2.0f)
|
||||
: x_(x), y_(y), xInit_(x), xMax_(xMax), xSpacing_(xSpacing), ySpacing_(ySpacing) {}
|
||||
virtual void GetPos(float *w, float *h, float *x, float *y) const {
|
||||
*x = x_;
|
||||
*y = y_;
|
||||
x_ += *w + xSpacing_;
|
||||
if (x_ >= xMax_) {
|
||||
x_ = xInit_;
|
||||
y_ += *h + ySpacing_;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
mutable float x_;
|
||||
mutable float y_;
|
||||
float xInit_;
|
||||
float xMax_;
|
||||
float xSpacing_;
|
||||
float ySpacing_;
|
||||
};
|
||||
|
||||
class VGrid : public LayoutManager {
|
||||
public:
|
||||
VGrid(float x, float y, float yMax, float xSpacing = 2.0f, float ySpacing = 2.0f)
|
||||
: x_(x), y_(y), yInit_(y), yMax_(yMax), xSpacing_(xSpacing), ySpacing_(ySpacing) {}
|
||||
virtual void GetPos(float *w, float *h, float *x, float *y) const {
|
||||
*x = x_;
|
||||
*y = y_;
|
||||
y_ += *h + ySpacing_;
|
||||
if (y_ >= yMax_) {
|
||||
x_ += *w + xSpacing_;
|
||||
y_ = yInit_;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
mutable float x_;
|
||||
mutable float y_;
|
||||
float yInit_;
|
||||
float yMax_;
|
||||
float xSpacing_;
|
||||
float ySpacing_;
|
||||
};
|
||||
|
||||
|
||||
#ifndef MAX_POINTERS
|
||||
#define MAX_POINTERS 8
|
||||
|
Loading…
x
Reference in New Issue
Block a user