mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
UI: Wrap long info items.
Avoid overlapping the label.
This commit is contained in:
parent
0fb655acf6
commit
6202e46e2c
2 changed files with 11 additions and 3 deletions
|
@ -66,6 +66,9 @@ struct Bounds {
|
|||
Bounds Expand(float amount) const {
|
||||
return Bounds(x - amount, y - amount, w + amount * 2, h + amount * 2);
|
||||
}
|
||||
Bounds Expand(float xAmount, float yAmount) const {
|
||||
return Bounds(x - xAmount, y - yAmount, w + xAmount * 2, h + yAmount * 2);
|
||||
}
|
||||
Bounds Offset(float xAmount, float yAmount) const {
|
||||
return Bounds(x + xAmount, y + yAmount, w, h);
|
||||
}
|
||||
|
|
|
@ -546,11 +546,16 @@ void InfoItem::Draw(UIContext &dc) {
|
|||
dc.FillRect(style.background, bounds_);
|
||||
|
||||
int paddingX = 12;
|
||||
Bounds padBounds = bounds_.Expand(-paddingX, 0);
|
||||
|
||||
float leftWidth, leftHeight;
|
||||
dc.MeasureTextRect(dc.theme->uiFont, 1.0f, 1.0f, text_.c_str(), (int)text_.size(), padBounds, &leftWidth, &leftHeight, ALIGN_VCENTER);
|
||||
|
||||
dc.SetFontStyle(dc.theme->uiFont);
|
||||
dc.DrawText(text_.c_str(), bounds_.x + paddingX, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
|
||||
dc.DrawText(rightText_.c_str(), bounds_.x2() - paddingX, bounds_.centerY(), style.fgColor, ALIGN_VCENTER | ALIGN_RIGHT);
|
||||
// dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y, bounds_.x2(), bounds_.y + 2, dc.theme->itemDownStyle.bgColor);
|
||||
dc.DrawTextRect(text_.c_str(), padBounds, style.fgColor, ALIGN_VCENTER);
|
||||
|
||||
Bounds rightBounds(padBounds.x + leftWidth, padBounds.y, padBounds.w - leftWidth, padBounds.h);
|
||||
dc.DrawTextRect(rightText_.c_str(), rightBounds, style.fgColor, ALIGN_VCENTER | ALIGN_RIGHT | FLAG_WRAP_TEXT);
|
||||
}
|
||||
|
||||
std::string InfoItem::DescribeText() const {
|
||||
|
|
Loading…
Add table
Reference in a new issue