-
Notifications
You must be signed in to change notification settings - Fork 115
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
Add padding attribute to sized_box
view
#736
Conversation
- Also add Padding struct with convenience methods for working with paddings. - Updated `http_cats` example to use padding when more convenient.
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.
This looks really great, thank you! There are a few things I'd like to see changed before this lands, but this is idiomatic for how Xilem/Masonry are currently designed. I think the behaviour with dynamic paddings is broken, which I'd like to see addressed (or a convincing check that it isn't).
The suggested name of Frame
is certainly compelling, but should be a follow-up.
|
||
let mut harness = TestHarness::create(widget); | ||
|
||
assert_debug_snapshot!(harness.root_widget()); |
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.
I'm not sure these debug snapshot tests are needed here.
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.
Should I remove them? I just copied them from the other test cases in the file.
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 can leave them from consistency. @PoignardAzur what are these snapshots actually testing?
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.
Looks good. Some tweaks to the docs and ordering in the file are still needed, but this is nearly ready.
masonry/src/widget/sized_box.rs
Outdated
} | ||
|
||
impl From<f64> for Padding { | ||
/// Converts the value to a [Padding] object with that amount of padding on all edges. |
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.
I've looked at the generated docs page, and these are really hard to discover.
These docs are in the right place, but we should also mention these impls at the top level of Padding
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.
I'm unsure how to best do this?
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.
As in, adding some text to the doc comment on Padding
describing that these implementations exist for convenience?
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.
Okay, I added this comment now, how does that look?
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.
I'd probably choose slightly different wording, but that form looks good. Thanks!
I'm in favor, but I think this should be a follow-up PR.
I guess we can do that as well. (Could also be a follow-up) |
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 unresolved comments still apply (#736 (comment) and #736 (comment)), plus this new one.
Otherwise this is really good, thanks!
masonry/src/widget/sized_box.rs
Outdated
} | ||
|
||
impl From<f64> for Padding { | ||
/// Converts the value to a [Padding] object with that amount of padding on all edges. |
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.
As in, adding some text to the doc comment on Padding
describing that these implementations exist for convenience?
And yes, the two suggested follow-ups (probably renaming to Frame first) would be welcome. |
Changes
Masonry
Xilem
Padding
struct with convenience methods for working with paddings.http_cats
example to use padding when more convenient and fixed hack.Examples
HTTP Cats
Added padding on the left in the
http_cats
example, to make it more balanced with the right side.Discussion
Rename
sized_box
toframe
?In swiftUI the view modifier
.frame()
is used to change the size of a view. I think the nameframe
better describes the purpose ofsized_box
, since it also does backgrounds, borders (and now padding). So I wanted to suggest thatsized_box
be renamed toframe
.Add
SizedBoxExt
for better ergonomics?Similar to
FlexExt
andGridExt
, I was thinking that a newSizedBoxExt
could be introduced to easily wrap any view in asized_box
, something like the following.This would allow for chaining modifiers like this:
Or even somthing more advanced like this: