Remove padding from Container for now

This commit is contained in:
Héctor Ramón Jiménez 2019-11-11 05:37:51 +01:00
parent ceb02f4a36
commit d4d14b68f4
5 changed files with 13 additions and 23 deletions

View file

@ -8,7 +8,6 @@ pub struct Container<Element> {
pub height: Length, pub height: Length,
pub max_width: u32, pub max_width: u32,
pub max_height: u32, pub max_height: u32,
pub padding: u16,
pub horizontal_alignment: Align, pub horizontal_alignment: Align,
pub vertical_alignment: Align, pub vertical_alignment: Align,
pub content: Element, pub content: Element,
@ -29,7 +28,6 @@ impl<Element> Container<Element> {
max_height: u32::MAX, max_height: u32::MAX,
horizontal_alignment: Align::Start, horizontal_alignment: Align::Start,
vertical_alignment: Align::Start, vertical_alignment: Align::Start,
padding: 0,
content: content.into(), content: content.into(),
} }
} }
@ -66,14 +64,6 @@ impl<Element> Container<Element> {
self self
} }
/// Sets the padding of the [`Container`].
///
/// [`Container`]: struct.Container.html
pub fn padding(mut self, units: u16) -> Self {
self.padding = units;
self
}
/// Centers the contents in the horizontal axis of the [`Container`]. /// Centers the contents in the horizontal axis of the [`Container`].
/// ///
/// [`Container`]: struct.Container.html /// [`Container`]: struct.Container.html

View file

@ -1,6 +1,6 @@
use iced::{ use iced::{
button, scrollable, Align, Application, Button, Column, Element, Image, button, scrollable, Align, Application, Button, Column, Container, Element,
Justify, Length, Scrollable, Text, Image, Length, Scrollable, Text,
}; };
pub fn main() { pub fn main() {
@ -65,11 +65,10 @@ impl Application for Example {
.border_radius(5), .border_radius(5),
); );
Column::new() Container::new(content)
.width(Length::Fill)
.height(Length::Fill) .height(Length::Fill)
.justify_content(Justify::Center) .center_y()
.padding(20)
.push(content)
.into() .into()
} }
} }

View file

@ -46,7 +46,9 @@ impl Node {
Align::Center => { Align::Center => {
self.bounds.x += (space.width - self.bounds.width) / 2.0; self.bounds.x += (space.width - self.bounds.width) / 2.0;
} }
Align::End => {} Align::End => {
self.bounds.x += space.width - self.bounds.width;
}
} }
match vertical_alignment { match vertical_alignment {
@ -54,7 +56,9 @@ impl Node {
Align::Center => { Align::Center => {
self.bounds.y += (space.height - self.bounds.height) / 2.0; self.bounds.y += (space.height - self.bounds.height) / 2.0;
} }
Align::End => {} Align::End => {
self.bounds.y += space.height - self.bounds.height;
}
} }
} }
} }

View file

@ -1,8 +1,6 @@
use std::hash::Hash; use std::hash::Hash;
use crate::{ use crate::{layout, Element, Event, Hasher, Layout, Length, Point, Widget};
layout, Element, Event, Hasher, Layout, Length, Point, Size, Widget,
};
/// A container that distributes its contents vertically. /// A container that distributes its contents vertically.
pub type Container<'a, Message, Renderer> = pub type Container<'a, Message, Renderer> =
@ -73,7 +71,6 @@ where
self.height.hash(state); self.height.hash(state);
self.max_width.hash(state); self.max_width.hash(state);
self.max_height.hash(state); self.max_height.hash(state);
self.padding.hash(state);
self.content.hash_layout(state); self.content.hash_layout(state);
} }

View file

@ -7,7 +7,7 @@ pub mod widget;
pub use bus::Bus; pub use bus::Bus;
pub use element::Element; pub use element::Element;
pub use iced_core::{Align, Background, Color, Justify, Length}; pub use iced_core::{Align, Background, Color, Length};
pub use widget::*; pub use widget::*;
pub trait Application { pub trait Application {