#[macro_export]
macro_rules! render_component_in_current_box {
(
in: $arg_surface : expr, // Eg: in: surface
component_id: $arg_component_id : expr, // Eg: "component1"
from: $arg_registry : expr, // Eg: from: registry
state: $arg_state : expr, // Eg: state
shared_store: $arg_shared_store : expr, // Eg: shared_store
shared_global_data: $arg_shared_global_data : expr, // Eg: shared_global_data
window_size: $arg_window_size : expr // Eg: window_size
) => {
let maybe_component_ref = ComponentRegistry::get_component_ref_by_id(
&mut $arg_registry,
$arg_component_id,
);
if let Some(component_ref) = maybe_component_ref {
let surface_bounds = SurfaceBounds::from(&*($arg_surface));
let current_box = $arg_surface.current_box()?;
let queue = component_ref
.write()
.await
.render(
ComponentScopeArgs {
shared_global_data: $arg_shared_global_data,
shared_store: $arg_shared_store,
state: $arg_state,
component_registry: &mut $arg_registry,
window_size: $arg_window_size,
},
current_box,
surface_bounds,
)
.await?;
$arg_surface.render_pipeline += queue;
}
};
}
#[macro_export]
macro_rules! render_component_in_given_box {
(
in: $arg_surface : expr, // Eg: in: surface
box: $arg_box : expr, // Eg: box: FlexBox::default()
component_id: $arg_component_id : expr, from: $arg_registry : expr, state: $arg_state : expr, shared_store: $arg_shared_store : expr, shared_global_data: $arg_shared_global_data : expr, window_size: $arg_window_size : expr ) => {{
let maybe_component_ref = ComponentRegistry::get_component_ref_by_id(
&mut $arg_registry,
$arg_component_id,
);
if let Some(component_ref) = maybe_component_ref {
let surface_bounds = SurfaceBounds::from(&*($arg_surface));
let queue: RenderPipeline = component_ref
.write()
.await
.render(
ComponentScopeArgs {
shared_global_data: $arg_shared_global_data,
shared_store: $arg_shared_store,
state: $arg_state,
component_registry: &mut $arg_registry,
window_size: $arg_window_size,
},
&$arg_box,
surface_bounds,
)
.await?;
$arg_surface.render_pipeline += queue;
}
}};
}