Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uilist line padding accounts for number of lines in text #76356

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading