summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/codegen/mod.rs15
-rw-r--r--src/main.rs1
-rw-r--r--src/types/mod.rs42
3 files changed, 48 insertions, 10 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
new file mode 100644
index 0000000..37ada3a
--- /dev/null
+++ b/src/codegen/mod.rs
@@ -0,0 +1,15 @@
+use crate::types::{ElementName, RenderedElement};
+
+impl RenderedElement {
+ pub fn codegen(&self) -> Result<(String, String), &str> {
+ let mut imports = String::new();
+ let mut view = String::new();
+
+ match self.name {
+ ElementName::Row => {
+ imports = format!("{imports}\nuse iced::widget::row");
+ view = format!("{view}\nrow![]");
+ }
+ }
+ }
+}
diff --git a/src/main.rs b/src/main.rs
index 6ee558b..16a1daa 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,4 @@
+mod codegen;
mod types;
use iced::{
diff --git a/src/types/mod.rs b/src/types/mod.rs
index 69df615..31c233d 100644
--- a/src/types/mod.rs
+++ b/src/types/mod.rs
@@ -1,4 +1,10 @@
-use iced::{Font, Length};
+use std::path::PathBuf;
+
+use iced::{
+ alignment::{Horizontal, Vertical},
+ widget::{text::Shaping, text_editor},
+ Alignment, ContentFit, Font, Length,
+};
pub struct DesignerState {
pub designer_content: Vec<RenderedElement>,
@@ -7,19 +13,35 @@ pub struct DesignerState {
pub struct RenderedElement {
pub id: String,
- pub children: Vec<RenderedElement>,
+ pub children: Option<Vec<RenderedElement>>,
pub name: ElementName,
- pub props: Vec<Prop>,
+ pub props: Props,
}
-pub enum ElementName {}
+pub enum ElementName {
+ Text(String),
+ Button(String),
+ TextEditor(text_editor::Content),
+ SVG(PathBuf),
+ Image(PathBuf),
+ Container,
+ Row,
+ Column,
+}
-pub enum Prop {
- String(String, String),
- Decimal(String, i32),
- Float(String, f32),
- Font(String, Font),
- Length(String, Length),
+pub struct Props {
+ align_items: Option<Alignment>,
+ align_x: Option<Horizontal>,
+ align_y: Option<Vertical>,
+ horizontal_alignment: Option<Horizontal>,
+ vertical_alignment: Option<Vertical>,
+ height: Option<Length>,
+ width: Option<Length>,
+ font: Option<Font>,
+ padding: Option<i32>,
+ spacing: Option<i32>,
+ content_fit: Option<ContentFit>,
+ shaping: Option<Shaping>,
}
pub enum DesignerPage {