This commit is contained in:
Stephan Dilly 2020-10-28 00:07:33 +01:00
parent 603fd75703
commit 6df98ada7f
3 changed files with 5 additions and 4 deletions

View file

@ -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;

View file

@ -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,
)
}

View file

@ -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);