Skip to content

Commit

Permalink
when items in a uilist don’t have a hotkey, leave space for one anyway
Browse files Browse the repository at this point in the history
This keeps the menu items lined up even when some items have hotkeys
and others do not.

Fixes #75695
  • Loading branch information
Daniel Brooks committed Aug 15, 2024
1 parent bd33241 commit d793a3e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 :
Expand Down

0 comments on commit d793a3e

Please sign in to comment.