✨ Añade acciones base y renderizado de componentes
- Añade acciones BeforeRender y AfterRender para ejecutar código personalizado antes y después de renderizar un componente. - Introduce la acción PrepareRender para personalizar totalmente el renderizado de un componente. - Se actualizan las definiciones de acciones para utilizar el nuevo "trait" ActionDispatcher. - Se crea un nuevo trait ComponentTrait para definir componentes renderizables. - Se implementan las estructuras Children y Child para gestionar componentes hijos dentro de un componente padre. - Se añade OptionComponent para encapsular de forma segura componentes opcionales y poder usarlos en otros componentes.
This commit is contained in:
parent
36ddbd7ecf
commit
8e67065aae
28 changed files with 1102 additions and 147 deletions
|
|
@ -1,9 +1,9 @@
|
|||
use crate::core::action::{ActionBox, ActionTrait};
|
||||
use crate::core::action::{ActionBox, ActionDispatcher};
|
||||
use crate::core::AnyCast;
|
||||
use crate::trace;
|
||||
use crate::AutoDefault;
|
||||
|
||||
use std::sync::RwLock;
|
||||
use parking_lot::RwLock;
|
||||
|
||||
#[derive(AutoDefault)]
|
||||
pub struct ActionsList(RwLock<Vec<ActionBox>>);
|
||||
|
|
@ -14,7 +14,7 @@ impl ActionsList {
|
|||
}
|
||||
|
||||
pub fn add(&mut self, action: ActionBox) {
|
||||
let mut list = self.0.write().unwrap();
|
||||
let mut list = self.0.write();
|
||||
list.push(action);
|
||||
list.sort_by_key(|a| a.weight());
|
||||
}
|
||||
|
|
@ -22,13 +22,12 @@ impl ActionsList {
|
|||
pub fn iter_map<A, B, F>(&self, mut f: F)
|
||||
where
|
||||
Self: Sized,
|
||||
A: ActionTrait,
|
||||
A: ActionDispatcher,
|
||||
F: FnMut(&A) -> B,
|
||||
{
|
||||
let _: Vec<_> = self
|
||||
.0
|
||||
.read()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.rev()
|
||||
.map(|a| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue