Skip to main content

FloatingList

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,

pub fn new() -> FloatingList<R>

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)

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)

Span the viewport’s width right above the anchor, rows a finger tall: a phone’s drawer docked above the keyboard.

pub fn is_docked(&self) -> bool

Whether the panel is docked across the viewport.

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>

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_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>

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>

Set the rows’ labels in role (a code completion’s labels are Code).

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)

Rows beyond rows scroll instead of growing the panel.

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)

No row shorter than height: a touch target on a coarse pointer.

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>

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)

Keep the bar over the rows’ edge instead of beside them (a menu).

pub fn set_text_role(&mut self, role: TextRole)

Set the rows’ label role; see Self::with_text_role.

pub fn theme(&self) -> &Theme

The theme the geometry came from.

pub fn metrics(&self) -> &FloatingMetrics

The geometry of the latest paint (stock before it).

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>)

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 rows(&self) -> &[R]

The rows, in order.

pub fn highlight(&self) -> Option<usize>

The armed row’s index.

pub fn highlighted(&self) -> Option<&R>

pub fn set_highlight(&mut self, index: Option<usize>)

Arm row index (None disarms) and scroll it into view.

pub fn cell(&self) -> usize

The armed cell, of a row that offers cells.

pub fn set_cell(&mut self, cell: usize)

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)

Arm the next (or previous) row, wrapping at both ends.

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>)

A line shown while there are no rows (“Searching…”, “No matches”); None clears it.

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>

The timing of the rows on their way, for an owner that names them.

pub fn is_busy(&self) -> bool

Whether rows are on their way.

pub fn next_arriving_step(&self, now: Instant) -> Option<Instant>

When the placeholder steps on next.

pub fn arriving_moved(&self) -> bool

Whether the placeholder stepped on since the last paint.

pub fn set_anchor(&mut self, anchor: Rect)

The rect the list opens from (a field, or the caret’s line).

pub fn anchor(&self) -> Rect

The rect the list opens from.

pub fn set_viewport(&mut self, viewport: Rect)

The bounds the list stays inside, normally the window.

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)

Clear rows, status and armed row.

pub fn content_height(&self) -> f64

The height of every row together.

pub fn row_top(&self, index: usize) -> f64

Where row index starts below the first row.

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)

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)

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)

Take the panel’s height as it is now, without growing into it.

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 in_view(&self) -> Range<usize> ⓘ

The rows at least partly in view.

pub fn row_rect(&self, index: usize) -> Option<Rect>

The part of row index in view, in host coordinates.

pub fn rows_rect(&self) -> Rect

The rows’ box on screen: where the rows show.

pub fn row_at_point(&self, point: Point) -> Option<usize>

The row under point, pickable or not.

pub fn row_at(&self, point: Point) -> Option<usize>

The pickable row under point.

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

Track the pointer for the hover lift; returns whether it changed.

pub fn scroll_by(&mut self, rows: i32)

Scroll by rows (positive scrolls down), within the rows.

pub fn scroll_px(&mut self, dy: f64)

Scroll by dy pixels (positive scrolls down), within the rows.

pub fn scroll_delta(&mut self, delta: Vec2) -> bool

Scroll by delta (positive scrolls down), within the rows.

pub fn scroll_offset(&self) -> f64

How far the rows are scrolled, in pixels.

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

Whether the bar’s thumb is being dragged: the pointer stays captured until it is released.

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

Whether the rows’ scroll is animating: a glide after a flick, or the bar fading in or out.

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

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

One row’s height.

pub fn row_height_at(&self, index: usize) -> f64

The height of row index.

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, )

Paint the list in the window’s top layer.

pub fn status(&self) -> Option<&str>

The status line the list shows, if any.

Trait Implementations§

§

impl<R> Default for FloatingList<R>
where R: FloatingRow,

§

fn default() -> FloatingList<R>

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsAny for T
where T: 'static,

§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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 T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,