Make it possible to set a slide background image and test that a slide with only an image works.

master
Zed A. Shaw 1 week ago
parent 59e75e9403
commit 494b0197db
  1. 10
      sample/01-a-good-first-program.md
  2. 18
      src/slides_ui.cpp

@ -1,7 +1,6 @@
{ {
"title": "Test", "title": "Test",
"description": "Test", "description": "Test"
"bg_image": "assets/sample_bg.jpg"
} }
=== ===
# 1: A Good First Program # 1: A Good First Program
@ -20,6 +19,9 @@
!(assets/sample_bg.jpg) !(assets/sample_bg.jpg)
--- ---
{
"bg_image": "assets/sample_bg.jpg"
}
# Common Student Questions # Common Student Questions
* This again. * This again.
@ -33,3 +35,7 @@
- See You Soon! - See You Soon!
--- ---
{
"bg_image": "assets/sample_bg.jpg"
}
---

@ -27,7 +27,10 @@ void Slide::init(lel::Cell& cell) {
$gui.layout( $gui.layout(
"[=*%(300,200)title|_|_]" "[=*%(300,200)title|_|_]"
"[_|_|_]" "[_|_|_]"
"[=*%(300,400)content|_|_]" "[=*%(300,600)content|_|_]"
"[_|_|_]"
"[_|_|_]"
"[_|_|_]"
"[_|_|_]" "[_|_|_]"
"[_|_|_]"); "[_|_|_]");
@ -62,7 +65,7 @@ SlidesUI::SlidesUI(shared_ptr<SlideDeck> deck) {
$gui.position(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); $gui.position(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
$gui.layout( $gui.layout(
"[t_left|t_center|t_right]" "[t_left|t_center|t_right]"
"[*%(300,400)slide|_|_|m_right|_]" "[*%(300,400)slide|_|_|_|_]"
"[_|_|_|_|_]" "[_|_|_|_|_]"
"[_|_|_|_|_]" "[_|_|_|_|_]"
"[_|_|_|_|_]" "[_|_|_|_|_]"
@ -106,9 +109,16 @@ void SlidesUI::show_slide() {
auto& bg = $gui.get<guecs::Background>($gui.MAIN); auto& bg = $gui.get<guecs::Background>($gui.MAIN);
sf::Color color = guecs::THEME.FILL_COLOR; sf::Color color = guecs::THEME.FILL_COLOR;
if($deck->config.contains("bg_image")) { if(slide.$config.contains("bg_image")) {
bg.set_sprite(slide.$config["bg_image"], true);
} else if($deck->config.contains("bg_image")) {
bg.set_sprite($deck->config["bg_image"], true); bg.set_sprite($deck->config["bg_image"], true);
} else if(slide.$config.contains("bg_color")) { } else {
bg.sprite = nullptr;
bg.texture = nullptr;
}
if(slide.$config.contains("bg_color")) {
auto color_conf = slide.$config["bg_color"]; auto color_conf = slide.$config["bg_color"];
color = {color_conf[0], color_conf[1], color_conf[2], color_conf[3]}; color = {color_conf[0], color_conf[1], color_conf[2], color_conf[3]};
} }

Loading…
Cancel
Save