1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 05:10:03 -04:00

Fix labels, propagate preferred size in scrollareas and add more examples from the issue

This commit is contained in:
lucasmerlin
2025-03-18 15:58:15 +01:00
parent 166e8e2092
commit 4675c4d9a7
3 changed files with 80 additions and 40 deletions

View File

@@ -1245,7 +1245,7 @@ impl Prepared {
}
}
ui.advance_cursor_after_rect(outer_rect, Vec2::ZERO); // TODO
ui.advance_cursor_after_rect(outer_rect, content_ui.placer().intrinsic_size());
if show_scroll_this_frame != state.show_scroll {
ui.ctx().request_repaint();

View File

@@ -214,6 +214,7 @@ impl Label {
assert!(!galley.rows.is_empty(), "Galleys are never empty");
// collect a response from many rows:
let rect = galley.rows[0].rect.translate(vec2(pos.x, pos.y));
dbg!(galley.desired_size());
let mut response = ui.allocate_rect(rect, sense, galley.desired_size());
for row in galley.rows.iter().skip(1) {
let rect = row.rect.translate(vec2(pos.x, pos.y));
@@ -247,7 +248,8 @@ impl Label {
};
let galley = ui.fonts(|fonts| fonts.layout_job(layout_job));
let (rect, response) = ui.allocate_exact_size(galley.size(), sense);
let (rect, response) =
ui.allocate_at_least(galley.size(), sense, galley.desired_size()); // TODO: Change back to allocate_exact_size
let galley_pos = match galley.job.halign {
Align::LEFT => rect.left_top(),
Align::Center => rect.center_top(),