-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Update Button
to correctly align contained image
#4891
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Button
to correctly align contained image
bircni
approved these changes
Aug 2, 2024
emilk
approved these changes
Aug 5, 2024
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Similar to #4889
Updated the
ui
method of theButton
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
After