Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: hint text follows the alignment set on the TextEdit #4889

Merged
merged 1 commit into from
Jul 30, 2024

Conversation

PrimmR
Copy link
Contributor

@PrimmR PrimmR commented Jul 30, 2024

Updated the show_content method of the TextEdit widget so that the requested text alignment (if any) is also applied to the hint text.

Currently, hint text is always aligned to the top left of the widget, which may be inconsistent with the actual location of text entered by the user. I think it's more intuitive for the hint text to be positioned as if the user had entered the same text themselves.

Here are some comparisons of the difference between how the hint text and the entered text looks, before and after this change:

Previous Behaviour

Prev

Updated Behaviour

Update

  • I have followed the instructions in the PR template

@PrimmR
Copy link
Contributor Author

PrimmR commented Jul 30, 2024

And all the checks seem to pass too!

@PrimmR PrimmR marked this pull request as ready for review July 30, 2024 13:07
Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

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

Makes sense!

@emilk emilk added the egui label Jul 30, 2024
@emilk emilk changed the title Update TextEdit so hint text is correctly aligned TextEdit hint text follo Jul 30, 2024
@emilk emilk changed the title TextEdit hint text follo Fix: hint text follows the alignment set on the TextEdit Jul 30, 2024
@emilk emilk added the bug Something is broken label Jul 30, 2024
@emilk emilk merged commit 37b1e15 into emilk:master Jul 30, 2024
19 of 20 checks passed
emilk pushed a commit that referenced this pull request Aug 5, 2024
Similar to #4889

Updated the `ui` method of the `Button` widget so that the alignment
given by the layout is applied to the image contained in the button (if
one exists).

Currently, only the text inside the button has alignment applied to it,
and only when it is not accompanied by an image or shortcut text. Images
within buttons are always aligned to the centre left, no matter the
alignment of the containing `Ui`. This update now also applies this
alignment to an image when it has no accompanying text, which makes
buttons with an image and no text more consistent with the appearance of
ones with text and no image.

I've also made an additional change so that the vertical alignment is
now also respected when displaying some combination of image and text,
but the original horizontal alignment remains the same, so that the
image always appears left of the text. Any shortcut text now also
follows vertical alignment, but is always horizontally aligned to the
right.

Here are some comparisons of the difference between how buttons look
with different alignments, before and after this change:

### Before

![Before](https://github.com/user-attachments/assets/b5086ccb-765d-42e6-88a5-8fa427544568)

### After

![After](https://github.com/user-attachments/assets/ecf6c6aa-b1b9-4b45-be44-8c71665df5c3)

* [x] I have followed the instructions in the PR template
486c pushed a commit to 486c/egui that referenced this pull request Oct 9, 2024
Updated the `show_content` method of the `TextEdit` widget so that the
requested text alignment (if any) is also applied to the hint text.

Currently, hint text is always aligned to the top left of the widget,
which may be inconsistent with the actual location of text entered by
the user. I think it's more intuitive for the hint text to be positioned
as if the user had entered the same text themselves.

Here are some comparisons of the difference between how the hint text
and the entered text looks, before and after this change:

### Previous Behaviour

![Prev](https://github.com/user-attachments/assets/8cd7858f-833e-4946-84f1-ff1ede60c64d)


### Updated Behaviour

![Update](https://github.com/user-attachments/assets/2596dd44-d6f9-4376-9012-5b074fc2cdea)

* [x] I have followed the instructions in the PR template
486c pushed a commit to 486c/egui that referenced this pull request Oct 9, 2024
Similar to emilk#4889

Updated the `ui` method of the `Button` widget so that the alignment
given by the layout is applied to the image contained in the button (if
one exists).

Currently, only the text inside the button has alignment applied to it,
and only when it is not accompanied by an image or shortcut text. Images
within buttons are always aligned to the centre left, no matter the
alignment of the containing `Ui`. This update now also applies this
alignment to an image when it has no accompanying text, which makes
buttons with an image and no text more consistent with the appearance of
ones with text and no image.

I've also made an additional change so that the vertical alignment is
now also respected when displaying some combination of image and text,
but the original horizontal alignment remains the same, so that the
image always appears left of the text. Any shortcut text now also
follows vertical alignment, but is always horizontally aligned to the
right.

Here are some comparisons of the difference between how buttons look
with different alignments, before and after this change:

### Before

![Before](https://github.com/user-attachments/assets/b5086ccb-765d-42e6-88a5-8fa427544568)

### After

![After](https://github.com/user-attachments/assets/ecf6c6aa-b1b9-4b45-be44-8c71665df5c3)

* [x] I have followed the instructions in the PR template
hacknus pushed a commit to hacknus/egui that referenced this pull request Oct 30, 2024
Updated the `show_content` method of the `TextEdit` widget so that the
requested text alignment (if any) is also applied to the hint text.

Currently, hint text is always aligned to the top left of the widget,
which may be inconsistent with the actual location of text entered by
the user. I think it's more intuitive for the hint text to be positioned
as if the user had entered the same text themselves.

Here are some comparisons of the difference between how the hint text
and the entered text looks, before and after this change:

### Previous Behaviour

![Prev](https://github.com/user-attachments/assets/8cd7858f-833e-4946-84f1-ff1ede60c64d)


### Updated Behaviour

![Update](https://github.com/user-attachments/assets/2596dd44-d6f9-4376-9012-5b074fc2cdea)

* [x] I have followed the instructions in the PR template
hacknus pushed a commit to hacknus/egui that referenced this pull request Oct 30, 2024
Similar to emilk#4889

Updated the `ui` method of the `Button` widget so that the alignment
given by the layout is applied to the image contained in the button (if
one exists).

Currently, only the text inside the button has alignment applied to it,
and only when it is not accompanied by an image or shortcut text. Images
within buttons are always aligned to the centre left, no matter the
alignment of the containing `Ui`. This update now also applies this
alignment to an image when it has no accompanying text, which makes
buttons with an image and no text more consistent with the appearance of
ones with text and no image.

I've also made an additional change so that the vertical alignment is
now also respected when displaying some combination of image and text,
but the original horizontal alignment remains the same, so that the
image always appears left of the text. Any shortcut text now also
follows vertical alignment, but is always horizontally aligned to the
right.

Here are some comparisons of the difference between how buttons look
with different alignments, before and after this change:

### Before

![Before](https://github.com/user-attachments/assets/b5086ccb-765d-42e6-88a5-8fa427544568)

### After

![After](https://github.com/user-attachments/assets/ecf6c6aa-b1b9-4b45-be44-8c71665df5c3)

* [x] I have followed the instructions in the PR template
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.

2 participants