You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.7 KiB
68 lines
1.7 KiB
#pragma once
|
|
|
|
#include <guecs/sfml/components.hpp>
|
|
#include <guecs/ui.hpp>
|
|
#include <nlohmann/json.hpp>
|
|
#include <memory>
|
|
#include "constants.hpp"
|
|
|
|
struct Slide {
|
|
std::wstring preview{L"NO PREVIEW"};
|
|
guecs::UI $gui;
|
|
std::wstring $title;
|
|
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};
|
|
std::shared_ptr<sf::Shader> $shader = nullptr;
|
|
|
|
Slide(const std::string& title, const std::string& content, nlohmann::json& config, nlohmann::json& deck_config);
|
|
|
|
Slide() {}
|
|
|
|
void init(lel::Cell& cell, const std::string& layout);
|
|
void render(sf::RenderTarget& view);
|
|
void config_text(guecs::Text &result, nlohmann::json& config, std::string prefix);
|
|
};
|
|
|
|
using SlideSet = std::vector<Slide>;
|
|
|
|
struct SlideDeck {
|
|
nlohmann::json config;
|
|
SlideSet slides;
|
|
size_t current = 0;
|
|
|
|
bool at_end();
|
|
Slide& current_slide();
|
|
Slide& slide_at(size_t index);
|
|
void next_slide();
|
|
void prev_slide();
|
|
void set_slide(size_t index);
|
|
};
|
|
|
|
struct SlidesUI {
|
|
guecs::UI $gui;
|
|
std::shared_ptr<SlideDeck> $deck = nullptr;
|
|
std::unordered_map<std::string, std::string> $layouts;
|
|
sf::RenderTexture $view_texture;
|
|
sf::Sprite $view_sprite;
|
|
sf::Clock $clock;
|
|
|
|
SlidesUI(std::shared_ptr<SlideDeck> deck, sf::Vector2u size);
|
|
void init();
|
|
|
|
Slide& current_slide();
|
|
|
|
void next_slide();
|
|
void prev_slide();
|
|
void show_slide();
|
|
void set_slide(size_t index);
|
|
void render(sf::RenderTarget& window);
|
|
void mouse(float x, float y, guecs::Modifiers mods);
|
|
void set_text(const std::string& name);
|
|
void handle_events(sf::RenderWindow& presenter, const sf::Event& event);
|
|
void configure_layouts();
|
|
};
|
|
|