Crate presentar_core

Crate presentar_core 

Source
Expand description

Core types and traits for Presentar UI framework.

This crate provides foundational types used throughout Presentar:

§Quick Start

use presentar_core::{Color, Size, Constraints, Rect};

// Create a size
let size = Size::new(100.0, 50.0);

// Create constraints
let constraints = Constraints::new(0.0, 200.0, 0.0, 100.0);
let bounded = constraints.constrain(size);

// Create a color
let red = Color::RED;
assert_eq!(red.r, 1.0);

§Widget Trait

The core Widget trait defines the measure-layout-paint cycle:

use presentar_core::{Widget, Constraints, Size, Canvas};

struct MyWidget;

impl Widget for MyWidget {
    fn measure(&self, constraints: &Constraints) -> Size {
        constraints.constrain(Size::new(100.0, 50.0))
    }

    fn layout(&mut self, size: Size) { }

    fn paint(&self, canvas: &mut dyn Canvas) { }
}

Re-exports§

pub use accessibility::AccessibilityTree;
pub use accessibility::AccessibilityTreeBuilder;
pub use accessibility::AccessibleNode;
pub use accessibility::AccessibleNodeId;
pub use accessibility::CheckedState;
pub use accessibility::HitTester;
pub use accessibility::LiveRegion;
pub use animation::AnimColor;
pub use animation::AnimatedValue;
pub use animation::AnimationController;
pub use animation::EasedValue;
pub use animation::Easing;
pub use animation::Interpolate;
pub use animation::Keyframe;
pub use animation::KeyframeTrack;
pub use animation::Spring;
pub use animation::SpringConfig;
pub use cache::CacheBuilder;
pub use cache::CacheCallback;
pub use cache::CacheConfig;
pub use cache::CacheEvent;
pub use cache::CacheKey;
pub use cache::CacheMetadata;
pub use cache::CacheOptions;
pub use cache::CacheSize;
pub use cache::CacheState;
pub use cache::CacheStats;
pub use cache::DataCache;
pub use cache::StringCache;
pub use chart::ArcGeometry;
pub use chart::CatmullRom;
pub use chart::CubicBezier;
pub use chart::CubicSpline;
pub use chart::DataNormalizer;
pub use chart::DrawBatch;
pub use chart::HistogramBins;
pub use chart::Interpolator;
pub use chart::LinearInterpolator;
pub use chart::PathTessellator;
pub use chart::Point2D;
pub use clipboard::Clipboard;
pub use clipboard::ClipboardData;
pub use clipboard::ClipboardEvent;
pub use clipboard::ClipboardFormat;
pub use clipboard::ClipboardHistory;
pub use clipboard::ClipboardOperation;
pub use clipboard::ClipboardResult;
pub use diff::diff_trees;
pub use diff::DiffNode;
pub use diff::DiffOp;
pub use diff::DiffResult;
pub use diff::TreeDiffer;
pub use diff::WidgetKey;
pub use dnd::DragData;
pub use dnd::DragDataType;
pub use dnd::DragDropManager;
pub use dnd::DragId;
pub use dnd::DragPayload;
pub use dnd::DragPhase;
pub use dnd::DragState;
pub use dnd::DropEffect;
pub use dnd::DropResult;
pub use dnd::DropTarget;
pub use draw::BoxStyle;
pub use draw::DrawCommand;
pub use draw::FillRule;
pub use draw::LineCap;
pub use draw::LineJoin;
pub use draw::PathRef;
pub use draw::Sampling;
pub use draw::Shadow;
pub use draw::StrokeStyle;
pub use draw::TensorRef;
pub use draw::Transform2D as DrawTransform;
pub use gesture::GestureConfig;
pub use gesture::GestureRecognizer;
pub use gesture::PointerGestureRecognizer;
pub use gesture::PointerInfo;
pub use gesture::RecognizedGesture;
pub use gesture::TouchPoint;
pub use history::Checkpoint;
pub use history::CheckpointId;
pub use history::Command as HistoryCommand;
pub use history::CommandHistory;
pub use history::CommandId;
pub use history::CommandResult;
pub use history::CompositeCommand;
pub use history::GroupId;
pub use history::HistoryCallback;
pub use history::HistoryConfig;
pub use history::HistoryEvent;
pub use history::SetValueCommand;
pub use lifecycle::Effect;
pub use lifecycle::EffectManager;
pub use lifecycle::HookId;
pub use lifecycle::LifecycleEvent;
pub use lifecycle::LifecycleManager;
pub use lifecycle::LifecyclePhase;
pub use shortcut::Modifiers;
pub use shortcut::Shortcut;
pub use shortcut::ShortcutBuilder;
pub use shortcut::ShortcutContext;
pub use shortcut::ShortcutId;
pub use shortcut::ShortcutManager;
pub use shortcut::ShortcutPriority;
pub use streaming::ConnectionState;
pub use streaming::DataStream;
pub use streaming::MessageBuffer;
pub use streaming::RateLimiter;
pub use streaming::ReconnectConfig;
pub use streaming::StreamConfig;
pub use streaming::StreamMessage;
pub use streaming::StreamSubscription;
pub use theme::ColorPalette;
pub use theme::ContrastCheck;
pub use theme::Radii;
pub use theme::Shadows;
pub use theme::Spacing;
pub use theme::Theme;
pub use theme::Typography;
pub use validation::FieldConfig;
pub use validation::FieldState;
pub use validation::FormValidator;
pub use validation::MaxLength;
pub use validation::MinLength;
pub use validation::Pattern;
pub use validation::PatternType;
pub use validation::Range;
pub use validation::Required;
pub use validation::ValidateOn;
pub use validation::ValidationResult;
pub use validation::Validator;
pub use virtualization::CellLayout;
pub use virtualization::GridCell;
pub use virtualization::ItemIndex;
pub use virtualization::ItemLayout;
pub use virtualization::ScrollAlign;
pub use virtualization::VirtualGrid;
pub use virtualization::VirtualGridConfig;
pub use virtualization::VirtualList;
pub use virtualization::VirtualListConfig;
pub use virtualization::VisibleGridRange;
pub use virtualization::VisibleRange;
pub use widget::AccessibleRole;
pub use widget::Canvas;
pub use widget::FontStyle;
pub use widget::FontWeight;
pub use widget::LayoutResult;
pub use widget::TextStyle;
pub use widget::Transform2D;
pub use widget::TypeId;
pub use widget::Widget;
pub use widget::WidgetId;
pub use brick_widget::BrickWidgetExt;
pub use brick_widget::DefaultBrick;
pub use brick_widget::SimpleBrick;

Modules§

accessibility
Accessibility support for screen readers and assistive technology.
animation
Animation system with spring physics, easing, and keyframe support.
binding
Interactive state binding for reactive UI.
brick_widget
Brick-based Widget helpers (PROBAR-SPEC-009)
cache
chart
Chart rendering algorithms for Presentar.
clipboard
Clipboard API for copy, cut, and paste operations.
diff
Widget tree diffing for efficient UI updates.
dnd
Drag and drop system for interactive data transfer.
draw
Draw commands for GPU rendering.
gesture
Gesture recognition from touch/pointer events.
history
lifecycle
Widget lifecycle hooks for mount, update, and unmount callbacks.
shortcut
Keyboard shortcut management system.
simd
SIMD-accelerated operations using Trueno.
streaming
Data streaming and live updates for Presentar.
theme
Theme system for consistent styling.
validation
Declarative validation system for forms and inputs.
virtualization
widget
Widget trait and related types.

Structs§

AnimatedProperty
An animated property that smoothly transitions between values.
AnimationInstance
An animation instance that can be managed by an Animator.
Animator
Manages multiple animations.
BrickBudget
Performance budget for a brick.
BrickVerification
Result of verifying brick assertions
BudgetViolation
Budget violation report
Color
RGBA color with values in the range [0.0, 1.0].
CommandExecutor
Command executor for synchronous commands.
Constraints
Layout constraints that specify minimum and maximum sizes.
CornerRadius
Corner radii for rounded rectangles.
CounterState
A simple counter state for testing.
DataRefreshManager
Manages periodic data refresh for data sources.
ExecutorConfig
Command executor configuration.
FocusManager
Manages keyboard focus for widgets.
FocusTrap
A focus trap that restricts focus to a subset of widgets.
FrameTimer
Frame timer for 60fps animations.
MemoryRouter
In-memory router for testing.
MemoryStorage
In-memory storage for testing.
Point
A 2D point with x and y coordinates.
PointerId
Pointer identifier for pointer events.
RecordingCanvas
A Canvas implementation that records draw operations as DrawCommands.
Rect
A rectangle defined by position and size.
RefreshTask
A scheduled data refresh task.
Size
A 2D size with width and height.
SpringAnimation
Spring-based animation for physics-like motion.
Store
Store manages state lifecycle with subscriptions and time-travel debugging.
Timer
A timer that fires at regular intervals.
TouchId
Touch identifier for multi-touch tracking.
TransitionConfig
Configuration for property transitions.
Tween
A tween that interpolates between two values over time.

Enums§

AnimationState
Animation state for tracking animation lifecycle.
BrickAssertion
Brick assertion that must be verified at runtime.
BrickError
Yuan Gate: Zero-swallow error handling for bricks
BrickPhase
Rendering phase for budget tracking
ColorParseError
Error type for color parsing.
Command
Commands for side effects.
CounterMessage
Messages for the counter state.
EasingFunction
Easing functions for smooth animations.
Event
Input event types.
ExecutionResult
Result of command execution.
FocusDirection
Focus direction for keyboard navigation.
GestureState
State of a gesture.
Key
Keyboard key identifiers.
MouseButton
Mouse button identifiers.
PointerType
Type of pointer device.

Traits§

Brick
Core Brick trait - the foundation of the Brick Architecture.
Router
Router trait for navigation commands.
State
Application state trait.
Storage
Storage trait for state persistence commands.

Functions§

default_executor
Create a default executor with memory-based backends.

Type Aliases§

AnimationId
Unique identifier for an animation.
BrickResult
Result type for brick operations