switch to macro

This commit is contained in:
2025-12-11 05:31:34 -05:00
parent 2dc5b0f62c
commit 174c447706
2 changed files with 5 additions and 29 deletions

View File

@@ -35,15 +35,8 @@ pub use event_ctx;
pub mod eventable { pub mod eventable {
use super::*; use super::*;
pub trait Eventable<W, Tag> { widget_trait! {
fn on<E: Event, Ctx: 'static>( pub trait Eventable;
self,
event: E,
f: impl WidgetEventFn<Ctx, E::Data, W>,
) -> impl WidgetIdFn<W> + Eventable<W, IdFnTag>;
}
impl<WL: WidgetLike<Tag>, Tag> Eventable<WL::Widget, Tag> for WL {
fn on<E: Event, Ctx: 'static>( fn on<E: Event, Ctx: 'static>(
self, self,
event: E, event: E,

View File

@@ -4,26 +4,9 @@ use crate::prelude::*;
// these methods should "not require any context" (require unit) because they're in core // these methods should "not require any context" (require unit) because they're in core
event_ctx!(()); event_ctx!(());
pub trait CoreWidget<W, Tag> { widget_trait! {
fn pad(self, padding: impl Into<Padding>) -> impl WidgetFn<Pad>; pub trait CoreWidget;
fn align(self, align: impl Into<Align>) -> impl WidgetFn<Aligned>;
fn center(self) -> impl WidgetFn<Aligned>;
fn label(self, label: impl Into<String>) -> impl WidgetIdFn<W>;
fn sized(self, size: impl Into<Size>) -> impl WidgetFn<Sized>;
fn width(self, len: impl Into<Len>) -> impl WidgetFn<Sized>;
fn height(self, len: impl Into<Len>) -> impl WidgetFn<Sized>;
fn max_width(self, width: impl Into<Len>) -> impl WidgetFn<MaxSize>;
fn max_height(self, height: impl Into<Len>) -> impl WidgetFn<MaxSize>;
fn offset(self, amt: impl Into<UiVec2>) -> impl WidgetFn<Offset>;
fn scroll(self) -> impl WidgetIdFn<Scroll>;
fn masked(self) -> impl WidgetFn<Masked>;
fn background<T>(self, w: impl WidgetLike<T>) -> impl WidgetFn<Stack>;
fn foreground<T>(self, w: impl WidgetLike<T>) -> impl WidgetFn<Stack>;
fn layer_offset(self, offset: usize) -> impl WidgetFn<LayerOffset>;
fn to_any(self) -> impl WidgetRet;
}
impl<W: WidgetLike<Tag>, Tag> CoreWidget<W::Widget, Tag> for W {
fn pad(self, padding: impl Into<Padding>) -> impl WidgetFn<Pad> { fn pad(self, padding: impl Into<Padding>) -> impl WidgetFn<Pad> {
|ui| Pad { |ui| Pad {
padding: padding.into(), padding: padding.into(),
@@ -42,7 +25,7 @@ impl<W: WidgetLike<Tag>, Tag> CoreWidget<W::Widget, Tag> for W {
self.align(Align::CENTER) self.align(Align::CENTER)
} }
fn label(self, label: impl Into<String>) -> impl WidgetIdFn<W::Widget> { fn label(self, label: impl Into<String>) -> impl WidgetIdFn<WL::Widget> {
|ui| { |ui| {
let id = self.add(ui); let id = self.add(ui);
ui.set_label(&id, label.into()); ui.set_label(&id, label.into());