Tree
展開、選択、キーボードナビゲーションに対応した仮想化階層コレクションです。
デモを読み込み中…
TreeState::new(nodes)
.element("files")#インポート
quickgui から Tree をインポートします。
use quickgui::*;#使い方
TreeState::new(nodes)
.element("files")#構成
Tree::rootTree::row
#API リファレンス
項目を展開すると説明と完全なシグネチャが表示されます。ダッシュは宣言に既定値が記載されていないことを示します。
TreeState
ソースを見るpub fn new(nodes: impl IntoIterator<Item = TreeNode<T>>) -> Result<Self, TreeError>with_layoutpub 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>—
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—
set_layoutpub 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—
visible_countpub fn visible_count(&self) -> usize—
root_countpub const fn root_count(&self) -> usize—
selected_idpub fn selected_id(&self) -> Option<ElementId>—
selected_valuepub 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>—
list_statepub 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—
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.
