mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-04-27 09:55:42 -04:00
FullscreenUI: Put bindings on one line
This commit is contained in:
parent
fc6359457b
commit
43c0ce0b3e
@ -1352,17 +1352,18 @@ void FullscreenUI::DrawInputBindingButton(SettingsInterface* bsi, InputBindingIn
|
|||||||
TinyString title;
|
TinyString title;
|
||||||
title.fmt("{}/{}", section, name);
|
title.fmt("{}/{}", section, name);
|
||||||
|
|
||||||
|
std::string value = bsi->GetStringValue(section, name);
|
||||||
|
const bool oneline = (std::count_if(value.begin(), value.end(), [](char ch) { return (ch == '&'); }) <= 1);
|
||||||
|
|
||||||
ImRect bb;
|
ImRect bb;
|
||||||
bool visible, hovered, clicked;
|
bool visible, hovered, clicked;
|
||||||
clicked =
|
clicked = MenuButtonFrame(title, true,
|
||||||
MenuButtonFrame(title, true, ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT, &visible, &hovered, &bb.Min, &bb.Max);
|
oneline ? ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY :
|
||||||
|
ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT,
|
||||||
|
&visible, &hovered, &bb.Min, &bb.Max);
|
||||||
if (!visible)
|
if (!visible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const float midpoint = bb.Min.y + g_large_font->FontSize + LayoutScale(4.0f);
|
|
||||||
const ImRect title_bb(bb.Min, ImVec2(bb.Max.x, midpoint));
|
|
||||||
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), bb.Max);
|
|
||||||
|
|
||||||
if (show_type)
|
if (show_type)
|
||||||
{
|
{
|
||||||
if (icon_name)
|
if (icon_name)
|
||||||
@ -1393,16 +1394,37 @@ void FullscreenUI::DrawInputBindingButton(SettingsInterface* bsi, InputBindingIn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::PushFont(g_large_font);
|
const float midpoint = bb.Min.y + g_large_font->FontSize + LayoutScale(4.0f);
|
||||||
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, show_type ? title.c_str() : display_name, nullptr, nullptr,
|
|
||||||
ImVec2(0.0f, 0.0f), &title_bb);
|
|
||||||
ImGui::PopFont();
|
|
||||||
|
|
||||||
const std::string value(bsi->GetStringValue(section, name));
|
if (oneline)
|
||||||
ImGui::PushFont(g_medium_font);
|
{
|
||||||
ImGui::RenderTextClipped(summary_bb.Min, summary_bb.Max, value.empty() ? FSUI_CSTR("No Binding") : value.c_str(),
|
ImGui::PushFont(g_large_font);
|
||||||
nullptr, nullptr, ImVec2(0.0f, 0.0f), &summary_bb);
|
|
||||||
ImGui::PopFont();
|
const ImVec2 value_size(ImGui::CalcTextSize(value.empty() ? FSUI_CSTR("-") : value.c_str(), nullptr));
|
||||||
|
const float text_end = bb.Max.x - value_size.x;
|
||||||
|
const ImRect title_bb(bb.Min, ImVec2(text_end, midpoint));
|
||||||
|
|
||||||
|
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, show_type ? title.c_str() : display_name, nullptr, nullptr,
|
||||||
|
ImVec2(0.0f, 0.0f), &title_bb);
|
||||||
|
ImGui::RenderTextClipped(bb.Min, bb.Max, value.empty() ? FSUI_CSTR("-") : value.c_str(), nullptr,
|
||||||
|
&value_size, ImVec2(1.0f, 0.5f), &bb);
|
||||||
|
ImGui::PopFont();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const ImRect title_bb(bb.Min, ImVec2(bb.Max.x, midpoint));
|
||||||
|
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), bb.Max);
|
||||||
|
|
||||||
|
ImGui::PushFont(g_large_font);
|
||||||
|
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, show_type ? title.c_str() : display_name, nullptr, nullptr,
|
||||||
|
ImVec2(0.0f, 0.0f), &title_bb);
|
||||||
|
ImGui::PopFont();
|
||||||
|
|
||||||
|
ImGui::PushFont(g_medium_font);
|
||||||
|
ImGui::RenderTextClipped(summary_bb.Min, summary_bb.Max, value.empty() ? FSUI_CSTR("No Binding") : value.c_str(),
|
||||||
|
nullptr, nullptr, ImVec2(0.0f, 0.0f), &summary_bb);
|
||||||
|
ImGui::PopFont();
|
||||||
|
}
|
||||||
|
|
||||||
if (clicked)
|
if (clicked)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user