1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-03 15:20:05 -04:00

[epaint] Add more text wrapping options (#1291)

This commit is contained in:
awaken1ng
2022-04-04 01:28:47 +07:00
committed by GitHub
parent d09fa63d9c
commit 901b7c7994
11 changed files with 256 additions and 57 deletions

View File

@@ -244,7 +244,7 @@ impl ColoredText {
// Selectable text:
let mut layouter = |ui: &egui::Ui, _string: &str, wrap_width: f32| {
let mut layout_job = self.0.clone();
layout_job.wrap_width = wrap_width;
layout_job.wrap.max_width = wrap_width;
ui.fonts().layout_job(layout_job)
};
@@ -257,7 +257,7 @@ impl ColoredText {
);
} else {
let mut job = self.0.clone();
job.wrap_width = ui.available_width();
job.wrap.max_width = ui.available_width();
let galley = ui.fonts().layout_job(job);
let (response, painter) = ui.allocate_painter(galley.size(), egui::Sense::hover());
painter.add(egui::Shape::galley(response.rect.min, galley));