💥 Standarize with() as constructor with arguments
This commit is contained in:
parent
baf683a278
commit
dd93cfb9c8
6 changed files with 12 additions and 12 deletions
|
|
@ -81,35 +81,35 @@ impl ComponentTrait for MegaItem {
|
|||
impl MegaItem {
|
||||
pub fn label(label: L10n) -> Self {
|
||||
MegaItem {
|
||||
item_type: MegaItemType::Label(OneComponent::new_with(label)),
|
||||
item_type: MegaItemType::Label(Label::with(label)),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn link(label: L10n, path: MegaItemPath) -> Self {
|
||||
MegaItem {
|
||||
item_type: MegaItemType::Link(OneComponent::new_with(label), path),
|
||||
item_type: MegaItemType::Link(Label::with(label), path),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn link_blank(label: L10n, path: MegaItemPath) -> Self {
|
||||
MegaItem {
|
||||
item_type: MegaItemType::LinkBlank(OneComponent::new_with(label), path),
|
||||
item_type: MegaItemType::LinkBlank(Label::with(label), path),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn html(content: Html) -> Self {
|
||||
MegaItem {
|
||||
item_type: MegaItemType::Html(OneComponent::new_with(content)),
|
||||
item_type: MegaItemType::Html(Content::with(content)),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn submenu(label: L10n, menu: MegaMenu) -> Self {
|
||||
MegaItem {
|
||||
item_type: MegaItemType::Submenu(OneComponent::new_with(label), menu),
|
||||
item_type: MegaItemType::Submenu(Label::with(label), menu),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ pub fn add_action(action: Action) {
|
|||
if let Some(list) = actions.get_mut(&action_handle) {
|
||||
list.add(action);
|
||||
} else {
|
||||
actions.insert(action_handle, ActionsList::new_with(action));
|
||||
actions.insert(action_handle, ActionsList::with(action));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ impl ActionsList {
|
|||
ActionsList(Arc::new(RwLock::new(Vec::new())))
|
||||
}
|
||||
|
||||
pub fn new_with(action: Action) -> Self {
|
||||
pub fn with(action: Action) -> Self {
|
||||
let mut list = ActionsList::new();
|
||||
list.add(action);
|
||||
list
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ impl<T: ComponentTrait + Default> OneComponent<T> {
|
|||
OneComponent::<T>::default()
|
||||
}
|
||||
|
||||
pub fn new_with(component: T) -> Self {
|
||||
pub fn with(component: T) -> Self {
|
||||
OneComponent(Some(Arc::new(RwLock::new(component))))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ impl PackComponents {
|
|||
PackComponents::default()
|
||||
}
|
||||
|
||||
pub fn new_with(cref: ComponentRef) -> Self {
|
||||
pub fn with(cref: ComponentRef) -> Self {
|
||||
let mut pack = PackComponents::new();
|
||||
pack.alter(PackOp::Add, cref);
|
||||
pack
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ impl ComponentsRegions {
|
|||
ComponentsRegions::default()
|
||||
}
|
||||
|
||||
pub fn new_with(region: &'static str, cref: ComponentRef) -> Self {
|
||||
pub fn with(region: &'static str, cref: ComponentRef) -> Self {
|
||||
let mut regions = ComponentsRegions::new();
|
||||
regions.add_in(region, cref);
|
||||
regions
|
||||
|
|
@ -29,7 +29,7 @@ impl ComponentsRegions {
|
|||
if let Some(region) = self.0.get_mut(region) {
|
||||
region.alter(PackOp::Add, cref);
|
||||
} else {
|
||||
self.0.insert(region, PackComponents::new_with(cref));
|
||||
self.0.insert(region, PackComponents::with(cref));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ pub fn add_component_in(region: Region, cref: ComponentRef) {
|
|||
if let Some(hm) = regions.get_mut(&theme.handle()) {
|
||||
hm.add_in(region, cref);
|
||||
} else {
|
||||
regions.insert(theme.handle(), ComponentsRegions::new_with(region, cref));
|
||||
regions.insert(theme.handle(), ComponentsRegions::with(region, cref));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue