DefaultActions

Struct DefaultActions 

Source
pub struct DefaultActions<Id>
where Id: Hash + Eq + Clone + Debug,
{ /* 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 implement Hash, Eq, and Clone.

§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>
where Id: Hash + Eq + Clone + Debug,

Source

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();
Source

pub fn with_logging(max_log_entries: usize) -> Self

Creates a new actions handler with event logging enabled.

§Arguments
  • max_log_entries - Maximum number of log entries to keep
§Examples
use egui_arbor::default_actions::DefaultActions;

let actions = DefaultActions::<u64>::with_logging(100);
Source

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());
Source

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();
}
Source

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);
Source

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);
Source

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);
Source

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));
Source

pub fn visible(&self) -> &HashSet<Id>

Returns a reference to the set of visible node IDs.

Source

pub fn locked(&self) -> &HashSet<Id>

Returns a reference to the set of locked node IDs.

Source

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));
Source

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>
where Id: Hash + Eq + Clone + Debug + Clone,

Source§

fn clone(&self) -> DefaultActions<Id>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Id> Debug for DefaultActions<Id>
where Id: Hash + Eq + Clone + Debug + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Id> Default for DefaultActions<Id>
where Id: Hash + Eq + Clone + Debug,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<Id, N> OutlinerActions<N> for DefaultActions<Id>
where Id: Hash + Eq + Clone + Debug, N: OutlinerNode<Id = Id>,

Source§

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)

Called when a node is moved via drag-and-drop. Read more
Source§

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

Returns whether a node is currently selected. Read more
Source§

fn is_visible(&self, id: &Id) -> bool

Returns whether a node is currently visible. Read more
Source§

fn is_locked(&self, id: &Id) -> bool

Returns whether a node is currently locked. Read more
Source§

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)

Called when the lock action icon is clicked. Read more
Source§

fn on_selection_toggle(&mut self, id: &Id)

Called when the selection action icon is clicked. Read more
Source§

fn on_custom_action(&mut self, id: &Id, icon: &str)

Called when a custom 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> 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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,