pub struct BlincApp { /* private fields */ }Expand description
The main Blinc application
This is the primary interface for rendering Blinc UI. It handles all GPU initialization and provides a clean API.
§Example
use blinc_app::prelude::*;
let app = BlincApp::new()?;
let ui = div()
.w(400.0).h(300.0)
.child(text("Hello!").size(24.0));
// Render to a texture - handles everything automatically
app.render(&ui, target_view, 400.0, 300.0)?;Implementations§
Source§impl BlincApp
impl BlincApp
Sourcepub fn with_config(config: BlincConfig) -> Result<Self>
pub fn with_config(config: BlincConfig) -> Result<Self>
Create a new Blinc application with custom configuration
Sourcepub fn render<E: ElementBuilder>(
&mut self,
element: &E,
target: &TextureView,
width: f32,
height: f32,
) -> Result<()>
pub fn render<E: ElementBuilder>( &mut self, element: &E, target: &TextureView, width: f32, height: f32, ) -> Result<()>
Render a UI element tree to a texture
This handles everything automatically:
- Computes layout
- Renders background elements
- Renders glass elements with backdrop blur
- Renders foreground elements on top
- Renders text at layout-computed positions
- Renders SVG icons at layout-computed positions
- Applies MSAA if configured
§Arguments
element- The root UI element (created withdiv(), etc.)target- The texture view to render towidth- Viewport width in pixelsheight- Viewport height in pixels
§Example
let ui = div().w(400.0).h(300.0)
.flex_col().gap(4.0)
.child(
div().glass().rounded(16.0)
.child(text("Hello!").size(24.0))
);
app.render(&ui, &target_view, 400.0, 300.0)?;Sourcepub fn render_tree(
&mut self,
tree: &RenderTree,
target: &TextureView,
width: u32,
height: u32,
) -> Result<()>
pub fn render_tree( &mut self, tree: &RenderTree, target: &TextureView, width: u32, height: u32, ) -> Result<()>
Render a pre-computed render tree
Use this when you want to compute layout once and render multiple times.
Sourcepub fn render_tree_with_state(
&mut self,
tree: &RenderTree,
render_state: &RenderState,
target: &TextureView,
width: u32,
height: u32,
) -> Result<()>
pub fn render_tree_with_state( &mut self, tree: &RenderTree, render_state: &RenderState, target: &TextureView, width: u32, height: u32, ) -> Result<()>
Render a pre-computed render tree with dynamic render state
This method renders the stable tree structure and overlays any dynamic elements from RenderState (cursor, selections, animated properties).
The tree structure is only rebuilt when elements are added/removed. The RenderState is updated every frame for animations and cursor blink.
Sourcepub fn render_tree_with_motion(
&mut self,
tree: &RenderTree,
render_state: &RenderState,
target: &TextureView,
width: u32,
height: u32,
) -> Result<()>
pub fn render_tree_with_motion( &mut self, tree: &RenderTree, render_state: &RenderState, target: &TextureView, width: u32, height: u32, ) -> Result<()>
Render a pre-computed render tree with motion animations
This method renders elements with enter/exit animations applied:
- opacity fading
- scale transformations
- translation animations
Use this when you have elements wrapped in motion() containers.
Sourcepub fn render_overlay_tree_with_motion(
&mut self,
tree: &RenderTree,
render_state: &RenderState,
target: &TextureView,
width: u32,
height: u32,
) -> Result<()>
pub fn render_overlay_tree_with_motion( &mut self, tree: &RenderTree, render_state: &RenderState, target: &TextureView, width: u32, height: u32, ) -> Result<()>
Render an overlay tree on top of existing content (no clear)
This is used for rendering modal/dialog/toast overlays on top of the main UI.
Unlike render_tree_with_motion, this method does NOT clear the render target,
preserving whatever was rendered before.
Sourcepub fn context(&mut self) -> &mut RenderContext
pub fn context(&mut self) -> &mut RenderContext
Get the render context for advanced usage
Sourcepub fn set_cursor_position(&mut self, x: f32, y: f32)
pub fn set_cursor_position(&mut self, x: f32, y: f32)
Update the current cursor position in physical pixels (for @flow pointer input)
Sourcepub fn set_blend_target(&mut self, texture: &Texture)
pub fn set_blend_target(&mut self, texture: &Texture)
Set the current render target texture for blend mode two-pass compositing.
Sourcepub fn clear_blend_target(&mut self)
pub fn clear_blend_target(&mut self)
Clear the blend target texture reference after rendering.
Sourcepub fn has_active_flows(&self) -> bool
pub fn has_active_flows(&self) -> bool
Whether the last render frame contained @flow shader elements.
Sourcepub fn config(&self) -> &BlincConfig
pub fn config(&self) -> &BlincConfig
Get the configuration
Sourcepub fn texture_format(&self) -> TextureFormat
pub fn texture_format(&self) -> TextureFormat
Get the texture format used by the renderer’s pipelines
This should match the format used for the surface configuration to avoid format mismatches.
Sourcepub fn font_registry(&self) -> Arc<Mutex<FontRegistry>>
pub fn font_registry(&self) -> Arc<Mutex<FontRegistry>>
Get the shared font registry
This can be used to share fonts between text measurement and rendering, ensuring consistent font loading and metrics.
Sourcepub fn load_font_data_to_registry(&mut self, data: Vec<u8>) -> usize
pub fn load_font_data_to_registry(&mut self, data: Vec<u8>) -> usize
Load font data into the text rendering registry
This adds fonts that will be available for text rendering. Returns the number of font faces loaded.
Use this to load bundled fonts on platforms (like iOS) where system fonts aren’t directly accessible via file paths.
Sourcepub fn with_window<W>(
window: Arc<W>,
config: Option<BlincConfig>,
) -> Result<(Self, Surface<'static>)>
pub fn with_window<W>( window: Arc<W>, config: Option<BlincConfig>, ) -> Result<(Self, Surface<'static>)>
Create a new Blinc application with a window surface
This creates a GPU renderer optimized for the given window and returns both the application and the wgpu surface for rendering.
§Arguments
window- The window to create a surface for (must implement raw-window-handle traits)config- Optional configuration (uses defaults if None)
§Example
let (app, surface) = BlincApp::with_window(window_arc, None)?;Auto Trait Implementations§
impl !Freeze for BlincApp
impl !RefUnwindSafe for BlincApp
impl !Send for BlincApp
impl !Sync for BlincApp
impl Unpin for BlincApp
impl UnsafeUnpin for BlincApp
impl !UnwindSafe for BlincApp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.