Euphoria
ui.h
Go to the documentation of this file.
1#pragma once
2
3#include "dear_imgui/imgui.h"
4
5namespace eu::render
6{
7struct FrameBuffer;
8}
9
10
11namespace eu::core
12{
13 struct SCurve;
14}
15
16namespace eu::imgui
17{
18
21 {
22 ImVec2 drag = { 0.5f, 0.5f };
23
24 SCurveGuiState() = default;
25 SCurveGuiState(float x, float y);
26
27 static constexpr std::size_t num_points = 21;
28 std::array<ImVec2, num_points> point_cache;
29 };
30
31 enum class FlipX
32 {
34 };
35
36
38{
39 unsigned int program_handle = 0;
42};
43
57
64
66
71
72bool button(const char* label, ButtonStyle style = ButtonStyle::secondary, const std::optional<ImVec2>& button_size = std::nullopt);
73bool centered_button(const char* label, ButtonStyle style = ButtonStyle::secondary, const std::optional<ImVec2>& button_size = std::nullopt);
74
75bool header(const char* label, bool* closeable = nullptr);
76
77void begin_disabled(bool enabled);
79
80enum class ProgressSize
81{
83};
84void progress(const char* title, std::optional<float> percentage, ProgressSize size = ProgressSize::normal);
85
87{
88 PropTable(const PropTable&) = delete;
89 void operator=(const PropTable&) = delete;
90 void operator=(const PropTable&&) = delete;
91
92 PropTable(PropTable&& r) noexcept;
93
94 constexpr operator bool() const { return started; }
95
96 static PropTable Begin(const char* label = "properties");
98
99 bool check(const char* label, bool* v) const;
100 bool slider(const char* label, float* v, float min, float max) const;
101 bool slider(const char* label, float* v) const;
102 void text(const char* label, const std::string& str) const;
103 bool edit(const char* label, std::string* str) const;
104
105 void display(const char* label, bool b) const;
106 void readonly(const char* label, const std::string& text) const;
107 void readonly(const char* label, const v3& v) const;
108 void readonly(const char* label, const Ypr& y) const;
109 bool color(const char* label, Rgb* color) const;
110 bool simple_gamma_slider(const char* label, float* gamma, float curve = 1.5f, float min_gamma = 1.6f, float max_gamma = 2.8f) const;
111 bool drag(const char* label, v3* drag, float reset_value = 0.0f) const;
112 bool drag(const char* label, Ypr* drag) const;
113 bool drag(const char* label, Rui* drag) const;
114 bool drag(const char* label, float* drag, float speed = 1.0f) const;
115 bool drag(const char* label, int* drag) const;
116 void transform(const m4& m) const;
117 bool transform(m4* m) const;
118 bool scurve(const char* label, core::SCurve* scurve, SCurveGuiState* gui, FlipX flip_x, const ImVec2& requested_widget_size = ImVec2{ 100, 100 }) const;
119
120 void image(const char* label, const render::FrameBuffer& img, ImguiShaderCache* cache, ImageShader shader) const;
121private:
122 bool started;
123
124 PropTable() = default;
125 explicit PropTable(bool b);
126};
127
128
129}
constexpr float min(float lhs, float rhs)
Definition numeric.h:78
constexpr float max(float lhs, float rhs)
Definition numeric.h:79
void begin_disabled(bool enabled)
bool header(const char *label, bool *closeable=nullptr)
ImageShader
Definition ui.h:59
FlipX
Definition ui.h:32
ProgressSize
Definition ui.h:81
ButtonStyle
Definition ui.h:68
bool centered_button(const char *label, ButtonStyle style=ButtonStyle::secondary, const std::optional< ImVec2 > &button_size=std::nullopt)
void setup_colors()
void progress(const char *title, std::optional< float > percentage, ProgressSize size=ProgressSize::normal)
void end_disabled()
bool button(const char *label, ButtonStyle style=ButtonStyle::secondary, const std::optional< ImVec2 > &button_size=std::nullopt)
Definition ui.h:6
Represents color in gamma (non-linear) space (aka sRGB).
Definition colors.h:14
Definition mat4.h:18
yaw + pitch + roll
Definition axisangle.h:33
Contains the parameters for an S-Curve.
Definition scurve.h:15
ImguiShaderCache(const ImguiShaderCache &)=delete
ImguiShaderCache & operator=(ImguiShaderCache &&)=delete
ImguiShaderCache(ImguiShaderCache &&)=delete
ImguiShaderProgram linear_to_gamma_shader
Definition ui.h:54
ImguiShaderProgram depth_ortho_shader
Definition ui.h:55
ImguiShaderCache & operator=(const ImguiShaderCache &)=delete
unsigned int program_handle
Definition ui.h:39
bool scurve(const char *label, core::SCurve *scurve, SCurveGuiState *gui, FlipX flip_x, const ImVec2 &requested_widget_size=ImVec2{ 100, 100 }) const
bool simple_gamma_slider(const char *label, float *gamma, float curve=1.5f, float min_gamma=1.6f, float max_gamma=2.8f) const
bool slider(const char *label, float *v) const
static PropTable Begin(const char *label="properties")
PropTable(const PropTable &)=delete
bool check(const char *label, bool *v) const
void text(const char *label, const std::string &str) const
bool drag(const char *label, Ypr *drag) const
void readonly(const char *label, const v3 &v) const
void operator=(const PropTable &)=delete
void display(const char *label, bool b) const
bool drag(const char *label, float *drag, float speed=1.0f) const
bool edit(const char *label, std::string *str) const
bool transform(m4 *m) const
void transform(const m4 &m) const
void readonly(const char *label, const Ypr &y) const
bool slider(const char *label, float *v, float min, float max) const
bool drag(const char *label, v3 *drag, float reset_value=0.0f) const
void operator=(const PropTable &&)=delete
bool drag(const char *label, int *drag) const
void readonly(const char *label, const std::string &text) const
PropTable(PropTable &&r) noexcept
void image(const char *label, const render::FrameBuffer &img, ImguiShaderCache *cache, ImageShader shader) const
bool color(const char *label, Rgb *color) const
bool drag(const char *label, Rui *drag) const
Represents the GUI state for an S-curve.
Definition ui.h:21
ImVec2 drag
the gui data
Definition ui.h:22
static constexpr std::size_t num_points
number of points to draw, more points means smoother curve, but more expensive
Definition ui.h:27
std::array< ImVec2, num_points > point_cache
Definition ui.h:28
SCurveGuiState(float x, float y)
4x4 matrix
Definition mat4.h:26
"render to texture" feature
Definition texture.h:103
a 3d vector
Definition vec3.h:27