Skip to main content

PivotState

Struct PivotState 

Source
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: PivotConfig

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

§agg_menu_open: bool

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: GridTheme

Theme shared with the host grid.

§scroll_handle: ScrollHandle

Scroll offset of the data region.

§focus_handle: FocusHandle

Focus handle for keyboard input.

§bounds: Bounds<Pixels>

Painted bounds, updated each layout pass.

§row_height: f32

Height of one data row.

§header_row_height: f32

Height of one column-header level.

§row_header_width: f32

Width of the row-label column.

§value_col_width: f32

Uniform width of every value column.

§font_size: f32

Font size for all pivot text.

§char_width: f32

Approximate monospace character width used for text measurement.

Implementations§

Source§

impl PivotState

Source

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.

Source

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.

Source

pub fn source_differs(&self, rows: &Arc<Vec<Vec<CellValue>>>) -> bool

true when rows is a different snapshot than the current source.

Source

pub fn source_columns(&self) -> &[Column]

Source column metadata (for building field lists).

Source

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.

Source

pub fn value_format(&self) -> &ResolvedColumnFormat

The format used for value cells (public for export code).

Source

pub fn visible_rows(&self) -> &[VisibleRow]

The flattened display rows.

Source

pub fn visible_cols(&self) -> &[VisibleCol]

The flattened display columns.

Source

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.

Source

pub fn toggle_col_group(&mut self, node: usize)

Toggle a column group open/closed. node is a column node id.

Source

pub fn collapse_all_rows(&mut self)

Collapse every row group at every level.

Source

pub fn expand_all_rows(&mut self)

Expand every row group.

Source

pub fn collapse_all_cols(&mut self)

Collapse every column group at every level.

Source

pub fn expand_all_cols(&mut self)

Expand every column group.

Source

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.

Source

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.

Source

pub fn cycle_col_label_sort(&mut self)

Cycle column ordering by the column labels.

Source

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.

Source

pub fn filter_popover(&self) -> Option<&PivotFilterPopover>

The open Filters-zone popover, if any.

Source

pub fn toggle_filter_popover_value(&mut self, index: usize)

Toggle one checklist row and re-apply immediately.

Source

pub fn toggle_filter_popover_select_all(&mut self)

Toggle all checklist rows at once and re-apply.

Source

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

Source

pub fn close_filter_popover(&mut self)

Close the popover (its edits are already applied — auto-apply).

Source

pub fn clear_filter(&mut self, field: usize)

Clear the filter on one Filters-zone field.

Source

pub fn filter_active(&self, field: usize) -> bool

true when the given Filters-zone field has an active (non-inert) filter.

Source

pub fn set_context_menu_provider( &mut self, provider: impl PivotContextMenuProvider + 'static, )

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.

Source

pub fn row_path_components(&self, row_key: usize) -> Vec<PivotPathComponent>

The grouping path for a row-axis key (TOTAL_KEY → empty).

Source

pub fn col_path_components(&self, col_key: usize) -> Vec<PivotPathComponent>

The grouping path for a column-axis key (TOTAL_KEY → empty).

Source

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.

Source

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.

Source

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.

Source

pub fn open_context_menu(&mut self, hit: PivotHitResult, anchor: Point<Pixels>)

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.

Source

pub fn row_label(&self, row: &VisibleRow) -> String

Display label for a visible row.

Source

pub fn col_label(&self, col: &VisibleCol) -> String

Display label for a visible column (as shown at the innermost header level).

Source

pub fn cell_value(&self, row: &VisibleRow, col: &VisibleCol) -> &CellValue

The value cell for a visible (row, col) pair.

Source

pub fn row_height(&self) -> f32

Current height of every pivot data row, in logical pixels.

Source

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.

Source

pub fn column_width(&self) -> f32

Current width of every pivot value column, in logical pixels.

Source

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.

Source

pub fn header_levels(&self) -> usize

Number of stacked header rows: one caption row plus one row per column-field level (minimum one).

Source

pub fn header_height(&self) -> f32

Total header block height in pixels.

Source

pub fn content_size(&self) -> (f32, f32)

Content size of the data region (all rows × all columns), in pixels.

Source

pub fn hit_test(&self, pos: Point<Pixels>) -> PivotHitResult

Resolve a grid-relative pointer position.

Source

pub fn handle_mouse_down(&mut self, pos: Point<Pixels>, shift: bool)

Handle a left mouse-down at a grid-relative position.

Source

pub fn handle_mouse_move(&mut self, pos: Point<Pixels>, left_down: bool)

Handle pointer movement (hover, drag-selection, scrollbar drags).

Source

pub fn handle_mouse_up(&mut self)

Handle mouse-up: end any drag.

Source

pub fn apply_scroll_delta(&mut self, dx: f32, dy: f32)

Apply a scroll-wheel delta, clamped to the content.

Source

pub fn handle_key(&mut self, ks: &Keystroke, cx: &mut App)

Handle a keystroke: copy bindings, escape, arrow-key selection moves.

Source

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.

Source

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.

Source

pub fn to_csv(&self) -> String

Export the fully expanded pivot as CSV: one column per row field (hierarchical labels), one column per leaf column, plus totals as configured. Ignores the current collapse state.

Auto Trait Implementations§

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

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

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.
Source§

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.
Source§

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.
Source§

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.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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