waft-winui 0.18.2

WinUI 3 controls and Fluent styling for the Waft UI framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Work a control defers until a frame of its view has been drawn, and the frame it waits for:
//! Flutter's `addPostFrameCallback` with `ensureVisualUpdate`, for a view of its own.

use waft_embedder::ViewId;
use waft_foundation::App;
use waft_scheduler::{FrameCallback, FrameTarget, SchedulerBinding};

/// Runs `callback` at the end of the next frame of `view`, and asks for that frame. Work of no
/// view, as a control outside every view has, runs at the end of the next frame of any view, and
/// a frame of every view is asked for.
pub(crate) fn after_next_frame(app: &mut App, view: Option<ViewId>, callback: FrameCallback) {
    SchedulerBinding::add_post_frame_callback(app, callback, view);
    let target = match view {
        Some(view) => FrameTarget::View(view),
        None => FrameTarget::EveryView,
    };
    SchedulerBinding::ensure_visual_update(app, target);
}