Skip to main content

euv_ui/component/virtual_list/hook/
struct.rs

1use crate::*;
2
3/// Reactive state for the virtual list scroll tracking.
4///
5/// Contains only `Copy` signal fields so the struct can be freely
6/// captured inside `html!` closures without causing `FnOnce` issues.
7#[derive(Clone, Copy, Data, Debug, Default, Eq, New, Ord, PartialEq, PartialOrd)]
8pub struct UseVirtualList {
9    /// The current scroll offset in pixels.
10    #[get(type(copy))]
11    pub scroll_offset: Signal<i32>,
12    /// The current viewport height in pixels.
13    #[get(type(copy))]
14    pub viewport_height: Signal<i32>,
15}
16
17/// A `Sync` wrapper for single-threaded global `HashSet` access.
18///
19/// SAFETY: This type is only safe to use in single-threaded contexts
20/// (e.g., WASM). It implements `Sync` to allow usage as a `static mut`
21/// variable, but concurrent access from multiple threads would be
22/// undefined behavior.
23#[derive(Data, Debug, New)]
24pub(crate) struct PendingMeasureCell(
25    /// Interior-mutable storage for the pending measurement set.
26    #[get(pub(crate))]
27    #[get_mut(pub(crate))]
28    #[set(pub(crate))]
29    pub(crate) UnsafeCell<Option<HashSet<String>>>,
30);