mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Fix ListView::important_area
This commit is contained in:
parent
7101c174f2
commit
db540452a4
@ -99,7 +99,7 @@ impl<'a> FromIterator<&'a Style> for Style {
|
|||||||
effects.insert_all(style.effects);
|
effects.insert_all(style.effects);
|
||||||
}
|
}
|
||||||
|
|
||||||
Style { color, effects }
|
Style { effects, color }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,9 +114,9 @@ impl<'a, T: Deref<Target = Child>, I: Iterator<Item = T>> Iterator
|
|||||||
self.offset += length;
|
self.offset += length;
|
||||||
|
|
||||||
ChildItem {
|
ChildItem {
|
||||||
|
child,
|
||||||
offset,
|
offset,
|
||||||
length,
|
length,
|
||||||
child,
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -408,8 +408,7 @@ impl View for ListView {
|
|||||||
let rel = source.relative(direction::Orientation::Vertical);
|
let rel = source.relative(direction::Orientation::Vertical);
|
||||||
let i = if let Some(i) = self
|
let i = if let Some(i) = self
|
||||||
.iter_mut(rel.is_none(), rel.unwrap_or(direction::Relative::Front))
|
.iter_mut(rel.is_none(), rel.unwrap_or(direction::Relative::Front))
|
||||||
.filter_map(|p| try_focus(p, source))
|
.find_map(|p| try_focus(p, source))
|
||||||
.next()
|
|
||||||
{
|
{
|
||||||
i
|
i
|
||||||
} else {
|
} else {
|
||||||
@ -434,13 +433,13 @@ impl View for ListView {
|
|||||||
&mut self,
|
&mut self,
|
||||||
selector: &Selector<'_>,
|
selector: &Selector<'_>,
|
||||||
) -> Result<(), ViewNotFound> {
|
) -> Result<(), ViewNotFound> {
|
||||||
|
// Try to focus each view. Skip over delimiters.
|
||||||
if let Some(i) = self
|
if let Some(i) = self
|
||||||
.children
|
.children
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter_map(|(i, v)| v.view().map(|v| (i, v)))
|
.filter_map(|(i, v)| v.view().map(|v| (i, v)))
|
||||||
.filter_map(|(i, v)| v.focus_view(selector).ok().map(|_| i))
|
.find_map(|(i, v)| v.focus_view(selector).ok().map(|_| i))
|
||||||
.next()
|
|
||||||
{
|
{
|
||||||
self.focus = i;
|
self.focus = i;
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -456,6 +455,7 @@ impl View for ListView {
|
|||||||
|
|
||||||
let labels_width = self.labels_width();
|
let labels_width = self.labels_width();
|
||||||
|
|
||||||
|
// This is the size of the focused view
|
||||||
let area = match self.children[self.focus] {
|
let area = match self.children[self.focus] {
|
||||||
ListChild::Row(_, ref view) => {
|
ListChild::Row(_, ref view) => {
|
||||||
let available =
|
let available =
|
||||||
@ -465,6 +465,11 @@ impl View for ListView {
|
|||||||
ListChild::Delimiter => Rect::from_size((0, 0), (size.x, 1)),
|
ListChild::Delimiter => Rect::from_size((0, 0), (size.x, 1)),
|
||||||
};
|
};
|
||||||
|
|
||||||
area + (0, self.focus)
|
// This is how far down the focused view is.
|
||||||
|
// (The size of everything above.)
|
||||||
|
let y_offset: usize =
|
||||||
|
self.children_heights[..self.focus].iter().copied().sum();
|
||||||
|
|
||||||
|
area + (0, y_offset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user