diff --git a/Common/UI/View.cpp b/Common/UI/View.cpp index 8be9b3076d..b6c3cc04e6 100644 --- a/Common/UI/View.cpp +++ b/Common/UI/View.cpp @@ -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); } diff --git a/Common/UI/View.h b/Common/UI/View.h index eb09ea342e..58f4d0e581 100644 --- a/Common/UI/View.h +++ b/Common/UI/View.h @@ -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;