fix reactivity 😭 + visual widget counter
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
use super::*;
|
||||
use crate::layout::{Dir, UiPos, UiRegion, Vec2, WidgetArrLike, WidgetFnRet, WidgetLike};
|
||||
use crate::layout::{
|
||||
Dir, UiPos, UiRegion, Vec2, WidgetArrLike, WidgetFnRet, WidgetIdFnRet, WidgetLike,
|
||||
};
|
||||
|
||||
pub trait CoreWidget<W: 'static, Ctx: 'static, Tag> {
|
||||
pub trait CoreWidget<W, Ctx: 'static, Tag> {
|
||||
fn pad(self, padding: impl Into<Padding>) -> WidgetFnRet!(Regioned, Ctx);
|
||||
fn center(self, size: impl Into<Vec2>) -> WidgetFnRet!(Regioned, Ctx);
|
||||
fn region(self, region: UiRegion) -> WidgetFnRet!(Regioned, Ctx);
|
||||
fn label(self, label: impl Into<String>) -> WidgetIdFnRet!(W, Ctx);
|
||||
}
|
||||
|
||||
impl<W: WidgetLike<Ctx, Tag>, Ctx: 'static, Tag> CoreWidget<W::Widget, Ctx, Tag> for W {
|
||||
@@ -28,6 +31,14 @@ impl<W: WidgetLike<Ctx, Tag>, Ctx: 'static, Tag> CoreWidget<W::Widget, Ctx, Tag>
|
||||
inner: self.add(ui).erase_type(),
|
||||
}
|
||||
}
|
||||
|
||||
fn label(self, label: impl Into<String>) -> WidgetIdFnRet!(W::Widget, Ctx) {
|
||||
|ui| {
|
||||
let id = self.add(ui);
|
||||
ui.set_label(&id, label.into());
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait CoreWidgetArr<const LEN: usize, Ctx: 'static, Tag> {
|
||||
|
||||
Reference in New Issue
Block a user