Clip List items that partially overflow
This commit is contained in:
parent
f6af7ab27c
commit
b78497bf54
1 changed files with 13 additions and 11 deletions
|
@ -1,7 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
point, px, AnyElement, AvailableSpace, BorrowAppContext, Bounds, DispatchPhase, Element,
|
point, px, AnyElement, AvailableSpace, BorrowAppContext, BorrowWindow, Bounds, ContentMask,
|
||||||
IntoElement, Pixels, Point, ScrollWheelEvent, Size, Style, StyleRefinement, Styled,
|
DispatchPhase, Element, IntoElement, Pixels, Point, ScrollWheelEvent, Size, Style,
|
||||||
WindowContext,
|
StyleRefinement, Styled, WindowContext,
|
||||||
};
|
};
|
||||||
use collections::VecDeque;
|
use collections::VecDeque;
|
||||||
use refineable::Refineable as _;
|
use refineable::Refineable as _;
|
||||||
|
@ -317,7 +317,7 @@ impl Element for List {
|
||||||
|
|
||||||
fn paint(
|
fn paint(
|
||||||
&mut self,
|
&mut self,
|
||||||
bounds: crate::Bounds<crate::Pixels>,
|
bounds: Bounds<crate::Pixels>,
|
||||||
_state: &mut Self::State,
|
_state: &mut Self::State,
|
||||||
cx: &mut crate::WindowContext,
|
cx: &mut crate::WindowContext,
|
||||||
) {
|
) {
|
||||||
|
@ -444,6 +444,7 @@ impl Element for List {
|
||||||
new_items.append(cursor.suffix(&()), &());
|
new_items.append(cursor.suffix(&()), &());
|
||||||
|
|
||||||
// Paint the visible items
|
// Paint the visible items
|
||||||
|
cx.with_content_mask(Some(ContentMask { bounds }), |cx| {
|
||||||
let mut item_origin = bounds.origin;
|
let mut item_origin = bounds.origin;
|
||||||
item_origin.y -= scroll_top.offset_in_item;
|
item_origin.y -= scroll_top.offset_in_item;
|
||||||
for item_element in &mut item_elements {
|
for item_element in &mut item_elements {
|
||||||
|
@ -451,6 +452,7 @@ impl Element for List {
|
||||||
item_element.draw(item_origin, available_item_space, cx);
|
item_element.draw(item_origin, available_item_space, cx);
|
||||||
item_origin.y += item_height;
|
item_origin.y += item_height;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
state.items = new_items;
|
state.items = new_items;
|
||||||
state.last_layout_bounds = Some(bounds);
|
state.last_layout_bounds = Some(bounds);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue