13#include <MachineLearning/FgColor.h>
18 namespace MachineLearning
22 int x, y, width, height;
23 Rect(
int x,
int y,
int width,
int height)
24 : x(x), y(y), width(width), height(height) {}
30 Size(
int width,
int height) : width(width), height(height) {}
36 Offset(
int x,
int y) : x(x), y(y) {}
39 typedef void(*MouseCallback)(
int event,
int x,
int y,
int flags,
void* param);
40 typedef void(*TrackbarCallback)(
int pos,
void* param);
47 View(
Window& window,
const std::string& title =
"",
Size size = { 300, 300 });
57 View& title(
const std::string& title);
59 View& alpha(
int alpha);
67 View& mouse(MouseCallback callback,
void* param = NULL);
69 void onmouse(
int event,
int x,
int y,
int flags);
71 Color backgroundColor();
83 void drawFill(
Color background = White);
85 void drawImage(
const void* image,
int alpha = 255);
87 void drawText(
const std::string& text,
Offset offset,
Color color)
const;
89 void drawFrame(
const std::string& title)
const;
91 void* buffer(
Rect& rect);
97 void hide(
bool hidden =
true);
99 View& operator=(
const View&) =
delete;
106 Color background_color_;
109 MouseCallback mouse_callback_;
117 Window(
const std::string& title =
"");
125 Window& title(
const std::string& title);
131 Window& cursor(
bool cursor);
137 View& view(
const std::string& name,
Size size = { 300, 300 });
143 void hide(
bool hidden =
true);
145 void onmouse(
int event,
int x,
int y,
int flags);
150 static void current(
Window& window);
151 static Window& current(
const std::string& title);
158 std::map<std::string, View> views_;
169 static void sleep(
float seconds = 0);
170 static char key(
float timeout = 0);
171 static std::string line(
float timeout = 0);