40 lines
968 B
C++
40 lines
968 B
C++
#pragma once
|
|
#include "context.h"
|
|
#include <vector>
|
|
|
|
namespace ui
|
|
{
|
|
enum MouseButton { mbLeft = 0, mbMiddle = 1, mbRight = 2 };
|
|
enum MouseButtonState { mbsReleased, mbsDown, mbsPressed, mbsUp };
|
|
struct Input {
|
|
struct {
|
|
int x, y;
|
|
MouseButtonState buttons[3] = {mbsReleased, mbsReleased, mbsReleased};
|
|
int wheel = 0;
|
|
} mouse;
|
|
struct {
|
|
uint8_t keyDown = 0;
|
|
uint8_t keyUp = 0;
|
|
const bool *keys;
|
|
} keyboard;
|
|
};
|
|
|
|
class Window {
|
|
public:
|
|
|
|
Window(const char *title, int width, int height);
|
|
~Window();
|
|
|
|
bool HandleEvents(SDL_Event *e);
|
|
virtual void Update();
|
|
|
|
static void DistributeEvent(SDL_Event *e);
|
|
|
|
protected:
|
|
SDL_Window *win;
|
|
Context *context;
|
|
Input input;
|
|
|
|
static std::vector<std::pair<uint32_t, Window*>> windows;
|
|
};
|
|
} |