strong & weak widgets

This commit is contained in:
2025-12-11 07:16:06 -05:00
parent a85e129026
commit 36668c82f4
19 changed files with 293 additions and 294 deletions

View File

@@ -1,12 +1,12 @@
use crate::{Len, Painter, SizeCtx, Ui};
use std::{any::Any, marker::PhantomData};
use std::any::Any;
mod id;
mod handle;
mod like;
mod tag;
mod widgets;
pub use id::*;
pub use handle::*;
pub use like::*;
pub use tag::*;
pub use widgets::*;
@@ -30,20 +30,16 @@ impl Widget for () {
/// A function that returns a widget given a UI.
/// Useful for defining trait functions on widgets that create a parent widget so that the children
/// don't need to be IDs yet
pub trait WidgetFn<W: Widget>: FnOnce(&mut Ui) -> W {}
impl<W: Widget, F: FnOnce(&mut Ui) -> W> WidgetFn<W> for F {}
pub trait WidgetFn<W: Widget + ?Sized>: FnOnce(&mut Ui) -> W {}
impl<W: Widget + ?Sized, F: FnOnce(&mut Ui) -> W> WidgetFn<W> for F {}
pub struct WidgetArr<const LEN: usize, Ws> {
pub struct WidgetArr<const LEN: usize> {
pub arr: [WidgetHandle; LEN],
_pd: PhantomData<Ws>,
}
impl<const LEN: usize, Ws> WidgetArr<LEN, Ws> {
impl<const LEN: usize> WidgetArr<LEN> {
pub fn new(arr: [WidgetHandle; LEN]) -> Self {
Self {
arr,
_pd: PhantomData,
}
Self { arr }
}
}