1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 14:50:03 -04:00

Better internal alignment

This commit is contained in:
RndUsr123
2026-03-25 12:15:58 +00:00
committed by GitHub
parent 0b0c561a81
commit 605ae0c7ed

View File

@@ -575,6 +575,11 @@ impl TextEdit<'_> {
atoms.push_right(atom); atoms.push_right(atom);
} }
// Push prefix to the left and enable alignment for the main text
if align.0[0] != Align::LEFT {
atoms.push_right(Atom::grow());
}
if text.as_str().is_empty() && !hint_text.is_empty() { if text.as_str().is_empty() && !hint_text.is_empty() {
// Add hint_text (if any): // Add hint_text (if any):
let mut shrunk = any_shrink; let mut shrunk = any_shrink;
@@ -598,9 +603,7 @@ impl TextEdit<'_> {
first = false; first = false;
} }
// The hint text should be shown left top instead of centered (important for atoms.push_right(atom);
// multi line text edits)
atoms.push_right(atom.atom_align(Align2::LEFT_TOP));
} }
// Calculate the empty galley, so it can be read later. The available width is // Calculate the empty galley, so it can be read later. The available width is
@@ -647,8 +650,8 @@ impl TextEdit<'_> {
); );
} }
// Ensure the suffix is always right-aligned // Push suffix to the right and enable alignment for the main text
if !suffix.is_empty() { if align.0[0] != Align::RIGHT {
atoms.push_right(Atom::grow()); atoms.push_right(Atom::grow());
} }