diff --git a/assets/layouts.json b/assets/layouts.json index 9bd4f2c..2481dfd 100644 --- a/assets/layouts.json +++ b/assets/layouts.json @@ -20,7 +20,7 @@ "[_|_|_|_|_]" ], "image_left": [ - "[=*%(300,200)title|_|_|_|_]", + "[=title]", "[_|_|_]", "[*%(200,600)image|_|*%(300,600)content|_|_]", "[_|_|_|_|_]", diff --git a/sample/about-bezos.md b/sample/about-bezos.md index a2defd5..1c8e6d4 100644 --- a/sample/about-bezos.md +++ b/sample/about-bezos.md @@ -67,13 +67,14 @@ One Word --- { "layout": "image_left", -"image_stretch": false +"image_stretch": false, +"title_size": 100, +"font_size": 50 } # Specific Positions ![image](assets/sample_bg.jpg) -* ![image] before () -* Places in image - cell in layout. +* ![image](assets/sample_bg.jpg) +* Places in image cell in layout. * Can combine with image_stretch and layout to place it anywhere. diff --git a/src/slides_ui.cpp b/src/slides_ui.cpp index f53bec6..55d64d5 100644 --- a/src/slides_ui.cpp +++ b/src/slides_ui.cpp @@ -18,12 +18,12 @@ Slide::Slide(const string& title, const string& content, json& config, json& dec $config(config) { // first config the text with any font stuff from the deck - config_text($title_font, deck_config); - config_text($content_font, deck_config); + config_text($title_font, deck_config, "title"); + config_text($content_font, deck_config, "font"); // then config it with the slide's config - config_text($title_font, $config); - config_text($content_font, $config); + config_text($title_font, $config, "title"); + config_text($content_font, $config, "font"); } void Slide::init(lel::Cell& cell, const std::string& layout) { @@ -50,11 +50,11 @@ void Slide::init(lel::Cell& cell, const std::string& layout) { } } -void Slide::config_text(guecs::Text &result, nlohmann::json& config) { - if(config.contains("font_size")) result.size = config["font_size"]; +void Slide::config_text(guecs::Text &result, nlohmann::json& config, std::string prefix) { + if(config.contains(prefix + "_size")) result.size = config[prefix + "_size"]; - if(config.contains("font_color")) { - std::vector color = config["font_color"]; + if(config.contains(prefix + "_color")) { + std::vector color = config[prefix + "_color"]; dbc::check(color.size() == 4, "font_color on slide must have 4 values rgba"); @@ -63,9 +63,9 @@ void Slide::config_text(guecs::Text &result, nlohmann::json& config) { color[0], color[1], color[2], color[3]}; } - if(config.contains("font_padding")) result.padding = config["font_padding"]; + if(config.contains(prefix + "_padding")) result.padding = config[prefix + "_padding"]; - if(config.contains("font_centered")) result.centered = config["font_centered"]; + if(config.contains(prefix + "_centered")) result.centered = config[prefix + "_centered"]; } void Slide::render(sf::RenderWindow& window) { diff --git a/src/slides_ui.hpp b/src/slides_ui.hpp index 2ec2fd4..3f7254a 100644 --- a/src/slides_ui.hpp +++ b/src/slides_ui.hpp @@ -23,7 +23,7 @@ struct Slide { void init(lel::Cell& cell, const std::string& layout); void render(sf::RenderWindow& window); - void config_text(guecs::Text &result, nlohmann::json& config); + void config_text(guecs::Text &result, nlohmann::json& config, std::string prefix); }; using SlideSet = std::vector;