Skip to content

Commit

Permalink
Fix mikedilger/gossip#336 and mikedilger/gossip#347 by ensuring ui.pl…
Browse files Browse the repository at this point in the history
…acer.region.cursor is set to the correct line height.
  • Loading branch information
bu5hm4nn committed Jul 23, 2024
1 parent 7ff46cf commit 521b087
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/egui/src/widgets/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ impl Label {

let pos = pos2(ui.max_rect().left(), ui.cursor().top());
assert!(!galley.rows.is_empty(), "Galleys are never empty");

// set the row height to ensure the cursor advancement is correct. when creating a child ui such as with
// ui.horizontal_wrapped, the initial cursor will be set to the height of the child ui. this can lead
// to the cursor not advancing to the second row but rather expanding the height of the cursor.
//
// note that we do not set the row height earlier in this function as we do want to allow populating
// `first_row_min_height` above. however it is crucial the placer knows the actual row height by
// setting the cursor height before ui.allocate_rect() gets called.
ui.set_row_height(galley.rows[0].height());

// collect a response from many rows:
let rect = galley.rows[0].rect.translate(vec2(pos.x, pos.y));
let mut response = ui.allocate_rect(rect, sense);
Expand Down

0 comments on commit 521b087

Please sign in to comment.