Newer
Older
let mut node_system = IntoSystem::into_system(calculate_nodes);
node_system.initialize(world);
let mut layout_system = IntoSystem::into_system(calculate_layout);
layout_system.initialize(world);
for _ in 0..3 {
context = node_system.run(context, world);
node_system.apply_buffers(world);
context = layout_system.run(context, world);
layout_system.apply_buffers(world);
LayoutEventDispatcher::dispatch(&mut context, world);
}
if event_dispatcher.hovered.is_none() {
context.current_cursor = CursorIcon::Default;
} else {
let hovered = event_dispatcher.hovered.unwrap();
if let Some(entity) = world.get_entity(hovered.0) {
if let Some(node) = entity.get::<crate::node::Node>() {
let icon = node.resolved_styles.cursor.resolve();
context.current_cursor = icon.0;
}
}
if let Some(ref mut windows) = world.get_resource_mut::<Windows>() {
if let Some(window) = windows.get_primary_mut() {
window.set_cursor_icon(context.current_cursor);
}
world.entity_mut(entity).insert((event_dispatcher, context));
}
// dbg!("Finished calculating nodes!");
// dbg!("Dispatching layout events!");
// dbg!("Finished dispatching layout events!");
}
/// A simple component that stores the type name of a widget
/// This is used by Kayak in order to find out which systems to run.
#[derive(Component, Debug, Clone, PartialEq, Eq)]
pub struct WidgetName(pub String);
impl From<String> for WidgetName {
fn from(value: String) -> Self {
WidgetName(value)
}
}
impl Into<String> for WidgetName {
fn into(self) -> String {
self.0