summaryrefslogtreecommitdiff
path: root/src/ui.h
blob: 16027aee0f109c79b2d668058564573cc50aa8d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef UI_H
#define UI_H

#include<SFML/Graphics.hpp>

enum class MouseButton{
    Left,
    Mid,
    Right
};

class UI{
    public:
        int hotItem, activeItem;

        // TODO: Move MouseStatus other class
        using MousePos = sf::Vector2i;
        MousePos mousePos;
        struct MouseState{
            bool leftDown, rightDown, midDown;
            MouseState(){
                leftDown  = false;
                rightDown = false;
                midDown   = false;
            }
        } currentMouse, previousMouse;

        bool mouseButtonPressed(MouseButton m);
        bool mouseButtonReleased(MouseButton m);
        bool mouseButtonIsDown(MouseButton m);
        bool mouseButtonIsUp(MouseButton m);
        sf::Vector2i mousePosition();
        // end of MouseStatus

        void handleEvent(const sf::Event &event);
        void initImUI();
        void finishImUI();
        bool button(sf::RenderWindow *win, int id, const std::string &text,
                sf::Vector2i pos, sf::Vector2i size);
        bool radioButton(sf::RenderWindow *win, int id,
                const std::string &text, bool state, sf::Vector2i pos,
                sf::Vector2i size);

};

#endif // UI_H