mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-27 23:40:39 +00:00
UI: Give ItemHeaders intrinsic size.
This commit is contained in:
parent
48c0407f21
commit
52ee2f7790
@ -617,6 +617,19 @@ void ItemHeader::Draw(UIContext &dc) {
|
|||||||
dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), dc.theme->headerStyle.fgColor);
|
dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), dc.theme->headerStyle.fgColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ItemHeader::GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const {
|
||||||
|
Bounds bounds(0, 0, layoutParams_->width, layoutParams_->height);
|
||||||
|
if (bounds.w < 0) {
|
||||||
|
// If there's no size, let's grow as big as we want.
|
||||||
|
bounds.w = horiz.size == 0 ? MAX_ITEM_SIZE : horiz.size;
|
||||||
|
}
|
||||||
|
if (bounds.h < 0) {
|
||||||
|
bounds.h = vert.size == 0 ? MAX_ITEM_SIZE : vert.size;
|
||||||
|
}
|
||||||
|
ApplyBoundsBySpec(bounds, horiz, vert);
|
||||||
|
dc.MeasureTextRect(dc.theme->uiFontSmall, 1.0f, 1.0f, text_.c_str(), (int)text_.length(), bounds, &w, &h, ALIGN_LEFT | ALIGN_VCENTER);
|
||||||
|
}
|
||||||
|
|
||||||
void PopupHeader::Draw(UIContext &dc) {
|
void PopupHeader::Draw(UIContext &dc) {
|
||||||
const float paddingHorizontal = 12;
|
const float paddingHorizontal = 12;
|
||||||
const float availableWidth = bounds_.w - paddingHorizontal * 2;
|
const float availableWidth = bounds_.w - paddingHorizontal * 2;
|
||||||
|
@ -702,6 +702,7 @@ class ItemHeader : public Item {
|
|||||||
public:
|
public:
|
||||||
ItemHeader(const std::string &text, LayoutParams *layoutParams = 0);
|
ItemHeader(const std::string &text, LayoutParams *layoutParams = 0);
|
||||||
void Draw(UIContext &dc) override;
|
void Draw(UIContext &dc) override;
|
||||||
|
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string text_;
|
std::string text_;
|
||||||
|
Loading…
Reference in New Issue
Block a user