blinc_layout 0.5.1

Blinc layout engine - Flexbox layout powered by Taffy
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
#![allow(unused, dead_code, deprecated, mismatched_lifetime_syntaxes)]
//! Blinc Layout Engine
//!
//! Flexbox layout powered by Taffy with GPUI-style builder API.
//!
//! # Example
//!
//! ```rust
//! use blinc_layout::prelude::*;
//!
//! let ui = div()
//!     .flex_col()
//!     .w(400.0)
//!     .h(300.0)
//!     .gap(4.0)
//!     .p(4.0)
//!     .child(
//!         div()
//!             .flex_row()
//!             .justify_between()
//!             .child(text("Title").size(24.0))
//!             .child(div().square(32.0).rounded(8.0))
//!     )
//!     .child(
//!         div().flex_grow()
//!     );
//!
//! let mut tree = RenderTree::from_element(&ui);
//! tree.compute_layout(800.0, 600.0);
//! ```

pub mod animated;
pub mod canvas;
pub mod diff;
pub mod div;
pub mod element;
pub mod notch;

// Layout animation systems
pub mod element_style;
pub mod event_handler;
pub mod event_router;
pub mod image;
pub mod interactive;
pub mod layout_animation;
pub mod motion;
pub mod render_state;
pub mod renderer;
pub mod rich_text;
pub mod scroll;
pub mod stack;
pub mod stateful;
pub mod style;
pub mod styled_text;
pub mod svg;
pub mod syntax;
pub mod text;
pub mod text_measure;
pub mod text_selection;
pub mod tree;
pub mod typography;
pub mod units;
pub mod visual_animation;
pub mod widgets;

// Markdown rendering
pub mod markdown;

// Selector API for programmatic element access
pub mod selector;

// Global overlay state singleton
pub mod overlay_state;

// Continuous pointer query system
pub mod pointer_query;

// Click-outside detection for dropdown dismissal
pub mod click_outside;

// Recorder bridge for event capture (blinc_recorder integration)
#[cfg(feature = "recorder")]
pub mod recorder_bridge;

// CSS calc() expression engine
pub mod calc;

// CSS subset parser for ElementStyle
pub mod css_parser;

// Stable unique key generation for components
pub mod back_handler;
pub mod key;
pub mod window_actions;

// Re-export InstanceKey and reset function at crate root
pub use key::{reset_call_counters, InstanceKey};

// Core types
pub use element::{
    BorderBuilder, BorderSide, BorderSides, CursorStyle, DynRenderProps, ElementBounds, FlowRef,
    MotionAnimation, MotionKeyframe, RenderLayer, RenderProps, ResolvedRenderProps,
};

// Diff and reconciliation
pub use diff::{
    diff, diff_children, diff_elements, reconcile, ChangeCategory, ChildDiff, DiffResult, DivHash,
    ReconcileActions,
};
pub use event_handler::{EventCallback, EventContext, EventHandlers, HandlerRegistry};
pub use event_router::{EventRouter, HitTestResult, MouseButton};
pub use interactive::{DirtyTracker, InteractiveContext, NodeState};
pub use style::LayoutStyle;
pub use tree::{LayoutNodeId, LayoutTree, TextMeasureContext};

// Material system
pub use element::{
    GlassMaterial, Material, MaterialShadow, MetallicMaterial, SolidMaterial, WoodMaterial,
};

// Builder API
pub use div::{
    div, Div, ElementBuilder, ElementTypeId, FontFamily, FontWeight, GenericFont, ImageRenderInfo,
    StyledTextRenderInfo, StyledTextSpanInfo, TextAlign, TextVerticalAlign,
};
// Stack container (overlayed children)
pub use stack::{stack, Stack};
// Reference binding
pub use div::{DivRef, ElementRef};
pub use image::{
    emoji, emoji_sized, image, img, Image, ImageFilter, LoadingStrategy, ObjectFit, ObjectPosition,
    Placeholder,
};
pub use rich_text::{rich_text, rich_text_styled, RichText};
pub use svg::{svg, Svg};
pub use text::{text, Text};

// Renderer
pub use renderer::{
    GlassPanel, ImageData, LayoutRenderer, OnReadyCallback, OnReadyEntry, RenderTree,
    RenderTreeDebugStats, StyledTextData, StyledTextSpan, SvgData, TextData, UpdateResult,
};

// Canvas element
pub use canvas::{canvas, Canvas, CanvasBounds, CanvasData, CanvasRenderFn};

// Render state (dynamic properties separate from tree structure)
pub use render_state::{
    create_shared_motion_states, get_global_scheduler, has_global_scheduler,
    queue_global_motion_exit_cancel, queue_global_motion_exit_start, queue_global_motion_start,
    set_global_scheduler, ActiveMotion, CssAnimationStore, MotionState, NodeRenderState, Overlay,
    RenderState, SharedMotionStates,
};

// Stateful elements
pub use stateful::{
    check_stateful_animations, check_stateful_deps, clear_stateful_animations,
    clear_stateful_base_updaters, clear_stateful_deps, has_animating_statefuls,
    has_pending_subtree_rebuilds, has_stateful_base_updater, peek_needs_redraw, queue_prop_update,
    queue_subtree_rebuild, request_redraw, take_needs_redraw, take_pending_prop_updates,
    take_pending_subtree_rebuilds, update_stateful_base_props, use_shared_state,
    use_shared_state_with, PendingSubtreeRebuild, SharedState, StateTransitions, StatefulInner,
};

// Animation integration
pub use animated::{AnimatedProperties, AnimationBuilder};

// Layout animation (FLIP-style bounds animation)
pub use layout_animation::{LayoutAnimation, LayoutAnimationConfig, LayoutAnimationState};

// CSS-like units
pub use units::{pct, px, sp, Length, Unit};

// Motion container for entry/exit animations
pub use motion::{
    check_and_clear_exiting, check_ready_for_enter, current_motion_key, is_inside_animating_motion,
    is_inside_motion, motion, motion_derived, motion_events, motion_presence_store,
    query_presence_state, start_exit_for_key, update_presence_state, ElementAnimation,
    ExitingChild, Motion, MotionBindings, MotionPresenceState, MotionPresenceStore,
    SharedAnimatedValue, SlideDirection, StaggerConfig, StaggerDirection,
};

// Text measurement
pub use text_measure::{
    measure_text, measure_text_with_options, set_text_measurer, TextLayoutOptions, TextMeasurer,
    TextMetrics,
};

// Text selection (clipboard support)
pub use text_selection::{
    clear_selection, get_selected_text, global_selection, set_selection, SelectionSource,
    SharedTextSelection, TextSelection,
};

/// Prelude module - import everything commonly needed
pub mod prelude {
    pub use crate::div::{
        div, Div, ElementBuilder, ElementTypeId, FontFamily, FontWeight, GenericFont,
        ImageRenderInfo, TextAlign, TextVerticalAlign,
    };
    // Stack container (overlayed children)
    pub use crate::stack::{stack, Stack};
    // Reference binding for external element access
    pub use crate::div::{DivRef, ElementRef};
    pub use crate::element::{
        CursorStyle, DynRenderProps, ElementBounds, RenderLayer, RenderProps, ResolvedRenderProps,
    };
    // Event handlers
    pub use crate::event_handler::{EventCallback, EventContext, EventHandlers, HandlerRegistry};
    // Event routing
    pub use crate::event_router::{EventRouter, HitTestResult, MouseButton};
    // Image element
    pub use crate::image::{
        emoji, emoji_sized, image, img, Image, ImageFilter, LoadingStrategy, ObjectFit,
        ObjectPosition, Placeholder,
    };
    // Interactive state management
    pub use crate::interactive::{DirtyTracker, InteractiveContext, NodeState};
    // Unified element styling
    pub use crate::element_style::{
        style, ElementStyle, SpacingRect, StyleAlign, StyleDisplay, StyleFlexDirection,
        StyleJustify, StyleOverflow, StyleVisibility,
    };
    // Diff and reconciliation
    pub use crate::diff::{
        diff, diff_children, diff_elements, reconcile, ChangeCategory, ChildDiff, DiffResult,
        DivHash, ReconcileActions,
    };
    // Stateful elements with user-defined state types (core infrastructure)
    pub use crate::stateful::{
        // Internal scroll events for FSM transitions
        scroll_events,
        // New StateContext API (recommended)
        stateful,
        stateful_button,
        stateful_checkbox,
        // Low-level constructor functions for custom styling (legacy)
        stateful_from_handle,
        stateful_with_key,
        text_field,
        toggle,
        // Utility functions for persistent shared state
        use_shared_state,
        use_shared_state_with,
        // Core generic type
        BoundStateful,
        // Type aliases for Stateful<S> - low-level for custom styling
        Button as StatefulButton,
        // Built-in state types (Copy-based for Stateful<S>)
        ButtonState,
        Checkbox as StatefulCheckbox,
        CheckboxState as StatefulCheckboxState,
        ChildKeyCounter,
        KeyframeHandle,
        // No-op state for dependency-based refreshing
        NoState,
        ScrollContainer,
        ScrollState,
        SharedAnimatedTimeline,
        SharedAnimatedValue,
        SharedKeyframeTrack,
        SharedState,
        StateContext,
        StateTransitions,
        Stateful,
        StatefulBuilder,
        StatefulInner,
        TextField,
        TextFieldState,
        Toggle,
        ToggleState,
    };

    // Ready-to-use widgets (production-ready, work in fluent API without .build())
    pub use crate::widgets::{
        // Button widget - ready-to-use
        button,
        // Checkbox widget - ready-to-use
        checkbox,
        checkbox_labeled,
        // Cursor blink timing (for use by app layer)
        elapsed_ms,
        has_focused_text_input,
        // Radio group widget - ready-to-use
        radio_group,
        // Text area widget - ready-to-use
        text_area,
        text_area_state,
        text_area_state_with_placeholder,
        // Text input widget - ready-to-use
        text_input,
        text_input_state,
        text_input_state_with_placeholder,
        Button,
        ButtonConfig,
        ButtonVisualState,
        Checkbox,
        CheckboxConfig,
        InputConstraints,
        InputType,
        RadioGroup,
        RadioGroupBuilder,
        RadioGroupConfig,
        RadioLayout,
        SharedTextAreaState,
        SharedTextInputState,
        TextArea,
        TextAreaConfig,
        TextAreaState,
        TextInput,
        TextInputConfig,
        TextInputState,
        TextPosition,
        CURSOR_BLINK_INTERVAL_MS,
    };
    // Material system
    pub use crate::element::{
        GlassMaterial, Material, MaterialShadow, MetallicMaterial, SolidMaterial, WoodMaterial,
    };
    #[allow(deprecated)]
    pub use crate::renderer::{
        GlassPanel, ImageData, LayoutRenderer, OnReadyCallback, RenderTree, SvgData, TextData,
        UpdateResult,
    };
    // Scroll container (ready-to-use widget with Div extension)
    pub use crate::rich_text::{rich_text, rich_text_styled, RichText};
    pub use crate::svg::{svg, Svg};
    pub use crate::text::{text, Text};
    pub use crate::tree::{LayoutNodeId, LayoutTree};
    pub use crate::widgets::{
        scroll, scroll_no_bounce, Scroll, ScrollConfig, ScrollDirection, ScrollPhysics,
        ScrollRenderInfo, SharedScrollPhysics,
    };

    // Code block widget with syntax highlighting
    pub use crate::widgets::{
        code, code_editor, code_editor_state, code_minimap, pre, Code, CodeConfig, CodeEditor,
        CodeEditorData, SharedCodeEditorState,
    };

    // CSS-like units for layout dimensions
    pub use crate::units::{pct, px, sp, Length, Unit};

    // Syntax highlighting
    pub use crate::syntax::{
        JsonHighlighter, PlainHighlighter, RustHighlighter, SyntaxConfig, SyntaxHighlighter,
        TokenHit, TokenRule, TokenType,
    };

    // Canvas element
    pub use crate::canvas::{canvas, Canvas, CanvasBounds};

    // Notch element (shapes with concave curves or sharp steps)
    pub use crate::notch::{notch, CornerConfig, CornerStyle, CornersConfig, Notch};

    // Re-export Shadow, Transform, and layer effect types from blinc_core for convenience
    pub use blinc_core::{BlurQuality, BlurStyle, LayerEffect, Shadow, Transform};

    // Animation integration
    pub use crate::animated::{AnimatedProperties, AnimationBuilder};

    // Layout animation (FLIP-style bounds animation)
    pub use crate::layout_animation::{LayoutAnimation, LayoutAnimationConfig};

    // Re-export animation types from blinc_animation for convenience
    pub use blinc_animation::{
        AnimatedKeyframe, AnimatedTimeline, AnimatedValue, AnimationPreset, Easing,
        KeyframeProperties, MultiKeyframeAnimation, SchedulerHandle, SpringConfig,
    };

    // Motion container for entry/exit animations
    pub use crate::motion::{
        current_motion_key, is_inside_animating_motion, is_inside_motion, motion, motion_derived,
        ElementAnimation, Motion, MotionBindings, SlideDirection, StaggerConfig, StaggerDirection,
    };

    // Text selection for clipboard support
    pub use crate::text_selection::{
        clear_selection, get_selected_text, global_selection, set_selection, SelectionSource,
        SharedTextSelection, TextSelection,
    };

    // Render state (dynamic properties separate from tree structure)
    pub use crate::render_state::{
        ActiveMotion, MotionState, NodeRenderState, Overlay, RenderState,
    };

    // Dynamic value system for render-time resolution
    pub use blinc_core::{AnimationAccess, DynFloat, DynValue, ReactiveAccess, ValueContext};

    // Typography helpers (h1-h6, b, span, etc.)
    pub use crate::typography::{
        b, caption, chained_text, h1, h2, h3, h4, h5, h6, heading, inline_code, label, muted, p,
        small, span, strong,
    };

    // Table elements
    pub use crate::widgets::{
        cell, striped_tr, table, tbody, td, td_text, tfoot, th, th_text, thead, tr, TableBuilder,
        TableCell,
    };

    // Overlay system (modals, dialogs, context menus, toasts)
    pub use crate::widgets::{
        overlay_events, overlay_manager, BackdropConfig, ContextMenuBuilder, Corner, DialogBuilder,
        DropdownBuilder, ModalBuilder, OverlayAnimation, OverlayConfig, OverlayHandle, OverlayKind,
        OverlayManager, OverlayManagerExt, OverlayPosition, OverlayState, ToastBuilder,
    };

    // Markdown rendering
    pub use crate::markdown::{
        markdown, markdown_light, markdown_with_config, MarkdownConfig, MarkdownRenderer,
    };

    // Additional markdown widgets
    pub use crate::widgets::{
        blockquote, blockquote_with_config, hr, hr_color, hr_thick, hr_with_bg, hr_with_config, li,
        link, ol, ol_start, task_item, ul, Blockquote, BlockquoteConfig, HrConfig, Link,
        LinkConfig, ListConfig, ListItem, ListMarker, OrderedList, TaskListItem, UnorderedList,
    };

    // Selector API for programmatic element access
    pub use crate::selector::{
        query, query_motion, ElementEvent, ElementHandle, ElementRegistry, MotionHandle,
        ScrollBehavior, ScrollBlock, ScrollInline, ScrollOptions, ScrollRef, SharedElementRegistry,
    };

    // Overlay context singleton
    pub use crate::overlay_state::{get_overlay_manager, OverlayContext};

    // CSS parser for loading stylesheets
    pub use crate::css_parser::{
        AnimationDirection, AnimationFillMode, AnimationTiming, Combinator, ComplexSelector,
        CompoundSelector, CssAnimation, CssKeyframe, CssKeyframes, CssParseResult, CssSelector,
        ElementState as CssElementState, ParseError as CssParseError, SelectorPart,
        Severity as CssSeverity, StructuralPseudo, Stylesheet,
    };

    // Flow DAG types (re-exported from blinc_core)
    pub use blinc_core::{
        FlowError, FlowExpr, FlowFunc, FlowGraph, FlowInput, FlowInputSource, FlowNode, FlowOutput,
        FlowOutputTarget, FlowTarget, FlowType,
    };

    // Stable unique key generation for components
    pub use crate::key::{reset_call_counters, InstanceKey};
}