VenomEngine
Cross-Platform Modern Graphics Engine
Loading...
Searching...
No Matches
GUI.h
Go to the documentation of this file.
1
8#pragma once
10
13
14namespace venom
15{
16namespace common
17{
18class GraphicsApplication;
19
20typedef void(*GUIDrawCallback)();
21class VENOM_COMMON_API GUI : public GraphicsPluginObject
22{
23public:
24 GUI();
25 ~GUI() override;
26
27 void SetGraphicsApplication(GraphicsApplication * app);
28
29 virtual vc::Error Initialize() = 0;
30 virtual vc::Error Reset() = 0;
31
32 inline void DrawCallback() { if (s_guiDrawCallback) s_guiDrawCallback(); }
33 static inline void SetGUIDrawCallback(GUIDrawCallback guiDrawCallback) { s_guiDrawCallback = guiDrawCallback; }
34
35 inline void Render() { DrawCallback(); s_gui->_Render(); }
36
37 static inline GUI * Get() { return s_gui; }
38
39 static inline void NewFrame() { s_gui->_NewFrame(); }
40 static inline void Begin(const char * name, bool * p_open = nullptr, GUIWindowFlags flags = 0) { s_gui->_Begin(name, p_open, flags); }
41 static inline void End() { s_gui->_End(); }
42 static inline void Text(const char* fmt, ...) { va_list args; va_start(args, fmt); s_gui->_Text(fmt, args); va_end(args); }
43 static inline void TextColored(const vcm::Vec4 & col, const char* fmt, ...) { va_list args; va_start(args, fmt); s_gui->_TextColored(col, fmt, args); va_end(args); }
44 static inline void LabelText(const char* label, const char* fmt, ...) { va_list args; va_start(args, fmt); s_gui->_LabelText(label, fmt, args); va_end(args); }
45
46 static inline bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f) { return s_gui->_SliderFloat(label, v, v_min, v_max, format, power); }
47 static inline bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f) { return s_gui->_SliderFloat3(label, v, v_min, v_max, format, power); }
48
49 static inline void ColorEdit3(const char* label, float col[3], GUIColorEditFlags flags = 0) { s_gui->_ColorEdit3(label, col, flags); }
50
51 static inline bool Button(const char* label, const vcm::Vec2 & size = vcm::Vec2(0, 0)) { return s_gui->_Button(label, size); }
52 static inline bool Checkbox(const char* label, bool* v) { return s_gui->_Checkbox(label, v); }
53 static inline void ProgressBar(float fraction, const vcm::Vec2 & size_arg = vcm::Vec2(-1, 0), const char* overlay = nullptr) { s_gui->_ProgressBar(fraction, size_arg, overlay); }
54
55 static inline bool Selectable(const char* label, bool selected, GUISelectableFlags flags = 0, const vcm::Vec2 & size = vcm::Vec2(0, 0)) { return s_gui->_Selectable(label, selected, flags, size); }
56
57 static inline bool BeginCombo(const char* label, const char* preview_value, GUIComboFlags flags = 0) { return s_gui->_BeginCombo(label, preview_value, flags); }
58 static inline void EndCombo() { s_gui->_EndCombo(); }
59
60 static inline void SetItemDefaultFocus() { s_gui->_SetItemDefaultFocus(); }
61
62 static inline void SameLine(float offset_from_start_x = 0.0f, float spacing = -1.0f) { s_gui->_SameLine(offset_from_start_x, spacing); }
63
64protected:
65 virtual void _NewFrame() = 0;
66 virtual void _Begin(const char * name, bool * p_open, GUIWindowFlags flags) = 0;
67 virtual void _End() = 0;
68 virtual void _Text(const char* fmt, ...) = 0;
69 virtual void _TextColored(const vcm::Vec4 & col, const char* fmt, ...) = 0;
70 virtual void _LabelText(const char* label, const char* fmt, ...) = 0;
71
72 virtual bool _SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format, float power) = 0;
73 virtual bool _SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format, float power) = 0;
74
75 virtual void _ColorEdit3(const char* label, float col[3], GUIColorEditFlags flags) = 0;
76
77 virtual bool _Button(const char* label, const vcm::Vec2 & size) = 0;
78 virtual bool _Checkbox(const char* label, bool* v) = 0;
79 virtual void _ProgressBar(float fraction, const vcm::Vec2 & size_arg, const char* overlay) = 0;
80
81 virtual bool _Selectable(const char* label, bool selected, GUISelectableFlags flags, const vcm::Vec2 & size) = 0;
82
83 virtual bool _BeginCombo(const char* label, const char* preview_value, GUIComboFlags flags) = 0;
84 virtual void _EndCombo() = 0;
85
86 virtual void _SetItemDefaultFocus() = 0;
87
88 virtual void _SameLine(float offset_from_start_x, float spacing) = 0;
89
90 virtual void _Render() = 0;
91
92protected:
94
95private:
96 static GUI * s_gui;
97
98private:
99 static GUIDrawCallback s_guiDrawCallback;
100};
101}
102}
Definition GUI.h:22
Definition GraphicsApplication.h:27
Base class for graphics plugin objects.
Definition GraphicsPluginObject.h:80
Contains the entirety of the code of the VenomEngine project.
Definition Config.h:13