mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 05:40:03 -04:00
Simplify text layout further with even less allocations
This commit is contained in:
@@ -119,7 +119,7 @@ impl<'a> Widget for Slider<'a> {
|
||||
// let galley = font.layout_multiline(&full_text, ui.available().width());
|
||||
let galley = font.layout_single_line(&full_text);
|
||||
let pos = ui.reserve_space(galley.size, None).rect.min;
|
||||
ui.add_text(pos, text_style, galley.fragments, text_color);
|
||||
ui.add_galley(pos, galley, text_style, text_color);
|
||||
slider_sans_text.ui(ui)
|
||||
} else {
|
||||
ui.columns(2, |columns| {
|
||||
|
||||
@@ -90,7 +90,7 @@ impl<'t> Widget for TextEdit<'t> {
|
||||
let show_cursor =
|
||||
(ui.input().time * cursor_blink_hz as f64 * 3.0).floor() as i64 % 3 != 0;
|
||||
if show_cursor {
|
||||
let cursor_pos = if let Some(last) = galley.fragments.last() {
|
||||
let cursor_pos = if let Some(last) = galley.lines.last() {
|
||||
interact.rect.min + vec2(last.max_x(), last.y_offset)
|
||||
} else {
|
||||
interact.rect.min
|
||||
@@ -103,12 +103,7 @@ impl<'t> Widget for TextEdit<'t> {
|
||||
}
|
||||
}
|
||||
|
||||
ui.add_text(
|
||||
interact.rect.min,
|
||||
self.text_style,
|
||||
galley.fragments,
|
||||
self.text_color,
|
||||
);
|
||||
ui.add_galley(interact.rect.min, galley, self.text_style, self.text_color);
|
||||
|
||||
ui.response(interact)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user