summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs24
-rw-r--r--src/types/element_name.rs4
-rw-r--r--src/types/project.rs7
-rwxr-xr-xsrc/types/rendered_element.rs42
4 files changed, 37 insertions, 40 deletions
diff --git a/src/main.rs b/src/main.rs
index 545f176..389c827 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -101,13 +101,14 @@ impl IcedBuilder {
let mut tasks =
vec![Task::perform(Config::load(), Message::ConfigLoad)];
- if let Some(path) = project_path.as_deref() {
- if path.exists() && path.is_file() {
- tasks.push(Task::perform(
- Project::from_path(path.to_path_buf()),
- Message::FileOpened,
- ));
- }
+ if let Some(path) = project_path.as_deref()
+ && path.exists()
+ && path.is_file()
+ {
+ tasks.push(Task::perform(
+ Project::from_path(path.to_path_buf()),
+ Message::FileOpened,
+ ));
}
(
@@ -159,10 +160,8 @@ impl IcedBuilder {
self.config = config;
self.theme.settle_at(self.config.selected_theme());
- if let Some(path) = self
- .config
- .last_project()
- .filter(|_| self.project_path.is_none())
+ if let Some(path) = self.config.last_project()
+ && self.project_path.is_none()
{
if path.exists() && path.is_file() {
return Task::perform(
@@ -378,7 +377,8 @@ impl IcedBuilder {
match result {
Ok((path, project)) => {
self.project = project;
- self.project_path = Some(path);
+ self.project_path =
+ Some(path.canonicalize().unwrap_or(path));
return Task::done(
ConfigChangeType::LastProject.into(),
diff --git a/src/types/element_name.rs b/src/types/element_name.rs
index 186285d..c824fc5 100644
--- a/src/types/element_name.rs
+++ b/src/types/element_name.rs
@@ -38,8 +38,8 @@ impl ElementName {
Self::Svg(_) => svg(""),
Self::Image(_) => image(""),
Self::Container => container(None),
- Self::Row => row(None),
- Self::Column => column(None),
+ Self::Row => row(vec![]),
+ Self::Column => column(vec![]),
};
match action {
Action::Stop | Action::Drop => Ok(None),
diff --git a/src/types/project.rs b/src/types/project.rs
index 9f78445..5bd986f 100644
--- a/src/types/project.rs
+++ b/src/types/project.rs
@@ -66,9 +66,10 @@ impl Project {
use tokio::fs;
let path = if let Some(p) = path {
- let parent = p.parent();
- if parent.is_some_and(|parent| !parent.exists()) {
- fs::create_dir_all(parent.unwrap()).await?;
+ if let Some(parent) = p.parent()
+ && !parent.exists()
+ {
+ fs::create_dir_all(parent).await?;
}
p
diff --git a/src/types/rendered_element.rs b/src/types/rendered_element.rs
index b7fd839..be2a004 100755
--- a/src/types/rendered_element.rs
+++ b/src/types/rendered_element.rs
@@ -95,12 +95,11 @@ impl RenderedElement {
let Some(parent) = self.find_parent(element) else {
return;
};
- if let Some(child_elements) = parent.child_elements.as_mut() {
- if let Some(index) =
+ if let Some(child_elements) = parent.child_elements.as_mut()
+ && let Some(index) =
child_elements.iter().position(|x| x == element)
- {
- let _ = child_elements.remove(index);
- }
+ {
+ let _ = child_elements.remove(index);
}
}
@@ -525,25 +524,22 @@ pub fn container(content: Option<RenderedElement>) -> RenderedElement {
])
}
-pub fn row(child_elements: Option<Vec<RenderedElement>>) -> RenderedElement {
- RenderedElement::with(ElementName::Row, child_elements.unwrap_or_default())
- .preset_options(&[
- "spacing", "padding", "width", "height", "align_y", "clip",
- ])
+pub fn row(child_elements: Vec<RenderedElement>) -> RenderedElement {
+ RenderedElement::with(ElementName::Row, child_elements).preset_options(&[
+ "spacing", "padding", "width", "height", "align_y", "clip",
+ ])
}
-pub fn column(child_elements: Option<Vec<RenderedElement>>) -> RenderedElement {
- RenderedElement::with(
- ElementName::Column,
- child_elements.unwrap_or_default(),
+pub fn column(child_elements: Vec<RenderedElement>) -> RenderedElement {
+ RenderedElement::with(ElementName::Column, child_elements).preset_options(
+ &[
+ "spacing",
+ "padding",
+ "width",
+ "height",
+ "max_width",
+ "align_x",
+ "clip",
+ ],
)
- .preset_options(&[
- "spacing",
- "padding",
- "width",
- "height",
- "max_width",
- "align_x",
- "clip",
- ])
}