Cleanup
This commit is contained in:
parent
65f5a625ad
commit
e913daf07c
|
@ -12,52 +12,49 @@ use dioxus_core::{Element, Mutations, Scope, ScopeState, VirtualDom};
|
|||
use std::{cell::RefCell, mem::transmute, rc::Rc};
|
||||
|
||||
pub fn tick_dioxus_ui(world: &mut World) {
|
||||
unsafe {
|
||||
let world_cell = world.as_unsafe_world_cell();
|
||||
let mut command_queue = CommandQueue::default();
|
||||
|
||||
let apply_mutations = |mutations: Mutations, root_entity: Entity| {
|
||||
todo!("Modify bevy_ui entities based on mutations");
|
||||
};
|
||||
let apply_mutations = |mutations: Mutations, root_entity: Entity| {
|
||||
todo!("Modify bevy_ui entities based on mutations");
|
||||
};
|
||||
|
||||
let mut command_queue = CommandQueue::default();
|
||||
let ecs_context = EcsContext {
|
||||
world_read_only: transmute(world_cell.world()),
|
||||
let ecs_context = unsafe {
|
||||
EcsContext {
|
||||
world_read_only: transmute(&world),
|
||||
commands: Rc::new(RefCell::new(Commands::new(
|
||||
transmute(&mut command_queue),
|
||||
transmute(world_cell.world()),
|
||||
transmute(&world),
|
||||
))),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
for (root_entity, mut dioxus_ui_root) in world_cell
|
||||
.world_mut()
|
||||
.query::<(Entity, &mut DioxusUiRoot)>()
|
||||
.iter_mut(world_cell.world_mut())
|
||||
{
|
||||
dioxus_ui_root
|
||||
.virtual_dom
|
||||
.get()
|
||||
.base_scope()
|
||||
.provide_context(ecs_context.clone());
|
||||
for (root_entity, mut dioxus_ui_root) in
|
||||
world.query::<(Entity, &mut DioxusUiRoot)>().iter_mut(world)
|
||||
{
|
||||
dioxus_ui_root
|
||||
.virtual_dom
|
||||
.get()
|
||||
.base_scope()
|
||||
.provide_context(ecs_context.clone());
|
||||
|
||||
if !dioxus_ui_root.initial_build {
|
||||
apply_mutations(dioxus_ui_root.virtual_dom.get().rebuild(), root_entity);
|
||||
dioxus_ui_root.initial_build = true;
|
||||
}
|
||||
|
||||
// TODO: Handle events from winit
|
||||
// dioxus_ui_root
|
||||
// .virtual_dom
|
||||
// .get()
|
||||
// .handle_event(todo!(), todo!(), todo!(), todo!());
|
||||
|
||||
apply_mutations(
|
||||
dioxus_ui_root.virtual_dom.get().render_immediate(),
|
||||
root_entity,
|
||||
);
|
||||
if !dioxus_ui_root.initial_build {
|
||||
apply_mutations(dioxus_ui_root.virtual_dom.get().rebuild(), root_entity);
|
||||
dioxus_ui_root.initial_build = true;
|
||||
}
|
||||
|
||||
command_queue.apply(world);
|
||||
// TODO: Handle events from winit
|
||||
// dioxus_ui_root
|
||||
// .virtual_dom
|
||||
// .get()
|
||||
// .handle_event(todo!(), todo!(), todo!(), todo!());
|
||||
|
||||
apply_mutations(
|
||||
dioxus_ui_root.virtual_dom.get().render_immediate(),
|
||||
root_entity,
|
||||
);
|
||||
}
|
||||
|
||||
command_queue.apply(world);
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
Loading…
Reference in a new issue