♻️ Rename smart pointers components for clarity

This commit is contained in:
Manuel Cillero 2024-03-04 22:21:40 +01:00
parent 9a5618ef4b
commit d80a594cf5
18 changed files with 151 additions and 155 deletions

View file

@ -8,7 +8,7 @@ pub struct Block {
renderable: Renderable,
classes : OptionClasses,
title : OptionTranslated,
stuff : AnyComponents,
stuff : MixedComponents,
}
impl ComponentTrait for Block {
@ -78,12 +78,12 @@ impl Block {
#[rustfmt::skip]
pub fn add_component(mut self, component: impl ComponentTrait) -> Self {
self.stuff.alter_value(ArcAnyOp::Add(ArcAnyComponent::new(component)));
self.stuff.alter_value(OneOp::Add(OneComponent::with(component)));
self
}
#[fn_builder]
pub fn alter_components(&mut self, op: ArcAnyOp) -> &mut Self {
pub fn alter_components(&mut self, op: OneOp) -> &mut Self {
self.stuff.alter_value(op);
self
}
@ -94,7 +94,7 @@ impl Block {
&self.title
}
pub fn components(&self) -> &AnyComponents {
pub fn components(&self) -> &MixedComponents {
&self.stuff
}
}

View file

@ -7,7 +7,7 @@ pub struct Container {
weight : Weight,
renderable : Renderable,
classes : OptionClasses,
items : TypedComponents<flex::Item>,
items : VectorComponents<flex::Item>,
direction : flex::Direction,
wrap_align : flex::WrapAlign,
content_justify: flex::ContentJustify,
@ -84,12 +84,12 @@ impl Container {
#[rustfmt::skip]
pub fn add_item(mut self, item: flex::Item) -> Self {
self.items.alter_value(ArcTypedOp::Add(ArcTypedComponent::new(item)));
self.items.alter_value(TypedOp::Add(TypedComponent::with(item)));
self
}
#[fn_builder]
pub fn alter_items(&mut self, op: ArcTypedOp<flex::Item>) -> &mut Self {
pub fn alter_items(&mut self, op: TypedOp<flex::Item>) -> &mut Self {
self.items.alter_value(op);
self
}
@ -126,7 +126,7 @@ impl Container {
// Container GETTERS.
pub fn items(&self) -> &TypedComponents<flex::Item> {
pub fn items(&self) -> &VectorComponents<flex::Item> {
&self.items
}

View file

@ -12,7 +12,7 @@ pub struct Item {
item_size : flex::ItemSize,
item_offset : flex::ItemOffset,
item_align : flex::ItemAlign,
stuff : AnyComponents,
stuff : MixedComponents,
}
impl ComponentTrait for Item {
@ -115,12 +115,12 @@ impl Item {
#[rustfmt::skip]
pub fn add_component(mut self, component: impl ComponentTrait) -> Self {
self.stuff.alter_value(ArcAnyOp::Add(ArcAnyComponent::new(component)));
self.stuff.alter_value(OneOp::Add(OneComponent::with(component)));
self
}
#[fn_builder]
pub fn alter_components(&mut self, op: ArcAnyOp) -> &mut Self {
pub fn alter_components(&mut self, op: OneOp) -> &mut Self {
self.stuff.alter_value(op);
self
}
@ -147,7 +147,7 @@ impl Item {
&self.item_align
}
pub fn components(&self) -> &AnyComponents {
pub fn components(&self) -> &MixedComponents {
&self.stuff
}
}

View file

@ -17,7 +17,7 @@ pub struct Form {
action : OptionString,
charset : OptionString,
method : FormMethod,
stuff : AnyComponents,
stuff : MixedComponents,
}
impl ComponentTrait for Form {
@ -99,12 +99,12 @@ impl Form {
#[rustfmt::skip]
pub fn add_element(mut self, element: impl ComponentTrait) -> Self {
self.stuff.alter_value(ArcAnyOp::Add(ArcAnyComponent::new(element)));
self.stuff.alter_value(OneOp::Add(OneComponent::with(element)));
self
}
#[fn_builder]
pub fn alter_elements(&mut self, op: ArcAnyOp) -> &mut Self {
pub fn alter_elements(&mut self, op: OneOp) -> &mut Self {
self.stuff.alter_value(op);
self
}
@ -123,7 +123,7 @@ impl Form {
&self.method
}
pub fn elements(&self) -> &AnyComponents {
pub fn elements(&self) -> &MixedComponents {
&self.stuff
}
}

View file

@ -2,8 +2,8 @@ use crate::prelude::*;
use super::Submenu;
type Content = ArcTypedComponent<Html>;
type SubmenuItems = ArcTypedComponent<Submenu>;
type Content = TypedComponent<Html>;
type SubmenuItems = TypedComponent<Submenu>;
#[derive(AutoDefault)]
pub enum ElementType {
@ -52,14 +52,14 @@ impl ComponentTrait for Element {
impl Element {
pub fn html(content: Html) -> Self {
Element {
element_type: ElementType::Html(Content::new(content)),
element_type: ElementType::Html(Content::with(content)),
..Default::default()
}
}
pub fn submenu(submenu: Submenu) -> Self {
Element {
element_type: ElementType::Submenu(SubmenuItems::new(submenu)),
element_type: ElementType::Submenu(SubmenuItems::with(submenu)),
..Default::default()
}
}

View file

@ -8,7 +8,7 @@ pub struct Group {
id : OptionId,
weight : Weight,
renderable: Renderable,
elements : TypedComponents<Element>,
elements : VectorComponents<Element>,
}
impl ComponentTrait for Group {
@ -60,19 +60,19 @@ impl Group {
#[rustfmt::skip]
pub fn add_element(mut self, element: Element) -> Self {
self.elements.alter_value(ArcTypedOp::Add(ArcTypedComponent::new(element)));
self.elements.alter_value(TypedOp::Add(TypedComponent::with(element)));
self
}
#[fn_builder]
pub fn alter_elements(&mut self, op: ArcTypedOp<Element>) -> &mut Self {
pub fn alter_elements(&mut self, op: TypedOp<Element>) -> &mut Self {
self.elements.alter_value(op);
self
}
// Group GETTERS.
pub fn elements(&self) -> &TypedComponents<Element> {
pub fn elements(&self) -> &VectorComponents<Element> {
&self.elements
}
}

View file

@ -3,9 +3,9 @@ use crate::prelude::*;
use super::{Megamenu, Submenu};
type Label = L10n;
type Content = ArcTypedComponent<Html>;
type SubmenuItems = ArcTypedComponent<Submenu>;
type MegamenuGroups = ArcTypedComponent<Megamenu>;
type Content = TypedComponent<Html>;
type SubmenuItems = TypedComponent<Submenu>;
type MegamenuGroups = TypedComponent<Megamenu>;
#[derive(AutoDefault)]
pub enum ItemType {
@ -135,21 +135,21 @@ impl Item {
pub fn html(content: Html) -> Self {
Item {
item_type: ItemType::Html(Content::new(content)),
item_type: ItemType::Html(Content::with(content)),
..Default::default()
}
}
pub fn submenu(label: L10n, submenu: Submenu) -> Self {
Item {
item_type: ItemType::Submenu(label, SubmenuItems::new(submenu)),
item_type: ItemType::Submenu(label, SubmenuItems::with(submenu)),
..Default::default()
}
}
pub fn megamenu(label: L10n, megamenu: Megamenu) -> Self {
Item {
item_type: ItemType::Megamenu(label, MegamenuGroups::new(megamenu)),
item_type: ItemType::Megamenu(label, MegamenuGroups::with(megamenu)),
..Default::default()
}
}

View file

@ -8,7 +8,7 @@ pub struct Megamenu {
id : OptionId,
weight : Weight,
renderable: Renderable,
groups : TypedComponents<Group>,
groups : VectorComponents<Group>,
}
impl ComponentTrait for Megamenu {
@ -60,19 +60,19 @@ impl Megamenu {
#[rustfmt::skip]
pub fn add_group(mut self, group: Group) -> Self {
self.groups.alter_value(ArcTypedOp::Add(ArcTypedComponent::new(group)));
self.groups.alter_value(TypedOp::Add(TypedComponent::with(group)));
self
}
#[fn_builder]
pub fn alter_groups(&mut self, op: ArcTypedOp<Group>) -> &mut Self {
pub fn alter_groups(&mut self, op: TypedOp<Group>) -> &mut Self {
self.groups.alter_value(op);
self
}
// Megamenu GETTERS.
pub fn groups(&self) -> &TypedComponents<Group> {
pub fn groups(&self) -> &VectorComponents<Group> {
&self.groups
}
}

View file

@ -8,7 +8,7 @@ pub struct Menu {
id : OptionId,
weight : Weight,
renderable: Renderable,
items : TypedComponents<Item>,
items : VectorComponents<Item>,
}
impl ComponentTrait for Menu {
@ -88,19 +88,19 @@ impl Menu {
#[rustfmt::skip]
pub fn add_item(mut self, item: Item) -> Self {
self.items.alter_value(ArcTypedOp::Add(ArcTypedComponent::new(item)));
self.items.alter_value(TypedOp::Add(TypedComponent::with(item)));
self
}
#[fn_builder]
pub fn alter_items(&mut self, op: ArcTypedOp<Item>) -> &mut Self {
pub fn alter_items(&mut self, op: TypedOp<Item>) -> &mut Self {
self.items.alter_value(op);
self
}
// Menu GETTERS.
pub fn items(&self) -> &TypedComponents<Item> {
pub fn items(&self) -> &VectorComponents<Item> {
&self.items
}
}

View file

@ -9,7 +9,7 @@ pub struct Submenu {
weight : Weight,
renderable: Renderable,
title : OptionTranslated,
items : TypedComponents<Item>,
items : VectorComponents<Item>,
}
impl ComponentTrait for Submenu {
@ -72,12 +72,12 @@ impl Submenu {
#[rustfmt::skip]
pub fn add_item(mut self, item: Item) -> Self {
self.items.alter_value(ArcTypedOp::Add(ArcTypedComponent::new(item)));
self.items.alter_value(TypedOp::Add(TypedComponent::with(item)));
self
}
#[fn_builder]
pub fn alter_items(&mut self, op: ArcTypedOp<Item>) -> &mut Self {
pub fn alter_items(&mut self, op: TypedOp<Item>) -> &mut Self {
self.items.alter_value(op);
self
}
@ -88,7 +88,7 @@ impl Submenu {
&self.title
}
pub fn items(&self) -> &TypedComponents<Item> {
pub fn items(&self) -> &VectorComponents<Item> {
&self.items
}
}

View file

@ -8,7 +8,7 @@ pub struct Paragraph {
renderable: Renderable,
classes : OptionClasses,
font_size : FontSize,
stuff : AnyComponents,
stuff : MixedComponents,
}
impl ComponentTrait for Paragraph {
@ -81,18 +81,18 @@ impl Paragraph {
#[rustfmt::skip]
pub fn add_component(mut self, component: impl ComponentTrait) -> Self {
self.stuff.alter_value(ArcAnyOp::Add(ArcAnyComponent::new(component)));
self.stuff.alter_value(OneOp::Add(OneComponent::with(component)));
self
}
#[rustfmt::skip]
pub fn add_translated(mut self, l10n: L10n) -> Self {
self.stuff.alter_value(ArcAnyOp::Add(ArcAnyComponent::new(Translate::with(l10n))));
self.stuff.alter_value(OneOp::Add(OneComponent::with(Translate::with(l10n))));
self
}
#[fn_builder]
pub fn alter_components(&mut self, op: ArcAnyOp) -> &mut Self {
pub fn alter_components(&mut self, op: OneOp) -> &mut Self {
self.stuff.alter_value(op);
self
}
@ -103,7 +103,7 @@ impl Paragraph {
&self.font_size
}
pub fn components(&self) -> &AnyComponents {
pub fn components(&self) -> &MixedComponents {
&self.stuff
}
}

View file

@ -18,7 +18,7 @@ pub struct Wrapper {
renderable : Renderable,
classes : OptionClasses,
wrapper_type : WrapperType,
stuff : AnyComponents,
stuff : MixedComponents,
}
impl ComponentTrait for Wrapper {
@ -126,12 +126,12 @@ impl Wrapper {
#[rustfmt::skip]
pub fn add_component(mut self, component: impl ComponentTrait) -> Self {
self.stuff.alter_value(ArcAnyOp::Add(ArcAnyComponent::new(component)));
self.stuff.alter_value(OneOp::Add(OneComponent::with(component)));
self
}
#[fn_builder]
pub fn alter_components(&mut self, op: ArcAnyOp) -> &mut Self {
pub fn alter_components(&mut self, op: OneOp) -> &mut Self {
self.stuff.alter_value(op);
self
}
@ -142,7 +142,7 @@ impl Wrapper {
&self.wrapper_type
}
pub fn components(&self) -> &AnyComponents {
pub fn components(&self) -> &MixedComponents {
&self.stuff
}
}