Struct FloatingList
pub struct FloatingList<R>where
R: FloatingRow,{ /* private fields */ }Expand description
A floating list of rows under (or, without room, above) an anchor: the
one menu list behind crate::widget::Autocomplete, a code editor’s
caret completion, the filter and slash menus, a dropdown’s open list and
every context menu.
It is a floating Panel (floating_surface, the panel radius, the floating
shadow) placed by floating_surface::place_aligned, so it flips above its
anchor near the window’s bottom and shifts to stay inside it. More rows
than fit scroll, the armed row always in view; a list taller than the room
beside its anchor shrinks to it. While rows are on their way the
framework’s placeholder stands where the first will be
(crate::arriving); a status line stands in for rows when there are
none.
Implementations§
§impl<R> FloatingList<R>where
R: FloatingRow,
impl<R> FloatingList<R>where
R: FloatingRow,
pub fn new() -> FloatingList<R>
pub fn set_side(&mut self, side: PopoverSide)
pub fn set_side(&mut self, side: PopoverSide)
Open on side of the anchor when there is room there: above a
composer at the bottom of a window, below a field near its top.
pub fn set_align(&mut self, align: PanelAlign)
pub fn set_align(&mut self, align: PanelAlign)
Line the panel up with the anchor’s align edge: a menu button’s
list hangs from its trailing edge.
pub fn set_docked(&mut self, docked: bool)
pub fn set_docked(&mut self, docked: bool)
Span the viewport’s width right above the anchor, rows a finger tall: a phone’s drawer docked above the keyboard.
pub fn is_animating(&self, now: Instant) -> bool
pub fn is_animating(&self, now: Instant) -> bool
Whether the panel’s height is still moving, or a row is on its way: the list asks for frames until it rests.
pub fn with_min_width(self, width: f64) -> FloatingList<R>
pub fn with_min_width(self, width: f64) -> FloatingList<R>
Never narrower than width, so a picker over short labels keeps
room for its field and hints.
pub fn set_min_width(&mut self, width: f64)
pub fn set_min_width(&mut self, width: f64)
See Self::with_min_width.
pub fn set_header(&mut self, height: f64)
pub fn set_header(&mut self, height: f64)
Keep a band height tall at the top of the panel, above the rows,
for its owner to paint in (Self::header_rect).
pub fn header_rect(&self) -> Option<Rect>
pub fn header_rect(&self) -> Option<Rect>
The header band (Self::set_header) inside the panel, inset like
the rows. None with nothing to show or no band.
pub fn with_text_role(self, role: TextRole) -> FloatingList<R>
pub fn with_text_role(self, role: TextRole) -> FloatingList<R>
Set the rows’ labels in role (a code completion’s labels are Code).
pub fn with_max_visible(self, rows: usize) -> FloatingList<R>
pub fn with_max_visible(self, rows: usize) -> FloatingList<R>
Rows beyond this scroll instead of growing the panel.
pub fn set_max_visible(&mut self, rows: usize)
pub fn set_max_visible(&mut self, rows: usize)
Rows beyond rows scroll instead of growing the panel.
pub fn set_max_height(&mut self, height: Option<f64>)
pub fn set_max_height(&mut self, height: Option<f64>)
Rows taller than height together scroll instead of growing the
panel; None leaves only Self::with_max_visible.
pub fn set_min_row_height(&mut self, height: f64)
pub fn set_min_row_height(&mut self, height: f64)
No row shorter than height: a touch target on a coarse pointer.
pub fn set_row_height(&mut self, height: Option<f64>)
pub fn set_row_height(&mut self, height: Option<f64>)
Pin every row’s height over the theme’s (None derives it from the
label’s line).
pub fn with_scrollbar(self) -> FloatingList<R>
pub fn with_scrollbar(self) -> FloatingList<R>
Show a bar beside the rows while they overflow, which a drag of its thumb scrolls as every bar does.
pub fn set_overlaid_bars(&mut self)
pub fn set_overlaid_bars(&mut self)
Keep the bar over the rows’ edge instead of beside them (a menu).
pub fn set_text_role(&mut self, role: TextRole)
pub fn set_text_role(&mut self, role: TextRole)
Set the rows’ label role; see Self::with_text_role.
pub fn metrics(&self) -> &FloatingMetrics
pub fn metrics(&self) -> &FloatingMetrics
The geometry of the latest paint (stock before it).
pub fn set_theme(&mut self, theme: &Theme)
pub fn set_theme(&mut self, theme: &Theme)
Take theme’s geometry now, before a paint measures the labels, so
rows are hit where they will be drawn.
pub fn set_rows(&mut self, rows: Vec<R>)
pub fn set_rows(&mut self, rows: Vec<R>)
Replace the rows. The same rows again leave the list as it is: scrolled where the person scrolled it and its width measured. Otherwise keeps the armed row when it still exists and clears the status line once rows arrive.
pub fn highlighted(&self) -> Option<&R>
pub fn set_highlight(&mut self, index: Option<usize>)
pub fn set_highlight(&mut self, index: Option<usize>)
Arm row index (None disarms) and scroll it into view.
pub fn set_cell(&mut self, cell: usize)
pub fn page(&mut self, forward: bool)
pub fn page(&mut self, forward: bool)
Arm the row a page (the rows in view) further on or back, stopping at the ends: Page Down and Page Up.
pub fn move_highlight(&mut self, forward: bool)
pub fn move_highlight(&mut self, forward: bool)
Arm the next (or previous) row, wrapping at both ends.
pub fn step_highlight(&mut self, forward: bool, wrap: bool)
pub fn step_highlight(&mut self, forward: bool, wrap: bool)
Arm the next (or previous) row; at either end wrap round, or stay
there without wrap (a chooser’s list).
pub fn set_status(&mut self, status: Option<String>)
pub fn set_status(&mut self, status: Option<String>)
A line shown while there are no rows (“Searching…”, “No matches”);
None clears it.
pub fn set_arriving(&mut self, clock: Option<ArrivalClock>)
pub fn set_arriving(&mut self, clock: Option<ArrivalClock>)
Rows are on their way, with clock’s timing (asked when, from
where): the framework’s placeholder stands where the first will be.
None once they are in, or nothing is asked.
pub fn arriving(&self) -> Option<&ArrivalClock>
pub fn arriving(&self) -> Option<&ArrivalClock>
The timing of the rows on their way, for an owner that names them.
pub fn next_arriving_step(&self, now: Instant) -> Option<Instant>
pub fn next_arriving_step(&self, now: Instant) -> Option<Instant>
When the placeholder steps on next.
pub fn arriving_moved(&self) -> bool
pub fn arriving_moved(&self) -> bool
Whether the placeholder stepped on since the last paint.
pub fn set_anchor(&mut self, anchor: Rect)
pub fn set_anchor(&mut self, anchor: Rect)
The rect the list opens from (a field, or the caret’s line).
pub fn set_viewport(&mut self, viewport: Rect)
pub fn set_viewport(&mut self, viewport: Rect)
The bounds the list stays inside, normally the window.
pub fn has_content(&self) -> bool
pub fn has_content(&self) -> bool
Whether there is anything to show: rows, a status line, a header band or rows on their way.
pub fn clear(&mut self)
pub fn clear(&mut self)
Clear rows, status and armed row.
pub fn content_height(&self) -> f64
pub fn content_height(&self) -> f64
The height of every row together.
pub fn place_scroll(&mut self)
pub fn place_scroll(&mut self)
Give the rows’ scroll region its box, how tall the rows are, and the step a wheel line takes (one row). It keeps the offset inside them.
pub fn wanted_size(&self) -> (f64, f64)
pub fn wanted_size(&self) -> (f64, f64)
The panel’s size for the rows as measured, which is what a host that places the list by hand needs before it paints once.
pub fn set_rect(&mut self, rect: Rect)
pub fn set_rect(&mut self, rect: Rect)
Put the panel where a host placed it, keeping the rows inside: a host
that places the list by the rules of its own surface (a menu beside a
control it must not cover) measures with Self::measure, places,
and hands the rect over here.
pub fn snap_height(&mut self)
pub fn snap_height(&mut self)
Take the panel’s height as it is now, without growing into it.
pub fn rect(&self) -> Option<Rect>
pub fn rect(&self) -> Option<Rect>
The panel’s rect: under the anchor, or above it when there is more
room there, inside the viewport. None with nothing to show.
pub fn row_rect(&self, index: usize) -> Option<Rect>
pub fn row_rect(&self, index: usize) -> Option<Rect>
The part of row index in view, in host coordinates.
pub fn row_at_point(&self, point: Point) -> Option<usize>
pub fn row_at_point(&self, point: Point) -> Option<usize>
The row under point, pickable or not.
pub fn arm_at(&mut self, point: Point) -> bool
pub fn arm_at(&mut self, point: Point) -> bool
Arm the row under point, as a pointer on a menu does, without
scrolling a row half in view. Whether the armed row changed.
pub fn hover_at(&mut self, point: Point) -> bool
pub fn hover_at(&mut self, point: Point) -> bool
Track the pointer for the hover lift; returns whether it changed.
pub fn scroll_delta(&mut self, delta: Vec2) -> bool
pub fn scroll_delta(&mut self, delta: Vec2) -> bool
Scroll by delta (positive scrolls down), within the rows.
pub fn scroll_offset(&self) -> f64
pub fn scroll_offset(&self) -> f64
How far the rows are scrolled, in pixels.
pub fn is_scrollbar_active(&self) -> bool
pub fn is_scrollbar_active(&self) -> bool
Whether the rows’ bar is held, hovered or has the pointer on it.
pub fn is_dragging(&self) -> bool
pub fn is_dragging(&self) -> bool
Whether the bar’s thumb is being dragged: the pointer stays captured until it is released.
pub fn pointer_left(&mut self)
pub fn pointer_left(&mut self)
The pointer left the window: the bar shows no hover, and a held thumb is let go (the window reports no release for it).
pub fn needs_animation_frame(&self) -> bool
pub fn needs_animation_frame(&self) -> bool
Whether the rows’ scroll is animating: a glide after a flick, or the bar fading in or out.
pub fn advance(&mut self) -> bool
pub fn advance(&mut self) -> bool
Step the scroll’s animation to this frame; returns whether a glide moved the rows.
pub fn scroll_event(
&mut self,
event: &WindowEvent,
ctx: &mut EventCtx<'_>,
) -> bool
pub fn scroll_event( &mut self, event: &WindowEvent, ctx: &mut EventCtx<'_>, ) -> bool
Forward event to the rows’ scroll region: the wheel over the rows,
a press on their bar, a drag of its thumb. ctx.handled says whether
the region took it; the return value is whether the scroll changed
(a repaint, not consumed input).
pub fn row_height(&self) -> f64
pub fn row_height(&self) -> f64
One row’s height.
pub fn row_height_at(&self, index: usize) -> f64
pub fn row_height_at(&self, index: usize) -> f64
The height of row index.
pub fn measure(&mut self, text: &mut TextRenderer, theme: &Theme)
pub fn measure(&mut self, text: &mut TextRenderer, theme: &Theme)
The width every row needs, as the next paint will: a host that places a list by hand measures before it has painted once.
pub fn paint(
&mut self,
scene: &mut Scene,
transform: Affine,
text: &mut TextRenderer,
theme: &Theme,
)
pub fn paint( &mut self, scene: &mut Scene, transform: Affine, text: &mut TextRenderer, theme: &Theme, )
Paint the list in the window’s top layer.
Trait Implementations§
§impl<R> Default for FloatingList<R>where
R: FloatingRow,
impl<R> Default for FloatingList<R>where
R: FloatingRow,
§fn default() -> FloatingList<R>
fn default() -> FloatingList<R>
Auto Trait Implementations§
impl<R> !Freeze for FloatingList<R>
impl<R> !RefUnwindSafe for FloatingList<R>
impl<R> !Send for FloatingList<R>
impl<R> !Sync for FloatingList<R>
impl<R> Unpin for FloatingList<R>where
R: Unpin,
impl<R> UnsafeUnpin for FloatingList<R>
impl<R> !UnwindSafe for FloatingList<R>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more