mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-08-26 07:25:14 +02:00
UI: Wrap long info items.
Avoid overlapping the label.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
+8
-3
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user