remove state generic from a lot of things
This commit is contained in:
@@ -2,13 +2,13 @@ use std::marker::PhantomData;
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
pub struct Stack<State> {
|
||||
pub children: Vec<WidgetHandle<State>>,
|
||||
pub struct Stack {
|
||||
pub children: Vec<WidgetHandle>,
|
||||
pub size: StackSize,
|
||||
}
|
||||
|
||||
impl<State: 'static> Widget<State> for Stack<State> {
|
||||
fn draw(&mut self, painter: &mut Painter<State>) {
|
||||
impl Widget for Stack {
|
||||
fn draw(&mut self, painter: &mut Painter) {
|
||||
let mut iter = self.children.iter();
|
||||
if let Some(child) = iter.next() {
|
||||
painter.child_layer();
|
||||
@@ -20,14 +20,14 @@ impl<State: 'static> Widget<State> for Stack<State> {
|
||||
}
|
||||
}
|
||||
|
||||
fn desired_width(&mut self, ctx: &mut SizeCtx<State>) -> Len {
|
||||
fn desired_width(&mut self, ctx: &mut SizeCtx) -> Len {
|
||||
match self.size {
|
||||
StackSize::Default => Len::default(),
|
||||
StackSize::Child(i) => ctx.width(&self.children[i]),
|
||||
}
|
||||
}
|
||||
|
||||
fn desired_height(&mut self, ctx: &mut SizeCtx<State>) -> Len {
|
||||
fn desired_height(&mut self, ctx: &mut SizeCtx) -> Len {
|
||||
match self.size {
|
||||
StackSize::Default => Len::default(),
|
||||
StackSize::Child(i) => ctx.height(&self.children[i]),
|
||||
@@ -48,14 +48,14 @@ pub struct StackBuilder<State, const LEN: usize, Wa: WidgetArrLike<State, LEN, T
|
||||
_pd: PhantomData<(State, Tag)>,
|
||||
}
|
||||
|
||||
impl<State, const LEN: usize, Wa: WidgetArrLike<State, LEN, Tag>, Tag> FnOnce<(&mut Ui<State>,)>
|
||||
impl<State, const LEN: usize, Wa: WidgetArrLike<State, LEN, Tag>, Tag> FnOnce<(&mut State,)>
|
||||
for StackBuilder<State, LEN, Wa, Tag>
|
||||
{
|
||||
type Output = Stack<State>;
|
||||
type Output = Stack;
|
||||
|
||||
extern "rust-call" fn call_once(self, args: (&mut Ui<State>,)) -> Self::Output {
|
||||
extern "rust-call" fn call_once(self, args: (&mut State,)) -> Self::Output {
|
||||
Stack {
|
||||
children: self.children.ui(args.0).arr.into_iter().collect(),
|
||||
children: self.children.add(args.0).arr.into_iter().collect(),
|
||||
size: self.size,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user