Add helper functions for padding

This commit is contained in:
Joscha 2022-07-23 22:34:18 +02:00
parent a5757d4660
commit ade3120134
2 changed files with 15 additions and 3 deletions

View file

@ -84,7 +84,7 @@ impl EuphRoom {
fn widget_without_nick_list(&self, status: &Option<Option<Status>>) -> BoxedWidget { fn widget_without_nick_list(&self, status: &Option<Option<Status>>) -> BoxedWidget {
VJoin::new(vec![ VJoin::new(vec![
Segment::new(Border::new( Segment::new(Border::new(
Padding::new(self.status_widget(status)).left(1).right(1), Padding::new(self.status_widget(status)).horizontal(1),
)), )),
Segment::new(self.chat.widget()).expanding(true), Segment::new(self.chat.widget()).expanding(true),
]) ])
@ -99,13 +99,13 @@ impl EuphRoom {
HJoin::new(vec![ HJoin::new(vec![
Segment::new(VJoin::new(vec![ Segment::new(VJoin::new(vec![
Segment::new(Border::new( Segment::new(Border::new(
Padding::new(self.status_widget(status)).left(1).right(1), Padding::new(self.status_widget(status)).horizontal(1),
)), )),
Segment::new(self.chat.widget()).expanding(true), Segment::new(self.chat.widget()).expanding(true),
])) ]))
.expanding(true), .expanding(true),
Segment::new(Border::new( Segment::new(Border::new(
Padding::new(self.nick_list_widget(joined)).left(1).right(1), Padding::new(self.nick_list_widget(joined)).horizontal(1),
)), )),
]) ])
.into() .into()

View file

@ -32,6 +32,10 @@ impl Padding {
self self
} }
pub fn horizontal(self, amount: u16) -> Self {
self.left(amount).right(amount)
}
pub fn top(mut self, amount: u16) -> Self { pub fn top(mut self, amount: u16) -> Self {
self.top = amount; self.top = amount;
self self
@ -41,6 +45,14 @@ impl Padding {
self.bottom = amount; self.bottom = amount;
self self
} }
pub fn vertical(self, amount: u16) -> Self {
self.top(amount).bottom(amount)
}
pub fn all(self, amount: u16) -> Self {
self.horizontal(amount).vertical(amount)
}
} }
#[async_trait] #[async_trait]