Conversation
|
Preview available at https://egui-pr-preview.github.io/pr/7587-lucasatomize-text-edit View snapshot changes at kitdiff |
crates/egui/src/atomics/atom_kind.rs
Outdated
| #[deprecated = "Use Atom::custom(id) instead"] | ||
| Custom(Id), |
There was a problem hiding this comment.
I suggest we put this in a separate PR so it gets a separate entry in the changelog ("Added AtomKind::Closure and deprecated AtomKind::Custom")
94c927c to
1992f0d
Compare
Change the signature from `impl IntoAtoms` to `Self` to avoid lifetime issues when working with atoms of different lifetimes. Use `push_left`/`push_right` in a loop as an alternative.
- Add `id` field to Atom/SizedAtom for custom rendering identification - Add `align` field (Align2) for per-atom alignment within available space - Add `AtomExt::atom_id` and `AtomExt::atom_align` builder methods - Deprecate `AtomKind::Custom` in favor of `Atom::custom(id)` + `atom_id()` - Replace `SizedAtomKind::Custom` with `SizedAtomKind::Sized` - Move custom rect tracking from SizedAtomKind to SizedAtom::id - Migrate DragValue to use new `atom.id` field
Add a closure-based atom kind for custom sizing logic. The closure receives available size, wrap mode, and font selection, and returns the intrinsic size and a SizedAtomKind. Also hoists `wrap_mode` resolution out of the `Text` match arm so all variants can use it.
Allows limiting the widget size below the available Ui size. Has no effect in justified layouts to avoid content/frame mismatch.
1992f0d to
0d6e754
Compare
0d6e754 to
5bb05a8
Compare
# Conflicts: # crates/egui/src/atomics/atom_layout.rs # crates/egui/src/widgets/text_edit/builder.rs # crates/egui_demo_app/tests/snapshots/imageviewer.png # crates/egui_demo_lib/tests/snapshots/demos/Clipboard Test.png # crates/egui_demo_lib/tests/snapshots/demos/Code Example.png # crates/egui_demo_lib/tests/snapshots/demos/Font Book.png # crates/egui_demo_lib/tests/snapshots/demos/TextEdit.png # crates/egui_demo_lib/tests/snapshots/demos/Undo Redo.png # crates/egui_demo_lib/tests/snapshots/demos/Window Options.png # crates/egui_demo_lib/tests/snapshots/demos/Window Resize Test.png # tests/egui_tests/tests/snapshots/layout/text_edit.png # tests/egui_tests/tests/snapshots/layout/text_edit_clip.png # tests/egui_tests/tests/snapshots/layout/text_edit_placeholder_clip.png # tests/egui_tests/tests/snapshots/text_edit_rtl_1.png # tests/egui_tests/tests/snapshots/visuals/drag_value.png
6c78c4c to
d043b60
Compare
|
The screenshot tests shows some TextEdit shrunk - why is that exactly? |
| // TODO(servo/rust-smallvec#146): Use extend_right instead of the loop once we have smallvec 2.0 | ||
| for atom in prefix { | ||
| atoms.push_right(atom); | ||
| } |
There was a problem hiding this comment.
We already have Atoms newtype wrapper that has .extend_right
| // TODO(servo/rust-smallvec#146): Use extend_right instead of the loop once we have smallvec 2.0 | |
| for atom in prefix { | |
| atoms.push_right(atom); | |
| } | |
| atoms.extend_right(prefix); |
There was a problem hiding this comment.
I tried, but it wouldn't compile due to lifetime errors, due to the SmallVec issue linked in the todo comment.
| // Layout again to avoid frame delay, and to keep `text` and `galley` in sync. | ||
| *galley = layouter(ui, text, wrap_width); |
There was a problem hiding this comment.
do we now have a frame delay? And is text and galley now out of sync?
There was a problem hiding this comment.
We can live with a frame-delay if it simplifies the code, but then maybe let's add a request_discard so we can avoid it when multi-pass is enabled?
There was a problem hiding this comment.
Found a nicer fix, which also allows me to remove the hack where we allocated extra space when the text was changed. Also added some tests for this.
Previously the style.text_edit_width was used for the inner width, meaning if it was 200, the text edit used slightly more than that for it's margins. Now this is the outer width, meaning it should be exactly 200 in width, which I feel is the correct behavior. |
This broke in #7587 --------- Co-authored-by: Emil Ernerfeldt <[email protected]>
* part of emilk#7264 * part of emilk#7445 This PR changes the layout within the TextEdit to be done with AtomLayout. It also adds a Prefix and Postfix that allows adding permanent icons / icon buttons within the textedit. Breaking changes: - Removed `TextEdit::hint_text_font`. Hint text is an atom now, so the font can be set that way <img width="264" height="130" alt="Screenshot 2025-10-06 at 12 25 21" src="https://github.com/user-attachments/assets/03b6b56b-ca82-4ac3-b5c0-585cca336834" /> --------- Co-authored-by: Emil Ernerfeldt <[email protected]> Co-authored-by: lucasmerlin <[email protected]>
This broke in emilk#7587 --------- Co-authored-by: Emil Ernerfeldt <[email protected]>
Frameon each widget and container #7445This PR changes the layout within the TextEdit to be done with AtomLayout. It also adds a Prefix and Postfix that allows adding permanent icons / icon buttons within the textedit.
Breaking changes:
TextEdit::hint_text_font. Hint text is an atom now, so the font can be set that way