Fix Column and Row fluidity being overridden by push
This commit is contained in:
parent
58a7007ac1
commit
01fbd5049d
4 changed files with 19 additions and 25 deletions
|
|
@ -48,12 +48,21 @@ impl Length {
|
||||||
/// Specifically:
|
/// Specifically:
|
||||||
/// - [`Length::Shrink`] if [`Length::Shrink`] or [`Length::Fixed`].
|
/// - [`Length::Shrink`] if [`Length::Shrink`] or [`Length::Fixed`].
|
||||||
/// - [`Length::Fill`] otherwise.
|
/// - [`Length::Fill`] otherwise.
|
||||||
pub fn fluid(&self) -> Length {
|
pub fn fluid(&self) -> Self {
|
||||||
match self {
|
match self {
|
||||||
Length::Fill | Length::FillPortion(_) => Length::Fill,
|
Length::Fill | Length::FillPortion(_) => Length::Fill,
|
||||||
Length::Shrink | Length::Fixed(_) => Length::Shrink,
|
Length::Shrink | Length::Fixed(_) => Length::Shrink,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Adapts the [`Length`] so it can contain the other [`Length`] and
|
||||||
|
/// match its fluidity.
|
||||||
|
pub fn enclose(self, other: Length) -> Self {
|
||||||
|
match (self, other) {
|
||||||
|
(Length::Shrink, Length::Fill | Length::FillPortion(_)) => other,
|
||||||
|
_ => self,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Pixels> for Length {
|
impl From<Pixels> for Length {
|
||||||
|
|
|
||||||
|
|
@ -115,15 +115,10 @@ where
|
||||||
child: impl Into<Element<'a, Message, Theme, Renderer>>,
|
child: impl Into<Element<'a, Message, Theme, Renderer>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let child = child.into();
|
let child = child.into();
|
||||||
let size = child.as_widget().size_hint();
|
let child_size = child.as_widget().size_hint();
|
||||||
|
|
||||||
if size.width.is_fill() {
|
self.width = self.width.enclose(child_size.width);
|
||||||
self.width = Length::Fill;
|
self.height = self.height.enclose(child_size.height);
|
||||||
}
|
|
||||||
|
|
||||||
if size.height.is_fill() {
|
|
||||||
self.height = Length::Fill;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.children.push(child);
|
self.children.push(child);
|
||||||
self
|
self
|
||||||
|
|
|
||||||
|
|
@ -110,15 +110,10 @@ where
|
||||||
child: impl Into<Element<'a, Message, Theme, Renderer>>,
|
child: impl Into<Element<'a, Message, Theme, Renderer>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let child = child.into();
|
let child = child.into();
|
||||||
let size = child.as_widget().size_hint();
|
let child_size = child.as_widget().size_hint();
|
||||||
|
|
||||||
if size.width.is_fill() {
|
self.width = self.width.enclose(child_size.width);
|
||||||
self.width = Length::Fill;
|
self.height = self.height.enclose(child_size.height);
|
||||||
}
|
|
||||||
|
|
||||||
if size.height.is_fill() {
|
|
||||||
self.height = Length::Fill;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.keys.push(key);
|
self.keys.push(key);
|
||||||
self.children.push(child);
|
self.children.push(child);
|
||||||
|
|
|
||||||
|
|
@ -106,15 +106,10 @@ where
|
||||||
child: impl Into<Element<'a, Message, Theme, Renderer>>,
|
child: impl Into<Element<'a, Message, Theme, Renderer>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let child = child.into();
|
let child = child.into();
|
||||||
let size = child.as_widget().size_hint();
|
let child_size = child.as_widget().size_hint();
|
||||||
|
|
||||||
if size.width.is_fill() {
|
self.width = self.width.enclose(child_size.width);
|
||||||
self.width = Length::Fill;
|
self.height = self.height.enclose(child_size.height);
|
||||||
}
|
|
||||||
|
|
||||||
if size.height.is_fill() {
|
|
||||||
self.height = Length::Fill;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.children.push(child);
|
self.children.push(child);
|
||||||
self
|
self
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue