Add some padding to the textview, buildfix

This commit is contained in:
Henrik Rydgård 2023-01-31 21:26:12 +01:00
parent 4f20852953
commit 5154e5e7b8
3 changed files with 10 additions and 4 deletions

View file

@ -998,7 +998,8 @@ void TextView::GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz
bounds.w -= bulletOffset;
}
dc.MeasureTextRect(small_ ? dc.theme->uiFontSmall : dc.theme->uiFont, 1.0f, 1.0f, text_.c_str(), (int)text_.length(), bounds, &w, &h, textAlign_);
w += pad_ * 2.0f;
h += pad_ * 2.0f;
if (bullet_) {
w += bulletOffset;
}
@ -1044,9 +1045,9 @@ void TextView::Draw(UIContext &dc) {
if (shadow_) {
uint32_t shadowColor = 0x80000000;
dc.DrawTextRect(text_.c_str(), textBounds.Offset(1.0f, 1.0f), shadowColor, textAlign_);
dc.DrawTextRect(text_.c_str(), textBounds.Offset(1.0f + pad_, 1.0f + pad_), shadowColor, textAlign_);
}
dc.DrawTextRect(text_.c_str(), textBounds, textColor, textAlign_);
dc.DrawTextRect(text_.c_str(), textBounds.Offset(pad_, pad_), textColor, textAlign_);
if (small_) {
// If we changed font style, reset it.
dc.SetFontStyle(dc.theme->uiFont);

View file

@ -934,6 +934,7 @@ public:
void SetFocusable(bool focusable) { focusable_ = focusable; }
void SetClip(bool clip) { clip_ = clip; }
void SetBullet(bool bullet) { bullet_ = bullet; }
void SetPadding(float pad) { pad_ = pad; }
bool CanBeFocused() const override { return focusable_; }
@ -947,6 +948,7 @@ private:
bool focusable_;
bool clip_;
bool bullet_ = false;
float pad_ = 0.0f;
};
class TextEdit : public View {

View file

@ -1063,6 +1063,8 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
#if PPSSPP_PLATFORM(ANDROID)
if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_MOBILE) {
auto co = GetI18NCategory("Controls");
static const char *screenRotation[] = { "Auto", "Landscape", "Portrait", "Landscape Reversed", "Portrait Reversed", "Landscape Auto" };
PopupMultiChoice *rot = systemSettings->Add(new PopupMultiChoice(&g_Config.iScreenRotation, co->T("Screen Rotation"), screenRotation, 0, ARRAY_SIZE(screenRotation), co->GetName(), screenManager()));
rot->OnChoice.Handle(this, &GameSettingsScreen::OnScreenRotation);
@ -2269,7 +2271,8 @@ void RestoreSettingsScreen::CreatePopupContents(UI::ViewGroup *parent) {
"RestoreDefaultSettings",
"Restore these settings back to their defaults?\nYou can't undo this.\nPlease restart PPSSPP after restoring settings.");
parent->Add(new TextView(text, FLAG_WRAP_TEXT, false));
TextView *textView = parent->Add(new TextView(text, FLAG_WRAP_TEXT, false));
textView->SetPadding(10.0f);
parent->Add(new BitCheckBox(&restoreFlags_, (int)RestoreSettingsBits::SETTINGS, ga->T("Game Settings")));
parent->Add(new BitCheckBox(&restoreFlags_, (int)RestoreSettingsBits::CONTROLS, ga->T("Controls")));