Skip to content

Commit

Permalink
Merge pull request #76356 from RenechCDDA/uilist_line_spacing
Browse files Browse the repository at this point in the history
uilist line padding accounts for number of lines in text
  • Loading branch information
Maleclypse authored Sep 13, 2024
2 parents f6d8ff2 + 7c4181e commit 2f865f7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,13 +627,15 @@ void uilist::calc_data()
bool has_titlebar = !title.empty();
if( has_titlebar ) {
title_size = calc_size( title );
title_size.y += s.FramePadding.y * 2.0;
float expected_num_lines = title_size.y / ImGui::GetTextLineHeight();
title_size.y += ( s.ItemSpacing.y * expected_num_lines ) + ( s.ItemSpacing.y * 2.0 );
}

ImVec2 text_size = {};
if( !text.empty() ) {
text_size = calc_size( text );
text_size.y += s.ItemSpacing.y * 2.0;
float expected_num_lines = text_size.y / ImGui::GetTextLineHeight();
text_size.y += ( s.ItemSpacing.y * expected_num_lines ) + ( s.ItemSpacing.y * 2.0 );
}

ImVec2 desc_size = {};
Expand All @@ -647,7 +649,8 @@ void uilist::calc_data()
if( desc_size.y <= 0.0 ) {
desc_enabled = false;
}
desc_size.y += s.ItemSpacing.y * 2.0;
float expected_num_lines = desc_size.y / ImGui::GetTextLineHeight();
desc_size.y += ( s.ItemSpacing.y * expected_num_lines ) + ( s.ItemSpacing.y * 2.0 );
}
float additional_height = title_size.y + text_size.y + desc_size.y + 2.0 *
( s.FramePadding.y + s.WindowBorderSize );
Expand Down

0 comments on commit 2f865f7

Please sign in to comment.