mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Add "SetDrawTextFlags" to Choice to allow specifying DYNAMIC_ASCII
This commit is contained in:
parent
77c84f78aa
commit
c8a71894e3
2 changed files with 9 additions and 5 deletions
|
@ -475,7 +475,7 @@ void Choice::GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz,
|
|||
float Choice::CalculateTextScale(const UIContext &dc, float availWidth) const {
|
||||
float actualWidth, actualHeight;
|
||||
Bounds availBounds(0, 0, availWidth, bounds_.h);
|
||||
dc.MeasureTextRect(dc.theme->uiFont, 1.0f, 1.0f, text_.c_str(), (int)text_.size(), availBounds, &actualWidth, &actualHeight);
|
||||
dc.MeasureTextRect(dc.theme->uiFont, 1.0f, 1.0f, text_.c_str(), (int)text_.size(), availBounds, &actualWidth, &actualHeight, drawTextFlags_);
|
||||
if (actualWidth > availWidth) {
|
||||
return std::max(MIN_TEXT_SCALE, availWidth / actualWidth);
|
||||
}
|
||||
|
@ -511,14 +511,14 @@ void Choice::Draw(UIContext &dc) {
|
|||
|
||||
dc.SetFontScale(scale, scale);
|
||||
if (centered_) {
|
||||
dc.DrawTextRect(text_.c_str(), bounds_, style.fgColor, ALIGN_CENTER | FLAG_WRAP_TEXT);
|
||||
dc.DrawTextRect(text_.c_str(), bounds_, style.fgColor, ALIGN_CENTER | FLAG_WRAP_TEXT | drawTextFlags_);
|
||||
} else {
|
||||
if (rightIconImage_.isValid()) {
|
||||
uint32_t col = rightIconKeepColor_ ? 0xffffffff : style.fgColor; // Don't apply theme to gold icon
|
||||
dc.Draw()->DrawImageRotated(rightIconImage_, bounds_.x2() - 32 - paddingX, bounds_.centerY(), rightIconScale_, rightIconRot_, col, rightIconFlipH_);
|
||||
}
|
||||
Bounds textBounds(bounds_.x + paddingX + textPadding_.left, bounds_.y, availWidth, bounds_.h);
|
||||
dc.DrawTextRect(text_.c_str(), textBounds, style.fgColor, ALIGN_VCENTER | FLAG_WRAP_TEXT);
|
||||
dc.DrawTextRect(text_.c_str(), textBounds, style.fgColor, ALIGN_VCENTER | FLAG_WRAP_TEXT | drawTextFlags_);
|
||||
}
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
}
|
||||
|
|
|
@ -719,10 +719,13 @@ public:
|
|||
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
virtual void SetCentered(bool c) {
|
||||
void SetCentered(bool c) {
|
||||
centered_ = c;
|
||||
}
|
||||
virtual void SetIcon(ImageID iconImage, float scale = 1.0f, float rot = 0.0f, bool flipH = false, bool keepColor = true) {
|
||||
void SetDrawTextFlags(u32 flags) {
|
||||
drawTextFlags_ = flags;
|
||||
}
|
||||
void SetIcon(ImageID iconImage, float scale = 1.0f, float rot = 0.0f, bool flipH = false, bool keepColor = true) {
|
||||
rightIconKeepColor_ = keepColor;
|
||||
rightIconScale_ = scale;
|
||||
rightIconRot_ = rot;
|
||||
|
@ -748,6 +751,7 @@ protected:
|
|||
float imgScale_ = 1.0f;
|
||||
float imgRot_ = 0.0f;
|
||||
bool imgFlipH_ = false;
|
||||
u32 drawTextFlags_ = 0;
|
||||
|
||||
private:
|
||||
bool selected_ = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue