Skip to main content

LiveGridDelegate

Trait LiveGridDelegate 

Source
pub trait LiveGridDelegate: Sized + 'static {
    type Row: GridRow;

Show 14 methods // Provided methods fn cell_style( &self, _cell: &CellStyleContext<'_, Self::Row>, _style: &mut CellStyle, _cx: &App, ) { ... } fn group_caption( &self, caption: &GroupCaptionContext<'_, Self::Row>, out: &mut String, _cx: &App, ) { ... } fn group_caption_tag( &self, _caption: &GroupCaptionContext<'_, Self::Row>, _out: &mut String, _cx: &App, ) -> Option<CaptionTag> { ... } fn aggregate_style( &self, _cell: &AggregateStyleContext<'_, Self::Row>, _style: &mut CellStyle, _cx: &App, ) { ... } fn primary_command( &self, _menu: &GridMenuContext<'_, Self::Row>, _cx: &App, ) -> Option<SharedString> { ... } fn context_menu( &self, menu_context: &GridMenuContext<'_, Self::Row>, menu: PopupMenu, window: &mut Window, cx: &mut Context<'_, PopupMenu>, ) -> PopupMenu { ... } fn tooltip( &self, cell: &CellTooltipContext<'_, Self::Row>, _cx: &App, ) -> Option<CellTooltip> { ... } fn header_tooltip( &self, header: &HeaderTooltipContext<'_, <Self::Row as GridRow>::Column>, _cx: &App, ) -> Option<CellTooltip> { ... } fn render_progress( &self, progress: &GridProgress, overlay: &ProgressContext, window: &mut Window, cx: &mut App, ) -> AnyElement { ... } fn render_cell( &self, _cell: &CellElementContext<'_, Self::Row>, _window: &mut Window, _cx: &mut App, ) -> Option<AnyElement> { ... } fn is_editable( &self, _cell: &EditableContext<'_, Self::Row>, _cx: &App, ) -> bool { ... } fn validate_edit( &self, _edit: &EditValidateContext<'_, Self::Row>, _cx: &App, ) -> Result<(), EditError> { ... } fn render_edit_message( &self, message: &EditMessageContext<'_>, window: &mut Window, cx: &mut App, ) -> Option<AnyElement> { ... } fn drag_payload( &self, _drag: &RowDragContext<'_, Self::Row>, _cx: &App, ) -> Option<DragPayload> { ... }
}
Expand description

Presentation and command hooks of a grid.

Every hook takes &self and must not read, update or notify the grid entity: the grid is borrowed while it calls them, so that panics. Commands leave the grid as Actions and LiveGridEvents instead.

HookRunsRule
cell_styleIn prepaint, per visible cell, every frameNo allocation, no lock
group_caption, group_caption_tagIn prepaint, per visible group caption, every frameNo allocation (write into out), no lock
aggregate_styleIn prepaint, per visible aggregate cell, every frameNo allocation, no lock
tooltipIn prepaint, for the hovered cell and, while a screen reader listens, the focused one: at most twice a frameMay allocate
header_tooltipIn render, for the hovered header cellMay allocate
primary_command, context_menuOnce per menu opening, from window.defer after the pressMay allocate
render_progressIn render, while progress is shownMay allocate
render_cellIn prepaint, per visible cell of an Element or Control column, every frameMay allocate: an element is one
is_editableOnce per edit start, per commit with no field, and per +/- on a cell with an editorCommand hook, outside prepaint
validate_editOnce per commit attemptMay allocate
render_edit_messageIn prepaint, once a frame while the open editor shows a messageMay allocate
drag_payloadOnce per row drag, when it startsCommand hook

Required Associated Types§

Source

type Row: GridRow

The row type.

Provided Methods§

Source

fn cell_style( &self, _cell: &CellStyleContext<'_, Self::Row>, _style: &mut CellStyle, _cx: &App, )

Adjusts the style of a visible cell, after the grid’s change paint. A removed row that fades out is planned too, with RowChange::Removed as every cell’s change and its last version as the row.

Source

fn group_caption( &self, caption: &GroupCaptionContext<'_, Self::Row>, out: &mut String, _cx: &App, )

Writes the text of a visible group caption into out, which is empty on entry and reused between captions. Default: GroupCaptionContext::default_caption, “Instrument: AAPL (120)”.

Source

fn group_caption_tag( &self, _caption: &GroupCaptionContext<'_, Self::Row>, _out: &mut String, _cx: &App, ) -> Option<CaptionTag>

Writes the text of a tag shown before a visible group caption’s text into out, which is empty on entry and reused between captions, and returns its colours: a pill such as a transit line’s, in the line’s colour. None, or no text, shows no tag. A screen reader hears the tag before the caption. In prepaint, per visible caption, every frame: no allocation, no lock. A custom key kept as itself (OwnedValue::custom) gives its data through GroupCaptionContext::value. Default: None.

Source

fn aggregate_style( &self, _cell: &AggregateStyleContext<'_, Self::Row>, _style: &mut CellStyle, _cx: &App, )

Adjusts the style of a visible aggregate cell: on a group caption, on a group footer and on the totals row. Called after the grid’s change paint, like Self::cell_style.

Source

fn primary_command( &self, _menu: &GridMenuContext<'_, Self::Row>, _cx: &App, ) -> Option<SharedString>

The label of the primary command: the first, bold item of a cell’s or a group caption’s context menu, shown when the command scope is not empty. It dispatches Confirm, so the item, Enter and a double click all emit one LiveGridEvent::Confirm. Default: no item (Enter and a double click still confirm).

Source

fn context_menu( &self, menu_context: &GridMenuContext<'_, Self::Row>, menu: PopupMenu, window: &mut Window, cx: &mut Context<'_, PopupMenu>, ) -> PopupMenu

Builds the context menu below the primary command. Items do their work later, through Actions dispatched to the grid (or its ancestors) or on_click handlers; a handler reads the command scope when it runs, not GridMenuContext::selection. Default: GridMenuContext::standard_items. An empty menu is not shown.

Source

fn tooltip( &self, cell: &CellTooltipContext<'_, Self::Row>, _cx: &App, ) -> Option<CellTooltip>

The tooltip of the hovered body cell, asked again every frame so a shown tooltip follows live values in place. Default: CellTooltipContext::default_tooltip, the full text of a truncated cell.

While the accessibility tree is built, it is also asked for the focused cell (once a frame; once in all if that cell is hovered): a CellTooltip::text describes the cell to a screen reader after its column title, unless it only repeats the cell’s text. Write tooltip text that reads without the screen.

Source

fn header_tooltip( &self, header: &HeaderTooltipContext<'_, <Self::Row as GridRow>::Column>, _cx: &App, ) -> Option<CellTooltip>

The tooltip of the hovered header cell. Default: HeaderTooltipContext::default_tooltip, the full title of a truncated one.

Source

fn render_progress( &self, progress: &GridProgress, overlay: &ProgressContext, window: &mut Window, cx: &mut App, ) -> AnyElement

Presents the shown progress (LiveGridState::progress) over the body, below the header. The element fills the body and has no hitbox of its own unless the delegate adds one: presses and the wheel should reach the rows. Default: ProgressContext::default_overlay, a thin bar under the header and, on an empty grid, the label.

Source

fn render_cell( &self, _cell: &CellElementContext<'_, Self::Row>, _window: &mut Window, _cx: &mut App, ) -> Option<AnyElement>

Builds the element of a visible cell of an Element or Control column; None paints the value as text. In prepaint, per visible cell of such a column, every frame: it may allocate (an element is an allocation), and must not read, update or notify the grid entity. The element’s own handlers run later, outside the grid’s borrow, and may write to the store. An element that can take the keyboard focus sets tab_stop(false): the grid is one Tab stop. A removed row that fades out is asked too, with RowChange::Removed as the cell’s change: fade the element by CellChange::intensity; it takes no press. Default: None.

Source

fn is_editable(&self, _cell: &EditableContext<'_, Self::Row>, _cx: &App) -> bool

Returns true if a cell of a column with an editor takes an edit now: a filled order’s price does not. Asked once per edit start, per commit with no field and per +/- on such a cell, outside prepaint. Default: true.

Source

fn validate_edit( &self, _edit: &EditValidateContext<'_, Self::Row>, _cx: &App, ) -> Result<(), EditError>

Checks a value before its EditCommit: Err keeps the editor open with the message. Once per commit attempt, outside prepaint; may allocate. Default: every value the editor parsed.

Source

fn render_edit_message( &self, message: &EditMessageContext<'_>, window: &mut Window, cx: &mut App, ) -> Option<AnyElement>

Presents the open editor’s message: a refused draft or a conflict with the store. In prepaint, once a frame while a message is shown; may allocate, as tooltip. None shows none (an application that shows LiveGridState::edit_message itself). Default: EditMessageContext::default_popup, a line under the cell.

Source

fn drag_payload( &self, _drag: &RowDragContext<'_, Self::Row>, _cx: &App, ) -> Option<DragPayload>

The application’s part of a row drag that is about to start: data for the drop target and the ghost’s label. None refuses the drag. Called once per drag, when the pointer passes the drag threshold, inside the grid’s update: it must not read or notify the grid. Default: an empty payload, so the keys alone are dragged.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§