diff --git a/src/elements/button.rs b/src/elements/button.rs index d4f8932..0d8d5ed 100644 --- a/src/elements/button.rs +++ b/src/elements/button.rs @@ -116,7 +116,7 @@ impl ButtonBuilder { self } - pub fn build(self, gui_handler: Arc) -> Result> { + pub fn build(self, gui_handler: Arc>) -> Result>> { let framable = Framable::new(gui_handler.clone(), false)?; let normal = FillType::new( @@ -150,7 +150,7 @@ impl ButtonBuilder { let clickable = Clickable::new(framable.clone(), click_executable.clone()); let selectable = Selectable::new( - gui_handler, + &gui_handler, click_executable.clone(), select_executable.clone(), on_select_executable.clone(), @@ -253,10 +253,10 @@ pub enum ButtonSelectMode { Bigger, } -pub struct Button { +pub struct Button<'a> { clickable: Arc, hoverable: Arc, - selectable: Arc, + selectable: Arc>, framable: Arc, iconizable: IconizableWrapper, textable: TextableWrapper, @@ -280,7 +280,7 @@ pub struct Button { visible: AtomicBool, } -impl Button { +impl<'a> Button<'a> { pub fn builder() -> ButtonBuilder { ButtonBuilder { icon: None, @@ -366,7 +366,10 @@ impl Button { self.textable.set_text_color(text_color) } - pub fn try_from(button_info: &ButtonInfo, gui_handler: &Arc) -> Result> { + pub fn try_from( + button_info: &ButtonInfo, + gui_handler: &Arc>, + ) -> Result> { let mut button_builder = Button::builder() .set_select_mode(button_info.select_mode) .set_isolate(button_info.isolate); @@ -423,7 +426,7 @@ impl Button { } } -impl GuiElementTraits for Button { +impl<'a> GuiElementTraits for Button<'a> { fn gridable(&self) -> Option<&dyn Gridable> { Some(self) } @@ -432,12 +435,12 @@ impl GuiElementTraits for Button { Some(self) } - fn downcast<'a>(&'a self) -> Option> { + fn downcast<'b>(&'b self) -> Option> { Some(GuiElement::Button(self)) } } -impl Visibility for Button { +impl<'a> Visibility for Button<'a> { fn visible(&self) -> bool { self.visible.load(SeqCst) } @@ -469,7 +472,7 @@ impl Visibility for Button { } } -impl Gridable for Button { +impl<'a> Gridable for Button<'a> { fn set_frame( &self, x: i32, @@ -494,7 +497,7 @@ impl Gridable for Button { Ok(()) } - fn selectable(&self) -> Option<&Arc> { + fn selectable(&self) -> Option<&Arc>> { Some(&self.selectable) } @@ -522,7 +525,7 @@ impl Gridable for Button { } } -impl Drop for Button { +impl<'a> Drop for Button<'a> { fn drop(&mut self) { if self.visible.load(SeqCst) { self.disable_base().unwrap(); @@ -531,7 +534,7 @@ impl Drop for Button { } // private -impl Button { +impl<'a> Button<'a> { // fn create_hovered_changed_callback(button: Arc