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.
| Hook | Runs | Rule |
|---|---|---|
cell_style | In prepaint, per visible cell, every frame | No allocation, no lock |
group_caption, group_caption_tag | In prepaint, per visible group caption, every frame | No allocation (write into out), no lock |
aggregate_style | In prepaint, per visible aggregate cell, every frame | No allocation, no lock |
tooltip | In prepaint, for the hovered cell and, while a screen reader listens, the focused one: at most twice a frame | May allocate |
header_tooltip | In render, for the hovered header cell | May allocate |
primary_command, context_menu | Once per menu opening, from window.defer after the press | May allocate |
render_progress | In render, while progress is shown | May allocate |
render_cell | In prepaint, per visible cell of an Element or Control column, every frame | May allocate: an element is one |
is_editable | Once per edit start, per commit with no field, and per +/- on a cell with an editor | Command hook, outside prepaint |
validate_edit | Once per commit attempt | May allocate |
render_edit_message | In prepaint, once a frame while the open editor shows a message | May allocate |
drag_payload | Once per row drag, when it starts | Command hook |
Required Associated Types§
Provided Methods§
Sourcefn cell_style(
&self,
_cell: &CellStyleContext<'_, Self::Row>,
_style: &mut CellStyle,
_cx: &App,
)
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.
Sourcefn group_caption(
&self,
caption: &GroupCaptionContext<'_, Self::Row>,
out: &mut String,
_cx: &App,
)
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)”.
Sourcefn group_caption_tag(
&self,
_caption: &GroupCaptionContext<'_, Self::Row>,
_out: &mut String,
_cx: &App,
) -> Option<CaptionTag>
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.
Sourcefn aggregate_style(
&self,
_cell: &AggregateStyleContext<'_, Self::Row>,
_style: &mut CellStyle,
_cx: &App,
)
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.
Sourcefn primary_command(
&self,
_menu: &GridMenuContext<'_, Self::Row>,
_cx: &App,
) -> Option<SharedString>
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).
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.
Sourcefn tooltip(
&self,
cell: &CellTooltipContext<'_, Self::Row>,
_cx: &App,
) -> Option<CellTooltip>
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.
Sourcefn header_tooltip(
&self,
header: &HeaderTooltipContext<'_, <Self::Row as GridRow>::Column>,
_cx: &App,
) -> Option<CellTooltip>
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.
Sourcefn render_progress(
&self,
progress: &GridProgress,
overlay: &ProgressContext,
window: &mut Window,
cx: &mut App,
) -> AnyElement
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.
Sourcefn render_cell(
&self,
_cell: &CellElementContext<'_, Self::Row>,
_window: &mut Window,
_cx: &mut App,
) -> Option<AnyElement>
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.
Sourcefn is_editable(&self, _cell: &EditableContext<'_, Self::Row>, _cx: &App) -> bool
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.
Sourcefn validate_edit(
&self,
_edit: &EditValidateContext<'_, Self::Row>,
_cx: &App,
) -> Result<(), EditError>
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.
Sourcefn render_edit_message(
&self,
message: &EditMessageContext<'_>,
window: &mut Window,
cx: &mut App,
) -> Option<AnyElement>
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.
Sourcefn drag_payload(
&self,
_drag: &RowDragContext<'_, Self::Row>,
_cx: &App,
) -> Option<DragPayload>
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.