mirror of https://github.com/PCSX2/pcsx2.git
ImGuiFullscreen: Display checkmark on right of choice dialog
Backport from: f5815f3183
This commit is contained in:
parent
69574aecc6
commit
04fdd09d1e
|
@ -1088,10 +1088,16 @@ bool ImGuiFullscreen::MenuHeadingButton(
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
// don't draw over a prerendered border
|
// don't draw over a prerendered border
|
||||||
const float border_size = ImGui::GetStyle().FrameBorderSize;
|
const float border_size = ImGui::GetStyle().FrameBorderSize;
|
||||||
const ImVec2 border_size_v = ImVec2(border_size, border_size);
|
const ImVec2 border_size_v = ImVec2(border_size, border_size);
|
||||||
ImVec2 pos, size;
|
ImVec2 pos, size;
|
||||||
|
@ -1112,6 +1118,16 @@ 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)
|
||||||
|
@ -1983,8 +1999,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())
|
||||||
|
@ -2124,7 +2140,8 @@ void ImGuiFullscreen::DrawChoiceDialog()
|
||||||
{
|
{
|
||||||
auto& option = s_choice_dialog_options[i];
|
auto& option = s_choice_dialog_options[i];
|
||||||
|
|
||||||
const std::string title(fmt::format("{0} {1}", option.second ? ICON_FA_CHECK_SQUARE : ICON_FA_SQUARE, option.first));
|
const SmallString title =
|
||||||
|
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;
|
||||||
|
@ -2142,7 +2159,8 @@ void ImGuiFullscreen::DrawChoiceDialog()
|
||||||
title += ICON_FA_CHECK " ";
|
title += ICON_FA_CHECK " ";
|
||||||
title += option.first;
|
title += option.first;
|
||||||
|
|
||||||
if (ActiveButton(title.c_str(), option.second, true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
|
if (ActiveButtonWithRightText(option.first.c_str(), option.second ? ICON_FA_CHECK : nullptr, 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++)
|
||||||
|
@ -2307,7 +2325,7 @@ void ImGuiFullscreen::OpenConfirmMessageDialog(
|
||||||
s_message_dialog_callback = std::move(callback);
|
s_message_dialog_callback = std::move(callback);
|
||||||
s_message_dialog_buttons[0] = std::move(yes_button_text);
|
s_message_dialog_buttons[0] = std::move(yes_button_text);
|
||||||
s_message_dialog_buttons[1] = std::move(no_button_text);
|
s_message_dialog_buttons[1] = std::move(no_button_text);
|
||||||
QueueResetFocus(FocusResetType::PopupOpened);
|
QueueResetFocus(FocusResetType::PopupOpened);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiFullscreen::OpenInfoMessageDialog(
|
void ImGuiFullscreen::OpenInfoMessageDialog(
|
||||||
|
|
|
@ -167,6 +167,8 @@ namespace ImGuiFullscreen
|
||||||
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, float height = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY,
|
bool ActiveButton(const char* title, bool is_active, bool enabled = true, float height = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY,
|
||||||
ImFont* font = g_large_font);
|
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, float height = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY,
|
bool MenuButtonWithoutSummary(const char* title, bool enabled = true, float height = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY,
|
||||||
|
|
Loading…
Reference in New Issue