fix: add width to scrollables
This commit is contained in:
parent
df68cca0c9
commit
046f3596ca
1 changed files with 10 additions and 2 deletions
|
|
@ -33,6 +33,7 @@ where
|
||||||
Renderer::Theme: StyleSheet,
|
Renderer::Theme: StyleSheet,
|
||||||
{
|
{
|
||||||
id: Option<Id>,
|
id: Option<Id>,
|
||||||
|
width: Length,
|
||||||
height: Length,
|
height: Length,
|
||||||
vertical: Properties,
|
vertical: Properties,
|
||||||
horizontal: Option<Properties>,
|
horizontal: Option<Properties>,
|
||||||
|
|
@ -50,6 +51,7 @@ where
|
||||||
pub fn new(content: impl Into<Element<'a, Message, Renderer>>) -> Self {
|
pub fn new(content: impl Into<Element<'a, Message, Renderer>>) -> Self {
|
||||||
Scrollable {
|
Scrollable {
|
||||||
id: None,
|
id: None,
|
||||||
|
width: Length::Shrink,
|
||||||
height: Length::Shrink,
|
height: Length::Shrink,
|
||||||
vertical: Properties::default(),
|
vertical: Properties::default(),
|
||||||
horizontal: None,
|
horizontal: None,
|
||||||
|
|
@ -65,6 +67,12 @@ where
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the width of the [`Scrollable`].
|
||||||
|
pub fn width(mut self, width: impl Into<Length>) -> Self {
|
||||||
|
self.width = width.into();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets the height of the [`Scrollable`].
|
/// Sets the height of the [`Scrollable`].
|
||||||
pub fn height(mut self, height: impl Into<Length>) -> Self {
|
pub fn height(mut self, height: impl Into<Length>) -> Self {
|
||||||
self.height = height.into();
|
self.height = height.into();
|
||||||
|
|
@ -173,7 +181,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn width(&self) -> Length {
|
fn width(&self) -> Length {
|
||||||
self.content.as_widget().width()
|
self.width
|
||||||
}
|
}
|
||||||
|
|
||||||
fn height(&self) -> Length {
|
fn height(&self) -> Length {
|
||||||
|
|
@ -188,7 +196,7 @@ where
|
||||||
layout(
|
layout(
|
||||||
renderer,
|
renderer,
|
||||||
limits,
|
limits,
|
||||||
Widget::<Message, Renderer>::width(self),
|
self.width,
|
||||||
self.height,
|
self.height,
|
||||||
self.horizontal.is_some(),
|
self.horizontal.is_some(),
|
||||||
|renderer, limits| {
|
|renderer, limits| {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue