-
Notifications
You must be signed in to change notification settings - Fork 108
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
Remove Dimension::Undefined
in favour of Option<Dimension>
#148
Conversation
@Weibye I've done my best to resolve the merge conflicts and rebase for you :) |
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.
Making progress, uncertain of a few things
@@ -95,7 +95,7 @@ struct AlgoConstants { | |||
padding_border: Rect<f32>, | |||
|
|||
/// The size of the internal node | |||
node_inner_size: Size<Option<f32>>, | |||
node_inner_size: Size<f32>, | |||
/// The size of the surrounding container | |||
container_size: Size<f32>, |
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.
Looking at this, do we need a Size
that does not have Optional fields? One that is guaranteed to have both width and height?
let margin = | ||
self.nodes[node].style.margin.map(|n| n.map(|d| d.resolve(parent_size.width)).unwrap_or(Some(0.0))); | ||
let padding = | ||
self.nodes[node].style.padding.map(|n| n.map(|d| d.resolve(parent_size.width)).unwrap_or(Some(0.0))); | ||
let border = | ||
self.nodes[node].style.border.map(|n| n.map(|d| d.resolve(parent_size.width)).unwrap_or(Some(0.0))); |
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 very uncertain if this is the correct logic. Still have more work to do before everything compiles and tests can start to yell at me.
src/flexbox.rs
Outdated
width: Some(node_size.width.maybe_sub(padding_border.horizontal_axis_sum())), | ||
height: Some(node_size.height.maybe_sub(padding_border.vertical_axis_sum())), |
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.
Compiler complains here: How can I satisfy the trait constraints of MaybeMath
so that these sums work?
src/geometry.rs
Outdated
T: MaybeMath<T, Option<T>> + Copy + Clone, | ||
T: MaybeMath<Option<T>, Option<T>> + Copy + Clone, | ||
T: MaybeMath<Option<T>, T> + Copy + Clone, |
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 did this to get the sums to work MaybeMath
but it didn't solve it.
pub(crate) fn horizontal_axis_sum(&self) -> T { | ||
self.start + self.end | ||
pub(crate) fn horizontal_axis_sum(&self) -> Option<T> { | ||
self.start.and_then(|start| start.maybe_add(self.end)) |
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.
With MaybeMath
I should be able to just use self.start.maybe_add(self.end)
here (?) but not sure exactly how to get that to work.
Traits this involved are new to me, so bear with me while I try to figure this out 🙃
Replaced by #188 |
Objective
Fixes #114
Fixes #154
Enabled by the work from #144
Changelog
Dimension::Undefined
has been removedOption<Dimension>
Size
The
geometry::Size<T>
has been changed fromto
Rect
Has changed from
to
Feedback wanted