summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-03-31 01:19:28 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-03-31 01:21:51 +0200
commit749a9588d738de9c3ae734e6f026768c77eb3cce (patch)
tree719597f4577c9329e738389847ff9224c2ac075d /web
parent6e9ab1cd6f5358d323040379e3aadbed2cc4f7f8 (diff)
downloadiced-749a9588d738de9c3ae734e6f026768c77eb3cce.tar.gz
iced-749a9588d738de9c3ae734e6f026768c77eb3cce.tar.bz2
iced-749a9588d738de9c3ae734e6f026768c77eb3cce.zip
Implement `padding` support for `Container`
Diffstat (limited to 'web')
-rw-r--r--web/src/widget/container.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/web/src/widget/container.rs b/web/src/widget/container.rs
index 8e4318f9..78be3543 100644
--- a/web/src/widget/container.rs
+++ b/web/src/widget/container.rs
@@ -8,6 +8,7 @@ pub use iced_style::container::{Style, StyleSheet};
/// It is normally used for alignment purposes.
#[allow(missing_debug_implementations)]
pub struct Container<'a, Message> {
+ padding: u16,
width: Length,
height: Length,
max_width: u32,
@@ -29,6 +30,7 @@ impl<'a, Message> Container<'a, Message> {
use std::u32;
Container {
+ padding: 0,
width: Length::Shrink,
height: Length::Shrink,
max_width: u32::MAX,
@@ -40,6 +42,14 @@ impl<'a, Message> Container<'a, Message> {
}
}
+ /// Sets the padding of the [`Container`].
+ ///
+ /// [`Container`]: struct.Column.html
+ pub fn padding(mut self, units: u16) -> Self {
+ self.padding = units;
+ self
+ }
+
/// Sets the width of the [`Container`].
///
/// [`Container`]: struct.Container.html
@@ -113,12 +123,15 @@ where
let column_class = style_sheet.insert(bump, css::Rule::Column);
+ let padding_class =
+ style_sheet.insert(bump, css::Rule::Padding(self.padding));
+
let style = self.style_sheet.style();
let node = div(bump)
.attr(
"class",
- bumpalo::format!(in bump, "{}", column_class).into_bump_str(),
+ bumpalo::format!(in bump, "{} {}", column_class, padding_class).into_bump_str(),
)
.attr(
"style",