Text @position

This commit is contained in:
2026-01-25 21:11:42 +01:00
parent 98598bec15
commit 4364177538
2 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ fn app(cx: &Arc<Context>) -> View {
// Dynamic scope // Dynamic scope
for %count (i in 0..count.get_dl()) { for %count (i in 0..count.get_dl()) {
"{i}" "{i}" @Point { x: 0, y: i };
} }
} }
.view(cx.clone()) .view(cx.clone())
+22
View File
@@ -53,6 +53,20 @@ macro_rules! rsx_scope {
$crate::rsx_scope!($rsx, $($rest)*); $crate::rsx_scope!($rsx, $($rest)*);
}; };
($rsx:expr, $(%$($dep:ident $(as $dp:pat,)?),+)? $text:literal @$d:expr; $($rest:tt)*) => {
{
let scope = $crate::component::Scope::new();
$($($crate::rsx_dep!($dep $(as $dp)?);)+)?
$crate::rsx_child!(scope, $text @$d;);
$rsx.static_scope(scope);
}
$crate::rsx_scope!($rsx, $($rest)*);
};
($rsx:expr, $(%$($dep:ident $(as $dp:pat,)?),+)? $text:literal $($rest:tt)*) => { ($rsx:expr, $(%$($dep:ident $(as $dp:pat,)?),+)? $text:literal $($rest:tt)*) => {
{ {
let scope = $crate::component::Scope::new(); let scope = $crate::component::Scope::new();
@@ -96,6 +110,14 @@ macro_rules! rsx_scope {
#[macro_export] #[macro_export]
macro_rules! rsx_child { macro_rules! rsx_child {
($scope:expr, $text:literal @$d:expr; $($rest:tt)*) => {
{
$scope.view(Arc::new(move |ctx| ctx.draw_text($d, &format!($text))));
}
$crate::rsx_child!($scope, $($rest)*);
};
($scope:expr, $text:literal $($rest:tt)*) => { ($scope:expr, $text:literal $($rest:tt)*) => {
{ {
$scope.view(Arc::new(move |ctx| ctx.draw_text(Point { x: 0, y: 0 }, &format!($text)))); $scope.view(Arc::new(move |ctx| ctx.draw_text(Point { x: 0, y: 0 }, &format!($text))));