From 4cfd912ebe0474ab8865f4528fae9a627cd94dea Mon Sep 17 00:00:00 2001 From: emilis Date: Tue, 8 Nov 2022 22:20:44 +0000 Subject: [PATCH] wip ui --- cowgen/src/lib.rs | 4 +- cowgen/tests/overlay_text_and_image.rs | 2 +- cowmic/Cargo.toml | 2 +- cowmic/src/main.rs | 102 ++++++++++++++++++++++++- 4 files changed, 104 insertions(+), 6 deletions(-) diff --git a/cowgen/src/lib.rs b/cowgen/src/lib.rs index 01f05cc..4e69c86 100644 --- a/cowgen/src/lib.rs +++ b/cowgen/src/lib.rs @@ -7,12 +7,12 @@ use std::{fs::File, path::Path}; // do not bother shutting down, we simply exit when we're done. static START: Once = Once::new(); -pub struct Template, V: AsRef> { +pub struct Generate, V: AsRef> { elements: Vec>, base: Image, } -impl, V: AsRef> Template { +impl, V: AsRef> Generate { pub fn new(base: Vec, elements: Vec>) -> Result { Ok(Self { base: match Image::::from_bytes_inferred(&base) { diff --git a/cowgen/tests/overlay_text_and_image.rs b/cowgen/tests/overlay_text_and_image.rs index a9004f2..8fc5c95 100644 --- a/cowgen/tests/overlay_text_and_image.rs +++ b/cowgen/tests/overlay_text_and_image.rs @@ -7,7 +7,7 @@ use std::{ #[test] fn test_overlay_text_and_image() { println!("{}", std::env::current_dir().unwrap().to_str().unwrap()); - let out = Template::new( + let out = Generate::new( include_bytes!("assets/cow.png").to_vec(), vec![ Element::new( diff --git a/cowmic/Cargo.toml b/cowmic/Cargo.toml index 426d961..e04ed0c 100644 --- a/cowmic/Cargo.toml +++ b/cowmic/Cargo.toml @@ -8,4 +8,4 @@ edition = "2021" [dependencies] cowgen = { path = "../cowgen" } - +iced = { git = "https://github.com/iced-rs/iced", branch = "master" } diff --git a/cowmic/src/main.rs b/cowmic/src/main.rs index 62bdf70..b264597 100644 --- a/cowmic/src/main.rs +++ b/cowmic/src/main.rs @@ -1,7 +1,105 @@ +use std::path::Path; use std::{fs::File, io::Write}; -use cowgen::{CowError, Element, Text}; +use cowgen::{CowError, Text}; +use iced::Sandbox; +use iced::Settings; fn main() -> Result<(), CowError> { - Ok(()) + Cowmic::run(Settings::default()) +} + +struct Element { + position: (i32, i32), + dimensions: (i32, i32), + media: Media, +} + +struct Text {} + +struct Image {} + +enum Media { + Image(Path), + Text(Text), +} + +struct Template { + image_path: String, + elements: Vec +} + +struct Cowmic { + templates: Vec