Skip to content

Commit

Permalink
minor fix greener pastures time
Browse files Browse the repository at this point in the history
  • Loading branch information
spectria-limina committed Dec 11, 2024
1 parent c1227f8 commit 37c15ae
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bevy_egui::{
EguiContexts,
};

use crate::ecs::{NestedSystem, NestedSystemId, NestedSystemRegistry, NestedWith};
use crate::ecs::{NestedSystem, NestedSystemId};

// TODO: TEST TEST TEST
pub fn egui_contexts_scope<U, F: FnOnce(SystemParamItem<EguiContexts>) -> U>(
Expand Down Expand Up @@ -56,21 +56,32 @@ impl Widget {

pub struct InitWidget(fn(&mut World, Entity) -> WidgetSystemId);

#[macro_export]
macro_rules! widget {
() => {
$crate::widget!(Self::show)
};
($show:path) => {
Widget(|world: &mut World, id: Entity| -> WidgetSystemId {
NestedSystemRegistry::register_with_data(world, $show, id)
$crate::widget::InitWidget(|world: &mut World, id: Entity| -> WidgetSystemId {
$crate::ecs::nested::NestedSystemRegistry::register_with_data(world, $show, id)
})
};
}
type _ItsNotUnusedISwear = NestedSystemRegistry;

#[derive(Component)]
#[require(InitWidget(|| widget!(Test::show)))]
struct Test;

impl Test {
pub fn show(NestedWith(_ns, _id, InMut(_ui)): NestedWith<Entity, InMut<Ui>>) {
// do ui stuff here i guess
#[allow(unused)]
pub use crate::widget;

#[cfg(test)]
mod test {
use super::*;
use crate::ecs::NestedWith;

#[derive(Component)]
#[require(InitWidget(|| widget!()))]
struct Test;

impl Test {
pub fn show(NestedWith(_ns, _id, InMut(_ui)): NestedWith<Entity, InMut<Ui>>) {
// do ui stuff here i guess
}
}
}

0 comments on commit 37c15ae

Please sign in to comment.