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 {
|
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,
|
||||||
|
|||||||
@@ -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());
|
||||||
|
|||||||
Reference in New Issue
Block a user