|
|
|
@ -12,7 +12,6 @@ |
|
|
|
#include "constants.hpp" |
|
|
|
#include "constants.hpp" |
|
|
|
#include "control_ui.hpp" |
|
|
|
#include "control_ui.hpp" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ControlUI::ControlUI(sf::RenderWindow& presenter, sf::RenderWindow& controller) : |
|
|
|
ControlUI::ControlUI(sf::RenderWindow& presenter, sf::RenderWindow& controller) : |
|
|
|
$presenter(presenter), |
|
|
|
$presenter(presenter), |
|
|
|
$controller(controller), |
|
|
|
$controller(controller), |
|
|
|
@ -20,48 +19,39 @@ ControlUI::ControlUI(sf::RenderWindow& presenter, sf::RenderWindow& controller) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$gui.position(0, 0, CONTROL_WIDTH, CONTROL_HEIGHT); |
|
|
|
$gui.position(0, 0, CONTROL_WIDTH, CONTROL_HEIGHT); |
|
|
|
$gui.layout( |
|
|
|
$gui.layout( |
|
|
|
"[status|=%(100,100)current]" |
|
|
|
"[status|*%(200,100)current|_]" |
|
|
|
"[docs|=%(100,100)next]" |
|
|
|
"[docs|*%(200,100)preview|_]" |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ControlUI::config_views(guecs::Entity current, guecs::Entity next) { |
|
|
|
|
|
|
|
// BUG jank ass bullshit, fix this in lel-guecs
|
|
|
|
|
|
|
|
auto& cur_cell = $gui.cell_for(current); |
|
|
|
|
|
|
|
$cur_view = std::make_shared<sf::RenderTexture>($presenter.getSize()); |
|
|
|
|
|
|
|
$cur_sprite = std::make_shared<sf::Sprite>($cur_view->getTexture()); |
|
|
|
|
|
|
|
$cur_sprite->setPosition({float(cur_cell.x), float(cur_cell.y)}); |
|
|
|
|
|
|
|
$cur_sprite->setScale({0.3f, 0.3f}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto& next_cell = $gui.cell_for(next); |
|
|
|
|
|
|
|
$next_view = std::make_shared<sf::RenderTexture>($presenter.getSize()); |
|
|
|
|
|
|
|
$next_sprite = std::make_shared<sf::Sprite>($next_view->getTexture()); |
|
|
|
|
|
|
|
$next_sprite->setPosition({float(next_cell.x), float(next_cell.y)}); |
|
|
|
|
|
|
|
$next_sprite->setScale({0.3f, 0.3f}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ControlUI::init() { |
|
|
|
void ControlUI::init() { |
|
|
|
auto status_id = $gui.entity("status"); |
|
|
|
auto status_id = $gui.entity("status"); |
|
|
|
$gui.set<guecs::Text>(status_id, {L""}); |
|
|
|
$gui.set<guecs::Text>(status_id, {L""}); |
|
|
|
|
|
|
|
|
|
|
|
auto docs_id = $gui.entity("docs"); |
|
|
|
auto docs_id = $gui.entity("docs"); |
|
|
|
$gui.set<guecs::Text>(docs_id, {L"F: fullscreen\nA: win left\nD: win right\nQ: quit"}); |
|
|
|
$gui.set<guecs::Text>(docs_id, {L"F: fullscreen\nA: win left\nD: win right\nQ: quit"}); |
|
|
|
$gui.init(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto current = $gui.entity("current"); |
|
|
|
auto current = $gui.entity("current"); |
|
|
|
auto next = $gui.entity("next"); |
|
|
|
$gui.set<guecs::Rectangle>(current, {}); |
|
|
|
|
|
|
|
$gui.set<guecs::Text>(current, {.content=L"CURRENT", .size=40}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto preview = $gui.entity("preview"); |
|
|
|
|
|
|
|
$gui.set<guecs::Rectangle>(preview, {.color=guecs::THEME.DARK_DARK}); |
|
|
|
|
|
|
|
$gui.set<guecs::Text>(preview, { |
|
|
|
|
|
|
|
.content=L"PREVIEW", |
|
|
|
|
|
|
|
.size=40, |
|
|
|
|
|
|
|
.color={180, 180, 180, 255} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
config_views(current, next); |
|
|
|
$gui.init(); |
|
|
|
|
|
|
|
|
|
|
|
// warning! must come after init so the thing is there
|
|
|
|
// warning! must come after init so the thing is there
|
|
|
|
$status = $gui.get_if<guecs::Text>(status_id); |
|
|
|
$status = $gui.get_if<guecs::Text>(status_id); |
|
|
|
dbc::check($status != nullptr, "failed to setup the status text"); |
|
|
|
dbc::check($status != nullptr, "failed to setup the status text"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inline void render_slide(sf::RenderTexture& view, Slide& slide) { |
|
|
|
void ControlUI::render_slide(const std::string& name, Slide& slide) { |
|
|
|
view.clear(); |
|
|
|
$gui.show_text(name, slide.preview); |
|
|
|
slide.render(view); |
|
|
|
|
|
|
|
view.display(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ControlUI::render(sf::RenderWindow& window, SlideDeck& deck) { |
|
|
|
void ControlUI::render(sf::RenderWindow& window, SlideDeck& deck) { |
|
|
|
@ -70,19 +60,16 @@ void ControlUI::render(sf::RenderWindow& window, SlideDeck& deck) { |
|
|
|
auto pos = $presenter.getPosition(); |
|
|
|
auto pos = $presenter.getPosition(); |
|
|
|
auto size = $presenter.getSize(); |
|
|
|
auto size = $presenter.getSize(); |
|
|
|
|
|
|
|
|
|
|
|
$status->update(fmt::format(L"pos={},{}\nsize={},{}", |
|
|
|
$status->update(fmt::format(L"Slide: {}\nOf: {}", |
|
|
|
pos.x, pos.y, size.x, size.y)); |
|
|
|
deck.current + 1, deck.slides.size())); |
|
|
|
|
|
|
|
|
|
|
|
window.clear(); |
|
|
|
window.clear(); |
|
|
|
$gui.render(window); |
|
|
|
$gui.render(window); |
|
|
|
|
|
|
|
|
|
|
|
render_slide(*$cur_view, deck.current_slide()); |
|
|
|
render_slide("current", deck.current_slide()); |
|
|
|
window.draw(*$cur_sprite); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
size_t preview = std::min(deck.slides.size() - 1, deck.current + 1); |
|
|
|
render_slide(*$next_view, deck.preview_slide()); |
|
|
|
render_slide("preview", deck.slide_at(preview)); |
|
|
|
window.draw(*$next_sprite); |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ControlUI::handle_events(std::shared_ptr<SlidesUI> slides, const sf::Event& event) { |
|
|
|
void ControlUI::handle_events(std::shared_ptr<SlidesUI> slides, const sf::Event& event) { |
|
|
|
|