Skip to main content

BlincApp

Struct BlincApp 

Source
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

Source

pub fn new() -> Result<Self>

Create a new Blinc application with default configuration

Source

pub fn with_config(config: BlincConfig) -> Result<Self>

Create a new Blinc application with custom configuration

Source

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 with div(), etc.)
  • target - The texture view to render to
  • width - Viewport width in pixels
  • height - 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)?;
Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn context(&mut self) -> &mut RenderContext

Get the render context for advanced usage

Source

pub fn set_cursor_position(&mut self, x: f32, y: f32)

Update the current cursor position in physical pixels (for @flow pointer input)

Source

pub fn set_blend_target(&mut self, texture: &Texture)

Set the current render target texture for blend mode two-pass compositing.

Source

pub fn clear_blend_target(&mut self)

Clear the blend target texture reference after rendering.

Source

pub fn has_active_flows(&self) -> bool

Whether the last render frame contained @flow shader elements.

Source

pub fn config(&self) -> &BlincConfig

Get the configuration

Source

pub fn device(&self) -> &Arc<Device>

Get the wgpu device

Source

pub fn queue(&self) -> &Arc<Queue>

Get the wgpu queue

Source

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.

Source

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.

Source

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.

Source

pub fn with_window<W>( window: Arc<W>, config: Option<BlincConfig>, ) -> Result<(Self, Surface<'static>)>
where W: HasWindowHandle + HasDisplayHandle + Send + Sync + '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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more