Can center one line and few words but then it falls apart. Must have a bug.

master
Zed A. Shaw 1 week ago
parent a0d3f5202c
commit 6ebdf6e26c
  1. 18
      sample/about-bezos.md
  2. 28
      src/slides_ui.cpp
  3. 5
      src/slides_ui.hpp

@ -37,6 +37,24 @@ Bare content like this
* { "bg_image": "file_path" }
* You don't even need text
---
{
"bg_color": [10, 10, 25, 255],
"font_color": [255, 146, 0, 255],
"font_size": 80,
"font_padding": 20
}
# Font Config
* Only on slides for now
* "font_color": [r,g,b,a]
* "font_size": int
* "font_padding": int
---
{
"font_size": 120,
"font_centered": true
}
One Word
---
# Images
!(assets/sample_bg.jpg)
* !(assets/sample_bg.jpg)

@ -35,13 +35,17 @@ void Slide::init(lel::Cell& cell) {
"[_|_|_]");
auto title = $gui.entity("title");
$gui.set<guecs::Text>(title, {$title, TITLE_SIZE});
guecs::Text title_text{$title, TITLE_SIZE};
config_text(title_text);
$gui.set<guecs::Text>(title, title_text);
auto content = $gui.entity("content");
$gui.set<guecs::Text>(content, {
guecs::Text content_text{
$content,
CONTENT_SIZE,
guecs::THEME.TEXT_COLOR, 20});
guecs::THEME.TEXT_COLOR, 20};
config_text(content_text);
$gui.set<guecs::Text>(content, content_text);
if($config.contains("image")) {
$gui.set<guecs::Sprite>(content, {$config["image"]});
@ -51,6 +55,24 @@ void Slide::init(lel::Cell& cell) {
}
}
void Slide::config_text(guecs::Text &result) {
if($config.contains("font_size")) result.size = $config["font_size"];
if($config.contains("font_color")) {
std::vector<uint8_t> color = $config["font_color"];
dbc::check(color.size() == 4, "font_color on slide must have 4 values rgba");
fmt::println("font_color is {},{},{},{}", color[0], color[1], color[2], color[3]);
result.color = sf::Color{
color[0], color[1], color[2], color[3]};
}
if($config.contains("font_padding")) result.padding = $config["font_padding"];
if($config.contains("font_centered")) result.centered = $config["font_centered"];
}
void Slide::render(sf::RenderWindow& window) {
$gui.render(window);
// $gui.debug_layout(window);

@ -18,8 +18,9 @@ struct Slide {
void init(lel::Cell& cell);
void render(sf::RenderWindow& window);
}
;
void config_text(guecs::Text &result);
};
using SlideSet = std::vector<Slide>;
struct SlideDeck {

Loading…
Cancel
Save