mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Replace usages of Rect::from
This commit is contained in:
parent
cbaf632cc1
commit
7cf597f9bb
@ -101,7 +101,7 @@ pub trait ViewWrapper: 'static {
|
||||
/// Wraps the `important_area` method.
|
||||
fn wrap_important_area(&self, size: Vec2) -> Rect {
|
||||
self.with_view(|v| v.important_area(size))
|
||||
.unwrap_or_else(|| Rect::from((0, 0)))
|
||||
.unwrap_or_else(|| Rect::from_size(Vec2::zero(), size))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -729,10 +729,10 @@ impl View for LinearLayout {
|
||||
Err(ViewNotFound)
|
||||
}
|
||||
|
||||
fn important_area(&self, _: Vec2) -> Rect {
|
||||
fn important_area(&self, size: Vec2) -> Rect {
|
||||
if self.is_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
|
||||
|
@ -303,7 +303,7 @@ impl MenuPopup {
|
||||
|
||||
fn inner_important_area(&self, size: Vec2) -> Rect {
|
||||
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))
|
||||
|
@ -414,9 +414,9 @@ impl View for Menubar {
|
||||
Vec2::new(width, 1)
|
||||
}
|
||||
|
||||
fn important_area(&self, _: Vec2) -> Rect {
|
||||
fn important_area(&self, size: Vec2) -> Rect {
|
||||
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
|
||||
|
@ -973,7 +973,7 @@ impl<T: 'static> View for SelectView<T> {
|
||||
fn important_area(&self, size: Vec2) -> Rect {
|
||||
self.selected_id()
|
||||
.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))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -364,9 +364,9 @@ impl<'a> ObservedLine<'a> {
|
||||
line_len: usize,
|
||||
) -> Self {
|
||||
ObservedLine {
|
||||
parent,
|
||||
line_start,
|
||||
line_len,
|
||||
parent,
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,9 +380,9 @@ impl<'a> ObservedLine<'a> {
|
||||
);
|
||||
|
||||
ObservedLine {
|
||||
parent: self.parent,
|
||||
line_start: Vec2::new(self.line_start.x - left, self.line_start.y),
|
||||
line_len: self.line_len + left + right,
|
||||
parent: self.parent,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ impl BufferView {
|
||||
fn new(size: usize, rx: mpsc::Receiver<String>) -> Self {
|
||||
let mut buffer = VecDeque::new();
|
||||
buffer.resize(size, String::new());
|
||||
BufferView { rx, buffer }
|
||||
BufferView { buffer, rx }
|
||||
}
|
||||
|
||||
// Reads available data from the stream into the buffer
|
||||
|
Loading…
Reference in New Issue
Block a user