mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-27 11:16:03 +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.
|
/// 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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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))
|
||||||
|
@ -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
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user