This commit is contained in:
2026-01-12 18:40:27 -05:00
parent a9c76e4326
commit 79813db3ba
35 changed files with 378 additions and 403 deletions

View File

@@ -8,9 +8,9 @@ impl<Rsc: HasEvents, W: Widget + 'static> WidgetAttr<Rsc, W> for Selector
where
Rsc::State: HasDefaultUiState,
{
type Input = WidgetRef<TextEdit>;
type Input = WeakWidget<TextEdit>;
fn run(rsc: &mut Rsc, container: WidgetRef<W>, id: Self::Input) {
fn run(rsc: &mut Rsc, container: WeakWidget<W>, id: Self::Input) {
rsc.register_event(container, CursorSense::click_or_drag(), move |ctx, rsc| {
let region = rsc.ui().window_region(&id).unwrap();
let id_pos = region.top_left;
@@ -30,7 +30,7 @@ where
{
type Input = ();
fn run(rsc: &mut Rsc, id: WidgetRef<TextEdit>, _: Self::Input) {
fn run(rsc: &mut Rsc, id: WeakWidget<TextEdit>, _: Self::Input) {
rsc.register_event(id, CursorSense::click_or_drag(), move |ctx, rsc| {
select(
rsc,
@@ -47,7 +47,7 @@ where
fn select(
rsc: &mut impl HasUi,
state: &mut impl HasDefaultUiState,
id: WidgetRef<TextEdit>,
id: WeakWidget<TextEdit>,
pos: Vec2,
size: Vec2,
dragging: bool,

View File

@@ -32,7 +32,7 @@ pub type Proxy<Event> = EventLoopProxy<Event>;
pub struct DefaultUiState {
pub renderer: UiRenderer,
pub input: Input,
pub focus: Option<WidgetRef<TextEdit>>,
pub focus: Option<WeakWidget<TextEdit>>,
pub clipboard: Clipboard,
pub window: Arc<Window>,
pub ime: usize,

View File

@@ -75,7 +75,7 @@ impl<
}
pub struct AsyncEventIdCtx<Rsc: HasEvents, Data, W: ?Sized> {
pub widget: WidgetRef<W>,
pub widget: WeakWidget<W>,
pub data: Data,
pub task: TaskCtx<Rsc>,
}

View File

@@ -1,7 +1,7 @@
use crate::prelude::*;
pub struct Masked {
pub inner: WidgetHandle,
pub inner: StrongWidget,
}
impl Widget for Masked {

View File

@@ -1,7 +1,7 @@
use crate::prelude::*;
pub struct Aligned {
pub inner: WidgetHandle,
pub inner: StrongWidget,
pub align: Align,
}

View File

@@ -1,7 +1,7 @@
use crate::prelude::*;
pub struct LayerOffset {
pub inner: WidgetHandle,
pub inner: StrongWidget,
pub offset: usize,
}

View File

@@ -1,7 +1,7 @@
use crate::prelude::*;
pub struct MaxSize {
pub inner: WidgetHandle,
pub inner: StrongWidget,
pub x: Option<Len>,
pub y: Option<Len>,
}

View File

@@ -1,7 +1,7 @@
use crate::prelude::*;
pub struct Offset {
pub inner: WidgetHandle,
pub inner: StrongWidget,
pub amt: UiVec2,
}

View File

@@ -2,7 +2,7 @@ use crate::prelude::*;
pub struct Pad {
pub padding: Padding,
pub inner: WidgetHandle,
pub inner: StrongWidget,
}
impl Widget for Pad {

View File

@@ -1,7 +1,7 @@
use crate::prelude::*;
pub struct Scroll {
inner: WidgetHandle,
inner: StrongWidget,
axis: Axis,
amt: f32,
snap_end: bool,
@@ -41,7 +41,7 @@ impl Widget for Scroll {
}
impl Scroll {
pub fn new(inner: WidgetHandle, axis: Axis) -> Self {
pub fn new(inner: StrongWidget, axis: Axis) -> Self {
Self {
inner,
axis,

View File

@@ -1,7 +1,7 @@
use crate::prelude::*;
pub struct Sized {
pub inner: WidgetHandle,
pub inner: StrongWidget,
pub x: Option<Len>,
pub y: Option<Len>,
}

View File

@@ -2,7 +2,7 @@ use crate::prelude::*;
use std::marker::PhantomData;
pub struct Span {
pub children: Vec<WidgetHandle>,
pub children: Vec<StrongWidget>,
pub dir: Dir,
pub gap: f32,
}
@@ -62,11 +62,11 @@ impl Span {
self
}
pub fn push(&mut self, w: WidgetHandle) {
pub fn push(&mut self, w: StrongWidget) {
self.children.push(w);
}
pub fn pop(&mut self) -> Option<WidgetHandle> {
pub fn pop(&mut self) -> Option<StrongWidget> {
self.children.pop()
}
@@ -193,7 +193,7 @@ impl<State, const LEN: usize, Wa: WidgetArrLike<State, LEN, Tag>, Tag>
}
impl std::ops::Deref for Span {
type Target = Vec<WidgetHandle>;
type Target = Vec<StrongWidget>;
fn deref(&self) -> &Self::Target {
&self.children

View File

@@ -3,7 +3,7 @@ use std::marker::PhantomData;
use crate::prelude::*;
pub struct Stack {
pub children: Vec<WidgetHandle>,
pub children: Vec<StrongWidget>,
pub size: StackSize,
}

View File

@@ -2,7 +2,7 @@ use crate::prelude::*;
use std::marker::{Sized, Unsize};
pub struct WidgetPtr {
pub inner: Option<WidgetHandle>,
pub inner: Option<StrongWidget>,
}
impl Widget for WidgetPtr {
@@ -38,14 +38,14 @@ impl WidgetPtr {
inner: Default::default(),
}
}
pub fn set<W: ?Sized + Unsize<dyn Widget>>(&mut self, to: WidgetHandle<W>) {
pub fn set<W: ?Sized + Unsize<dyn Widget>>(&mut self, to: StrongWidget<W>) {
self.inner = Some(to)
}
pub fn replace<W: ?Sized + Unsize<dyn Widget>>(
&mut self,
to: WidgetHandle<W>,
) -> Option<WidgetHandle> {
to: StrongWidget<W>,
) -> Option<StrongWidget> {
self.inner.replace(to)
}
}

View File

@@ -22,11 +22,11 @@ pub struct TextView {
// cache
tex: Option<RenderedText>,
width: Option<f32>,
pub hint: Option<WidgetHandle>,
pub hint: Option<StrongWidget>,
}
impl TextView {
pub fn new(buf: TextBuffer, attrs: TextAttrs, hint: Option<WidgetHandle>) -> Self {
pub fn new(buf: TextBuffer, attrs: TextAttrs, hint: Option<StrongWidget>) -> Self {
Self {
attrs: attrs.into(),
buf: buf.into(),

View File

@@ -125,7 +125,7 @@ widget_trait! {
|state| self.add(state)
}
fn set_ptr(self, ptr: WidgetRef<WidgetPtr>, state: &mut Rsc) {
fn set_ptr(self, ptr: WeakWidget<WidgetPtr>, state: &mut Rsc) {
let id = self.add_strong(state);
state.ui_mut()[ptr].inner = Some(id);
}