diff --git a/constants.hpp b/constants.hpp index 7e5a7f1..7d4e114 100644 --- a/constants.hpp +++ b/constants.hpp @@ -6,5 +6,5 @@ constexpr const int FRAME_LIMIT=60; constexpr const bool VSYNC=true; constexpr const int TITLE_SIZE=124; constexpr const int CONTENT_SIZE=94; -constexpr const int CONTROL_WIDTH=400; -constexpr const int CONTROL_HEIGHT=400; +constexpr const int CONTROL_WIDTH=1000; +constexpr const int CONTROL_HEIGHT=1000; diff --git a/control.cpp b/control.cpp index f0834dd..c027096 100644 --- a/control.cpp +++ b/control.cpp @@ -17,8 +17,8 @@ ControlUI::ControlUI(sf::RenderWindow& presenter) : { $gui.position(0, 0, CONTROL_WIDTH, CONTROL_HEIGHT); $gui.layout( - "[status]" - "[docs]" + "[status|=%(100,100)current]" + "[docs|=%(100,100)next]" ); } @@ -29,12 +29,24 @@ void ControlUI::init() { auto docs_id = $gui.entity("docs"); $gui.set(docs_id, {L"A: win left\nD: win right\nQ: quit"}); - $status = $gui.get_if(status_id); + auto current = $gui.entity("current"); + $gui.set(current, {L"Current Slide"}); + $gui.set(current, {}); + + auto next = $gui.entity("next"); + $gui.set(next, {L"Next Slide"}); + $gui.set(next, {}); $gui.init(); + + // warning! must come after init so the thing is there + $status = $gui.get_if(status_id); + dbc::check($status != nullptr, "failed to setup the status text"); } void ControlUI::render(sf::RenderWindow& window) { + dbc::check($status != nullptr, "called render before init?"); + auto pos = $presenter.getPosition(); auto size = $presenter.getSize(); @@ -46,12 +58,14 @@ void ControlUI::render(sf::RenderWindow& window) { } void ControlUI::handle_events(sf::RenderWindow& controller, const sf::Event& event) { - if(const auto* key = event.getIf()) { - if(event.is()) { - controller.close(); - return; - } + dbc::check($status != nullptr, "handle_events called before init?!"); + if(event.is()) { + controller.close(); + return; + } + + if(const auto* key = event.getIf()) { auto pos = $presenter.getPosition(); auto size = $presenter.getSize(); diff --git a/main.cpp b/main.cpp index 8201b0b..34e8a67 100644 --- a/main.cpp +++ b/main.cpp @@ -26,7 +26,6 @@ int main(int argc, char *argv[]) { presenter.setFramerateLimit(FRAME_LIMIT); presenter.setVerticalSyncEnabled(VSYNC); - auto data = parse_slides(argv[1]); SlidesUI slides(data); @@ -35,6 +34,8 @@ int main(int argc, char *argv[]) { ControlUI control_ui(presenter); control_ui.init(); + dbc::check(control_ui.$status != nullptr, "bad ptr"); + while(controller.isOpen()) { while (const auto event = presenter.pollEvent()) { if(const auto* mouse = event->getIf()) {