pub struct PortalList { /* private fields */ }Implementations§
Source§impl PortalList
impl PortalList
Sourcepub fn next_visible_item(&mut self, cx: &mut Cx2d<'_, '_>) -> Option<usize>
pub fn next_visible_item(&mut self, cx: &mut Cx2d<'_, '_>) -> Option<usize>
Returns the index of the next visible item that will be drawn by this PortalList.
Sourcepub fn item(
&mut self,
cx: &mut Cx,
entry_id: usize,
template: LiveId,
) -> WidgetRef
pub fn item( &mut self, cx: &mut Cx, entry_id: usize, template: LiveId, ) -> WidgetRef
Creates a new widget from the given template or returns an existing widget,
if one already exists with the same entry_id.
If you care whether the widget already existed or not, use PortalList::item_with_existed() instead.
§Return
- If a widget already existed for the given
entry_idandtemplate, this returns a reference to that widget. - If a new widget was created successfully, this returns a reference to that new widget.
- If the given
templatecould not be found, this returnsNone.
Sourcepub fn item_with_existed(
&mut self,
cx: &mut Cx,
entry_id: usize,
template: LiveId,
) -> (WidgetRef, bool)
pub fn item_with_existed( &mut self, cx: &mut Cx, entry_id: usize, template: LiveId, ) -> (WidgetRef, bool)
Creates a new widget from the given template or returns an existing widget,
if one already exists with the same entry_id and template.
- If you only want to check whether the item already existed without creating one,
use
PortalList::get_item()instead. - If you don’t care whether the widget already existed or not, use
PortalList::item()instead.
§Return
- If a widget of the same
templatealready existed for the givenentry_id, this returns a tuple of that widget andtrue. - If a new widget was created successfully, either because an item with the given
entry_iddid not exist or because the existing item with the givenentry_iddid not use the giventemplate, this returns a tuple of that widget andfalse. - If the given
templatecould not be found, this returnsNone.
Sourcepub fn position_of_item(&self, cx: &Cx, entry_id: usize) -> Option<f64>
pub fn position_of_item(&self, cx: &Cx, entry_id: usize) -> Option<f64>
Returns the “start” position of the item with the given entry_id
relative to the “start” position of the PortalList.
- For vertical lists, the start position is the top of the item relative to the top of the PortalList.
- For horizontal lists, the start position is the left side of the item relative to the left side of the PortalList.
Returns None if the item with the given entry_id does not exist
or if the item’s area rectangle is zero.
TODO: FIXME: this may not properly handle bottom-up lists or lists that go from right to left.
Sourcepub fn get_item(&self, entry_id: usize) -> Option<(LiveId, WidgetRef)>
pub fn get_item(&self, entry_id: usize) -> Option<(LiveId, WidgetRef)>
Returns a reference to the template and widget for the given entry_id.
pub fn set_item_range( &mut self, cx: &mut Cx, range_start: usize, range_end: usize, )
pub fn update_scroll_bar(&mut self, cx: &mut Cx)
Sourcepub fn is_at_end(&self) -> bool
pub fn is_at_end(&self) -> bool
Returns true if currently at the end of the list, meaning that the lasat item
is visible in the viewport.
Sourcepub fn visible_items(&self) -> usize
pub fn visible_items(&self) -> usize
Returns the number of items that are currently visible in the viewport, including partially visible items.
Sourcepub fn fails_sanity_check_first_id_within_item_range(&self) -> bool
pub fn fails_sanity_check_first_id_within_item_range(&self) -> bool
Returns true if this sanity check fails: the first item ID is within the item range.
Returns false if the sanity check passes as expected.
Sourcepub fn smooth_scroll_to(
&mut self,
cx: &mut Cx,
target_id: usize,
speed: f64,
max_items_to_show: Option<usize>,
)
pub fn smooth_scroll_to( &mut self, cx: &mut Cx, target_id: usize, speed: f64, max_items_to_show: Option<usize>, )
Initiates a smooth scrolling animation to the specified target item in the list.
§Arguments
target_id: The ID (index) of the item to scroll to.speed: A positive floating-point value that controls the speed of the animation. Thespeedwill always be treated as an absolute value, with the direction of the scroll (up or down) determined by whethertarget_idis above or below the current item.max_items_to_show: The maximum number of items to show during the scrolling animation. IfNone, the default value of 20 is used.
§Example
// Scrolls to item 42 at speed 100.0, including at most 30 items in the scroll animation.
smooth_scroll_to(&mut cx, 42, 100.0, Some(30));Sourcepub fn smooth_scroll_to_end(
&mut self,
cx: &mut Cx,
speed: f64,
max_items_to_show: Option<usize>,
)
pub fn smooth_scroll_to_end( &mut self, cx: &mut Cx, speed: f64, max_items_to_show: Option<usize>, )
Trigger an scrolling animation to the end of the list
§Arguments
speed: This value controls how fast the scrolling animation is. Note: This number should be large enough to reach the end, so it is important to test the passed number. TODO provide a better implementation to ensure that the end is always reached, no matter the speed value.max_items_to_show: The maximum number of items to show during the scrolling animation. IfNone, the default value of 20 is used.