RE ADD CONTEXT

This commit is contained in:
2025-12-15 21:50:53 -05:00
parent dc2be7f688
commit 0b8a93c5ce
39 changed files with 925 additions and 713 deletions

View File

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