Rename iced_sentinel to iced_beacon and refactor its API

This commit is contained in:
Héctor Ramón Jiménez 2024-05-10 20:08:09 +02:00
parent aaf396256e
commit 57033dc4d0
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
19 changed files with 596 additions and 438 deletions

View file

@ -117,7 +117,7 @@ where
{
use winit::event_loop::EventLoop;
let boot_timer = debug::boot_time();
let boot_span = debug::boot();
let event_loop = EventLoop::with_user_event()
.build()
@ -153,7 +153,7 @@ where
event_receiver,
control_sender,
init_command,
boot_timer,
boot_span,
));
let context = task::Context::from_waker(task::noop_waker_ref());
@ -452,7 +452,7 @@ async fn run_instance<A, E, C>(
mut event_receiver: mpsc::UnboundedReceiver<Event<A::Message>>,
mut control_sender: mpsc::UnboundedSender<Control>,
init_command: Command<A::Message>,
boot_timer: debug::Timer,
boot_span: debug::Span,
) where
A: Application + 'static,
E: Executor + 'static,
@ -524,7 +524,7 @@ async fn run_instance<A, E, C>(
);
runtime.track(application.subscription().into_recipes());
boot_timer.finish();
boot_span.finish();
let mut messages = Vec::new();
let mut user_events = 0;
@ -636,7 +636,7 @@ async fn run_instance<A, E, C>(
&mut messages,
);
let draw_timer = debug::draw_time(id);
let draw_span = debug::draw(id);
let new_mouse_interaction = ui.draw(
&mut window.renderer,
window.state.theme(),
@ -645,7 +645,7 @@ async fn run_instance<A, E, C>(
},
cursor,
);
draw_timer.finish();
draw_span.finish();
if new_mouse_interaction != window.mouse_interaction {
window.raw.set_cursor(
@ -692,7 +692,7 @@ async fn run_instance<A, E, C>(
{
let logical_size = window.state.logical_size();
let layout_time = debug::layout_time(id);
let layout = debug::layout(id);
let ui = user_interfaces
.remove(&id)
.expect("Remove user interface");
@ -701,9 +701,9 @@ async fn run_instance<A, E, C>(
id,
ui.relayout(logical_size, &mut window.renderer),
);
layout_time.finish();
layout.finish();
let draw_time = debug::draw_time(id);
let draw = debug::draw(id);
let new_mouse_interaction = user_interfaces
.get_mut(&id)
.expect("Get user interface")
@ -715,7 +715,7 @@ async fn run_instance<A, E, C>(
},
window.state.cursor(),
);
draw_time.finish();
draw.finish();
if new_mouse_interaction != window.mouse_interaction
{
@ -739,7 +739,7 @@ async fn run_instance<A, E, C>(
window.state.viewport_version();
}
let render_time = debug::render_time(id);
let present_span = debug::present(id);
match compositor.present(
&mut window.renderer,
&mut window.surface,
@ -747,7 +747,7 @@ async fn run_instance<A, E, C>(
window.state.background_color(),
) {
Ok(()) => {
render_time.finish();
present_span.finish();
// TODO: Handle animations!
// Maybe we can use `ControlFlow::WaitUntil` for this.
@ -821,7 +821,7 @@ async fn run_instance<A, E, C>(
let mut uis_stale = false;
for (id, window) in window_manager.iter_mut() {
let interact_time = debug::interact_time(id);
let interact = debug::interact(id);
let mut window_events = vec![];
events.retain(|(window_id, event)| {
@ -864,7 +864,7 @@ async fn run_instance<A, E, C>(
{
runtime.broadcast(event, status);
}
interact_time.finish();
interact.finish();
}
// TODO mw application update returns which window IDs to update
@ -938,13 +938,13 @@ fn build_user_interface<'a, A: Application>(
where
A::Theme: DefaultStyle,
{
let view_timer = debug::view_time(id);
let view_span = debug::view(id);
let view = application.view(id);
view_timer.finish();
view_span.finish();
let layout_timer = debug::layout_time(id);
let layout_span = debug::layout(id);
let user_interface = UserInterface::build(view, size, cache, renderer);
layout_timer.finish();
layout_span.finish();
user_interface
}
@ -968,9 +968,9 @@ fn update<A: Application, C, E: Executor>(
for message in messages.drain(..) {
debug::log_message(&message);
let update_timer = debug::update_time();
let update_span = debug::update();
let command = runtime.enter(|| application.update(message));
update_timer.finish();
update_span.finish();
run_command(
application,