Replace usages of Rect::from

This commit is contained in:
Alexandre Bury 2021-03-02 18:25:32 -08:00
parent cbaf632cc1
commit 7cf597f9bb
7 changed files with 10 additions and 10 deletions

View File

@ -101,7 +101,7 @@ pub trait ViewWrapper: 'static {
/// Wraps the `important_area` method. /// Wraps the `important_area` method.
fn wrap_important_area(&self, size: Vec2) -> Rect { fn wrap_important_area(&self, size: Vec2) -> Rect {
self.with_view(|v| v.important_area(size)) self.with_view(|v| v.important_area(size))
.unwrap_or_else(|| Rect::from((0, 0))) .unwrap_or_else(|| Rect::from_size(Vec2::zero(), size))
} }
} }

View File

@ -729,10 +729,10 @@ impl View for LinearLayout {
Err(ViewNotFound) Err(ViewNotFound)
} }
fn important_area(&self, _: Vec2) -> Rect { fn important_area(&self, size: Vec2) -> Rect {
if self.is_empty() { if self.is_empty() {
// Return dummy area if we are empty. // Return dummy area if we are empty.
return Rect::from((0, 0)); return Rect::from_size(Vec2::zero(), size);
} }
// Pick the focused item, with its offset // Pick the focused item, with its offset

View File

@ -303,7 +303,7 @@ impl MenuPopup {
fn inner_important_area(&self, size: Vec2) -> Rect { fn inner_important_area(&self, size: Vec2) -> Rect {
if self.menu.is_empty() { if self.menu.is_empty() {
return Rect::from((0, 0)); return Rect::from_size(Vec2::zero(), size);
} }
Rect::from_size((0, self.focus), (size.x, 1)) Rect::from_size((0, self.focus), (size.x, 1))

View File

@ -414,9 +414,9 @@ impl View for Menubar {
Vec2::new(width, 1) Vec2::new(width, 1)
} }
fn important_area(&self, _: Vec2) -> Rect { fn important_area(&self, size: Vec2) -> Rect {
if self.root.is_empty() { if self.root.is_empty() {
return Rect::from((0, 0)); return Rect::from_size(Vec2::zero(), size);
} }
// X position is 1 (margin before the first item) + sum of widths // X position is 1 (margin before the first item) + sum of widths

View File

@ -973,7 +973,7 @@ impl<T: 'static> View for SelectView<T> {
fn important_area(&self, size: Vec2) -> Rect { fn important_area(&self, size: Vec2) -> Rect {
self.selected_id() self.selected_id()
.map(|i| Rect::from_size((0, i), (size.x, 1))) .map(|i| Rect::from_size((0, i), (size.x, 1)))
.unwrap_or_else(|| Rect::from((0, 0))) .unwrap_or_else(|| Rect::from_size(Vec2::zero(), size))
} }
} }

View File

@ -364,9 +364,9 @@ impl<'a> ObservedLine<'a> {
line_len: usize, line_len: usize,
) -> Self { ) -> Self {
ObservedLine { ObservedLine {
parent,
line_start, line_start,
line_len, line_len,
parent,
} }
} }
@ -380,9 +380,9 @@ impl<'a> ObservedLine<'a> {
); );
ObservedLine { ObservedLine {
parent: self.parent,
line_start: Vec2::new(self.line_start.x - left, self.line_start.y), line_start: Vec2::new(self.line_start.x - left, self.line_start.y),
line_len: self.line_len + left + right, line_len: self.line_len + left + right,
parent: self.parent,
} }
} }
} }

View File

@ -63,7 +63,7 @@ impl BufferView {
fn new(size: usize, rx: mpsc::Receiver<String>) -> Self { fn new(size: usize, rx: mpsc::Receiver<String>) -> Self {
let mut buffer = VecDeque::new(); let mut buffer = VecDeque::new();
buffer.resize(size, String::new()); buffer.resize(size, String::new());
BufferView { rx, buffer } BufferView { buffer, rx }
} }
// Reads available data from the stream into the buffer // Reads available data from the stream into the buffer