pub struct DefaultActions<Id>{ /* private fields */ }Expand description
Default implementation of outliner actions with state tracking.
This struct provides a complete, ready-to-use implementation of the
OutlinerActions trait. It tracks:
- Selection state: Which nodes are currently selected
- Visibility state: Which nodes are visible/hidden
- Lock state: Which nodes are locked
- Event log: Optional logging of all interactions
§Type Parameters
Id- The type used to identify nodes. Must implementHash,Eq, andClone.
§Examples
§Basic Usage
use egui_arbor::default_actions::DefaultActions;
use egui_arbor::OutlinerActions;
let mut actions = DefaultActions::<u64>::new();
// All nodes start unselected, visible, and unlocked
assert!(!OutlinerActions::<TestNode>::is_selected(&actions, &1));
assert!(!OutlinerActions::<TestNode>::is_visible(&actions, &1));
assert!(!OutlinerActions::<TestNode>::is_locked(&actions, &1));§With Event Logging
use egui_arbor::default_actions::DefaultActions;
use egui_arbor::OutlinerActions;
let mut actions = DefaultActions::<u64>::with_logging(50);
// Events are automatically logged
OutlinerActions::<TestNode>::on_select(&mut actions, &1, true);
assert_eq!(actions.event_log().unwrap().len(), 1);§Pre-populate State
use egui_arbor::default_actions::DefaultActions;
use egui_arbor::OutlinerActions;
use std::collections::HashSet;
let mut actions = DefaultActions::<u64>::new();
// Make all nodes visible by default
let visible_ids: HashSet<_> = (0..10).collect();
actions.set_all_visible(visible_ids);
assert!(OutlinerActions::<TestNode>::is_visible(&actions, &5));Implementations§
Source§impl<Id> DefaultActions<Id>
impl<Id> DefaultActions<Id>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new actions handler with no event logging.
All nodes start unselected, invisible, and unlocked.
§Examples
use egui_arbor::default_actions::DefaultActions;
let actions = DefaultActions::<u64>::new();Sourcepub fn with_logging(max_log_entries: usize) -> Self
pub fn with_logging(max_log_entries: usize) -> Self
Sourcepub fn event_log(&self) -> Option<&EventLog<Id>>
pub fn event_log(&self) -> Option<&EventLog<Id>>
Returns a reference to the event log, if logging is enabled.
§Examples
use egui_arbor::default_actions::DefaultActions;
let actions = DefaultActions::<u64>::with_logging(10);
assert!(actions.event_log().is_some());
let actions = DefaultActions::<u64>::new();
assert!(actions.event_log().is_none());Sourcepub fn event_log_mut(&mut self) -> Option<&mut EventLog<Id>>
pub fn event_log_mut(&mut self) -> Option<&mut EventLog<Id>>
Returns a mutable reference to the event log, if logging is enabled.
§Examples
use egui_arbor::default_actions::DefaultActions;
let mut actions = DefaultActions::<u64>::with_logging(10);
if let Some(log) = actions.event_log_mut() {
log.clear();
}Sourcepub fn selected_count(&self) -> usize
pub fn selected_count(&self) -> usize
Returns the number of selected nodes.
§Examples
use egui_arbor::default_actions::DefaultActions;
use egui_arbor::OutlinerActions;
let mut actions = DefaultActions::<u64>::new();
OutlinerActions::<TestNode>::on_select(&mut actions, &1, true);
OutlinerActions::<TestNode>::on_select(&mut actions, &2, true);
assert_eq!(actions.selected_count(), 2);Sourcepub fn visible_count(&self) -> usize
pub fn visible_count(&self) -> usize
Returns the number of visible nodes.
§Examples
use egui_arbor::default_actions::DefaultActions;
use egui_arbor::OutlinerActions;
let mut actions = DefaultActions::<u64>::new();
OutlinerActions::<TestNode>::on_visibility_toggle(&mut actions, &1);
assert_eq!(actions.visible_count(), 1);Sourcepub fn locked_count(&self) -> usize
pub fn locked_count(&self) -> usize
Returns the number of locked nodes.
§Examples
use egui_arbor::default_actions::DefaultActions;
use egui_arbor::OutlinerActions;
let mut actions = DefaultActions::<u64>::new();
OutlinerActions::<TestNode>::on_lock_toggle(&mut actions, &1);
assert_eq!(actions.locked_count(), 1);Sourcepub fn selected(&self) -> &HashSet<Id>
pub fn selected(&self) -> &HashSet<Id>
Returns a reference to the set of selected node IDs.
§Examples
use egui_arbor::default_actions::DefaultActions;
use egui_arbor::OutlinerActions;
let mut actions = DefaultActions::<u64>::new();
OutlinerActions::<TestNode>::on_select(&mut actions, &1, true);
OutlinerActions::<TestNode>::on_select(&mut actions, &2, true);
assert!(actions.selected().contains(&1));
assert!(actions.selected().contains(&2));Sourcepub fn set_all_visible(&mut self, ids: HashSet<Id>)
pub fn set_all_visible(&mut self, ids: HashSet<Id>)
Sets all nodes as visible.
§Arguments
ids- Set of node IDs to mark as visible
§Examples
use egui_arbor::default_actions::DefaultActions;
use egui_arbor::OutlinerActions;
use std::collections::HashSet;
let mut actions = DefaultActions::<u64>::new();
let visible: HashSet<_> = (0..10).collect();
actions.set_all_visible(visible);
assert!(OutlinerActions::<TestNode>::is_visible(&actions, &5));Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clears all selections.
§Examples
use egui_arbor::default_actions::DefaultActions;
use egui_arbor::OutlinerActions;
let mut actions = DefaultActions::<u64>::new();
OutlinerActions::<TestNode>::on_select(&mut actions, &1, true);
OutlinerActions::<TestNode>::on_select(&mut actions, &2, true);
assert_eq!(actions.selected_count(), 2);
actions.clear_selection();
assert_eq!(actions.selected_count(), 0);Trait Implementations§
Source§impl<Id> Clone for DefaultActions<Id>
impl<Id> Clone for DefaultActions<Id>
Source§fn clone(&self) -> DefaultActions<Id>
fn clone(&self) -> DefaultActions<Id>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<Id> Debug for DefaultActions<Id>
impl<Id> Debug for DefaultActions<Id>
Source§impl<Id> Default for DefaultActions<Id>
impl<Id> Default for DefaultActions<Id>
Source§impl<Id, N> OutlinerActions<N> for DefaultActions<Id>
impl<Id, N> OutlinerActions<N> for DefaultActions<Id>
Source§fn on_rename(&mut self, id: &Id, new_name: String)
fn on_rename(&mut self, id: &Id, new_name: String)
Called when a node is renamed by the user. Read more
Source§fn on_move(&mut self, id: &Id, target: &Id, position: DropPosition)
fn on_move(&mut self, id: &Id, target: &Id, position: DropPosition)
Called when a node is moved via drag-and-drop. Read more
Source§fn on_select(&mut self, id: &Id, selected: bool)
fn on_select(&mut self, id: &Id, selected: bool)
Called when a node’s selection state changes. Read more
Source§fn is_selected(&self, id: &Id) -> bool
fn is_selected(&self, id: &Id) -> bool
Returns whether a node is currently selected. Read more
Source§fn on_visibility_toggle(&mut self, id: &Id)
fn on_visibility_toggle(&mut self, id: &Id)
Called when the visibility action icon is clicked. Read more
Source§fn on_lock_toggle(&mut self, id: &Id)
fn on_lock_toggle(&mut self, id: &Id)
Called when the lock action icon is clicked. Read more
Source§fn on_selection_toggle(&mut self, id: &Id)
fn on_selection_toggle(&mut self, id: &Id)
Called when the selection action icon is clicked. Read more
Auto Trait Implementations§
impl<Id> Freeze for DefaultActions<Id>
impl<Id> RefUnwindSafe for DefaultActions<Id>where
Id: RefUnwindSafe,
impl<Id> Send for DefaultActions<Id>where
Id: Send,
impl<Id> Sync for DefaultActions<Id>where
Id: Sync,
impl<Id> Unpin for DefaultActions<Id>where
Id: Unpin,
impl<Id> UnwindSafe for DefaultActions<Id>where
Id: UnwindSafe,
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
Mutably borrows from an owned value. Read more