Skip to content

Commit 44af55a

Browse files
committed
FullscreenUI: Differentiate title/subtitle colours
Makes it easier to read.
1 parent 72a0ba1 commit 44af55a

3 files changed

Lines changed: 54 additions & 50 deletions

File tree

src/core/fullscreen_ui.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7512,7 +7512,8 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
75127512
BeginMenuButtons();
75137513

75147514
SmallString summary;
7515-
const u32 text_color = ImGui::GetColorU32(ImGuiCol_Text);
7515+
const u32 text_color = ImGui::GetColorU32(ImGui::GetStyle().Colors[ImGuiCol_Text]);
7516+
const u32 subtitle_text_color = ImGui::GetColorU32(DarkerColor(ImGui::GetStyle().Colors[ImGuiCol_Text]));
75167517

75177518
for (const GameList::Entry* entry : s_state.game_list_sorted_entries)
75187519
{
@@ -7552,8 +7553,8 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
75527553

75537554
if (!summary.empty())
75547555
{
7555-
RenderShadowedTextClipped(UIStyle.MediumFont, summary_bb.Min, summary_bb.Max, text_color, summary.c_str(),
7556-
summary.end_ptr(), nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
7556+
RenderShadowedTextClipped(UIStyle.MediumFont, summary_bb.Min, summary_bb.Max, subtitle_text_color,
7557+
summary.c_str(), summary.end_ptr(), nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
75577558
}
75587559

75597560
if (pressed)

src/util/imgui_fullscreen.cpp

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,14 +1481,14 @@ bool ImGuiFullscreen::MenuButton(const char* title, const char* summary, bool en
14811481
const float midpoint = bb.Min.y + font->FontSize + LayoutScale(4.0f);
14821482
const ImRect title_bb(bb.Min, ImVec2(bb.Max.x, midpoint));
14831483
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), bb.Max);
1484-
const u32 color = enabled ? ImGui::GetColorU32(ImGuiCol_Text) : ImGui::GetColorU32(ImGuiCol_TextDisabled);
1485-
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, color, title, nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f,
1486-
&title_bb);
1484+
const ImVec4& color = ImGui::GetStyle().Colors[enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled];
1485+
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr, nullptr,
1486+
ImVec2(0.0f, 0.0f), 0.0f, &title_bb);
14871487

14881488
if (summary)
14891489
{
1490-
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, color, summary, nullptr, nullptr,
1491-
ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
1490+
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, ImGui::GetColorU32(DarkerColor(color)),
1491+
summary, nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
14921492
}
14931493

14941494
s_state.menu_button_index++;
@@ -1507,9 +1507,9 @@ bool ImGuiFullscreen::MenuButtonWithoutSummary(const char* title, bool enabled,
15071507
const float midpoint = bb.Min.y + font->FontSize + LayoutScale(4.0f);
15081508
const ImRect title_bb(bb.Min, ImVec2(bb.Max.x, midpoint));
15091509
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), bb.Max);
1510-
const u32 color = enabled ? ImGui::GetColorU32(ImGuiCol_Text) : ImGui::GetColorU32(ImGuiCol_TextDisabled);
1511-
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, color, title, nullptr, nullptr, text_align, 0.0f,
1512-
&title_bb);
1510+
const ImVec4& color = ImGui::GetStyle().Colors[enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled];
1511+
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr, nullptr,
1512+
text_align, 0.0f, &title_bb);
15131513

15141514
s_state.menu_button_index++;
15151515
return pressed;
@@ -1533,14 +1533,14 @@ bool ImGuiFullscreen::MenuImageButton(const char* title, const char* summary, Im
15331533
const float text_start_x = bb.Min.x + image_size.x + LayoutScale(15.0f);
15341534
const ImRect title_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint));
15351535
const ImRect summary_bb(ImVec2(text_start_x, midpoint), bb.Max);
1536-
const u32 color = enabled ? ImGui::GetColorU32(ImGuiCol_Text) : ImGui::GetColorU32(ImGuiCol_TextDisabled);
1537-
RenderShadowedTextClipped(title_font, title_bb.Min, title_bb.Max, color, title, nullptr, nullptr, ImVec2(0.0f, 0.0f),
1538-
0.0f, &title_bb);
1536+
const ImVec4& color = ImGui::GetStyle().Colors[enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled];
1537+
RenderShadowedTextClipped(title_font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr, nullptr,
1538+
ImVec2(0.0f, 0.0f), 0.0f, &title_bb);
15391539

15401540
if (summary)
15411541
{
1542-
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, color, summary, nullptr, nullptr,
1543-
ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
1542+
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, ImGui::GetColorU32(DarkerColor(color)),
1543+
summary, nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
15441544
}
15451545

15461546
s_state.menu_button_index++;
@@ -1641,15 +1641,15 @@ bool ImGuiFullscreen::ToggleButton(const char* title, const char* summary, bool*
16411641
const ImRect title_bb(bb.Min, ImVec2(bb.Max.x, midpoint));
16421642
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), bb.Max);
16431643

1644-
const u32 color = enabled ? ImGui::GetColorU32(ImGuiCol_Text) : ImGui::GetColorU32(ImGuiCol_TextDisabled);
1644+
const ImVec4& color = ImGui::GetStyle().Colors[enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled];
16451645

1646-
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, color, title, nullptr, nullptr, ImVec2(0.0, 0.0f), 0.0f,
1647-
&title_bb);
1646+
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr, nullptr,
1647+
ImVec2(0.0, 0.0f), 0.0f, &title_bb);
16481648

16491649
if (summary)
16501650
{
1651-
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, color, summary, nullptr, nullptr,
1652-
ImVec2(0.0, 0.0f), 0.0f, &summary_bb);
1651+
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, ImGui::GetColorU32(DarkerColor(color)),
1652+
summary, nullptr, nullptr, ImVec2(0.0, 0.0f), 0.0f, &summary_bb);
16531653
}
16541654

16551655
const float toggle_width = LayoutScale(50.0f);
@@ -1708,15 +1708,15 @@ bool ImGuiFullscreen::ThreeWayToggleButton(const char* title, const char* summar
17081708
const ImRect title_bb(bb.Min, ImVec2(bb.Max.x, midpoint));
17091709
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), bb.Max);
17101710

1711-
const u32 color = enabled ? ImGui::GetColorU32(ImGuiCol_Text) : ImGui::GetColorU32(ImGuiCol_TextDisabled);
1711+
const ImVec4& color = ImGui::GetStyle().Colors[enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled];
17121712

1713-
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, color, title, nullptr, nullptr, ImVec2(0.0, 0.0f), 0.0f,
1714-
&title_bb);
1713+
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr, nullptr,
1714+
ImVec2(0.0, 0.0f), 0.0f, &title_bb);
17151715

17161716
if (summary)
17171717
{
1718-
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, color, summary, nullptr, nullptr,
1719-
ImVec2(0.0, 0.0f), 0.0f, &summary_bb);
1718+
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, ImGui::GetColorU32(DarkerColor(color)),
1719+
summary, nullptr, nullptr, ImVec2(0.0, 0.0f), 0.0f, &summary_bb);
17201720
}
17211721

17221722
const float toggle_width = LayoutScale(50.0f);
@@ -1787,16 +1787,16 @@ bool ImGuiFullscreen::RangeButton(const char* title, const char* summary, s32* v
17871787
const float text_end = bb.Max.x - value_size.x;
17881788
const ImRect title_bb(bb.Min, ImVec2(text_end, midpoint));
17891789
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), ImVec2(text_end, bb.Max.y));
1790-
const u32 color = enabled ? ImGui::GetColorU32(ImGuiCol_Text) : ImGui::GetColorU32(ImGuiCol_TextDisabled);
1791-
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, color, title, nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f,
1792-
&title_bb);
1793-
RenderShadowedTextClipped(font, bb.Min, bb.Max, color, value_text.c_str(), value_text.end_ptr(), &value_size,
1794-
ImVec2(1.0f, 0.5f), 0.0f, &bb);
1790+
const ImVec4& color = ImGui::GetStyle().Colors[enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled];
1791+
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr, nullptr,
1792+
ImVec2(0.0f, 0.0f), 0.0f, &title_bb);
1793+
RenderShadowedTextClipped(font, bb.Min, bb.Max, ImGui::GetColorU32(color), value_text.c_str(), value_text.end_ptr(),
1794+
&value_size, ImVec2(1.0f, 0.5f), 0.0f, &bb);
17951795

17961796
if (summary)
17971797
{
1798-
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, color, summary, nullptr, nullptr,
1799-
ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
1798+
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, ImGui::GetColorU32(DarkerColor(color)),
1799+
summary, nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
18001800
}
18011801

18021802
if (pressed)
@@ -1846,16 +1846,16 @@ bool ImGuiFullscreen::RangeButton(const char* title, const char* summary, float*
18461846
const float text_end = bb.Max.x - value_size.x;
18471847
const ImRect title_bb(bb.Min, ImVec2(text_end, midpoint));
18481848
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), ImVec2(text_end, bb.Max.y));
1849-
const u32 color = enabled ? ImGui::GetColorU32(ImGuiCol_Text) : ImGui::GetColorU32(ImGuiCol_TextDisabled);
1850-
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, color, title, nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f,
1851-
&title_bb);
1852-
RenderShadowedTextClipped(font, bb.Min, bb.Max, color, value_text.c_str(), value_text.end_ptr(), &value_size,
1853-
ImVec2(1.0f, 0.5f), 0.0f, &bb);
1849+
const ImVec4& color = ImGui::GetStyle().Colors[enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled];
1850+
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr, nullptr,
1851+
ImVec2(0.0f, 0.0f), 0.0f, &title_bb);
1852+
RenderShadowedTextClipped(font, bb.Min, bb.Max, ImGui::GetColorU32(color), value_text.c_str(), value_text.end_ptr(),
1853+
&value_size, ImVec2(1.0f, 0.5f), 0.0f, &bb);
18541854

18551855
if (summary)
18561856
{
1857-
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, color, summary, nullptr, nullptr,
1858-
ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
1857+
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, ImGui::GetColorU32(DarkerColor(color)),
1858+
summary, nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
18591859
}
18601860

18611861
if (pressed)
@@ -1900,15 +1900,16 @@ bool ImGuiFullscreen::MenuButtonWithValue(const char* title, const char* summary
19001900
const float text_end = bb.Max.x - value_size.x;
19011901
const ImRect title_bb(bb.Min, ImVec2(text_end, midpoint));
19021902
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), ImVec2(text_end, bb.Max.y));
1903-
const u32 color = enabled ? ImGui::GetColorU32(ImGuiCol_Text) : ImGui::GetColorU32(ImGuiCol_TextDisabled);
1904-
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, color, title, nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f,
1905-
&title_bb);
1906-
RenderShadowedTextClipped(font, bb.Min, bb.Max, color, value, nullptr, nullptr, ImVec2(1.0f, 0.5f), 0.0f, &bb);
1903+
const ImVec4& color = ImGui::GetStyle().Colors[enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled];
1904+
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr, nullptr,
1905+
ImVec2(0.0f, 0.0f), 0.0f, &title_bb);
1906+
RenderShadowedTextClipped(font, bb.Min, bb.Max, ImGui::GetColorU32(color), value, nullptr, nullptr,
1907+
ImVec2(1.0f, 0.5f), 0.0f, &bb);
19071908

19081909
if (summary)
19091910
{
1910-
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, color, summary, nullptr, nullptr,
1911-
ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
1911+
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, ImGui::GetColorU32(DarkerColor(color)),
1912+
summary, nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
19121913
}
19131914

19141915
return pressed;
@@ -2235,16 +2236,18 @@ bool ImGuiFullscreen::HorizontalMenuItem(GPUTexture* icon, const char* title, co
22352236
ImVec2(bb.Min.x + (avail_width - title_size.x) * 0.5f, icon_pos.y + icon_size + LayoutScale(10.0f));
22362237
const ImRect title_bb = ImRect(title_pos, title_pos + title_size);
22372238

2238-
RenderShadowedTextClipped(title_font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(ImGuiCol_Text), title, nullptr,
2239-
&title_size, ImVec2(0.0f, 0.0f), avail_width, &title_bb);
2239+
RenderShadowedTextClipped(title_font, title_bb.Min, title_bb.Max,
2240+
ImGui::GetColorU32(ImGui::GetStyle().Colors[ImGuiCol_Text]), title, nullptr, &title_size,
2241+
ImVec2(0.0f, 0.0f), avail_width, &title_bb);
22402242

22412243
ImFont* desc_font = UIStyle.MediumFont;
22422244
const ImVec2 desc_size =
22432245
desc_font->CalcTextSizeA(desc_font->FontSize, std::numeric_limits<float>::max(), avail_width, description);
22442246
const ImVec2 desc_pos = ImVec2(bb.Min.x + (avail_width - desc_size.x) * 0.5f, title_bb.Max.y + LayoutScale(10.0f));
22452247
const ImRect desc_bb = ImRect(desc_pos, desc_pos + desc_size);
22462248

2247-
RenderShadowedTextClipped(desc_font, desc_bb.Min, desc_bb.Max, ImGui::GetColorU32(ImGuiCol_Text), description,
2249+
RenderShadowedTextClipped(desc_font, desc_bb.Min, desc_bb.Max,
2250+
ImGui::GetColorU32(DarkerColor(ImGui::GetStyle().Colors[ImGuiCol_Text])), description,
22482251
nullptr, nullptr, ImVec2(0.0f, 0.0f), avail_width, &desc_bb);
22492252

22502253
ImGui::SameLine();

src/util/imgui_fullscreen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ ALWAYS_INLINE static u32 ModAlpha(u32 col32, float a)
117117
}
118118

119119
// lighter in light themes
120-
ALWAYS_INLINE static ImVec4 DarkerColor(const ImVec4& v, float f = 0.75f)
120+
ALWAYS_INLINE static ImVec4 DarkerColor(const ImVec4& v, float f = 0.8f)
121121
{
122122
// light theme
123123
f = (UIStyle.PrimaryTextColor.x < UIStyle.PrimaryColor.x) ? (1.0f / f) : f;

0 commit comments

Comments
 (0)