Text @position
This commit is contained in:
@@ -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())
|
||||||
|
|||||||
@@ -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))));
|
||||||
|
|||||||
Reference in New Issue
Block a user