From 6df98ada7f40c5b1ad4f1676466a4fc6b6436177 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 28 Oct 2020 00:07:33 +0100 Subject: [PATCH] cleanup --- src/components/select_branch.rs | 2 +- src/components/textinput.rs | 4 ++-- src/ui/mod.rs | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/select_branch.rs b/src/components/select_branch.rs index f73558b5..cbc25db1 100644 --- a/src/components/select_branch.rs +++ b/src/components/select_branch.rs @@ -53,7 +53,7 @@ impl DrawableComponent for SelectBranchComponent { f.size(), ); let area = - ui::rect_inside(&MIN_SIZE, &f.size().into(), area); + ui::rect_inside(MIN_SIZE, f.size().into(), area); let area = area.intersection(rect); let scroll_threshold = area.height / 3; diff --git a/src/components/textinput.rs b/src/components/textinput.rs index c965e826..50c62575 100644 --- a/src/components/textinput.rs +++ b/src/components/textinput.rs @@ -202,8 +202,8 @@ impl DrawableComponent for TextInputComponent { InputType::Multiline => { let area = ui::centered_rect(60, 20, f.size()); ui::rect_inside( - &Size::new(10, 3), - &f.size().into(), + Size::new(10, 3), + f.size().into(), area, ) } diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 3cba131e..fa61d272 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -22,6 +22,7 @@ pub const fn calc_scroll_top( } /// ui component size representation +#[derive(Copy, Clone)] pub struct Size { pub width: u16, pub height: u16, @@ -72,7 +73,7 @@ pub fn centered_rect( } /// makes sure Rect `r` at least stays as big as min and not bigger than max -pub fn rect_inside(min: &Size, max: &Size, r: Rect) -> Rect { +pub fn rect_inside(min: Size, max: Size, r: Rect) -> Rect { let new_width = r.width.max(min.width).min(max.width); let new_height = r.height.max(min.height).min(max.height); let diff_width = new_width.saturating_sub(r.width);