Files
quip/src/quip.h
2025-11-01 15:54:37 +00:00

49 lines
1.3 KiB
C++

#pragma once
#include <SDL3/SDL.h>
#include <SDL3_ttf/SDL_ttf.h>
#include <string>
#include <variant>
#include <functional>
#include <map>
namespace Quip {
extern int windowCount;
namespace Widget {
class TextLabel {
public:
std::string text;
int xpos, ypos = 0;
explicit TextLabel(std::string text, int xpos, int ypos);
TextLabel();
};
class Button {
public:
std::string text;
std::function<void()> callback;
int xpos, ypos = 0;
int width = 100, height = 30;
explicit Button(std::string text, std::function<void()> callback, int xpos, int ypos);
};
typedef std::variant<TextLabel, Button> Widget;
}
class Window {
SDL_Window* window;
SDL_Renderer* renderer;
SDL_Event event;
TTF_Font* font;
std::string title;
int width, height;
std::map<std::string, Widget::Widget> widgets;
void error(int errCode = 0, const std::string& context = "");
public:
int run();
void addChild(const std::string& id, const Widget::Widget& widget);
Widget::Widget* getChild(const std::string& id);
explicit Window(std::string title, int width = 800, int height = 600);
Window();
};
}