mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-22 16:25:39 +00:00
ImGuiFullscreen: Display checkmark on right of choice dialog
This commit is contained in:
parent
05f9f33ec6
commit
f5815f3183
|
@ -1120,6 +1120,12 @@ bool ImGuiFullscreen::MenuHeadingButton(const char* title, const char* value /*=
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGuiFullscreen::ActiveButton(const char* title, bool is_active, bool enabled, float height, ImFont* font)
|
bool ImGuiFullscreen::ActiveButton(const char* title, bool is_active, bool enabled, float height, ImFont* font)
|
||||||
|
{
|
||||||
|
return ActiveButtonWithRightText(title, nullptr, is_active, enabled, height, font);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ImGuiFullscreen::ActiveButtonWithRightText(const char* title, const char* right_title, bool is_active,
|
||||||
|
bool enabled, float height, ImFont* font)
|
||||||
{
|
{
|
||||||
if (is_active)
|
if (is_active)
|
||||||
{
|
{
|
||||||
|
@ -1144,6 +1150,15 @@ bool ImGuiFullscreen::ActiveButton(const char* title, bool is_active, bool enabl
|
||||||
|
|
||||||
ImGui::PushFont(font);
|
ImGui::PushFont(font);
|
||||||
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, title, nullptr, nullptr, ImVec2(0.0f, 0.0f), &title_bb);
|
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, title, nullptr, nullptr, ImVec2(0.0f, 0.0f), &title_bb);
|
||||||
|
|
||||||
|
if (right_title && *right_title)
|
||||||
|
{
|
||||||
|
const ImVec2 right_text_size = font->CalcTextSizeA(font->FontSize, title_bb.GetWidth(), 0.0f, right_title);
|
||||||
|
const ImVec2 right_text_start = ImVec2(title_bb.Max.x - right_text_size.x, title_bb.Min.y);
|
||||||
|
ImGui::RenderTextClipped(right_text_start, title_bb.Max, right_title, nullptr, &right_text_size, ImVec2(0.0f, 0.0f),
|
||||||
|
&title_bb);
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
|
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
|
@ -2187,8 +2202,8 @@ void ImGuiFullscreen::DrawFileSelector()
|
||||||
|
|
||||||
if (!s_file_selector_current_directory.empty())
|
if (!s_file_selector_current_directory.empty())
|
||||||
{
|
{
|
||||||
MenuButton(fmt::format(ICON_FA_FOLDER_OPEN " {}", s_file_selector_current_directory).c_str(), nullptr, false,
|
MenuButton(SmallString::from_format(ICON_FA_FOLDER_OPEN " {}", s_file_selector_current_directory).c_str(),
|
||||||
LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
|
nullptr, false, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_file_selector_directory && !s_file_selector_current_directory.empty())
|
if (s_file_selector_directory && !s_file_selector_current_directory.empty())
|
||||||
|
@ -2332,8 +2347,8 @@ void ImGuiFullscreen::DrawChoiceDialog()
|
||||||
{
|
{
|
||||||
auto& option = s_choice_dialog_options[i];
|
auto& option = s_choice_dialog_options[i];
|
||||||
|
|
||||||
const std::string title(
|
const SmallString title =
|
||||||
fmt::format("{0} {1}", option.second ? ICON_FA_CHECK_SQUARE : ICON_FA_SQUARE, option.first));
|
SmallString::from_format("{0} {1}", option.second ? ICON_FA_CHECK_SQUARE : ICON_FA_SQUARE, option.first);
|
||||||
if (MenuButton(title.c_str(), nullptr, true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
|
if (MenuButton(title.c_str(), nullptr, true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
|
||||||
{
|
{
|
||||||
choice = i;
|
choice = i;
|
||||||
|
@ -2346,12 +2361,8 @@ void ImGuiFullscreen::DrawChoiceDialog()
|
||||||
for (s32 i = 0; i < static_cast<s32>(s_choice_dialog_options.size()); i++)
|
for (s32 i = 0; i < static_cast<s32>(s_choice_dialog_options.size()); i++)
|
||||||
{
|
{
|
||||||
auto& option = s_choice_dialog_options[i];
|
auto& option = s_choice_dialog_options[i];
|
||||||
std::string title;
|
if (ActiveButtonWithRightText(option.first.c_str(), option.second ? ICON_FA_CHECK : nullptr, option.second,
|
||||||
if (option.second)
|
true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
|
||||||
title += ICON_FA_CHECK " ";
|
|
||||||
title += option.first;
|
|
||||||
|
|
||||||
if (ActiveButton(title.c_str(), option.second, true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
|
|
||||||
{
|
{
|
||||||
choice = i;
|
choice = i;
|
||||||
for (s32 j = 0; j < static_cast<s32>(s_choice_dialog_options.size()); j++)
|
for (s32 j = 0; j < static_cast<s32>(s_choice_dialog_options.size()); j++)
|
||||||
|
|
|
@ -200,6 +200,8 @@ void MenuHeading(const char* title, bool draw_line = true);
|
||||||
bool MenuHeadingButton(const char* title, const char* value = nullptr, bool enabled = true, bool draw_line = true);
|
bool MenuHeadingButton(const char* title, const char* value = nullptr, bool enabled = true, bool draw_line = true);
|
||||||
bool ActiveButton(const char* title, bool is_active, bool enabled = true,
|
bool ActiveButton(const char* title, bool is_active, bool enabled = true,
|
||||||
float height = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, ImFont* font = g_large_font);
|
float height = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, ImFont* font = g_large_font);
|
||||||
|
bool ActiveButtonWithRightText(const char* title, const char* right_title, bool is_active, bool enabled = true,
|
||||||
|
float height = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, ImFont* font = g_large_font);
|
||||||
bool MenuButton(const char* title, const char* summary, bool enabled = true, float height = LAYOUT_MENU_BUTTON_HEIGHT,
|
bool MenuButton(const char* title, const char* summary, bool enabled = true, float height = LAYOUT_MENU_BUTTON_HEIGHT,
|
||||||
ImFont* font = g_large_font, ImFont* summary_font = g_medium_font);
|
ImFont* font = g_large_font, ImFont* summary_font = g_medium_font);
|
||||||
bool MenuButtonWithoutSummary(const char* title, bool enabled = true,
|
bool MenuButtonWithoutSummary(const char* title, bool enabled = true,
|
||||||
|
|
Loading…
Reference in a new issue