-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathimgui_widgets.h
59 lines (41 loc) · 1.57 KB
/
imgui_widgets.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <imgui.h>
#include <core/md_vec_math.h>
// This is very messy, but it works for now
struct CoordSystemWidgetParam {
ImVec2 pos = ImVec2(0,0);
ImVec2 size;
const mat4_t& view_matrix;
quat_t& camera_ori;
vec3_t& camera_pos;
float& camera_dist;
};
namespace ImGui {
IMGUI_API bool RangeSliderFloat(const char* label, float* v1, float* v2, float v_min, float v_max, const char* display_format = "(%.3f, %.3f)", ImGuiSliderFlags flags = 0);
// custom ImGui procedures
bool DeleteButton(const char* label, const ImVec2& size = ImVec2(0, 0));
void CreateDockspace();
void BeginCanvas(const char* id, bool allow_inputs = false);
void EndCanvas();
inline void PushInvalid() {
ImGui::PushStyleColor(ImGuiCol_FrameBg, 0xAA222299);
}
inline void PopInvalid() {
ImGui::PopStyleColor();
}
inline bool InputQuery(const char* label, char* buf, size_t buf_size, bool is_valid, const char* err_text = 0, ImGuiInputTextFlags flags = 0) {
if (!is_valid) ImGui::PushInvalid();
bool result = ImGui::InputText(label, buf, buf_size, flags);
if (!is_valid) ImGui::PopInvalid();
if (ImGui::IsItemHovered() && !is_valid && err_text) {
ImGui::SetTooltip("%s", err_text);
}
return result;
}
void init_theme();
void PushDisabled();
void PopDisabled();
bool ColorEdit3Minimal(const char* label, float color[3]);
bool ColorEdit4Minimal(const char* label, float color[4]);
void DrawCheckerboard(ImDrawList* draw_list, ImVec2 p_min, ImVec2 p_max, ImU32 col1, ImU32 col2, float grid_step, ImVec2 grid_off);
bool DrawCoordinateSystemWidget(const CoordSystemWidgetParam& param);
} // namespace ImGui