summaryrefslogtreecommitdiffstats
path: root/web/src/widget
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-03-31 17:48:41 +0200
committerLibravatar GitHub <noreply@github.com>2020-03-31 17:48:41 +0200
commit327347501c78a1c8e55a39fe1b5d54d7c2fcbcab (patch)
tree3100782d2dfb19dea456402d6615ec340e97d9b7 /web/src/widget
parent291dc728a42c6e888ca6d97eea0f3308591b15a5 (diff)
parent990b4aa0b75d069c08e5f4018f9430a70a394eb7 (diff)
downloadiced-327347501c78a1c8e55a39fe1b5d54d7c2fcbcab.tar.gz
iced-327347501c78a1c8e55a39fe1b5d54d7c2fcbcab.tar.bz2
iced-327347501c78a1c8e55a39fe1b5d54d7c2fcbcab.zip
Merge pull request #248 from hecrj/feature/container-padding
Implement `padding` support for `Container`
Diffstat (limited to 'web/src/widget')
-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",