Skip to main content

hadrone_core/
events.rs

1//! Structured layout lifecycle events (RGL-style callbacks).
2
3use crate::interaction::InteractionType;
4use crate::{CollisionStrategy, CompactionType, LayoutItem};
5
6/// Phase of a drag or resize interaction.
7#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
8pub enum InteractionPhase {
9    Start,
10    Update,
11    Stop,
12    Cancel,
13}
14
15/// Emitted by hosts for undo stacks, analytics, and custom constraints.
16#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
17pub enum LayoutEvent {
18    Interaction {
19        phase: InteractionPhase,
20        id: String,
21        interaction: InteractionType,
22        /// Snapshot of the full layout after applying this step (when applicable).
23        layout: Vec<LayoutItem>,
24        compaction: CompactionType,
25        collision: CollisionStrategy,
26    },
27    /// Column count or compaction changed outside an interaction (e.g. responsive).
28    ConfigChanged {
29        cols: i32,
30        compaction: CompactionType,
31    },
32}