From de225cf25ca20f9efe7851a11db813fd37e4700f Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Thu, 12 Mar 2026 23:29:32 -0400 Subject: [PATCH] More improvements in config and using a more fancy bullet char. --- src/main.cpp | 4 ++-- src/md_parser.cpp | 42 +++++++++++++++++++++--------------------- src/md_parser.rl | 4 ++-- src/slides_ui.cpp | 36 +++++++++++++++++++----------------- src/slides_ui.hpp | 9 +++++++-- 5 files changed, 51 insertions(+), 44 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ff4a718..f4ac34b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,10 +18,10 @@ int main(int argc, char *argv[]) { return a.size.x == WINDOW_WIDTH && a.size.y == WINDOW_HEIGHT; }); - sf::RenderWindow controller(sf::VideoMode({CONTROL_WIDTH, CONTROL_HEIGHT}), "Besos Loves Control"); + sf::RenderWindow controller(sf::VideoMode({CONTROL_WIDTH, CONTROL_HEIGHT}), "Bezos Loves Control"); sf::RenderWindow presenter(*screen_mode, - "Besos Loves Slides", sf::Style::None, sf::State::Windowed); + "Bezos Loves Slides", sf::Style::None, sf::State::Windowed); presenter.setFramerateLimit(FRAME_LIMIT); presenter.setVerticalSyncEnabled(VSYNC); diff --git a/src/md_parser.cpp b/src/md_parser.cpp index ea687e5..46392dd 100644 --- a/src/md_parser.cpp +++ b/src/md_parser.cpp @@ -1,5 +1,5 @@ -#line 1 "..//src/md_parser.rl" +#line 1 "src/md_parser.rl" #include #include @@ -11,11 +11,11 @@ enum { }; -#line 90 "..//src/md_parser.rl" +#line 90 "src/md_parser.rl" -#line 14 "..//src/md_parser.cpp" +#line 14 "src/md_parser.cpp" static const char _Parser_actions[] = { 0, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, @@ -122,7 +122,7 @@ static const int Parser_error = 0; static const int Parser_en_main = 1; -#line 93 "..//src/md_parser.rl" +#line 93 "src/md_parser.rl" bool Parser::parse(const std::string& input) { @@ -138,14 +138,14 @@ bool Parser::parse(const std::string& input) { last = DECK; -#line 133 "..//src/md_parser.cpp" +#line 133 "src/md_parser.cpp" { cs = Parser_start; } -#line 108 "..//src/md_parser.rl" +#line 108 "src/md_parser.rl" -#line 136 "..//src/md_parser.cpp" +#line 136 "src/md_parser.cpp" { int _klen; unsigned int _trans; @@ -220,30 +220,30 @@ _match: switch ( *_acts++ ) { case 0: -#line 15 "..//src/md_parser.rl" +#line 15 "src/md_parser.rl" { start = p; } break; case 1: -#line 16 "..//src/md_parser.rl" +#line 16 "src/md_parser.rl" { last = TITLE; } break; case 2: -#line 17 "..//src/md_parser.rl" +#line 17 "src/md_parser.rl" { last = PLAIN; } break; case 3: -#line 18 "..//src/md_parser.rl" +#line 18 "src/md_parser.rl" { last = ENUM; } break; case 4: -#line 20 "..//src/md_parser.rl" +#line 20 "src/md_parser.rl" { tk = input.substr(start - begin, p - start); if(last == TITLE) { title = tk; } else if(last == ENUM) { - content += "* " + tk; + content += "° " + tk; content += "\n"; } else { content += input.substr(start - begin, p - start); @@ -254,7 +254,7 @@ _match: } break; case 5: -#line 36 "..//src/md_parser.rl" +#line 36 "src/md_parser.rl" { tk = input.substr(start - begin, p - start); if(last == DECK) { @@ -267,7 +267,7 @@ _match: } break; case 6: -#line 47 "..//src/md_parser.rl" +#line 47 "src/md_parser.rl" { std::string image = input.substr(start - begin, p - start); fmt::println("IMAGE image={}, start={}, length={}", @@ -276,27 +276,27 @@ _match: } break; case 7: -#line 54 "..//src/md_parser.rl" +#line 54 "src/md_parser.rl" { last = PLAIN; fmt::println("----- START"); } break; case 8: -#line 59 "..//src/md_parser.rl" +#line 59 "src/md_parser.rl" { title.clear(); content.clear(); } break; case 9: -#line 64 "..//src/md_parser.rl" +#line 64 "src/md_parser.rl" { - deck->slides.emplace_back(title, content, config); + deck->slides.emplace_back(title, content, config, deck->config); config.clear(); } break; -#line 276 "..//src/md_parser.cpp" +#line 276 "src/md_parser.cpp" } } @@ -309,7 +309,7 @@ _again: _out: {} } -#line 109 "..//src/md_parser.rl" +#line 109 "src/md_parser.rl" bool good = pe - p == 0; diff --git a/src/md_parser.rl b/src/md_parser.rl index f43605e..753cfaf 100644 --- a/src/md_parser.rl +++ b/src/md_parser.rl @@ -23,7 +23,7 @@ enum { if(last == TITLE) { title = tk; } else if(last == ENUM) { - content += "* " + tk; + content += "° " + tk; content += "\n"; } else { content += input.substr(start - begin, fpc - start); @@ -62,7 +62,7 @@ enum { } action end_slide { - deck->slides.emplace_back(title, content, config); + deck->slides.emplace_back(title, content, config, deck->config); config.clear(); } diff --git a/src/slides_ui.cpp b/src/slides_ui.cpp index 55c02e0..8fd0b88 100644 --- a/src/slides_ui.cpp +++ b/src/slides_ui.cpp @@ -6,17 +6,23 @@ #include #include "dbc.hpp" #include -#include "constants.hpp" #include "slides_ui.hpp" using std::string, std::wstring, std::shared_ptr, std::make_shared; using nlohmann::json; -Slide::Slide(const string& title, const string& content, json& config) : +Slide::Slide(const string& title, const string& content, json& config, json& deck_config) : $title(guecs::to_wstring(title)), $content(guecs::to_wstring(content)), $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); + + // then config it with the slide's config + config_text($title_font, $config); + config_text($content_font, $config); } void Slide::init(lel::Cell& cell) { @@ -35,17 +41,10 @@ void Slide::init(lel::Cell& cell) { "[_|_|_]"); auto title = $gui.entity("title"); - guecs::Text title_text{$title, TITLE_SIZE}; - config_text(title_text); - $gui.set(title, title_text); + $gui.set(title, $title_font); auto content = $gui.entity("content"); - guecs::Text content_text{ - $content, - CONTENT_SIZE, - guecs::THEME.TEXT_COLOR, 20}; - config_text(content_text); - $gui.set(content, content_text); + $gui.set(content, $content_font); if($config.contains("image")) { $gui.set(content, {$config["image"]}); @@ -55,11 +54,11 @@ void Slide::init(lel::Cell& cell) { } } -void Slide::config_text(guecs::Text &result) { - if($config.contains("font_size")) result.size = $config["font_size"]; +void Slide::config_text(guecs::Text &result, nlohmann::json& config) { + if(config.contains("font_size")) result.size = config["font_size"]; - if($config.contains("font_color")) { - std::vector color = $config["font_color"]; + if(config.contains("font_color")) { + std::vector color = config["font_color"]; dbc::check(color.size() == 4, "font_color on slide must have 4 values rgba"); @@ -68,9 +67,9 @@ void Slide::config_text(guecs::Text &result) { color[0], color[1], color[2], color[3]}; } - if($config.contains("font_padding")) result.padding = $config["font_padding"]; + if(config.contains("font_padding")) result.padding = config["font_padding"]; - if($config.contains("font_centered")) result.centered = $config["font_centered"]; + if(config.contains("font_centered")) result.centered = config["font_centered"]; } void Slide::render(sf::RenderWindow& window) { @@ -159,6 +158,9 @@ void SlidesUI::show_slide() { if(slide.$config.contains("bg_color")) { auto color_conf = slide.$config["bg_color"]; color = {color_conf[0], color_conf[1], color_conf[2], color_conf[3]}; + } else if($deck->config.contains("bg_color")) { + auto color_conf = $deck->config["bg_color"]; + color = {color_conf[0], color_conf[1], color_conf[2], color_conf[3]}; } bg.set_color(color); diff --git a/src/slides_ui.hpp b/src/slides_ui.hpp index 0b1a196..f549314 100644 --- a/src/slides_ui.hpp +++ b/src/slides_ui.hpp @@ -4,6 +4,7 @@ #include "guecs/ui.hpp" #include #include +#include "constants.hpp" struct Slide { guecs::UI $gui; @@ -11,14 +12,18 @@ struct Slide { std::wstring $content; nlohmann::json $config; bool $initialized = false; + guecs::Text $content_font{$content, + CONTENT_SIZE, + guecs::THEME.TEXT_COLOR, 20}; + guecs::Text $title_font{$title, TITLE_SIZE}; - Slide(const std::string& title, const std::string& content, nlohmann::json& config); + Slide(const std::string& title, const std::string& content, nlohmann::json& config, nlohmann::json& deck_config); Slide() {} void init(lel::Cell& cell); void render(sf::RenderWindow& window); - void config_text(guecs::Text &result); + void config_text(guecs::Text &result, nlohmann::json& config); }; using SlideSet = std::vector;