1use crate::core::layout;
3use crate::core::mouse;
4use crate::core::renderer;
5use crate::core::widget::{Meta, Tree};
6use crate::core::{Layout, Length, Rectangle, Size, Widget};
7
8pub fn horizontal() -> Space {
13 Space::new().width(Length::Fill)
14}
15
16pub fn vertical() -> Space {
21 Space::new().height(Length::Fill)
22}
23
24#[derive(Debug)]
28pub struct Space {
29 width: Length,
30 height: Length,
31}
32
33impl Space {
34 pub fn new() -> Self {
36 Space {
37 width: Length::Fit,
38 height: Length::Fit,
39 }
40 }
41
42 pub fn width(mut self, width: impl Into<Length>) -> Self {
44 self.width = width.into();
45 self
46 }
47
48 pub fn height(mut self, height: impl Into<Length>) -> Self {
50 self.height = height.into();
51 self
52 }
53}
54
55impl Default for Space {
56 fn default() -> Self {
57 Space::new()
58 }
59}
60
61impl Meta for Space {}
62
63impl<Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Space {
64 fn size(&self) -> Size<Length> {
65 Size {
66 width: self.width,
67 height: self.height,
68 }
69 }
70
71 fn layout(&mut self, tree: &mut Tree, _renderer: &Renderer, limits: &layout::Limits) {
72 tree.size = layout::atomic(limits, self.width, self.height);
73 }
74
75 fn draw(
76 &self,
77 _tree: &Tree,
78 _renderer: &mut Renderer,
79 _theme: &Theme,
80 _style: &renderer::Style,
81 _layout: Layout,
82 _cursor: mouse::Cursor,
83 _viewport: &Rectangle,
84 ) {
85 }
86}