remove state generic from a lot of things

This commit is contained in:
2025-12-17 21:37:55 -05:00
parent 7e6369029f
commit 30bc55c78e
45 changed files with 740 additions and 856 deletions

View File

@@ -1,13 +1,13 @@
use crate::prelude::*;
pub struct Sized<State> {
pub inner: WidgetHandle<State>,
pub struct Sized {
pub inner: WidgetHandle,
pub x: Option<Len>,
pub y: Option<Len>,
}
impl<State: 'static> Sized<State> {
fn apply_to_outer(&self, ctx: &mut SizeCtx<State>) {
impl Sized {
fn apply_to_outer(&self, ctx: &mut SizeCtx) {
if let Some(x) = self.x {
ctx.outer.x.select_len(x.apply_rest());
}
@@ -17,17 +17,17 @@ impl<State: 'static> Sized<State> {
}
}
impl<State: 'static> Widget<State> for Sized<State> {
fn draw(&mut self, painter: &mut Painter<State>) {
impl Widget for Sized {
fn draw(&mut self, painter: &mut Painter) {
painter.widget(&self.inner);
}
fn desired_width(&mut self, ctx: &mut SizeCtx<State>) -> Len {
fn desired_width(&mut self, ctx: &mut SizeCtx) -> Len {
self.apply_to_outer(ctx);
self.x.unwrap_or_else(|| ctx.width(&self.inner))
}
fn desired_height(&mut self, ctx: &mut SizeCtx<State>) -> Len {
fn desired_height(&mut self, ctx: &mut SizeCtx) -> Len {
self.apply_to_outer(ctx);
self.y.unwrap_or_else(|| ctx.height(&self.inner))
}