本文へスキップ

Tree

展開、選択、キーボードナビゲーションに対応した仮想化階層コレクションです。

デモを読み込み中…

#インポート

quickgui から Tree をインポートします。

use quickgui::*;

#使い方

TreeState::new(nodes)
    .element("files")

#構成

  • Tree::root
  • Tree::row

#API リファレンス

項目を展開すると説明と完全なシグネチャが表示されます。ダッシュは宣言に既定値が記載されていないことを示します。

pub fn new(nodes: impl IntoIterator<Item = TreeNode<T>>) -> Result<Self, TreeError>
with_layoutpub fn with_layout(mut self, layout: TreeLayout) -> Self—

Configures with layout for this part.

pub fn with_layout(mut self, layout: TreeLayout) -> Self
ソースを見る
with_loading_labelpub fn with_loading_label(mut self, label: impl Into<Arc<str>>) -> Self—

Replace the accessible name of the placeholder row shown while children load. Longer text than [`MAX_TREE_LABEL_BYTES`] keeps [`DEFAULT_TREE_LOADING_LABEL`].

pub fn with_loading_label(mut self, label: impl Into<Arc<str>>) -> Self
ソースを見る
loading_labelpub fn loading_label(&self) -> &Arc<str>—

Configures loading label for this part.

pub fn loading_label(&self) -> &Arc<str>
ソースを見る
is_loadingpub fn is_loading(&self, id: impl Into<ElementId>) -> bool—

Whether one branch is expanded with its children still outstanding.

pub fn is_loading(&self, id: impl Into<ElementId>) -> bool
ソースを見る
is_pendingpub fn is_pending(&self, id: impl Into<ElementId>) -> bool—

Whether one branch still has to load its children.

pub fn is_pending(&self, id: impl Into<ElementId>) -> bool
ソースを見る
layoutpub const fn layout(&self) -> TreeLayout—

Configures layout for this part.

pub const fn layout(&self) -> TreeLayout
ソースを見る
set_layoutpub fn set_layout(&mut self, layout: TreeLayout) -> bool—

Configures set layout for this part.

pub fn set_layout(&mut self, layout: TreeLayout) -> bool
ソースを見る
set_nodespub fn set_nodes( &mut self, nodes: impl IntoIterator<Item = TreeNode<T>>, ) -> Result<(), TreeError>—

Configures set nodes for this part.

pub fn set_nodes( &mut self, nodes: impl IntoIterator<Item = TreeNode<T>>, ) -> Result<(), TreeError>
ソースを見る
node_countpub fn node_count(&self) -> usize—

Configures node count for this part.

pub fn node_count(&self) -> usize
ソースを見る
visible_countpub fn visible_count(&self) -> usize—

Configures visible count for this part.

pub fn visible_count(&self) -> usize
ソースを見る
root_countpub const fn root_count(&self) -> usize—

Configures root count for this part.

pub const fn root_count(&self) -> usize
ソースを見る
selected_idpub fn selected_id(&self) -> Option<ElementId>—

Configures selected id for this part.

pub fn selected_id(&self) -> Option<ElementId>
ソースを見る
selected_valuepub fn selected_value(&self) -> Option<&T>—

Configures selected value for this part.

pub fn selected_value(&self) -> Option<&T>
ソースを見る
rowpub fn row(&self, visible_index: usize) -> Option<TreeRow<'_, T>>—

Configures row for this part.

pub fn row(&self, visible_index: usize) -> Option<TreeRow<'_, T>>
ソースを見る
visible_rowspub fn visible_rows(&self) -> std::ops::Range<usize>—

Configures visible rows for this part.

pub fn visible_rows(&self) -> std::ops::Range<usize>
ソースを見る
list_statepub fn list_state(&self) -> &ListState—

Configures list state for this part.

pub fn list_state(&self) -> &ListState
ソースを見る
is_expandedpub fn is_expanded(&self, id: impl Into<ElementId>) -> bool—

Configures is expanded for this part.

pub fn is_expanded(&self, id: impl Into<ElementId>) -> bool
ソースを見る
set_expandedpub fn set_expanded(&mut self, id: impl Into<ElementId>, expanded: bool) -> bool—

Configures set expanded for this part.

pub fn set_expanded(&mut self, id: impl Into<ElementId>, expanded: bool) -> bool
ソースを見る
toggle_expandedpub fn toggle_expanded(&mut self, id: impl Into<ElementId>) -> bool—

Configures toggle expanded for this part.

pub fn toggle_expanded(&mut self, id: impl Into<ElementId>) -> bool
ソースを見る
selectpub fn select(&mut self, id: impl Into<ElementId>) -> bool—

Configures select for this part.

pub fn select(&mut self, id: impl Into<ElementId>) -> bool
ソースを見る
focus_handlepub fn focus_handle(id: impl Into<ElementId>) -> FocusHandle—

Configures focus handle for this part.

pub fn focus_handle(id: impl Into<ElementId>) -> FocusHandle
ソースを見る
row_idpub fn row_id(id: impl Into<ElementId>, node: ElementId) -> ElementId—

Configures row id for this part.

pub fn row_id(id: impl Into<ElementId>, node: ElementId) -> ElementId
ソースを見る
disclosure_idpub fn disclosure_id(id: impl Into<ElementId>, node: ElementId) -> ElementId—

Configures disclosure id for this part.

pub fn disclosure_id(id: impl Into<ElementId>, node: ElementId) -> ElementId
ソースを見る
loading_row_idpub fn loading_row_id(id: impl Into<ElementId>, node: ElementId) -> ElementId—

The stable identity of the placeholder row mounted while one branch loads.

pub fn loading_row_id(id: impl Into<ElementId>, node: ElementId) -> ElementId
ソースを見る
set_childrenpub fn set_children( &mut self, id: impl Into<ElementId>, children: impl IntoIterator<Item = TreeNode<T>>, ) -> Result<bool, TreeError>—

Supply the children of a pending branch in one atomic, validated splice. The replacement is built and validated before any live state changes: an over-deep, oversize, or duplicate-ID payload leaves the tree exactly as it was. On success the branch stops being pending, its placeholder row disappears, and selection, expansion, and the logical scroll anchor are preserved. An unknown node ID reports `Ok(false)`.

pub fn set_children( &mut self, id: impl Into<ElementId>, children: impl IntoIterator<Item = TreeNode<T>>, ) -> Result<bool, TreeError>
ソースを見る

TreeState::element

ソースを見る
pub fn element<V, E, RenderRow, Activate>( &mut self, cx: &mut ViewContext<'_, V>, id: impl Into<ElementId>, access: fn(&mut V) -> &mut TreeState<T>, render_row: RenderRow, activate: Activate, ) -> Element where V: 'static, T: 'static, E: IntoElement, RenderRow: FnMut(TreeRow<'_, T>, Option<Element>) -> E, Activate: Fn(&mut V, ElementId, &mut EventContext) + Clone + 'static,

Build a complete unstyled virtualized, expandable, keyboard-navigable tree. `render_row` runs only for mounted rows and receives an optional behavior-decorated, appearance-free disclosure element. The caller decides where to place that control and owns the complete row layout and paint. QuickGUI decorates the returned row with fixed virtual geometry, tree semantics, selection, and pointer behavior. `activate` receives the selected application value by stable node ID; the tree retains no closure or scheduler afterward.

TreeState::element_with

ソースを見る
pub fn element_with<V, E, RenderRow, Activate>( &mut self, cx: &mut ViewContext<'_, V>, id: impl Into<ElementId>, access_source: StateAccessor<V, TreeState<T>>, mut render_row: RenderRow, activate: Activate, ) -> Element where V: 'static, T: 'static, E: IntoElement, RenderRow: FnMut(TreeRow<'_, T>, Option<Element>) -> E, Activate: Fn(&mut V, ElementId, &mut EventContext) + Clone + 'static,

Build the tree against a per-instance retained-state accessor. A host that renders many declared trees through one view passes an accessor that captures which [`TreeState`] each registered listener resolves.