diff --git a/assets/layouts.json b/assets/layouts.json index 3bf4897..fe70220 100644 --- a/assets/layouts.json +++ b/assets/layouts.json @@ -1,18 +1,28 @@ { "default_ui": [ "[t_left|t_center|t_right]", - "[*%(300,500)slide|_|_|*%(200,500)alternate|_]", - "[_|_|_|_|_]", - "[_|_|_|_|_]", - "[_|_|_|_|_]", - "[_|_|_|_|_]", + "[*%(100,600)slide]", "[_]", - "[title|*%(200,100)description|_|_|_]" + "[_]", + "[_]", + "[_]", + "[_]", + "[=title|=*%(200,100)description|_|_|_]" ], "default_slide": [ - "[=*%(300,200)title|_|_]", + "[=*%(300,200)title|_|_|_|_]", + "[_|_|_]", + "[*%(300,600)content|_|_|*%(200,600)alt|_]", + "[_|_|_|_|_]", + "[_|_|_|_|_]", + "[_|_|_|_|_]", + "[_|_|_|_|_]", + "[_|_|_|_|_]" + ], + "centered": [ + "[=*%(300,200)title|_|_|_|_]", "[_|_|_]", - "[*%(300,600)content|_|_]", + "[=*%(300,600)content]", "[_|_|_]", "[_|_|_]", "[_|_|_]", diff --git a/sample/about-bezos.md b/sample/about-bezos.md index 861f38e..1ad05e0 100644 --- a/sample/about-bezos.md +++ b/sample/about-bezos.md @@ -54,7 +54,8 @@ Bare content like this --- { "font_size": 120, - "font_centered": true + "font_centered": true, + "layout": "centered" } One Word --- diff --git a/src/main.cpp b/src/main.cpp index 418eede..b669ec1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -36,7 +36,7 @@ struct ChangeDetector { sf::Clock timer{}; std::filesystem::file_time_type last_mod_time = std::filesystem::last_write_time(input_md); - bool check_changed() { + bool changed() { if(timer.getElapsedTime().toDuration() > 500ms) { try { auto mod_time = std::filesystem::last_write_time(input_md); @@ -89,7 +89,8 @@ int main(int argc, char *argv[]) { dbc::check(control_ui.$status != nullptr, "bad ptr"); - ChangeDetector reloader{argv[1]}; + ChangeDetector slides_reloader{argv[1]}; + ChangeDetector layout_reloader{slides.$deck->config["layouts"]}; while(controller.isOpen()) { while (const auto event = presenter.pollEvent()) { @@ -106,7 +107,7 @@ int main(int argc, char *argv[]) { presenter.display(); controller.display(); - if(reloader.check_changed()) { + if(slides_reloader.changed() || layout_reloader.changed()) { auto new_slides = load_slides(argv[1], backend); if(new_slides) { diff --git a/src/slides_ui.cpp b/src/slides_ui.cpp index 0c5a321..a0e2563 100644 --- a/src/slides_ui.cpp +++ b/src/slides_ui.cpp @@ -153,11 +153,18 @@ void SlidesUI::show_slide() { color = {color_conf[0], color_conf[1], color_conf[2], color_conf[3]}; } + std::string layout_name{"default_slide"}; + + if(slide.$config.contains("layout")) { + layout_name = slide.$config["layout"]; + } + + auto& layout = $layouts[layout_name]; + bg.set_color(color); bg.init(); auto& cell = $gui.cell_for("slide"); - auto& layout = $layouts["default_slide"]; slide.init(cell, layout); }