106 lines
No EOL
1.7 KiB
C++
106 lines
No EOL
1.7 KiB
C++
#pragma once
|
|
|
|
#include "Window.hpp"
|
|
|
|
#include "Color.hpp"
|
|
#include "Rect.hpp"
|
|
|
|
#include "Buffer.hpp"
|
|
|
|
namespace tp {
|
|
|
|
class DebugGUI {
|
|
class Context;
|
|
Context* mContext;
|
|
|
|
public:
|
|
explicit DebugGUI(Window* window);
|
|
~DebugGUI();
|
|
|
|
void procBegin() {}
|
|
void procEnd() {}
|
|
|
|
void drawBegin();
|
|
void drawEnd();
|
|
};
|
|
|
|
class Canvas {
|
|
class Context;
|
|
Context* mContext;
|
|
|
|
public:
|
|
explicit Canvas(Window* window);
|
|
~Canvas();
|
|
|
|
void procBegin() {}
|
|
void procEnd() {}
|
|
|
|
void drawBegin();
|
|
void drawEnd();
|
|
|
|
public:
|
|
enum Align : int2 {
|
|
CC = 0x0000,
|
|
CT = 0x0001,
|
|
CB = 0x0002,
|
|
LC = 0x0100,
|
|
LT = 0x0101,
|
|
LB = 0x0102,
|
|
RC = 0x0200,
|
|
RT = 0x0201,
|
|
RB = 0x0202,
|
|
};
|
|
|
|
struct ImageHandle {
|
|
ualni id = 0;
|
|
};
|
|
|
|
void pushClamp(const RectF& rec);
|
|
void popClamp();
|
|
void rect(const RectF& rec, const RGBA& col, halnf round = 0);
|
|
void text(const char*, const RectF&, halnf size, Align, halnf padding, const RGBA&);
|
|
|
|
ImageHandle createImageFromTextId(ualni id, Vec2F size);
|
|
void updateTextureID(ImageHandle handle, ualni id);
|
|
|
|
void deleteImageHandle(ImageHandle image);
|
|
void drawImage(const RectF& rec, ImageHandle* image, halnf angle = 0, halnf alpha = 1.f, halnf rounding = 0.f);
|
|
|
|
private:
|
|
Buffer<RectF> mScissors;
|
|
bool mIsClamping = false;
|
|
};
|
|
|
|
class Graphics {
|
|
public:
|
|
explicit Graphics(Window* window) :
|
|
mGui(window),
|
|
mCanvas(window) {}
|
|
|
|
void procBegin() {
|
|
mCanvas.procBegin();
|
|
mGui.procBegin();
|
|
}
|
|
|
|
void procEnd() {
|
|
mCanvas.procEnd();
|
|
mGui.procEnd();
|
|
}
|
|
|
|
void drawBegin() {
|
|
mCanvas.drawBegin();
|
|
mGui.drawBegin();
|
|
}
|
|
|
|
void drawEnd() {
|
|
mCanvas.drawEnd();
|
|
mGui.drawEnd();
|
|
}
|
|
|
|
Canvas* getCanvas() { return &mCanvas; }
|
|
|
|
private:
|
|
Canvas mCanvas;
|
|
DebugGUI mGui;
|
|
};
|
|
} |