This commit is contained in:
emilis 2022-11-08 22:20:44 +00:00
parent d81c0dee73
commit 4cfd912ebe
4 changed files with 104 additions and 6 deletions

View File

@ -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<T: AsRef<str>, V: AsRef<Path>> {
pub struct Generate<T: AsRef<str>, V: AsRef<Path>> {
elements: Vec<Element<T, V>>,
base: Image<Rgba>,
}
impl<T: AsRef<str>, V: AsRef<Path>> Template<T, V> {
impl<T: AsRef<str>, V: AsRef<Path>> Generate<T, V> {
pub fn new(base: Vec<u8>, elements: Vec<Element<T, V>>) -> Result<Self, CowError> {
Ok(Self {
base: match Image::<Rgba>::from_bytes_inferred(&base) {

View File

@ -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(

View File

@ -8,4 +8,4 @@ edition = "2021"
[dependencies]
cowgen = { path = "../cowgen" }
iced = { git = "https://github.com/iced-rs/iced", branch = "master" }

View File

@ -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<Element>
}
struct Cowmic {
templates: Vec<Template>,
view: View,
}
enum Message {}
impl Sandbox for Cowmic {
type Message = Message;
fn new() -> Self {
Self {
view: View::Library(Library::View::new()),
templates: vec![],
}
}
fn title(&self) -> String {
"Cowmic".to_string()
}
fn update(&mut self, message: Self::Message) {
todo!()
}
fn view(&self) -> iced::Element<'_, Self::Message> {
todo!()
}
}
// library -> view template -> create image (fill out template) -> save to filesystem
// \-> new template
enum View {
Library(Library::View),
// Template(Template),
// Generate(Generate),
}
// features:
// import template
// delete template
// rename template
// autosave all templates
mod Library {
use super::Template;
pub struct View;
impl View {
pub fn new(templates: Vec<Template>) -> Self {
Self
}
fn update(&mut self, message: Message) {
todo!()
}
fn view(&self) -> iced::Element<'_, Message> {
todo!()
}
}
enum Message {}
}
mod NewTemplate {
struct View {
image: Image
};
enum Message {}
}
mod Generate {
enum Message {}
}