switch away from handles to refs that must be upgraded once
This commit is contained in:
@@ -151,14 +151,15 @@ pub struct SpanBuilder<State, const LEN: usize, Wa: WidgetArrLike<State, LEN, Ta
|
||||
_pd: PhantomData<(State, Tag)>,
|
||||
}
|
||||
|
||||
impl<State: StateLike<State>, const LEN: usize, Wa: WidgetArrLike<State, LEN, Tag>, Tag> FnOnce<(&mut State,)>
|
||||
for SpanBuilder<State, LEN, Wa, Tag>
|
||||
impl<State: StateLike<State>, const LEN: usize, Wa: WidgetArrLike<State, LEN, Tag>, Tag>
|
||||
WidgetFnTrait<State> for SpanBuilder<State, LEN, Wa, Tag>
|
||||
{
|
||||
type Output = Span;
|
||||
type Widget = Span;
|
||||
|
||||
extern "rust-call" fn call_once(self, args: (&mut State,)) -> Self::Output {
|
||||
#[track_caller]
|
||||
fn run(self, state: &mut State) -> Self::Widget {
|
||||
Span {
|
||||
children: self.children.add(args.0).arr.into_iter().collect(),
|
||||
children: self.children.add(state).arr.into_iter().collect(),
|
||||
dir: self.dir,
|
||||
gap: self.gap,
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ impl<State: HasUi + StateLike<State>, O> TextBuilder<State, O> {
|
||||
TextBuilder {
|
||||
content: self.content,
|
||||
attrs: self.attrs,
|
||||
hint: move |ui: &mut State| Some(hint.add(ui).any()),
|
||||
hint: move |ui: &mut State| Some(hint.add_strong(ui).any()),
|
||||
output: self.output,
|
||||
state: PhantomData,
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@ widget_trait! {
|
||||
fn pad(self, padding: impl Into<Padding>) -> impl WidgetFn<State, Pad> {
|
||||
|state| Pad {
|
||||
padding: padding.into(),
|
||||
inner: self.add(state),
|
||||
inner: self.add_strong(state),
|
||||
}
|
||||
}
|
||||
|
||||
fn align(self, align: impl Into<Align>) -> impl WidgetFn<State, Aligned> {
|
||||
move |state| Aligned {
|
||||
inner: self.add(state),
|
||||
inner: self.add_strong(state),
|
||||
align: align.into(),
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ widget_trait! {
|
||||
fn label(self, label: impl Into<String>) -> impl WidgetIdFn<State, WL::Widget> {
|
||||
|state| {
|
||||
let id = self.add(state);
|
||||
state.get_mut().set_label(&id, label.into());
|
||||
state.get_mut().set_label(id, label.into());
|
||||
id
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ widget_trait! {
|
||||
fn sized(self, size: impl Into<Size>) -> impl WidgetFn<State, Sized> {
|
||||
let size = size.into();
|
||||
move |state| Sized {
|
||||
inner: self.add(state),
|
||||
inner: self.add_strong(state),
|
||||
x: Some(size.x),
|
||||
y: Some(size.y),
|
||||
}
|
||||
@@ -43,7 +43,7 @@ widget_trait! {
|
||||
fn max_width(self, len: impl Into<Len>) -> impl WidgetFn<State, MaxSize> {
|
||||
let len = len.into();
|
||||
move |state| MaxSize {
|
||||
inner: self.add(state),
|
||||
inner: self.add_strong(state),
|
||||
x: Some(len),
|
||||
y: None,
|
||||
}
|
||||
@@ -52,7 +52,7 @@ widget_trait! {
|
||||
fn max_height(self, len: impl Into<Len>) -> impl WidgetFn<State, MaxSize> {
|
||||
let len = len.into();
|
||||
move |state| MaxSize {
|
||||
inner: self.add(state),
|
||||
inner: self.add_strong(state),
|
||||
x: None,
|
||||
y: Some(len),
|
||||
}
|
||||
@@ -61,7 +61,7 @@ widget_trait! {
|
||||
fn width(self, len: impl Into<Len>) -> impl WidgetFn<State, Sized> {
|
||||
let len = len.into();
|
||||
move |state| Sized {
|
||||
inner: self.add(state),
|
||||
inner: self.add_strong(state),
|
||||
x: Some(len),
|
||||
y: None,
|
||||
}
|
||||
@@ -70,7 +70,7 @@ widget_trait! {
|
||||
fn height(self, len: impl Into<Len>) -> impl WidgetFn<State, Sized> {
|
||||
let len = len.into();
|
||||
move |state| Sized {
|
||||
inner: self.add(state),
|
||||
inner: self.add_strong(state),
|
||||
x: None,
|
||||
y: Some(len),
|
||||
}
|
||||
@@ -78,7 +78,7 @@ widget_trait! {
|
||||
|
||||
fn offset(self, amt: impl Into<UiVec2>) -> impl WidgetFn<State, Offset> {
|
||||
move |state| Offset {
|
||||
inner: self.add(state),
|
||||
inner: self.add_strong(state),
|
||||
amt: amt.into(),
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ widget_trait! {
|
||||
fn scrollable(self) -> impl WidgetIdFn<State, Scroll> where State: HasEvents {
|
||||
use eventable::*;
|
||||
move |state| {
|
||||
Scroll::new(self.add(state), Axis::Y)
|
||||
Scroll::new(self.add_strong(state), Axis::Y)
|
||||
.on(CursorSense::Scroll, |ctx: &mut EventIdCtx<'_, State::State, CursorData<'_>, Scroll>| {
|
||||
let delta = ctx.data.scroll_delta.y * 50.0;
|
||||
ctx.widget().scroll(delta);
|
||||
@@ -97,27 +97,27 @@ widget_trait! {
|
||||
|
||||
fn masked(self) -> impl WidgetFn<State, Masked> {
|
||||
move |state| Masked {
|
||||
inner: self.add(state),
|
||||
inner: self.add_strong(state),
|
||||
}
|
||||
}
|
||||
|
||||
fn background<T>(self, w: impl WidgetLike<State, T>) -> impl WidgetFn<State, Stack> {
|
||||
move |state| Stack {
|
||||
children: vec![w.add(state), self.add(state)],
|
||||
children: vec![w.add_strong(state), self.add_strong(state)],
|
||||
size: StackSize::Child(1),
|
||||
}
|
||||
}
|
||||
|
||||
fn foreground<T>(self, w: impl WidgetLike<State, T>) -> impl WidgetFn<State, Stack> {
|
||||
move |state| Stack {
|
||||
children: vec![self.add(state), w.add(state)],
|
||||
children: vec![self.add_strong(state), w.add_strong(state)],
|
||||
size: StackSize::Child(0),
|
||||
}
|
||||
}
|
||||
|
||||
fn layer_offset(self, offset: usize) -> impl WidgetFn<State, LayerOffset> {
|
||||
move |state| LayerOffset {
|
||||
inner: self.add(state),
|
||||
inner: self.add_strong(state),
|
||||
offset,
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ widget_trait! {
|
||||
}
|
||||
|
||||
fn set_ptr(self, ptr: WidgetRef<WidgetPtr>, state: &mut State) {
|
||||
let id = self.add(state);
|
||||
let id = self.add_strong(state);
|
||||
state.get_mut()[ptr].inner = Some(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user