diff --git a/hui-examples/examples/test.rs b/hui-examples/examples/test.rs index b139cd8..b784490 100644 --- a/hui-examples/examples/test.rs +++ b/hui-examples/examples/test.rs @@ -6,15 +6,13 @@ use winit::{ event_loop::{EventLoopBuilder, ControlFlow} }; use hui::{ - UiInstance, + UiInstance, UiSize, UiDirection, element::{ UiElement, progress_bar::ProgressBar, container::{Container, Sides, Alignment}, rect::Rect }, - interaction::IntoInteractable, - UiSize, UiDirection, }; use hui_glium::GliumUiRenderer; @@ -122,9 +120,7 @@ fn main() { Box::new(Rect { size: (UiSize::Static(50.), UiSize::Static(50.)), color: Some(vec4(1., 1., 1., 0.75)) - }.into_interactable().on_click(|| { - println!("clicked"); - })) + }), ], ..Default::default() }) diff --git a/hui/src/interaction.rs b/hui/src/interaction.rs index ee5412a..059f299 100644 --- a/hui/src/interaction.rs +++ b/hui/src/interaction.rs @@ -1,51 +1,51 @@ -use crate::element::{UiElement, MeasureContext, ProcessContext}; +// use crate::element::{UiElement, MeasureContext, ProcessContext}; -pub struct Interactable { - pub element: T, - pub hovered: Option>, - pub clicked: Option>, -} +// pub struct Interactable { +// pub element: T, +// pub hovered: Option>, +// pub clicked: Option>, +// } -impl Interactable { - pub fn new(element: T) -> Self { - Self { - element, - hovered: None, - clicked: None, - } - } +// impl Interactable { +// pub fn new(element: T) -> Self { +// Self { +// element, +// hovered: None, +// clicked: None, +// } +// } - pub fn on_click(self, clicked: impl FnOnce() + 'static) -> Self { - Self { - clicked: Some(Box::new(clicked)), - ..self - } - } +// pub fn on_click(self, clicked: impl FnOnce() + 'static) -> Self { +// Self { +// clicked: Some(Box::new(clicked)), +// ..self +// } +// } - pub fn on_hover(self, clicked: impl FnOnce() + 'static) -> Self { - Self { - clicked: Some(Box::new(clicked)), - ..self - } - } -} +// pub fn on_hover(self, clicked: impl FnOnce() + 'static) -> Self { +// Self { +// clicked: Some(Box::new(clicked)), +// ..self +// } +// } +// } -impl UiElement for Interactable { - fn measure(&self, ctx: MeasureContext) -> crate::measure::Response { - self.element.measure(ctx) - } +// impl UiElement for Interactable { +// fn measure(&self, ctx: MeasureContext) -> crate::measure::Response { +// self.element.measure(ctx) +// } - fn process(&self, ctx: ProcessContext) { - self.element.process(ctx) - } -} +// fn process(&self, ctx: ProcessContext) { +// self.element.process(ctx) +// } +// } -pub trait IntoInteractable: UiElement { - fn into_interactable(self) -> Interactable; -} +// pub trait IntoInteractable: UiElement { +// fn into_interactable(self) -> Interactable; +// } -impl IntoInteractable for T { - fn into_interactable(self) -> Interactable { - Interactable::new(self) - } -} +// impl IntoInteractable for T { +// fn into_interactable(self) -> Interactable { +// Interactable::new(self) +// } +// }