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};
|
use std::{cell::RefCell, mem::transmute, rc::Rc};
|
||||||
|
|
||||||
pub fn tick_dioxus_ui(world: &mut World) {
|
pub fn tick_dioxus_ui(world: &mut World) {
|
||||||
unsafe {
|
let mut command_queue = CommandQueue::default();
|
||||||
let world_cell = world.as_unsafe_world_cell();
|
|
||||||
|
|
||||||
let apply_mutations = |mutations: Mutations, root_entity: Entity| {
|
let apply_mutations = |mutations: Mutations, root_entity: Entity| {
|
||||||
todo!("Modify bevy_ui entities based on mutations");
|
todo!("Modify bevy_ui entities based on mutations");
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut command_queue = CommandQueue::default();
|
let ecs_context = unsafe {
|
||||||
let ecs_context = EcsContext {
|
EcsContext {
|
||||||
world_read_only: transmute(world_cell.world()),
|
world_read_only: transmute(&world),
|
||||||
commands: Rc::new(RefCell::new(Commands::new(
|
commands: Rc::new(RefCell::new(Commands::new(
|
||||||
transmute(&mut command_queue),
|
transmute(&mut command_queue),
|
||||||
transmute(world_cell.world()),
|
transmute(&world),
|
||||||
))),
|
))),
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
for (root_entity, mut dioxus_ui_root) in world_cell
|
for (root_entity, mut dioxus_ui_root) in
|
||||||
.world_mut()
|
world.query::<(Entity, &mut DioxusUiRoot)>().iter_mut(world)
|
||||||
.query::<(Entity, &mut DioxusUiRoot)>()
|
{
|
||||||
.iter_mut(world_cell.world_mut())
|
dioxus_ui_root
|
||||||
{
|
.virtual_dom
|
||||||
dioxus_ui_root
|
.get()
|
||||||
.virtual_dom
|
.base_scope()
|
||||||
.get()
|
.provide_context(ecs_context.clone());
|
||||||
.base_scope()
|
|
||||||
.provide_context(ecs_context.clone());
|
|
||||||
|
|
||||||
if !dioxus_ui_root.initial_build {
|
if !dioxus_ui_root.initial_build {
|
||||||
apply_mutations(dioxus_ui_root.virtual_dom.get().rebuild(), root_entity);
|
apply_mutations(dioxus_ui_root.virtual_dom.get().rebuild(), root_entity);
|
||||||
dioxus_ui_root.initial_build = true;
|
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,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)]
|
#[derive(Clone)]
|
||||||
|
|
Loading…
Reference in a new issue