docs.rs failed to build hyperchad_renderer_egui-0.3.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
hyperchad_renderer_egui-0.1.0
HyperChad Egui Renderer
Native desktop UI renderer for HyperChad using the egui immediate mode GUI framework.
Overview
The HyperChad Egui Renderer provides:
- Native Desktop UI: Render HyperChad components as native desktop applications
- Immediate Mode GUI: Built on egui's immediate mode architecture
- Hardware Acceleration: Optional WGPU backend for GPU-accelerated rendering
- Cross-platform: Works on Windows, macOS, and Linux
- Layout Engine: Complete CSS-like layout system with flexbox support
- Interactive Elements: Full support for forms, buttons, and user interactions
- Image Loading: Async image loading with caching
- Viewport Management: Scrolling and viewport-aware rendering
- Event System: Complete action and event handling
Features
Rendering Capabilities
- Container Rendering: Full HyperChad container hierarchy support
- Element Types: All HTML-equivalent elements (div, span, input, button, image, etc.)
- Layout Systems: Flexbox, positioning, margins, padding, borders
- Typography: Font sizing, text alignment, headings (H1-H6)
- Styling: Colors, backgrounds, borders, opacity, visibility
- Responsive Design: Conditional styling and responsive breakpoints
Interactive Features
- Form Elements: Text inputs, checkboxes, buttons with validation
- Event Handling: Click, hover, focus, resize, and custom events
- Action System: Comprehensive action framework with effects
- State Management: Component state and data binding
- Navigation: Route handling and page navigation
- Canvas Support: Canvas rendering for graphics (available in v1 renderer)
Performance Features
- Efficient Rendering: Immediate mode rendering with minimal overhead
- Layout Caching: Cached layout calculations for performance
- Image Caching: Smart image loading and caching system
- Viewport Culling: Only render visible elements
- Profiling Support: Optional profiling with puffin and tracing
Installation
Add this to your Cargo.toml:
[]
= { = "../hyperchad/renderer/egui" }
# Or with GPU acceleration
# hyperchad_renderer_egui = { path = "../hyperchad/renderer/egui", features = ["wgpu"] }
# Or with profiling
# hyperchad_renderer_egui = { path = "../hyperchad/renderer/egui", features = ["profiling", "profiling-puffin"] }
Usage
Basic Desktop Application
use EguiRenderer;
use ;
use Router;
use Value;
use unbounded;
use Arc;
// You need to implement a custom calculator that implements both
// hyperchad_transformer::layout::Calc and hyperchad_renderer_egui::layout::EguiCalc
// See packages/hyperchad/app/src/renderer.rs for a complete example
;
Navigation Events
EguiRenderer also exposes wait_for_navigation() for handling link navigation
events generated by rendered anchors:
use Handle;
let renderer = renderer.clone;
current.spawn;
Rendering HyperChad Components
use container;
use ;
// Create HyperChad components
let view = container! ;
// Render the view
renderer.render.await?;
Form Handling
use container;
let form_view = container! ;
renderer.render.await?;
Image Display
use container;
let image_view = container! ;
renderer.render.await?;
Custom Layout Calculator
For a complete working example of implementing a custom layout calculator with font metrics
and default sizing, see packages/hyperchad/app/src/renderer.rs which demonstrates:
- Creating a calculator that implements both
CalcandEguiCalctraits - Using
CalculatorwithCalculatorDefaultsfor font sizes and margins - Integrating
EguiFontMetricsfor accurate text measurement - Setting up H1-H6 heading sizes and margins
The calculator is initialized with the egui context via the with_context method
when the renderer starts.
Event Handling
use ;
use Handle;
// Handle action events
current.spawn;
// Handle resize events
current.spawn;
Canvas Rendering
Note: Canvas rendering is implemented in the v1 renderer only. The v2 renderer has canvas rendering stubbed but not yet implemented.
use ;
use Color;
let canvas_update = CanvasUpdate ;
renderer.render_canvas.await?;
Feature Flags
wgpu: Enable WGPU backend for GPU acceleration (enabled by default)glow: Enable OpenGL backendwayland: Enable Wayland support on Linuxx11: Enable X11 support on Linuxprofiling: Enable performance profiling supportprofiling-puffin: Enable puffin profiler integrationprofiling-tracing: Enable tracing profiler integrationprofiling-tracy: Enable Tracy profiler integrationdebug: Enable debug rendering features (enabled by default)v1: Use v1 renderer implementation (enabled by default) - Full-featured renderer with complete canvas support, comprehensive action handling, and mature viewport management. This is the production-ready implementation (~3800 lines).v2: Use v2 renderer implementation (enabled by default) - Refactored renderer with modular action handling using the newActionHandlerAPI fromhyperchad_actions. This version uses simplified, more maintainable code architecture (~1000 lines). Canvas rendering and some advanced features are stubbed but not yet fully implemented. When both features are enabled, v2 takes precedence.
Performance Considerations
- Immediate Mode: UI is rebuilt every frame for maximum flexibility
- Layout Caching: Layout calculations are cached when possible
- Image Caching: Images are cached to avoid repeated loading
- Viewport Culling: Only visible elements are processed
- GPU Acceleration: Use WGPU backend for better performance
Dependencies
- eframe: egui application framework
- egui: Immediate mode GUI library
- HyperChad Core: Template, transformer, and action systems
- switchy_async: Runtime abstraction for async operations
- Image: Image processing and loading
Integration
This renderer is designed for:
- Desktop Applications: Native desktop apps with rich UI
- Development Tools: IDE-like applications and editors
- Games: Game UI and tools with immediate mode benefits
- Prototyping: Rapid UI prototyping and development
- Cross-platform Apps: Applications targeting multiple desktop platforms
Limitations
- Mobile Support: Not designed for mobile platforms
- Web Deployment: Cannot run in web browsers
- Immediate Mode: UI state must be managed externally
- Memory Usage: Higher memory usage due to immediate mode architecture