Skip to content

Fixes sense issues in TextEdit when vertical alignment is used#7436

Merged
emilk merged 6 commits intoemilk:mainfrom
RndUsr123:align_fix
Aug 12, 2025
Merged

Fixes sense issues in TextEdit when vertical alignment is used#7436
emilk merged 6 commits intoemilk:mainfrom
RndUsr123:align_fix

Conversation

@RndUsr123
Copy link
Copy Markdown
Contributor

I'm running a rustup-less rust install on Windows, so I don't have clippy nor fmt and can't run the .sh script.
It's very little code and I manually tested this, so hopefully that's ok...

Let me know if the comment in state.rs needs to be updated or the text_offset name isn't clear enough.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 8, 2025

Preview available at https://egui-pr-preview.github.io/pr/7436-alignfix
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

Copy link
Copy Markdown
Collaborator

@lucasmerlin lucasmerlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Just for the record, here is a video of the bug and fix:

Screen.Recording.2025-08-08.at.14.24.12.mov
Screen.Recording.2025-08-08.at.14.25.07.mov

};

let mut offset_x = state.singleline_offset;
let mut offset_x = state.text_offset[0];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut offset_x = state.text_offset[0];
let mut offset_x = state.text_offset.x;

A bit more idiomatic

@lucasmerlin lucasmerlin added bug Something is broken egui labels Aug 8, 2025
Comment on lines 52 to 53
// Visual offset when editing singleline text bigger than the width.
#[cfg_attr(feature = "serde", serde(skip))]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah it'd be nice if you could update the comment

Comment on lines +655 to +656
let align_offset_x = rect.left() - galley_pos.x;
let align_offset_y = rect.top() - galley_pos.y;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let align_offset_x = rect.left() - galley_pos.x;
let align_offset_y = rect.top() - galley_pos.y;
let align_offset = rect.left_top() - galley_pos;

@emilk emilk merged commit 68d456a into emilk:main Aug 12, 2025
26 checks passed
@RndUsr123 RndUsr123 deleted the align_fix branch August 13, 2025 19:29
Masterchef365 pushed a commit to Masterchef365/egui that referenced this pull request Apr 3, 2026
…#7436)

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/main/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

* Closes <emilk#7433>
* [ ] I have followed the instructions in the PR template

I'm running a rustup-less rust install on Windows, so I don't have
`clippy` nor `fmt` and can't run the .sh script.
It's very little code and I manually tested this, so hopefully that's
ok...

Let me know if the comment in `state.rs` needs to be updated or the
`text_offset` name isn't clear enough.

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is broken egui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong sense area for a TextEdit using vertical_align

3 participants