better global state structure?
This commit is contained in:
@@ -3,7 +3,7 @@ use crate::prelude::*;
|
||||
|
||||
// these methods should "not require any context" (require unit) because they're in core
|
||||
widget_trait! {
|
||||
pub trait CoreWidget<State: HasUi>;
|
||||
pub trait CoreWidget<State: HasUi + 'static>;
|
||||
|
||||
fn pad(self, padding: impl Into<Padding>) -> impl WidgetFn<State, Pad> {
|
||||
|state| Pad {
|
||||
@@ -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.ui().set_label(&id, label.into());
|
||||
state.get_mut().set_label(&id, label.into());
|
||||
id
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,7 @@ widget_trait! {
|
||||
use eventable::*;
|
||||
move |state| {
|
||||
Scroll::new(self.add(state), Axis::Y)
|
||||
.on(CursorSense::Scroll, |mut ctx| {
|
||||
.on(CursorSense::Scroll, |ctx: &mut EventIdCtx<'_, State::State, CursorData<'_>, Scroll>| {
|
||||
let delta = ctx.data.scroll_delta.y * 50.0;
|
||||
ctx.widget().scroll(delta);
|
||||
})
|
||||
@@ -128,7 +128,7 @@ widget_trait! {
|
||||
|
||||
fn set_ptr(self, ptr: WidgetRef<WidgetPtr>, state: &mut State) {
|
||||
let id = self.add(state);
|
||||
state.ui()[ptr].inner = Some(id);
|
||||
state.get_mut()[ptr].inner = Some(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user