mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-12 17:19:28 +01:00
Add a new Choice subclass which lets the UI display a value in addition to the title, similar to other controls.
This commit is contained in:
1 parent
ceb5a94c4a
commit
085faa87cc
2 files changed
+30
No files matched your search
@@ -450,4 +450,19 @@ void TextEditPopupScreen::OnCompleted(DialogResult result) {
|
||||
}
|
||||
}
|
||||
|
||||
void ChoiceWithValueDisplay::Draw(UIContext &dc) {
|
||||
Style style = dc.theme->itemStyle;
|
||||
std::ostringstream valueText;
|
||||
Choice::Draw(dc);
|
||||
dc.SetFontStyle(dc.theme->uiFont);
|
||||
|
||||
if (sValue_ != nullptr) {
|
||||
valueText << *sValue_;
|
||||
} else if (iValue_ != nullptr) {
|
||||
valueText << *iValue_;
|
||||
}
|
||||
|
||||
dc.DrawText(valueText.str().c_str(), bounds_.x2() - 12, bounds_.centerY(), style.fgColor, ALIGN_RIGHT | ALIGN_VCENTER);
|
||||
}
|
||||
|
||||
} // namespace UI
|
||||
@@ -266,4 +266,19 @@ private:
|
||||
std::string defaultText_;
|
||||
};
|
||||
|
||||
class ChoiceWithValueDisplay : public UI::Choice {
|
||||
public:
|
||||
ChoiceWithValueDisplay(int *value, const std::string &text, LayoutParams *layoutParams = 0)
|
||||
: Choice(text, layoutParams), iValue_(value) { sValue_ = nullptr; }
|
||||
|
||||
ChoiceWithValueDisplay(std::string *value, const std::string &text, LayoutParams *layoutParams = 0)
|
||||
: Choice(text, layoutParams), sValue_(value) { iValue_ = nullptr; }
|
||||
|
||||
void Draw(UIContext &dc);
|
||||
|
||||
private:
|
||||
int *iValue_;
|
||||
std::string *sValue_;
|
||||
};
|
||||
|
||||
} // namespace UI
|
||||
Reference in new issue
Block a user