From 30f488cdcb88dad5dd1df425588cb6a7fd206bb5 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Mon, 5 Dec 2022 22:55:40 +0100 Subject: Sketch ImGUI: - Still needs font rendering --- src/states/titleState.cpp | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'src/states/titleState.cpp') diff --git a/src/states/titleState.cpp b/src/states/titleState.cpp index a0d17c8..d96c840 100644 --- a/src/states/titleState.cpp +++ b/src/states/titleState.cpp @@ -1,8 +1,12 @@ #include "titleState.h" #include +#include + TitleState::TitleState(StateStack &stack, State::Context context) : State(stack, context) + // TODO: Initialize UI properly to zeros + //, ui(0,0,false,false,0,0) { } @@ -12,14 +16,31 @@ void TitleState::update(sf::Time dt){ } void TitleState::render(){ - sf::RectangleShape rectangle; - rectangle.setSize(sf::Vector2f(100, 50)); - rectangle.setOutlineColor(sf::Color::Red); - rectangle.setOutlineThickness(5); - rectangle.setPosition(10, 20); - context_.window->draw(rectangle); + static bool radioState = false; + + ui.initImUI(); + + if (ui.button(context_.window, 17, "Button 1", sf::Vector2i(0,0), sf::Vector2i(200,100)) ){ + printf("Button 1 pressed!!\n"); + } + if (ui.button(context_.window, 18, "Button 2", sf::Vector2i(0,200), sf::Vector2i(200,100)) ){ + printf("Button 2 pressed!!\n"); + } + if (ui.button(context_.window, 19, "Button 3", sf::Vector2i(0,400), sf::Vector2i(200,100)) ){ + printf("Button 3 pressed!!\n"); + } + + + radioState = ui.radioButton(context_.window, 21, "Radio", radioState, + sf::Vector2i(0,800), sf::Vector2i(200,100)); + + if (radioState){ + ui.button(context_.window, 20, "Hidden button", sf::Vector2i(0,600), sf::Vector2i(200,100)); + } + + ui.finishImUI(); } void TitleState::handleEvent(const sf::Event &event){ - + ui.handleEvent(event); } -- cgit v1.2.3