switch to macro
This commit is contained in:
11
src/event.rs
11
src/event.rs
@@ -35,15 +35,8 @@ pub use event_ctx;
|
||||
pub mod eventable {
|
||||
use super::*;
|
||||
|
||||
pub trait Eventable<W, Tag> {
|
||||
fn on<E: Event, Ctx: 'static>(
|
||||
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 {
|
||||
widget_trait! {
|
||||
pub trait Eventable;
|
||||
fn on<E: Event, Ctx: 'static>(
|
||||
self,
|
||||
event: E,
|
||||
|
||||
@@ -4,26 +4,9 @@ use crate::prelude::*;
|
||||
// these methods should "not require any context" (require unit) because they're in core
|
||||
event_ctx!(());
|
||||
|
||||
pub trait CoreWidget<W, Tag> {
|
||||
fn pad(self, padding: impl Into<Padding>) -> impl WidgetFn<Pad>;
|
||||
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;
|
||||
}
|
||||
widget_trait! {
|
||||
pub trait CoreWidget;
|
||||
|
||||
impl<W: WidgetLike<Tag>, Tag> CoreWidget<W::Widget, Tag> for W {
|
||||
fn pad(self, padding: impl Into<Padding>) -> impl WidgetFn<Pad> {
|
||||
|ui| Pad {
|
||||
padding: padding.into(),
|
||||
@@ -42,7 +25,7 @@ impl<W: WidgetLike<Tag>, Tag> CoreWidget<W::Widget, Tag> for W {
|
||||
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| {
|
||||
let id = self.add(ui);
|
||||
ui.set_label(&id, label.into());
|
||||
|
||||
Reference in New Issue
Block a user