Skip to content

Commit

Permalink
Store: Minor layout fixes, bigger title text
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Sep 2, 2024
1 parent f0c8d07 commit 1b12a58
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
18 changes: 15 additions & 3 deletions Common/UI/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,13 @@ void TextView::GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz
if (bullet_) {
bounds.w -= bulletOffset;
}
dc.MeasureTextRect(small_ ? dc.theme->uiFontSmall : dc.theme->uiFont, 1.0f, 1.0f, text_, bounds, &w, &h, textAlign_);
const FontStyle *style = &dc.theme->uiFont;
if (small_) {
style = &dc.theme->uiFontSmall;
} else if (big_) {
style = &dc.theme->uiFontBig;
}
dc.MeasureTextRect(*style, 1.0f, 1.0f, text_, bounds, &w, &h, textAlign_);
w += pad_ * 2.0f;
h += pad_ * 2.0f;
if (bullet_) {
Expand Down Expand Up @@ -1074,7 +1080,13 @@ void TextView::Draw(UIContext &dc) {
style.background.color &= 0x7fffffff;
dc.FillRect(style.background, bounds_);
}
dc.SetFontStyle(small_ ? dc.theme->uiFontSmall : dc.theme->uiFont);
const FontStyle *style = &dc.theme->uiFont;
if (small_) {
style = &dc.theme->uiFontSmall;
} else if (big_) {
style = &dc.theme->uiFontBig;
}
dc.SetFontStyle(*style);

Bounds textBounds = bounds_;

Expand All @@ -1094,7 +1106,7 @@ void TextView::Draw(UIContext &dc) {
dc.DrawTextRect(text_, textBounds.Offset(1.0f + pad_, 1.0f + pad_), shadowColor, textAlign_);
}
dc.DrawTextRect(text_, textBounds.Offset(pad_, pad_), textColor, textAlign_);
if (small_) {
if (small_ || big_) {
// If we changed font style, reset it.
dc.SetFontStyle(dc.theme->uiFont);
}
Expand Down
14 changes: 8 additions & 6 deletions Common/UI/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct FontStyle {
struct Theme {
FontStyle uiFont;
FontStyle uiFontSmall;
FontStyle uiFontSmaller;
FontStyle uiFontBig;

ImageID checkOn;
ImageID checkOff;
Expand Down Expand Up @@ -982,10 +982,10 @@ class BorderView : public InertView {
class TextView : public InertView {
public:
TextView(std::string_view text, LayoutParams *layoutParams = 0)
: InertView(layoutParams), text_(text), textAlign_(0), textColor_(0xFFFFFFFF), small_(false), shadow_(false), focusable_(false), clip_(true) {}
: InertView(layoutParams), text_(text), textAlign_(0), textColor_(0xFFFFFFFF), small_(false) {}

TextView(std::string_view text, int textAlign, bool small, LayoutParams *layoutParams = 0)
: InertView(layoutParams), text_(text), textAlign_(textAlign), textColor_(0xFFFFFFFF), small_(small), shadow_(false), focusable_(false), clip_(true) {}
: InertView(layoutParams), text_(text), textAlign_(textAlign), textColor_(0xFFFFFFFF), small_(small) {}

void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;
void Draw(UIContext &dc) override;
Expand All @@ -994,6 +994,7 @@ class TextView : public InertView {
const std::string &GetText() const { return text_; }
std::string DescribeText() const override { return GetText(); }
void SetSmall(bool small) { small_ = small; }
void SetBig(bool big) { big_ = big; }
void SetTextColor(uint32_t color) { textColor_ = color; hasTextColor_ = true; }
void SetShadow(bool shadow) { shadow_ = shadow; }
void SetFocusable(bool focusable) { focusable_ = focusable; }
Expand All @@ -1009,9 +1010,10 @@ class TextView : public InertView {
uint32_t textColor_;
bool hasTextColor_ = false;
bool small_;
bool shadow_;
bool focusable_;
bool clip_;
bool big_ = false;
bool shadow_ = false;
bool focusable_ = false;
bool clip_ = true;
bool bullet_ = false;
float pad_ = 0.0f;
};
Expand Down
8 changes: 4 additions & 4 deletions UI/Store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void ProductView::CreateViews() {
if (!entry_.iconURL.empty()) {
Add(new HttpImageFileView(&g_DownloadManager, ResolveUrl(StoreBaseUrl(), entry_.iconURL), IS_FIXED))->SetFixedSize(144, 88);
}
Add(new TextView(entry_.name));
Add(new TextView(entry_.name))->SetBig(true);
Add(new TextView(entry_.author));

auto st = GetI18NCategory(I18NCat::STORE);
Expand All @@ -313,7 +313,7 @@ void ProductView::CreateViews() {
g_GameManager.UninstallGameOnThread(entry_.file);
return UI::EVENT_DONE;
});
Add(new TextView(st->T("Installed")));
// Add(new TextView(st->T("Installed"))); // Not really needed
}

cancelButton_ = Add(new Button(di->T("Cancel")));
Expand All @@ -334,8 +334,8 @@ void ProductView::CreateViews() {

if (!entry_.license.empty()) {
LinearLayout *horiz = Add(new LinearLayout(ORIENT_HORIZONTAL));
horiz->Add(new TextView(StringFromFormat("%s: %s", st->T_cstr("License"), entry_.license.c_str())));
horiz->Add(new Button(di->T("More information...")))->OnClick.Add([this](UI::EventParams) {
horiz->Add(new TextView(StringFromFormat("%s: %s", st->T_cstr("License"), entry_.license.c_str()), new LinearLayoutParams(0.0, G_VCENTER)));
horiz->Add(new Button(di->T("More information..."), new LinearLayoutParams(0.0, G_VCENTER)))->OnClick.Add([this](UI::EventParams) {
std::string url = StringFromFormat("https://www.ppsspp.org/docs/reference/homebrew-store-distribution/#%s", entry_.file.c_str());
System_LaunchUrl(LaunchUrlType::BROWSER_URL, url.c_str());
return UI::EVENT_DONE;
Expand Down
4 changes: 2 additions & 2 deletions UI/Theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ void UpdateTheme(UIContext *ctx) {
#if defined(USING_WIN_UI) || PPSSPP_PLATFORM(UWP) || defined(USING_QT_UI)
ui_theme.uiFont = UI::FontStyle(FontID("UBUNTU24"), g_Config.sFont.c_str(), 22);
ui_theme.uiFontSmall = UI::FontStyle(FontID("UBUNTU24"), g_Config.sFont.c_str(), 17);
ui_theme.uiFontSmaller = UI::FontStyle(FontID("UBUNTU24"), g_Config.sFont.c_str(), 13);
ui_theme.uiFontBig = UI::FontStyle(FontID("UBUNTU24"), g_Config.sFont.c_str(), 28);
#else
ui_theme.uiFont = UI::FontStyle(FontID("UBUNTU24"), "", 20);
ui_theme.uiFontSmall = UI::FontStyle(FontID("UBUNTU24"), "", 15);
ui_theme.uiFontSmaller = UI::FontStyle(FontID("UBUNTU24"), "", 12);
ui_theme.uiFontBig = UI::FontStyle(FontID("UBUNTU24"), "", 26);
#endif

ui_theme.checkOn = ImageID("I_CHECKEDBOX");
Expand Down

0 comments on commit 1b12a58

Please sign in to comment.