Compare commits
1 Commits
e44bb8eca4
...
7f4846a2d3
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f4846a2d3 |
@@ -21,6 +21,7 @@ struct InputFn {
|
||||
impl Parse for Input {
|
||||
fn parse(input: ParseStream) -> Result<Self> {
|
||||
let vis = input.parse()?;
|
||||
input.parse::<Token![trait]>()?;
|
||||
let name = input.parse()?;
|
||||
input.parse::<Token![;]>()?;
|
||||
let mut fns = Vec::new();
|
||||
|
||||
@@ -1,6 +1,25 @@
|
||||
use crate::prelude::*;
|
||||
use iris_macro::widget_trait;
|
||||
|
||||
pub mod eventable {
|
||||
use super::*;
|
||||
|
||||
widget_trait! {
|
||||
pub trait Eventable;
|
||||
fn on<E: Event, Ctx: 'static>(
|
||||
self,
|
||||
event: E,
|
||||
f: impl WidgetEventFn<Ctx, E::Data, WL::Widget>,
|
||||
) -> impl WidgetIdFn<WL::Widget> {
|
||||
move |ui| {
|
||||
let id = self.add(ui);
|
||||
ui.register_widget_event(&id, event, f);
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: naming in here is a bit weird like eventable
|
||||
#[macro_export]
|
||||
macro_rules! event_ctx {
|
||||
@@ -61,22 +80,3 @@ macro_rules! event_ctx {
|
||||
};
|
||||
}
|
||||
pub use event_ctx;
|
||||
|
||||
pub mod eventable {
|
||||
use super::*;
|
||||
|
||||
widget_trait!(
|
||||
pub Eventable;
|
||||
fn on<E: Event, Ctx: 'static>(
|
||||
self,
|
||||
event: E,
|
||||
f: impl WidgetEventFn<Ctx, E::Data, WL::Widget>,
|
||||
) -> impl WidgetIdFn<WL::Widget> {
|
||||
move |ui| {
|
||||
let id = self.add(ui);
|
||||
ui.register_widget_event(&id, event, f);
|
||||
id
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
#![feature(associated_type_defaults)]
|
||||
|
||||
mod default;
|
||||
mod traits;
|
||||
mod event;
|
||||
mod widget;
|
||||
|
||||
pub use iris_core::*;
|
||||
@@ -12,7 +12,7 @@ pub use iris_macro::*;
|
||||
|
||||
pub mod prelude {
|
||||
pub use super::default::*;
|
||||
pub use super::traits::*;
|
||||
pub use super::event::*;
|
||||
pub use super::widget::*;
|
||||
|
||||
pub use iris_core::layout::*;
|
||||
|
||||
@@ -4,8 +4,8 @@ use iris_macro::widget_trait;
|
||||
// these methods should "not require any context" (require unit) because they're in core
|
||||
event_ctx!(());
|
||||
|
||||
widget_trait!(
|
||||
pub CoreWidget;
|
||||
widget_trait! {
|
||||
pub trait CoreWidget;
|
||||
|
||||
fn pad(self, padding: impl Into<Padding>) -> impl WidgetFn<Pad> {
|
||||
|ui| Pad {
|
||||
@@ -130,7 +130,7 @@ widget_trait!(
|
||||
fn set_ptr(self, ptr: &WidgetRef<WidgetPtr>, ui: &mut Ui) {
|
||||
ptr.get_mut().inner = Some(self.add(ui));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
pub trait CoreWidgetArr<const LEN: usize, Wa: WidgetArrLike<LEN, Tag>, Tag> {
|
||||
fn span(self, dir: Dir) -> SpanBuilder<LEN, Wa, Tag>;
|
||||
|
||||
Reference in New Issue
Block a user