You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.2 KiB
Rust

use uwui_dsl::NativeComponent;
use crate::backend::Backend;
use crate::layout::Gravity;
use crate::view::{NativeComponent, NewNative, NewNativeGroup, View};
#[derive(Default)]
pub struct StackParams {
pub gravity: Gravity,
pub homogay: bool,
}
impl From<(Gravity,)> for StackParams {
fn from(value: (Gravity,)) -> Self {
Self {
gravity: value.0,
..Default::default()
}
}
}
macro_rules! stack_impl {
($name:ident) => {
#[derive(NativeComponent)]
pub struct $name {
params: StackParams,
}
impl<B: Backend> NewNative<B> for $name
where
$name: NativeComponent<B>,
{
type Params = StackParams;
fn new(params: Self::Params) -> Self {
Self { params }
}
}
impl<B: Backend> NewNativeGroup<B> for $name
where
$name: NativeComponent<B>,
{
fn new_group<'a, I>(params: Self::Params, _children: I) -> Self
where
I: Iterator<Item = &'a View<B>>,
{
Self { params }
}
}
};
}
stack_impl!(HStack);
stack_impl!(VStack);