use crate::forme::MemberId;
use crate::forme::subgraph::SubgraphId;
use crate::forme::layout::LayoutMode;
use crate::forme::lens::ProjectionLens;
use crate::forme::member::{LayoutOverride, Lifecycle, Provenance};
#[derive(Clone, Debug)]
pub enum NavAction<N: MemberId> {
Select(N),
Activate(N),
Dismiss(N),
ToggleExpand(N),
Reveal(N),
Attach {
member: N,
provenance: Provenance<N>,
},
Detach { member: N, recursive: bool },
Reparent { member: N, new_parent: N },
Reorder { parent: N, new_order: Vec<N> },
SetLifecycle(N, Lifecycle),
SetLayoutMode(LayoutMode),
SetLens(ProjectionLens),
CycleFocus(FocusDirection),
CycleFocusRegion(FocusCycleRegion),
SetLayoutOverride(N, LayoutOverride),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FocusDirection {
Next,
Previous,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FocusCycleRegion {
Roots,
Branches,
Leaves,
}
#[derive(Clone, Debug)]
pub struct NavResult<N: MemberId> {
pub intents: Vec<TreeIntent<N>>,
pub structure_changed: bool,
pub session_changed: bool,
}
impl<N: MemberId> NavResult<N> {
pub fn empty() -> Self {
Self {
intents: Vec::new(),
structure_changed: false,
session_changed: false,
}
}
pub fn session(intents: Vec<TreeIntent<N>>) -> Self {
Self {
intents,
structure_changed: false,
session_changed: true,
}
}
pub fn structural(intents: Vec<TreeIntent<N>>) -> Self {
Self {
intents,
structure_changed: true,
session_changed: true,
}
}
}
#[derive(Clone, Debug)]
pub enum TreeIntent<N: MemberId> {
SelectionChanged(N),
RequestActivation(N),
RequestDismissal(N),
RequestFocus(N),
ReconciliationNeeded {
subgraph: SubgraphId,
reason: String,
},
LensChanged(ProjectionLens),
LayoutModeChanged(LayoutMode),
MemberAttached(N),
MemberDetached(N),
}