Skip to content

Commit

Permalink
Only round up area size after sizing pass
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed May 28, 2024
1 parent 79138c1 commit 49191c0
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions crates/egui/src/containers/area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,15 +508,19 @@ impl Prepared {
enabled: _,
constrain: _,
constrain_rect: _,
sizing_pass: _,
sizing_pass,
} = self;

// We round up to an integer point size.
// This avoid rounding errors, especially important after a sizing pass.
// If during the sizing pass we measure our width to `123.45` and
// then try to wrap to exactly that next frame,
// we may accidentally wrap the last letter of some text.
state.size = content_ui.min_size().ceil();
state.size = content_ui.min_size();

if sizing_pass {
// If during the sizing pass we measure our width to `123.45` and
// then try to wrap to exactly that next frame,
// we may accidentally wrap the last letter of some text.
// We only do this after the initial sizing pass though;
// otherwise we could end up with for-ever expanding areas.
state.size = state.size.ceil();
}

ctx.memory_mut(|m| m.areas_mut().set_state(layer_id, state));

Expand Down

0 comments on commit 49191c0

Please sign in to comment.