changed inputs for second section and implemented Clone and Copy traits for Alignment data structure

This commit is contained in:
2024-04-14 20:13:15 +04:00
parent 5687d6773a
commit 48057646a8
11 changed files with 399 additions and 433 deletions

View File

@@ -1,30 +1,29 @@
use crate::{
model::model::*,
gtk::{
*,
prelude::*
},
};
use crate::{gtk::prelude::*, model::model::*};
impl<F, C> EventHandler<F, C>
where F: Fn(&C) + FnOnce(&C) + FnMut(&C){
pub fn new(component: C, callback: F) -> EventHandler<F, C>{
Self{
where
F: Fn(&C) + FnOnce(&C) + FnMut(&C),
{
pub fn new(component: C, callback: F) -> EventHandler<F, C> {
Self {
component,
callback,
}
}
}
pub trait BtnEventHandler{
pub trait BtnEventHandler {
fn on_click(self) -> ();
}
impl<F, C> BtnEventHandler for EventHandler<F, C>
where F: Fn(&C) + FnOnce(&C) + FnMut(&C) + 'static, C: ButtonExt + WidgetExt{
where
F: Fn(&C) + FnOnce(&C) + FnMut(&C) + 'static,
C: ButtonExt + WidgetExt,
{
fn on_click(self) -> () {
self.component.connect_clicked(move |button| {
(self.callback)(button)
});
self.component
.connect_clicked(move |button| (self.callback)(button));
}
}
}