Draft custom layout engine based on druid

This commit is contained in:
Héctor Ramón Jiménez 2019-11-10 06:05:20 +01:00
parent 2303111e09
commit 0240c3981b
38 changed files with 974 additions and 249 deletions

View file

@ -1,10 +1,12 @@
use crate::{Align, Column, Length, Point, Rectangle};
use std::u32;
#[derive(Debug)]
pub struct Scrollable<'a, Element> {
pub state: &'a mut State,
pub height: Length,
pub max_height: Length,
pub max_height: u32,
pub align_self: Option<Align>,
pub content: Column<Element>,
}
@ -14,7 +16,7 @@ impl<'a, Element> Scrollable<'a, Element> {
Scrollable {
state,
height: Length::Shrink,
max_height: Length::Shrink,
max_height: u32::MAX,
align_self: None,
content: Column::new(),
}
@ -57,7 +59,7 @@ impl<'a, Element> Scrollable<'a, Element> {
/// Sets the maximum width of the [`Scrollable`].
///
/// [`Scrollable`]: struct.Scrollable.html
pub fn max_width(mut self, max_width: Length) -> Self {
pub fn max_width(mut self, max_width: u32) -> Self {
self.content = self.content.max_width(max_width);
self
}
@ -65,7 +67,7 @@ impl<'a, Element> Scrollable<'a, Element> {
/// Sets the maximum height of the [`Scrollable`] in pixels.
///
/// [`Scrollable`]: struct.Scrollable.html
pub fn max_height(mut self, max_height: Length) -> Self {
pub fn max_height(mut self, max_height: u32) -> Self {
self.max_height = max_height;
self
}