Expand description
Core systems for Horizon Lattice.
This crate provides the foundational components of the Horizon Lattice GUI framework:
- Event Loop: The main application event loop built on winit
- Application: Global application state and lifecycle management
- Object Model: Parent-child ownership, naming, dynamic properties
- Signal/Slot System: Type-safe inter-object communication
- Property System: Reactive properties with change notification
- Timers: One-shot and repeating timer system
- Task Queue: Deferred/idle task processing
- Scheduler: Background work scheduling with one-shot and periodic tasks
§Signal/Slot Example
use horizon_lattice_core::{Signal, Property};
// Create a signal that notifies when a value changes
let value_changed = Signal::<i32>::new();
// Connect a slot to handle the signal
let conn_id = value_changed.connect(|value| {
println!("Value changed to: {}", value);
});
// Emit the signal
value_changed.emit(42);
// Disconnect when done
value_changed.disconnect(conn_id);§Property Example
use horizon_lattice_core::{Property, Signal};
// A reactive counter with change notification
struct Counter {
value: Property<i32>,
value_changed: Signal<i32>,
}
impl Counter {
fn new() -> Self {
Self {
value: Property::new(0),
value_changed: Signal::new(),
}
}
fn increment(&self) {
let new_value = self.value.get() + 1;
if self.value.set(new_value) {
self.value_changed.emit(new_value);
}
}
}§Event Loop Example
use horizon_lattice_core::{Application, LatticeEvent};
use std::time::Duration;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = Application::new()?;
// Set up an event handler
app.set_event_handler(|event| {
match event {
LatticeEvent::Timer { id } => {
println!("Timer {:?} fired!", id);
}
_ => {}
}
});
// Start a repeating timer
let _timer_id = app.start_repeating_timer(Duration::from_secs(1));
// Post a deferred task
app.post_task(|| {
println!("Idle task executed!");
});
// Run the event loop (blocks until quit)
Ok(app.run()?)
}Re-exports§
pub use logging::ObjectTreeDebug;pub use logging::PerfSpan;pub use logging::TreeFormatOptions;pub use logging::TreeStyle;pub use meta::MetaError;pub use meta::MetaObject;pub use meta::MetaProperty;pub use meta::MetaResult;pub use meta::MethodMeta;pub use meta::SignalMeta;pub use meta::TypeRegistry;pub use meta::init_type_registry;pub use object::Object;pub use object::ObjectBase;pub use object::ObjectError;pub use object::ObjectId;pub use object::ObjectRegistry;pub use object::ObjectResult;pub use object::WidgetState;pub use object::global_registry;pub use object::init_global_registry;pub use object::object_cast;pub use object::object_cast_mut;pub use progress::AggregateProgress;pub use progress::ProgressReporter;pub use progress::ProgressUpdate;pub use property::Binding;pub use property::IntoProperty;pub use property::Property;pub use property::PropertyError;pub use property::PropertyMeta;pub use property::ReadOnlyProperty;pub use signal::ConnectionGuard;pub use signal::ConnectionId;pub use signal::ConnectionType;pub use signal::Signal;pub use signal::SignalEmitter;pub use thread_check::ThreadAffinity;pub use thread_check::are_thread_checks_enabled;pub use thread_check::is_main_thread;pub use thread_check::main_thread_id;pub use thread_check::set_thread_checks_enabled;pub use worker::Worker;pub use worker::WorkerBuilder;pub use worker::WorkerConfig;
Modules§
- invocation
- Queued invocation registry for cross-thread signal delivery.
- logging
- Logging and debugging facilities for Horizon Lattice.
- meta
- Meta-object system for Horizon Lattice.
- object
- Object model for Horizon Lattice.
- progress
- Progress reporting for background tasks.
- property
- Property system for Horizon Lattice.
- signal
- Signal/slot system for Horizon Lattice.
- thread_
check - Thread safety verification utilities for Horizon Lattice.
- threadpool
- Thread pool for background task execution.
- worker
- Worker pattern for dedicated background thread processing.
Macros§
- assert_
main_ thread - Panics if the current thread is not the main thread.
- debug_
assert_ main_ thread - Debug-only assertion that panics if not on the main thread.
- lattice_
debug - Log a debug-level message to the Horizon Lattice target.
- lattice_
error - Log an error-level message to the Horizon Lattice target.
- lattice_
info - Log an info-level message to the Horizon Lattice target.
- lattice_
trace - Macros for common tracing patterns.
- lattice_
warn - Log a warning-level message to the Horizon Lattice target.
Structs§
- Active
Event Loop - Target that associates windows with an
EventLoop. - Application
- The main application event loop and coordinator.
- Modifiers
- Describes keyboard modifiers event.
- Scheduled
Task Id - A unique identifier for a scheduled task.
- TaskId
- A unique identifier for a deferred task.
- TimerId
- A unique identifier for a timer.
- Window
- Represents a window.
- Window
Attributes - Attributes used when creating a window.
- Window
Id - Identifier of a window. Unique for each window.
Enums§
- Event
Priority - Priority levels for internal events. Higher priority events are processed first within the same event loop iteration.
- Lattice
Error - The main error type for Horizon Lattice operations.
- Lattice
Event - Internal events dispatched through the Horizon Lattice event loop.
- Scheduled
Task Kind - The type of scheduled task.
- Scheduler
Error - Scheduler-specific errors.
- Signal
Error - Signal-specific errors.
- Thread
Error - Thread safety-specific errors.
- Thread
Pool Error - Thread pool-specific errors.
- Timer
Error - Timer-specific errors.
Type Aliases§
- Result
- A specialized Result type for Horizon Lattice operations.
- Window
Event Handler - The main application struct, managing the event loop and global state.