From 23274bdccd9c9918b3b09fc0e0b93abbf9e6ecb9 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Wed, 28 Oct 2026 02:35:06 -0400 Subject: [PATCH] Finally use this to do stream start/end displays. --- README.md | 164 -------------------------------------------- assets/layouts.json | 4 +- src/app.cpp | 9 +-- src/control_ui.cpp | 8 ++- src/control_ui.hpp | 2 +- src/md_parser.cpp | 103 ++++++++++++++-------------- src/md_parser.rl | 2 +- src/options.cpp | 10 ++- src/options.hpp | 2 + 9 files changed, 76 insertions(+), 228 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 4012cf5..0000000 --- a/README.md +++ /dev/null @@ -1,164 +0,0 @@ -# Besos Loves Slides - -There's an amazing story about Amazon. One day Jeff Besos saw a PowerPoint presentation so heinous, -so evil, so boring, that he full on _banned_ PowerPoint presentations at Amazon. Immediately after -this presentation he emailed the entire company declaring all PowerPoint presentations dead. - -Can you imagine being the guy who gave this fateful presentation? I personally would be proud. I'd -take that .ppt on the road and show everyone the power of _POWER POINT_! Who knew it has the ability to destroy the -will of even the wealthiest of individuals with its unmitigated and complete boredom. - -This project is a celebration of that one PPT presentation. That .ppt that sent Jeff into a tailspin -of madness. It seeks to bring Jeff Besos painful memories of that one fateful day when he crashed -out over some slides in a boardroom. - -## Status - -This is mostly a simple presentation tool for my videos in my courses. I decided to take some of -the knowledge from my Game Development adventures and use those to make something better than -PowerPoint for my use cases. I mostly need to show text and some videos for a short amount of time -on a randomly attached monitor while also looking at a status screen on another one. - -Currently you can run `besos.exe` (it might work on other platforms, let me know) and give it a -`.md` file formatted to have slides. See `samples/about-bezos.md` which is a quick -example from one of my courses. - -## Features - -1. Metadata at the top is json which can set fonts, sizes, etc. -2. Slides start with `===`. -3. Each slide is separated with `---`. -4. Each slide can also have json metadata for font sizes, shaders, colors, etc. -4. Use `# Title` on the first line for the title. -5. Everything after is content. -6. Hot reloading mostly works. -7. There's a remote control program `bezos_ctl` you can use from the command line. -8. There's one for windows named `bezos_ctrl` that won't open a `cmd.exe`. -9. You can apply shaders to slides. -10. Horrible performance for now. -11. Separate control window to see current/next slides and control the present window. -12. The ability to easily move the present window to another monitor (only tested on Windows). - -# Supported "Markdown" - -It's barely markdown at this point, but look in `samples/about-bezos.md` for a demo of everything. -The features supported are: - -`{}` -: JSON meta data can go at the top of the deck and on each slide. Settings at the top are defaults -and you change then in the slides. - -`#` -: This tags the line as the title. You can change its style using `"title_"` options. - -`Plain Text` -: Just put lines of text. - -`*` -: Bullet points are supported, but nothing fancy. - -`!(assets/some_image.jpg)` -: Images are supported and should work with at least `.png` and `.jpg`. - -`![cell_name](assets/some_image.jpg)` -: You can explicitly place an image in a specific cell by giving the cell name where you'd normally -put alt text. - -That's it. The parser is also very basic and gives terrible errors. If you make a change and -nothing reloads then check the logs in the console. - -## Available Metadata Options - -## Shaders - -You can apply a shader to your slide with `"shader": "name"`. The shaders are configured in -`assets/shaders.json` but I may change this to be just a file. - -Here's an example from `samples/about-bezos.md`: - -``` -{ - "shader": "flame", - "bg_color": [80, 0, 0, 255], - "layout": "no_title", - "font_size": 200 -} -I Made a -PowerPoint -Killer -``` - -I'm actually not very good at writing shaders, but I'm sure you'll cook up something really great. - -## Layout Language - -The layouts are defined in `assets/layouts.json` and use my layout description language from -[lel-guecs](https://git.zedshaw.games/games/lel-guecs). - -Layout Expression Language (lel) is a small -language that describes how ragged arrays of cells are structured. The idea is that you define -where stuff goes separate from the stuff that goes there. This makes it easier to work out common -UI layouts and reuse them, and also makes your code _way_ simpler. Instead of crazy nested objects -inside objects you just create a layout and put stuff in it like a container. - -I'll document this further in a later release, but ifyou look at `"default_ui"` in -`assets/layouts.json" you see this: - -``` -"[t_left|t_center|t_right]", -"[*%(100,600)slide]", -"[_]", -"[_]", -"[_]", -"[_]", -"[_]", -"[=title|=*%(200,100)description|_|_|_]" -``` - -This is multiple strings only because JSON doesn't have a multiline string. This is converted into a -single string to define the layout. - -The `[]` Creates a single cell. The `[t_left]` creates a cell name `t_left`. The `[*%(100,600)slide]` says, "Expand (`*`) to fill percent (`%`) 100 wide by 600 long." In this case the `slide` cell will take up 1 column and 6 rows. If you see `=` that means to center it. - -## Command Line Remote - -There's a `builddir/bezos_cli` that allows for remote control of your presentation. It can do most -things the control window does. Here's the options: - -`-L`/`-R` -: Move the present window to the "Left" or "Right" screen. - -`-N`/`-P` -: Next and Previous slide. - -`-q` -: Quit. - -`-f` -: Toggle full screen. - -`-p` -: What port to use. - -> __WARNING__ This works by opening a UDP port on port 9898. If it doesn't work that's probably -> why. Also, it should only be on localhost but let me know if it's getting it wrong. - -## `bezos_cli` vs. `bezos_ctrl` - -You may notice there's a `bezos_cli` and `bezos_ctrl` - but *only on Windows*. This is because Windows makes a distinction between "console" apps and -"windows" apps. - -The `bezos_cli` is what you want when using it from the command line or on Unix systems. It just -works like you think it does and the code is in `src/bezos_ctl.cpp`. - -The `bezos_ctrl` is compiled as a `windows` subsystem app so when run it does _no console output_. -This lets you run it in things like Stream Deck and other launchers without popping open a `cmd.exe` -window to run it. - -## Future Features - -I'm pretty good with this so far but I may tinker with it more later. If you have ideas or requests -send them to help@learncodethehardway.com and I'll take a look. - -Or...just write your own. This ain't that hard. diff --git a/assets/layouts.json b/assets/layouts.json index 99b715c..9a1b76d 100644 --- a/assets/layouts.json +++ b/assets/layouts.json @@ -1,7 +1,7 @@ { "default_ui": [ - "[t_left|t_center|t_right]", - "[*%(100,600)slide]", + "[*%(100,700)slide]", + "[_]", "[_]", "[_]", "[_]", diff --git a/src/app.cpp b/src/app.cpp index d5e6bd9..808a737 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -4,6 +4,8 @@ #include "dbc.hpp" void App::init() { + controller.setVisible(options.control_window); + presenter.setPosition({0,0}); presenter.setFramerateLimit(FRAME_LIMIT); presenter.setVerticalSyncEnabled(VSYNC); @@ -13,7 +15,7 @@ void App::init() { control_ui = std::make_shared(presenter, controller, options.port); control_ui->init(); - control_ui->full_screen(false); + control_ui->full_screen(options.full_screen); reloader.watch(options.deck_file); reloader.watch(slides->$deck->config["layouts"]); @@ -36,15 +38,14 @@ void App::update() { change_slides(); } - slides->update(presenter); control_ui->update(slides); } void App::render() { slides->render(presenter); - control_ui->render(controller, *slides->$deck); - presenter.display(); + + control_ui->render(*slides->$deck); controller.display(); } diff --git a/src/control_ui.cpp b/src/control_ui.cpp index f55db76..8071032 100644 --- a/src/control_ui.cpp +++ b/src/control_ui.cpp @@ -71,7 +71,7 @@ void ControlUI::render_slide(const std::string& name, Slide& slide) { $gui.show_text(name, slide.preview); } -void ControlUI::render(sf::RenderWindow& window, SlideDeck& deck) { +void ControlUI::render(SlideDeck& deck) { dbc::check($status != nullptr, "called render before init?"); auto pos = $presenter.getPosition(); @@ -80,8 +80,8 @@ void ControlUI::render(sf::RenderWindow& window, SlideDeck& deck) { $status->update(fmt::format(L"Slide: {}\nOf: {}", deck.current + 1, deck.slides.size())); - window.clear(); - $gui.render(window); + $controller.clear(); + $gui.render($controller); render_slide("current", deck.current_slide()); @@ -140,6 +140,8 @@ void ControlUI::move(int dir) { void ControlUI::update(std::shared_ptr slides) { dbc::check($status != nullptr, "handle_events called before init?!"); + slides->update($presenter); + process_commands(slides); while (const auto event = $controller.pollEvent()) { diff --git a/src/control_ui.hpp b/src/control_ui.hpp index 56d0356..d2db79a 100644 --- a/src/control_ui.hpp +++ b/src/control_ui.hpp @@ -17,7 +17,7 @@ struct ControlUI { ControlUI(sf::RenderWindow& presenter, sf::RenderWindow& controller, unsigned short port); void init(); - void render(sf::RenderWindow& window, SlideDeck& deck); + void render(SlideDeck& deck); void update(std::shared_ptr slides); void render_slide(const std::string& name, Slide& slide); void full_screen(bool do_it); diff --git a/src/md_parser.cpp b/src/md_parser.cpp index 0c60073..64084f1 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 #include "guecs/ui.hpp" @@ -12,20 +12,21 @@ enum { }; -#line 101 "..//src/md_parser.rl" +#line 101 "src/md_parser.rl" -#line 15 "..//src/md_parser.cpp" +#line 15 "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, 7, 1, 8, 1, 9, 1, 10, 2, - 0, 4, 2, 0, 9, 2, 4, 0, - 2, 5, 9, 2, 9, 0, 3, 0, - 4, 9, 3, 4, 0, 9, 3, 5, - 0, 9, 3, 5, 9, 0, 4, 5, - 0, 4, 9 + 0, 4, 2, 0, 9, 2, 2, 4, + 2, 4, 0, 2, 4, 2, 2, 5, + 9, 2, 9, 0, 3, 0, 4, 9, + 3, 4, 0, 9, 3, 5, 0, 9, + 3, 5, 9, 0, 4, 5, 0, 4, + 9 }; static const char _Parser_key_offsets[] = { @@ -82,19 +83,19 @@ static const char _Parser_indicies[] = { 0, 1, 1, 2, 3, 2, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 11, 10, 12, 13, 14, 15, 1, 10, - 9, 1, 16, 18, 17, 21, 20, 22, - 23, 24, 25, 1, 1, 20, 19, 27, - 26, 26, 16, 27, 28, 28, 17, 29, - 20, 22, 23, 24, 25, 1, 1, 20, - 19, 30, 31, 1, 32, 34, 33, 35, - 34, 33, 36, 36, 1, 38, 37, 37, - 1, 30, 1, 39, 39, 1, 42, 41, - 41, 40, 18, 41, 41, 40, 43, 43, - 1, 1, 44, 16, 18, 45, 17, 46, - 1, 48, 47, 47, 16, 48, 49, 49, - 17, 50, 10, 12, 13, 14, 51, 1, - 1, 10, 9, 1, 52, 53, 52, 56, - 55, 57, 58, 59, 1, 1, 55, 54, + 9, 17, 16, 19, 18, 22, 21, 23, + 24, 25, 26, 1, 1, 21, 20, 28, + 27, 27, 16, 30, 29, 29, 18, 31, + 21, 23, 24, 25, 26, 1, 1, 21, + 20, 32, 33, 1, 34, 36, 35, 37, + 36, 35, 38, 38, 1, 40, 39, 39, + 1, 32, 1, 41, 41, 1, 44, 43, + 43, 42, 19, 43, 43, 42, 45, 45, + 1, 17, 46, 16, 19, 47, 18, 48, + 1, 50, 49, 49, 16, 52, 51, 51, + 18, 53, 10, 12, 13, 14, 54, 1, + 1, 10, 9, 1, 55, 56, 55, 59, + 58, 60, 61, 62, 1, 1, 58, 57, 11, 10, 12, 13, 14, 15, 1, 10, 9, 0 }; @@ -102,23 +103,23 @@ static const char _Parser_indicies[] = { static const char _Parser_trans_targs[] = { 2, 0, 3, 4, 5, 6, 7, 8, 9, 10, 30, 32, 16, 23, 26, 33, - 11, 11, 12, 10, 13, 15, 16, 23, - 26, 27, 14, 15, 14, 15, 17, 20, - 18, 18, 19, 12, 21, 21, 22, 24, - 11, 25, 24, 24, 28, 29, 36, 31, - 32, 31, 32, 27, 34, 35, 10, 30, - 32, 16, 23, 26 + 11, 12, 11, 12, 10, 13, 15, 16, + 23, 26, 27, 14, 15, 14, 15, 15, + 17, 20, 18, 18, 19, 12, 21, 21, + 22, 24, 11, 25, 24, 24, 28, 29, + 36, 31, 32, 31, 32, 32, 27, 34, + 35, 10, 30, 32, 16, 23, 26 }; static const char _Parser_trans_actions[] = { 1, 0, 0, 0, 11, 0, 0, 0, - 17, 35, 26, 38, 19, 19, 19, 1, - 5, 0, 9, 1, 1, 23, 0, 0, - 0, 1, 5, 9, 0, 29, 0, 0, - 1, 0, 15, 0, 1, 0, 13, 3, - 1, 1, 0, 7, 5, 0, 21, 5, - 9, 0, 42, 35, 0, 0, 50, 46, - 54, 32, 32, 32 + 17, 41, 26, 44, 19, 19, 19, 1, + 5, 29, 0, 9, 1, 1, 23, 0, + 0, 0, 1, 5, 29, 0, 9, 32, + 0, 0, 1, 0, 15, 0, 1, 0, + 13, 3, 1, 1, 0, 7, 5, 0, + 21, 5, 35, 0, 9, 48, 41, 0, + 0, 56, 52, 60, 38, 38, 38 }; static const int Parser_start = 1; @@ -128,7 +129,7 @@ static const int Parser_error = 0; static const int Parser_en_main = 1; -#line 104 "..//src/md_parser.rl" +#line 104 "src/md_parser.rl" bool Parser::parse(const std::string& input) { @@ -144,14 +145,14 @@ bool Parser::parse(const std::string& input) { last = DECK; -#line 139 "..//src/md_parser.cpp" +#line 140 "src/md_parser.cpp" { cs = Parser_start; } -#line 119 "..//src/md_parser.rl" +#line 119 "src/md_parser.rl" -#line 142 "..//src/md_parser.cpp" +#line 143 "src/md_parser.cpp" { int _klen; unsigned int _trans; @@ -226,23 +227,23 @@ _match: switch ( *_acts++ ) { case 0: -#line 16 "..//src/md_parser.rl" +#line 16 "src/md_parser.rl" { start = p; } break; case 1: -#line 17 "..//src/md_parser.rl" +#line 17 "src/md_parser.rl" { last = TITLE; } break; case 2: -#line 18 "..//src/md_parser.rl" +#line 18 "src/md_parser.rl" { last = PLAIN; } break; case 3: -#line 19 "..//src/md_parser.rl" +#line 19 "src/md_parser.rl" { last = ENUM; } break; case 4: -#line 21 "..//src/md_parser.rl" +#line 21 "src/md_parser.rl" { tk = input.substr(start - begin, p - start); @@ -260,7 +261,7 @@ _match: } break; case 5: -#line 37 "..//src/md_parser.rl" +#line 37 "src/md_parser.rl" { tk = input.substr(start - begin, p - start); if(last == DECK) { @@ -275,7 +276,7 @@ _match: } break; case 6: -#line 50 "..//src/md_parser.rl" +#line 50 "src/md_parser.rl" { std::string cell = input.substr(start - begin, p - start); fmt::println("CELL {}", cell); @@ -283,7 +284,7 @@ _match: } break; case 7: -#line 56 "..//src/md_parser.rl" +#line 56 "src/md_parser.rl" { std::string image = input.substr(start - begin, p - start); fmt::println("IMAGE image={}, start={}, length={}", @@ -292,27 +293,27 @@ _match: } break; case 8: -#line 63 "..//src/md_parser.rl" +#line 63 "src/md_parser.rl" { last = PLAIN; fmt::println("----- START"); } break; case 9: -#line 68 "..//src/md_parser.rl" +#line 68 "src/md_parser.rl" { title.clear(); content.clear(); } break; case 10: -#line 73 "..//src/md_parser.rl" +#line 73 "src/md_parser.rl" { deck->slides.emplace_back(title, content, config, deck->config); config.clear(); } break; -#line 291 "..//src/md_parser.cpp" +#line 292 "src/md_parser.cpp" } } @@ -325,7 +326,7 @@ _again: _out: {} } -#line 120 "..//src/md_parser.rl" +#line 120 "src/md_parser.rl" bool good = pe - p == 0; diff --git a/src/md_parser.rl b/src/md_parser.rl index 639d021..a54685a 100644 --- a/src/md_parser.rl +++ b/src/md_parser.rl @@ -92,7 +92,7 @@ enum { meta = ('{' ( any+ -- '}') '}') >mark %meta; title = pound space+ content :>> eol; enum = asterisk space+ content :>> eol; - raw = (other (any+ -- eol)) >mark %content :>> eol; + raw = (other (any* -- eol)) >mark %content :>> eol; blank = space* >mark %content eol; slide = meta? blank* (title | enum | raw | blank | image)+ >start_slide :>> end eol; diff --git a/src/options.cpp b/src/options.cpp index a1f45e3..9ba3b26 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -3,14 +3,14 @@ #include void print_usage() { - fmt::println("USAGE: bezos [-W width] [-H height] [-p PORT] [-h] -d deck.md"); + fmt::println("USAGE: bezos [-W width] [-H height] [-p PORT] [-h] [-F] [-C] -d deck.md"); } Options parse_options(int argc, char* argv[]) { int opt = 0; Options result; - while((opt = getopt(argc, argv, "hp:d:W:H:")) != -1) { + while((opt = getopt(argc, argv, "hpFCd:W:H:")) != -1) { switch(opt) { case 'h': print_usage(); @@ -29,6 +29,12 @@ Options parse_options(int argc, char* argv[]) { case 'H': result.pres_size.y = std::stoi(optarg); break; + case 'F': + result.full_screen = true; + break; + case 'C': + result.control_window = false; + break; default: print_usage(); return {.error=true}; diff --git a/src/options.hpp b/src/options.hpp index bd0d7ac..897cdad 100644 --- a/src/options.hpp +++ b/src/options.hpp @@ -11,6 +11,8 @@ struct Options { sf::Vector2u control_size{CONTROL_WIDTH, CONTROL_HEIGHT}; bool error{false}; unsigned short port=9898; + bool full_screen = false; + bool control_window = true; }; void print_usage();