Skip to content

Commit

Permalink
Fix: respect existing text layout wrap settings in Label (emilk#4704)
Browse files Browse the repository at this point in the history
* Broke in github.com/emilk/pull/4556
* Closes emilk#4701
  • Loading branch information
emilk authored and hacknus committed Oct 30, 2024
1 parent c164070 commit 4a9156d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions crates/egui/src/widgets/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,21 @@ impl Label {
}
(pos, galley, response)
} else {
layout_job.wrap =
text::TextWrapping::from_wrap_mode_and_width(wrap_mode, available_width);
// Apply wrap_mode, but don't overwrite anything important
// the user may have set manually on the layout_job:
match wrap_mode {
TextWrapMode::Extend => {
layout_job.wrap.max_width = f32::INFINITY;
}
TextWrapMode::Wrap => {
layout_job.wrap.max_width = available_width;
}
TextWrapMode::Truncate => {
layout_job.wrap.max_width = available_width;
layout_job.wrap.max_rows = 1;
layout_job.wrap.break_anywhere = true;
}
}

if ui.is_grid() {
// TODO(emilk): remove special Grid hacks like these
Expand Down

0 comments on commit 4a9156d

Please sign in to comment.