-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix DragValue
expansion when editing
#5809
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
Conversation
Preview available at https://egui-pr-preview.github.io/pr/5809-drag-value-expansion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Seems to work well.
About the snapshots, could you try running the script I added in this PR to update your snapshots (by downloading / copying or merging that branch)?
#5816
let mut output = self.show_content(ui); | ||
|
||
// TODO(emilk): return full outer_rect in `TextEditOutput`. | ||
// Can't do it now because this fix is ging into a patch release. | ||
let outer_rect = output.response.rect; | ||
let inner_rect = outer_rect - margin; | ||
output.response.rect = inner_rect; | ||
let output = self.show_content(ui); | ||
|
||
if frame { | ||
let visuals = ui.style().interact(&output.response); | ||
let frame_rect = outer_rect.expand(visuals.expansion); | ||
let frame_rect = output.response.rect.expand(visuals.expansion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should mention this as a breaking change in the changelog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that something I should do? And where? CHANGELOG.md
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, sorry, I was just commenting this for myself, I'll update the title / description accordingly when merging the PR
7c0eea9
to
4a53f4c
Compare
After |
Hmm weird, but thanks for trying! |
crates/egui/src/widgets/button.rs
Outdated
let font_selection = FontSelection::default(); | ||
let font_id = font_selection.resolve(ui.style()); | ||
let row_height = ui.fonts(|f| f.row_height(&font_id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think this could break though, if the RichText sets a different font?
There is RichText::font_height
, I think you could use that instead 👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The text is the more generic WidgetText
, but the font_height
method is still there. Nevertheless, there seems to be a bug in the text layouter that results in different text heights, becase the font height reported by the WidgetText
is different than the text height reported by the Galley
, that is created from the WidgetText
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This PR fixes an issue, where
DragValue
would expand when it enters editing state. There were 3 contributing problems:TextEdit
an atomic widget #4276 caused theDragValue
to report incorrect outer size.DragValue
usesTextEdit
internally and sets bothmin_size
anddesired_width
to the same value - desired width is used before padding is applied - this is in contrast toButton
(also used internally byDragValue
), which only usesmin_size
. This caused theDragValue
to expand horizontally by the size of button padding.TextEdit
is (among other things) determined by the height of the row, which was not present inButton
. This caused a small vertical expansion, when the contents (including padding) were larger than themin_size
.Here the dimensions set in code are:
Note: I do not know what's up with the tests. When I ran the check script, they were failing because of 3 UI missmatches, so I updated the snapshots. Now, the updated snapshots cause the same failure in CI, that appeared locally before the update. Now the locally run tests fail with
The platform you're compiling for is not supported by winit
and couple more following errors coming from the same source (winit 0.30.7
).