From 5154e5e7b83426225264abccff436bcadf68a543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 31 Jan 2023 21:26:12 +0100 Subject: [PATCH] Add some padding to the textview, buildfix --- Common/UI/View.cpp | 7 ++++--- Common/UI/View.h | 2 ++ UI/GameSettingsScreen.cpp | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Common/UI/View.cpp b/Common/UI/View.cpp index 7a2bb50c7e..bef6320156 100644 --- a/Common/UI/View.cpp +++ b/Common/UI/View.cpp @@ -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); diff --git a/Common/UI/View.h b/Common/UI/View.h index 7caa8ef0ba..c50a335151 100644 --- a/Common/UI/View.h +++ b/Common/UI/View.h @@ -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 { diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index aacd15160d..d35838f5ba 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -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")));