pub struct PivotState {Show 16 fields
pub config: PivotConfig,
pub result: Arc<PivotResult>,
pub sort: Option<(PivotSortKey, SortDirection)>,
pub agg_menu_open: bool,
pub selection: Option<(usize, usize, usize, usize)>,
pub hover_hit: Option<PivotHitResult>,
pub theme: GridTheme,
pub scroll_handle: ScrollHandle,
pub focus_handle: FocusHandle,
pub bounds: Bounds<Pixels>,
pub row_height: f32,
pub header_row_height: f32,
pub row_header_width: f32,
pub value_col_width: f32,
pub font_size: f32,
pub char_width: f32,
/* private fields */
}Expand description
Complete pivot-view state owned by a GPUI Entity<PivotState>.
Fields§
§config: PivotConfigLive pivot layout. Mutate it (or use the helper methods) and call
PivotState::recompute; read it back for persistence — this struct
is the “current configuration” API.
result: Arc<PivotResult>The computed pivot, Arc-wrapped so paint snapshots clone in O(1).
sort: Option<(PivotSortKey, SortDirection)>Active ordering. None = canonical (ascending by grouping value).
Whether the sidebar’s aggregation picker is expanded.
selection: Option<(usize, usize, usize, usize)>Selected rectangle in visible coordinates (r1, c1, r2, c2),
normalized.
hover_hit: Option<PivotHitResult>Last hit under the pointer (drives hover affordances).
theme: GridThemeTheme shared with the host grid.
scroll_handle: ScrollHandleScroll offset of the data region.
focus_handle: FocusHandleFocus handle for keyboard input.
bounds: Bounds<Pixels>Painted bounds, updated each layout pass.
row_height: f32Height of one data row.
header_row_height: f32Height of one column-header level.
row_header_width: f32Width of the row-label column.
value_col_width: f32Uniform width of every value column.
font_size: f32Font size for all pivot text.
char_width: f32Approximate monospace character width used for text measurement.
Implementations§
Source§impl PivotState
impl PivotState
Sourcepub fn new(
source_columns: Vec<Column>,
source_rows: Arc<Vec<Vec<CellValue>>>,
resolved_formats: Vec<ResolvedColumnFormat>,
config: PivotConfig,
key_bindings: KeyBindings,
focus_handle: FocusHandle,
) -> Self
pub fn new( source_columns: Vec<Column>, source_rows: Arc<Vec<Vec<CellValue>>>, resolved_formats: Vec<ResolvedColumnFormat>, config: PivotConfig, key_bindings: KeyBindings, focus_handle: FocusHandle, ) -> Self
Build a pivot state over a shared source snapshot and compute the initial result.
Sourcepub fn set_source(
&mut self,
columns: Vec<Column>,
rows: Arc<Vec<Vec<CellValue>>>,
)
pub fn set_source( &mut self, columns: Vec<Column>, rows: Arc<Vec<Vec<CellValue>>>, )
Replace the source snapshot (e.g. after the flat grid appended rows)
and recompute. O(1) extra memory when rows shares the grid’s Arc.
Sourcepub fn source_differs(&self, rows: &Arc<Vec<Vec<CellValue>>>) -> bool
pub fn source_differs(&self, rows: &Arc<Vec<Vec<CellValue>>>) -> bool
true when rows is a different snapshot than the current source.
Sourcepub fn source_columns(&self) -> &[Column]
pub fn source_columns(&self) -> &[Column]
Source column metadata (for building field lists).
Sourcepub fn recompute(&mut self)
pub fn recompute(&mut self)
Re-run the pivot engine against the current config/filters, then rebuild the flattened display lists. Never mutates the source rows.
Sourcepub fn value_format(&self) -> &ResolvedColumnFormat
pub fn value_format(&self) -> &ResolvedColumnFormat
The format used for value cells (public for export code).
Sourcepub fn visible_rows(&self) -> &[VisibleRow]
pub fn visible_rows(&self) -> &[VisibleRow]
The flattened display rows.
Sourcepub fn visible_cols(&self) -> &[VisibleCol]
pub fn visible_cols(&self) -> &[VisibleCol]
The flattened display columns.
Sourcepub fn toggle_row_group(&mut self, node: usize)
pub fn toggle_row_group(&mut self, node: usize)
Toggle a row group open/closed. node is a row node id. Instant —
only re-flattens, no engine recompute.
Sourcepub fn toggle_col_group(&mut self, node: usize)
pub fn toggle_col_group(&mut self, node: usize)
Toggle a column group open/closed. node is a column node id.
Sourcepub fn collapse_all_rows(&mut self)
pub fn collapse_all_rows(&mut self)
Collapse every row group at every level.
Sourcepub fn expand_all_rows(&mut self)
pub fn expand_all_rows(&mut self)
Expand every row group.
Sourcepub fn collapse_all_cols(&mut self)
pub fn collapse_all_cols(&mut self)
Collapse every column group at every level.
Sourcepub fn expand_all_cols(&mut self)
pub fn expand_all_cols(&mut self)
Expand every column group.
Sourcepub fn cycle_sort_by_column(&mut self, col_key: usize)
pub fn cycle_sort_by_column(&mut self, col_key: usize)
Cycle row ordering by a visible column key (asc → desc → canonical).
Pass TOTAL_KEY to sort by the row subtotals.
Sourcepub fn cycle_label_sort(&mut self)
pub fn cycle_label_sort(&mut self)
Cycle row ordering by the row labels. The canonical order is itself ascending, so this cycles asc → desc → canonical.
Sourcepub fn cycle_col_label_sort(&mut self)
pub fn cycle_col_label_sort(&mut self)
Cycle column ordering by the column labels.
Sourcepub fn open_filter_popover(&mut self, field: usize, anchor: Point<Pixels>)
pub fn open_filter_popover(&mut self, field: usize, anchor: Point<Pixels>)
Open (or re-open) the value checklist for a Filters-zone field.
anchor is the window-absolute position the popover opens at.
Sourcepub fn filter_popover(&self) -> Option<&PivotFilterPopover>
pub fn filter_popover(&self) -> Option<&PivotFilterPopover>
The open Filters-zone popover, if any.
Sourcepub fn toggle_filter_popover_value(&mut self, index: usize)
pub fn toggle_filter_popover_value(&mut self, index: usize)
Toggle one checklist row and re-apply immediately.
Sourcepub fn toggle_filter_popover_select_all(&mut self)
pub fn toggle_filter_popover_select_all(&mut self)
Toggle all checklist rows at once and re-apply.
Sourcepub fn apply_filter_popover(&mut self)
pub fn apply_filter_popover(&mut self)
Commit the popover’s checked set to the active filters and recompute. All-checked stores no entry (inert filter).
Sourcepub fn close_filter_popover(&mut self)
pub fn close_filter_popover(&mut self)
Close the popover (its edits are already applied — auto-apply).
Sourcepub fn clear_filter(&mut self, field: usize)
pub fn clear_filter(&mut self, field: usize)
Clear the filter on one Filters-zone field.
Sourcepub fn filter_active(&self, field: usize) -> bool
pub fn filter_active(&self, field: usize) -> bool
true when the given Filters-zone field has an active (non-inert)
filter.
Register (or replace) the right-click menu provider. When set, the
provider fully controls the pivot’s context menu; built-in pivot.*
action ids remain handled by the pivot itself.
Sourcepub fn row_path_components(&self, row_key: usize) -> Vec<PivotPathComponent>
pub fn row_path_components(&self, row_key: usize) -> Vec<PivotPathComponent>
The grouping path for a row-axis key (TOTAL_KEY → empty).
Sourcepub fn col_path_components(&self, col_key: usize) -> Vec<PivotPathComponent>
pub fn col_path_components(&self, col_key: usize) -> Vec<PivotPathComponent>
The grouping path for a column-axis key (TOTAL_KEY → empty).
Sourcepub fn source_rows_for(&self, row_key: usize, col_key: usize) -> Vec<usize>
pub fn source_rows_for(&self, row_key: usize, col_key: usize) -> Vec<usize>
Indices into the source rows that drive the (row_key, col_key)
intersection: rows passing the pivot’s source filters whose grouping
labels match both paths. TOTAL_KEY on either axis means “no
constraint on that axis”, so totals and subtotals resolve naturally.
Sourcepub fn drill_down_filters(
&self,
row_key: usize,
col_key: usize,
) -> Vec<(usize, HashSet<String>)>
pub fn drill_down_filters( &self, row_key: usize, col_key: usize, ) -> Vec<(usize, HashSet<String>)>
Per-source-column allowed formatted values that reproduce the
(row_key, col_key) cell’s driving rows as flat-grid value filters:
the pivot’s active source filters plus one allow-set per grouping
path component. Blank groups map to the empty formatted value the
grid’s filter pipeline produces for null cells.
Sourcepub fn request_drill_down(&mut self, row: usize, col: usize)
pub fn request_drill_down(&mut self, row: usize, col: usize)
Queue a drill-through for the visible cell at (row, col): the host
widget applies the resulting filters to the flat grid and switches
to the Grid tab. Triggered by double-click and by the built-in
“Show source rows in Grid” menu action.
Open the right-click menu for a hit-test result at the given
grid-relative anchor. Builds the PivotContextMenuRequest and asks
the provider (or the built-in default) for items. Non-interactive
hits close any open menu.
Sourcepub fn row_label(&self, row: &VisibleRow) -> String
pub fn row_label(&self, row: &VisibleRow) -> String
Display label for a visible row.
Sourcepub fn col_label(&self, col: &VisibleCol) -> String
pub fn col_label(&self, col: &VisibleCol) -> String
Display label for a visible column (as shown at the innermost header level).
Sourcepub fn cell_value(&self, row: &VisibleRow, col: &VisibleCol) -> &CellValue
pub fn cell_value(&self, row: &VisibleRow, col: &VisibleCol) -> &CellValue
The value cell for a visible (row, col) pair.
Sourcepub fn row_height(&self) -> f32
pub fn row_height(&self) -> f32
Current height of every pivot data row, in logical pixels.
Sourcepub fn set_row_height(&mut self, height: f32)
pub fn set_row_height(&mut self, height: f32)
Set the height of every pivot data row.
Non-finite values are ignored and finite values are clamped to the minimum supported height.
Sourcepub fn column_width(&self) -> f32
pub fn column_width(&self) -> f32
Current width of every pivot value column, in logical pixels.
Sourcepub fn set_column_width(&mut self, width: f32)
pub fn set_column_width(&mut self, width: f32)
Set the width of every pivot value column.
Non-finite values are ignored and finite values are clamped to the minimum supported width.
Sourcepub fn header_levels(&self) -> usize
pub fn header_levels(&self) -> usize
Number of stacked header rows: one caption row plus one row per column-field level (minimum one).
Sourcepub fn header_height(&self) -> f32
pub fn header_height(&self) -> f32
Total header block height in pixels.
Sourcepub fn content_size(&self) -> (f32, f32)
pub fn content_size(&self) -> (f32, f32)
Content size of the data region (all rows × all columns), in pixels.
Sourcepub fn hit_test(&self, pos: Point<Pixels>) -> PivotHitResult
pub fn hit_test(&self, pos: Point<Pixels>) -> PivotHitResult
Resolve a grid-relative pointer position.
Sourcepub fn handle_mouse_down(&mut self, pos: Point<Pixels>, shift: bool)
pub fn handle_mouse_down(&mut self, pos: Point<Pixels>, shift: bool)
Handle a left mouse-down at a grid-relative position.
Sourcepub fn handle_mouse_move(&mut self, pos: Point<Pixels>, left_down: bool)
pub fn handle_mouse_move(&mut self, pos: Point<Pixels>, left_down: bool)
Handle pointer movement (hover, drag-selection, scrollbar drags).
Sourcepub fn handle_mouse_up(&mut self)
pub fn handle_mouse_up(&mut self)
Handle mouse-up: end any drag.
Sourcepub fn apply_scroll_delta(&mut self, dx: f32, dy: f32)
pub fn apply_scroll_delta(&mut self, dx: f32, dy: f32)
Apply a scroll-wheel delta, clamped to the content.
Sourcepub fn handle_key(&mut self, ks: &Keystroke, cx: &mut App)
pub fn handle_key(&mut self, ks: &Keystroke, cx: &mut App)
Handle a keystroke: copy bindings, escape, arrow-key selection moves.
Sourcepub fn copy_selection(&self, with_headers: bool, cx: &mut App)
pub fn copy_selection(&self, with_headers: bool, cx: &mut App)
Copy the selected rectangle (or the whole visible pivot when nothing is selected) to the clipboard as TSV.
Sourcepub fn selection_text(&self, with_headers: bool, sep: char) -> String
pub fn selection_text(&self, with_headers: bool, sep: char) -> String
Build the copy text for the current selection (whole pivot if none),
using sep between fields.
Auto Trait Implementations§
impl !RefUnwindSafe for PivotState
impl !Send for PivotState
impl !Sync for PivotState
impl !UnwindSafe for PivotState
impl Freeze for PivotState
impl Unpin for PivotState
impl UnsafeUnpin for PivotState
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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