NeuralEngine A Game Engine with embeded Machine Learning algorithms based on Gaussian Processes. |

FgWindow.h
1
11#pragma once
12
13#include <MachineLearning/FgColor.h>
14#include <string>
15
16 namespace NeuralEngine
17{
18 namespace MachineLearning
19 {
20 struct NE_IMPEXP Rect
21 {
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) {}
25 };
26
27 struct NE_IMPEXP Size
28 {
29 int width, height;
30 Size(int width, int height) : width(width), height(height) {}
31 };
32
33 struct NE_IMPEXP Offset
34 {
35 int x, y;
36 Offset(int x, int y) : x(x), y(y) {}
37 };
38
39 typedef void(*MouseCallback)(int event, int x, int y, int flags, void* param);
40 typedef void(*TrackbarCallback)(int pos, void* param);
41
42 class Window;
43
44 class NE_IMPEXP View
45 {
46 public:
47 View(Window& window, const std::string& title = "", Size size = { 300, 300 });
48
49 View& resize(Rect rect);
50
51 View& size(Size size);
52
53 View& offset(Offset offset);
54
55 View& autosize();
56
57 View& title(const std::string& title);
58
59 View& alpha(int alpha);
60
61 View& backgroundColor(Color color);
62
63 View& frameColor(Color color);
64
65 View& textColor(Color color);
66
67 View& mouse(MouseCallback callback, void* param = NULL);
68
69 void onmouse(int event, int x, int y, int flags);
70
71 Color backgroundColor();
72
73 Color frameColor();
74
75 Color textColor();
76
77 std::string& title();
78
79 bool has(Offset offset);
80
81 void drawRect(Rect rect, Color color);
82
83 void drawFill(Color background = White);
84
85 void drawImage(const void* image, int alpha = 255);
86
87 void drawText(const std::string& text, Offset offset, Color color) const;
88
89 void drawFrame(const std::string& title) const;
90
91 void* buffer(Rect& rect);
92
93 void finish();
94
95 void flush();
96
97 void hide(bool hidden = true);
98
99 View& operator=(const View&) = delete;
100
101 protected:
102 Rect rect_;
103 std::string title_;
104 bool frameless_;
105 Window& window_;
106 Color background_color_;
107 Color frame_color_;
108 Color text_color_;
109 MouseCallback mouse_callback_;
110 void* mouse_param_;
111 bool hidden_;
112 };
113
114 class NE_IMPEXP Window
115 {
116 public:
117 Window(const std::string& title = "");
118
119 Window& resize(Rect rect);
120
121 Window& size(Size size);
122
123 Window& offset(Offset offset);
124
125 Window& title(const std::string& title);
126
127 Window& fps(float fps);
128
129 Window& ensure(Rect rect);
130
131 Window& cursor(bool cursor);
132
133 void* buffer();
134
135 void flush();
136
137 View& view(const std::string& name, Size size = { 300, 300 });
138
139 void dirty();
140
141 void tick();
142
143 void hide(bool hidden = true);
144
145 void onmouse(int event, int x, int y, int flags);
146
147 Window& operator=(const Window&) = delete;
148
149 static Window& current();
150 static void current(Window& window);
151 static Window& current(const std::string& title);
152
153 protected:
154 Offset offset_;
155 void* buffer_;
156 std::string title_;
157 std::string name_;
158 std::map<std::string, View> views_;
159 bool dirty_;
160 float flush_time_;
161 float fps_;
162 bool hidden_;
163 bool show_cursor_;
164 Offset cursor_;
165 };
166
167 class NE_IMPEXP Util {
168 public:
169 static void sleep(float seconds = 0);
170 static char key(float timeout = 0);
171 static std::string line(float timeout = 0);
172 };
173 }
174}
NeuralEngine::MachineLearning::Color
Definition: FgColor.h:21
NeuralEngine::MachineLearning::Util
Definition: FgWindow.h:167
NeuralEngine::MachineLearning::View
Definition: FgWindow.h:45
NeuralEngine::MachineLearning::Window
Definition: FgWindow.h:115
NeuralEngine
Definition: NeArray2.h:18
NeuralEngine::MachineLearning::Offset
Definition: FgWindow.h:34
NeuralEngine::MachineLearning::Rect
Definition: FgWindow.h:21
NeuralEngine::MachineLearning::Size
Definition: FgWindow.h:28