#[derive(Clone)]
pub struct InputHitTarget {
pub input_index: usize,
pub input_id: Option<String>,
pub entity_id: Option<strata_primitives::EntityId>,
pub current_value: String,
pub font_size: f32,
pub line_height: f32,
pub is_mono: bool,
pub font_family: strata_primitives::AtomId,
pub content_box_x: f32,
pub content_box_y: f32,
pub content_box_width: f32,
pub on_input: Option<std::rc::Rc<dyn Fn(strata_dom::Event)>>,
pub on_change: Option<std::rc::Rc<dyn Fn(strata_dom::Event)>>,
pub on_submit: Option<std::rc::Rc<dyn Fn(strata_dom::Event)>>,
pub on_focus: Option<std::rc::Rc<dyn Fn(strata_dom::Event)>>,
pub on_blur: Option<std::rc::Rc<dyn Fn(strata_dom::Event)>>,
}
#[derive(Clone)]
pub struct ActiveInput {
pub input_index: usize,
pub input_id: Option<String>,
pub entity_id: Option<strata_primitives::EntityId>,
pub state: strata_dom::text_input::TextInputState,
pub on_input: Option<std::rc::Rc<dyn Fn(strata_dom::Event)>>,
pub on_change: Option<std::rc::Rc<dyn Fn(strata_dom::Event)>>,
pub on_submit: Option<std::rc::Rc<dyn Fn(strata_dom::Event)>>,
pub on_blur: Option<std::rc::Rc<dyn Fn(strata_dom::Event)>>,
}
impl std::fmt::Debug for ActiveInput {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ActiveInput")
.field("text", &self.state.text.get())
.field("cursor", &self.state.cursor_index.get())
.finish()
}
}
#[derive(Debug, Clone)]
pub struct ActiveScrollbar {
pub bounds: strata_layout::Rect,
pub clip_bounds: strata_layout::Rect,
pub border_radius: strata_style::types::BorderRadius,
pub is_top_layer: bool,
pub track_bounds: strata_layout::Rect,
pub thumb_bounds: strata_layout::Rect,
pub scroll_y: f32,
pub max_scroll_y: f32,
pub content_h: f32,
pub is_id: bool,
pub id: String,
pub path: Vec<usize>,
pub available_travel: f32,
}
#[derive(Debug, Clone)]
pub struct ScrollbarDrag {
pub is_id: bool,
pub id: String,
pub path: Vec<usize>,
pub start_pointer_y: f32,
pub start_scroll_y: f32,
pub available_travel: f32,
pub max_scroll_y: f32,
}
#[derive(Debug, Clone)]
pub struct SmoothScrollTracker {
pub container_path: Vec<usize>,
pub container_id: String,
pub is_id: bool,
pub max_scroll_y: f32,
pub available_travel: f32,
pub bounds_y: f32,
pub current_y: f32,
pub target_y: f32,
pub start_y: f32,
pub initial_velocity: f32,
pub start_time: std::time::Instant,
pub last_event_time: std::time::Instant,
pub omega: f32,
}
#[derive(Debug, Clone)]
pub struct ScrollTarget {
pub path: Vec<usize>,
pub id: Option<String>,
pub bounds: strata_layout::Rect,
pub max_scroll_x: f32,
pub max_scroll_y: f32,
}
pub fn path_to_node_id(path: &[usize]) -> u64 {
let mut hash = 0xcbf29ce484222325u64;
for &idx in path {
hash ^= idx as u64;
hash = hash.wrapping_mul(0x100000001b3u64);
}
hash
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EditCommand {
Undo,
Redo,
Cut,
Copy,
Paste,
SelectAll,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PointerDownAction {
Ignored,
CaretMoved,
FocusChanged,
DomListenerInvoked,
}
impl PointerDownAction {
#[inline]
pub fn is_handled(self) -> bool {
self != PointerDownAction::Ignored
}
#[inline]
pub fn needs_rebuild(self) -> bool {
matches!(
self,
PointerDownAction::FocusChanged | PointerDownAction::DomListenerInvoked
)
}
#[inline]
pub fn needs_redraw(self) -> bool {
self != PointerDownAction::Ignored
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PointerMoveAction {
Ignored,
SelectionDragged,
DomListenerInvoked,
}
impl PointerMoveAction {
#[inline]
pub fn is_handled(self) -> bool {
self != PointerMoveAction::Ignored
}
#[inline]
pub fn needs_rebuild(self) -> bool {
self == PointerMoveAction::DomListenerInvoked
}
#[inline]
pub fn needs_redraw(self) -> bool {
self != PointerMoveAction::Ignored
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PointerUpAction {
Ignored,
SelectionEnded,
DomListenerInvoked,
}
impl PointerUpAction {
#[inline]
pub fn is_handled(self) -> bool {
self != PointerUpAction::Ignored
}
#[inline]
pub fn needs_rebuild(self) -> bool {
self == PointerUpAction::DomListenerInvoked
}
#[inline]
pub fn needs_redraw(self) -> bool {
self != PointerUpAction::Ignored
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum KeyDispatchResult {
Ignored,
RedrawOnly,
NeedsRebuild,
}
impl KeyDispatchResult {
#[inline]
pub fn is_handled(self) -> bool {
self != KeyDispatchResult::Ignored
}
#[inline]
pub fn needs_rebuild(self) -> bool {
self == KeyDispatchResult::NeedsRebuild
}
#[inline]
pub fn needs_redraw(self) -> bool {
self != KeyDispatchResult::Ignored
}
}
#[derive(Clone)]
pub struct DynamicTextBinding {
pub path: Vec<usize>,
pub closure: std::rc::Rc<dyn Fn() -> String>,
pub last_value: String,
}
impl std::fmt::Debug for DynamicTextBinding {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("DynamicTextBinding")
.field("path", &self.path)
.field("last_value", &self.last_value)
.finish()
}
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct InteractionContext<'a> {
pub hovered_path: Option<&'a [usize]>,
pub focused_path: Option<&'a [usize]>,
pub is_mouse_down: bool,
pub is_dark_mode: bool,
}
#[derive(Debug, Clone)]
pub(crate) struct CascadeElementMeta {
pub tag: &'static str,
pub classes: Vec<String>,
pub id: Option<String>,
pub attributes: Vec<(String, String)>,
pub pseudo_state: strata_style::selector::PseudoState,
}
#[derive(Debug, Clone)]
pub struct ActiveDomDrag {
pub source_path: Vec<usize>,
pub start_pos: (f32, f32),
pub started: bool,
pub last_over_path: Option<Vec<usize>>,
pub data_transfer: std::rc::Rc<std::cell::RefCell<std::collections::HashMap<String, String>>>,
}