Rsx scope child
This commit is contained in:
+26
-4
@@ -13,10 +13,12 @@ macro_rules! rsx {
|
|||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! rsx_scope {
|
macro_rules! rsx_scope {
|
||||||
($rsx:expr, $text:literal $($rest:tt)*) => {
|
($rsx:expr, $(%$($dep:ident)+)? $text:literal $($rest:tt)*) => {
|
||||||
let scope = $crate::component::Scope::new();
|
let scope = $crate::component::Scope::new();
|
||||||
|
|
||||||
scope.view(Arc::new(move |ctx| ctx.draw_text(Point { x: 0, y: 0 }, &format!($text))));
|
$($(let $dep = $dep.clone();)+)?
|
||||||
|
|
||||||
|
$crate::rsx_child!(scope, $text);
|
||||||
|
|
||||||
$rsx.static_scope(scope);
|
$rsx.static_scope(scope);
|
||||||
$crate::rsx_scope!($rsx, $($rest)*);
|
$crate::rsx_scope!($rsx, $($rest)*);
|
||||||
@@ -25,7 +27,7 @@ macro_rules! rsx_scope {
|
|||||||
($rsx:expr, $component:ident ($ctx:ident, $view:ident) $body:block $($rest:tt)*) => {
|
($rsx:expr, $component:ident ($ctx:ident, $view:ident) $body:block $($rest:tt)*) => {
|
||||||
let scope = $crate::component::Scope::new();
|
let scope = $crate::component::Scope::new();
|
||||||
|
|
||||||
scope.child($component, Some(Arc::new(|$ctx, $view| $body)));
|
$crate::rsx_child!(scope, $component ($ctx, $view) $body);
|
||||||
|
|
||||||
$rsx.static_scope(scope);
|
$rsx.static_scope(scope);
|
||||||
$crate::rsx_scope!($rsx, $($rest)*);
|
$crate::rsx_scope!($rsx, $($rest)*);
|
||||||
@@ -34,7 +36,7 @@ macro_rules! rsx_scope {
|
|||||||
($rsx:expr, $component:ident $($rest:tt)*) => {
|
($rsx:expr, $component:ident $($rest:tt)*) => {
|
||||||
let scope = $crate::component::Scope::new();
|
let scope = $crate::component::Scope::new();
|
||||||
|
|
||||||
scope.child($component, None);
|
$crate::rsx_child!(scope, $component $body);
|
||||||
|
|
||||||
$rsx.static_scope(scope);
|
$rsx.static_scope(scope);
|
||||||
$crate::rsx_scope!($rsx, $($rest)*);
|
$crate::rsx_scope!($rsx, $($rest)*);
|
||||||
@@ -42,3 +44,23 @@ macro_rules! rsx_scope {
|
|||||||
|
|
||||||
($rsx:expr,) => {};
|
($rsx:expr,) => {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! rsx_child {
|
||||||
|
($scope:expr, $text:literal $($rest:tt)*) => {
|
||||||
|
$scope.view(Arc::new(move |ctx| ctx.draw_text(Point { x: 0, y: 0 }, &format!($text))));
|
||||||
|
$crate::rsx_child!($scope, $($rest)*);
|
||||||
|
};
|
||||||
|
|
||||||
|
($scope:expr, $component:ident ($ctx:ident, $view:ident) $body:block $($rest:tt)*) => {
|
||||||
|
$scope.child($component, Some(Arc::new(|$ctx, $view| $body)));
|
||||||
|
$crate::rsx_child!($scope, $($rest)*);
|
||||||
|
};
|
||||||
|
|
||||||
|
($scope:expr, $component:ident $($rest:tt)*) => {
|
||||||
|
$scope.child($component, None);
|
||||||
|
$crate::rsx_child!($scope, $($rest)*);
|
||||||
|
};
|
||||||
|
|
||||||
|
($rsx:expr,) => {};
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user