17 #define GUIT_VERSION_MAJOR 0
18 #define GUIT_VERSION_MINOR 1
19 #define GUIT_VERSION_PATCH 1
25 using ssize_t =
signed long;
31 using GString = std::string;
34 using GStrings = std::vector<GString>;
40 using GTexture = uint32_t;
43 using GTime = uint32_t;
46 using GKeyCode = uint32_t;
49 enum struct GEventType : uint32_t;
52 enum struct GEventState : uint32_t;
55 enum struct GHandle : uint8_t;
59 using GFunction = std::function<void()>;
60 using GEventFunction = std::function<void(class GEvent&)>;
61 using GPredicate = std::function<bool(class Gadget&)>;
67 void gerror(GString const& where, GString const& message, class GObject const* = {});
72 void gexec(GFunction const& fun);
75 void gsleep(GTime milliseconds);
84 GPoint(
float x,
float y) : x(x), y(y) {}
86 void set(
float x_,
float y_) {x = x_; y = y_;}
89 bool operator==(
GPoint const&)
const;
90 bool operator!=(
GPoint const&)
const;
91 friend std::istream& operator>>(std::istream& in,
GPoint&);
92 friend std::ostream& operator<<(std::ostream& out,
GPoint const&);
102 GDim(
float w,
float h) : w(w), h(h) {}
104 void set(
float width,
float height) {w = width; h = height;}
105 bool operator==(
const GDim&)
const;
106 bool operator!=(
const GDim&)
const;
107 friend std::ostream& operator<<(std::ostream& out,
GDim const&);
108 friend std::istream& operator>>(std::istream& in,
GDim&);
116 GRect() : x{}, y{}, w{}, h{} {}
117 GRect(
float x,
float y,
float w,
float h) : x(x), y(y), w(w), h(h) {}
118 GRect(
GPoint const& p,
GDim const& d) : x(p.x), y(p.y), w(d.w), h(d.h) {}
124 GRect frame()
const {
return *
this;}
125 void set(
float x,
float y,
float width,
float height);
126 void translate(
float dx,
float dy);
127 bool contain(
GPoint const& point)
const {
128 return point.x >= x && point.x <= x+w && point.y >= y && point.y <= y+h;
130 bool contain(
GPoint const& point,
float tolerance)
const;
131 bool intersect(
GPoint const& line_point1,
GPoint const& line_point2)
const;
132 bool operator==(
const GRect&)
const;
133 bool operator!=(
const GRect&)
const;
134 friend std::ostream& operator<<(std::ostream&,
GRect const&);
135 friend std::istream& operator>>(std::istream&,
GRect&);
142 void translate(
float dx,
float dy);
143 bool contain(
GPoint const& point)
const;
144 bool contain(
GRect const& rect)
const;
145 bool intersect(
GRect const& rect)
const;
146 friend std::ostream& operator<<(std::ostream&,
GPoints const&);
147 friend std::istream& operator>>(std::istream&,
GPoints&);
153 inline bool gconvert(GString
const& from, GString& to) {to = from;
return true;}
154 bool gconvert(GString
const& from,
bool& to);
155 bool gconvert(GString
const& from,
float& to);
156 bool gconvert(GString
const& from,
int& to);
157 bool gconvert(GString
const& from, int8_t& to);
158 bool gconvert(GString
const& from, int16_t& to);
160 bool gconvert(
const bool& from, GString& to);
161 bool gconvert(
const float& from, GString& to);
162 inline bool gconvert(
const int& from, GString& to) {to = std::to_string(from);
return true;}
163 inline bool gconvert(
const int8_t& from, GString& to) {to = std::to_string(from);
return true;}
164 inline bool gconvert(
const int16_t& from, GString& to) {to = std::to_string(from);
return true;}
166 bool gconvert(
const float& from,
int& to);
167 inline bool gconvert(
const int& from,
float& to) {to = float(from);
return true;}
169 inline bool gconvert(
const float& from,
float& to) {to = from;
return true;}
170 inline bool gconvert(
const int& from,
int& to) {to = from;
return true;}
171 inline bool gconvert(
const bool& from,
bool& to) {to = from;
return true;}
173 bool gconvert(
const double& from,
float& to);
174 bool gconvert(
const double& from,
int& to);
176 template <
typename T>
177 inline GString toString(T
const& val) {GString s; gconvert(val,s);
return s;}
179 template <
typename T>
180 inline int toInt(T
const& val) {
int num{}; gconvert(val,num);
return num;}
182 template <
typename T>
183 inline float toFloat(T
const& val) {
float num{}; gconvert(val,num);
return num;}
271 class GRenderGraphics;
272 class GTextAttributes;