From d793a3e3a7d6b51b9a97a8798fcb0750fae58570 Mon Sep 17 00:00:00 2001 From: Daniel Brooks Date: Wed, 14 Aug 2024 21:49:03 -0700 Subject: [PATCH] =?UTF-8?q?when=20items=20in=20a=20uilist=20don=E2=80=99t?= =?UTF-8?q?=20have=20a=20hotkey,=20leave=20space=20for=20one=20anyway?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This keeps the menu items lined up even when some items have hotkeys and others do not. Fixes #75695 --- src/ui.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ui.cpp b/src/ui.cpp index c7eb4a434eeba..a0b77fa07f881 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -61,6 +61,9 @@ void uilist_impl::on_resized() void uilist_impl::draw_controls() { + float hotkey_width = + ImGui::CalcTextSize( "[X]" ).x + ImGui::GetStyle().ItemSpacing.x; + if( !parent.text.empty() ) { cataimgui::draw_colored_text( parent.text ); ImGui::Separator(); @@ -108,6 +111,8 @@ void uilist_impl::draw_controls() ImGui::SameLine( 0, 0 ); ImGui::Text( "%c", ']' ); ImGui::SameLine(); + } else { + ImGui::SetCursorPosX( hotkey_width ); } nc_color color = ( is_selected ? parent.hilight_color :