Now you can set title vs. font color, size, etc.

master
Zed A. Shaw 2 days ago
parent 53c76de2d1
commit 2c3c105ca7
  1. 2
      assets/layouts.json
  2. 9
      sample/about-bezos.md
  3. 20
      src/slides_ui.cpp
  4. 2
      src/slides_ui.hpp

@ -20,7 +20,7 @@
"[_|_|_|_|_]" "[_|_|_|_|_]"
], ],
"image_left": [ "image_left": [
"[=*%(300,200)title|_|_|_|_]", "[=title]",
"[_|_|_]", "[_|_|_]",
"[*%(200,600)image|_|*%(300,600)content|_|_]", "[*%(200,600)image|_|*%(300,600)content|_|_]",
"[_|_|_|_|_]", "[_|_|_|_|_]",

@ -67,13 +67,14 @@ One Word
--- ---
{ {
"layout": "image_left", "layout": "image_left",
"image_stretch": false "image_stretch": false,
"title_size": 100,
"font_size": 50
} }
# Specific Positions # Specific Positions
![image](assets/sample_bg.jpg) ![image](assets/sample_bg.jpg)
* ![image] before () * ![image](assets/sample_bg.jpg)
* Places in image * Places in image cell in layout.
cell in layout.
* Can combine with * Can combine with
image_stretch and layout image_stretch and layout
to place it anywhere. to place it anywhere.

@ -18,12 +18,12 @@ Slide::Slide(const string& title, const string& content, json& config, json& dec
$config(config) $config(config)
{ {
// first config the text with any font stuff from the deck // first config the text with any font stuff from the deck
config_text($title_font, deck_config); config_text($title_font, deck_config, "title");
config_text($content_font, deck_config); config_text($content_font, deck_config, "font");
// then config it with the slide's config // then config it with the slide's config
config_text($title_font, $config); config_text($title_font, $config, "title");
config_text($content_font, $config); config_text($content_font, $config, "font");
} }
void Slide::init(lel::Cell& cell, const std::string& layout) { 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) { void Slide::config_text(guecs::Text &result, nlohmann::json& config, std::string prefix) {
if(config.contains("font_size")) result.size = config["font_size"]; if(config.contains(prefix + "_size")) result.size = config[prefix + "_size"];
if(config.contains("font_color")) { if(config.contains(prefix + "_color")) {
std::vector<uint8_t> color = config["font_color"]; std::vector<uint8_t> color = config[prefix + "_color"];
dbc::check(color.size() == 4, "font_color on slide must have 4 values rgba"); 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]}; 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) { void Slide::render(sf::RenderWindow& window) {

@ -23,7 +23,7 @@ struct Slide {
void init(lel::Cell& cell, const std::string& layout); void init(lel::Cell& cell, const std::string& layout);
void render(sf::RenderWindow& window); 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<Slide>; using SlideSet = std::vector<Slide>;

Loading…
Cancel
Save