Line |
Branch |
Exec |
Source |
1 |
|
|
// This file is part of INSTINCT, the INS Toolkit for Integrated |
2 |
|
|
// Navigation Concepts and Training by the Institute of Navigation of |
3 |
|
|
// the University of Stuttgart, Germany. |
4 |
|
|
// |
5 |
|
|
// This Source Code Form is subject to the terms of the Mozilla Public |
6 |
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this |
7 |
|
|
// file, You can obtain one at https://mozilla.org/MPL/2.0/. |
8 |
|
|
|
9 |
|
|
/// @file InputWithUnit.hpp |
10 |
|
|
/// @brief Defines Widgets which allow the input of values and the selection of the unit |
11 |
|
|
/// @author T. Topp (topp@ins.uni-stuttgart.de) |
12 |
|
|
/// @date 2021-10-21 |
13 |
|
|
|
14 |
|
|
#pragma once |
15 |
|
|
|
16 |
|
|
#include <cstdint> |
17 |
|
|
#include <fmt/format.h> |
18 |
|
|
#include <imgui.h> |
19 |
|
|
#include <string> |
20 |
|
|
#include <algorithm> |
21 |
|
|
#include "imgui_ex.hpp" |
22 |
|
|
|
23 |
|
|
namespace NAV |
24 |
|
|
{ |
25 |
|
|
|
26 |
|
|
/// @brief Units separated by '\0' and terminated by double '\0' |
27 |
|
|
template<typename T> |
28 |
|
✗ |
[[nodiscard]] std::string MakeComboItems() |
29 |
|
|
{ |
30 |
|
✗ |
std::string str; |
31 |
|
✗ |
for (size_t i = 0; i < static_cast<size_t>(T::COUNT); i++) |
32 |
|
|
{ |
33 |
|
✗ |
if (!str.empty()) { str += '\0'; } |
34 |
|
✗ |
str += to_string(static_cast<T>(i)); |
35 |
|
|
} |
36 |
|
✗ |
str += '\0'; |
37 |
|
✗ |
str += '\0'; |
38 |
|
✗ |
return str; |
39 |
|
✗ |
} |
40 |
|
|
|
41 |
|
|
namespace gui::widgets |
42 |
|
|
{ |
43 |
|
|
/// Return value signaling that the input or the unit changed |
44 |
|
|
enum InputWithUnitChange : uint8_t |
45 |
|
|
{ |
46 |
|
|
InputWithUnitChange_None = 0, ///< Nothing changed |
47 |
|
|
InputWithUnitChange_Input, ///< The Input changed |
48 |
|
|
InputWithUnitChange_Unit, ///< The Unit changed |
49 |
|
|
}; |
50 |
|
|
|
51 |
|
|
namespace internal |
52 |
|
|
{ |
53 |
|
|
|
54 |
|
|
/// @brief Shows a Unit input combo |
55 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
56 |
|
|
/// @param unitWidth Width of the unit combo |
57 |
|
|
/// @param combo_current_item The selected item in the unit combo |
58 |
|
|
/// @param combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
59 |
|
|
/// @param combo_popup_max_height_in_items Maximum height of the combo in number of items |
60 |
|
|
/// @return Returns if the unit was changed |
61 |
|
|
template<typename U> |
62 |
|
✗ |
InputWithUnitChange Unit(const char* label, float unitWidth, |
63 |
|
|
U& combo_current_item, const char* combo_items_separated_by_zeros, |
64 |
|
|
int combo_popup_max_height_in_items) |
65 |
|
|
{ |
66 |
|
✗ |
InputWithUnitChange retVal = InputWithUnitChange_None; |
67 |
|
|
|
68 |
|
✗ |
ImGui::SetNextItemWidth(unitWidth - ImGui::GetStyle().ItemSpacing.x); |
69 |
|
|
|
70 |
|
✗ |
char first = '1'; |
71 |
|
✗ |
char second = '1'; |
72 |
|
✗ |
bool disable = true; |
73 |
|
✗ |
for (size_t i = 0; first != '\0' || second != '\0'; i++) |
74 |
|
|
{ |
75 |
|
✗ |
first = *(combo_items_separated_by_zeros + i); |
76 |
|
✗ |
second = *(combo_items_separated_by_zeros + i + 1); |
77 |
|
|
|
78 |
|
✗ |
if (first == '\0' && second != '\0') |
79 |
|
|
{ |
80 |
|
✗ |
disable = false; |
81 |
|
✗ |
break; |
82 |
|
|
} |
83 |
|
|
} |
84 |
|
|
|
85 |
|
✗ |
if (disable) { ImGui::BeginDisabled(); } |
86 |
|
✗ |
if (auto current_item = static_cast<int>(combo_current_item); |
87 |
|
✗ |
ImGui::Combo(fmt::format("##{} - unit", label).c_str(), ¤t_item, combo_items_separated_by_zeros, combo_popup_max_height_in_items)) |
88 |
|
|
{ |
89 |
|
✗ |
combo_current_item = static_cast<U>(current_item); |
90 |
|
✗ |
retVal = InputWithUnitChange_Unit; |
91 |
|
|
} |
92 |
|
✗ |
if (disable) { ImGui::EndDisabled(); } |
93 |
|
✗ |
ImGui::SameLine(); |
94 |
|
✗ |
ImGui::SetCursorPosX(ImGui::GetCursorPosX() - ImGui::GetStyle().ItemSpacing.x + ImGui::GetStyle().ItemInnerSpacing.x); |
95 |
|
✗ |
std::string strLabel{ label }; |
96 |
|
✗ |
ImGui::TextUnformatted(strLabel.substr(0, strLabel.find('#')).c_str()); |
97 |
|
|
|
98 |
|
✗ |
return retVal; |
99 |
|
✗ |
} |
100 |
|
|
|
101 |
|
|
/// @brief Shows an InputText GUI element to modify the provided value and also set its unit |
102 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
103 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
104 |
|
|
/// @param[in] unitWidth Width of the unit combo |
105 |
|
|
/// @param[in, out] v Pointer to the value to modify |
106 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
107 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
108 |
|
|
/// @param[in] step Step size of the InputText |
109 |
|
|
/// @param[in] step_fast Fast step size of the InputText |
110 |
|
|
/// @param[in] format Printf format to display the value with |
111 |
|
|
/// @param[in] flags InputText flags to modify the behavior |
112 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
113 |
|
|
/// @return Returns if the value or unit was changed |
114 |
|
|
template<ImGuiDataType_ _Scalar, unsigned int _Size, typename T, typename U> |
115 |
|
✗ |
InputWithUnitChange InputWithUnit(const char* label, float itemWidth, float unitWidth, |
116 |
|
|
T v[_Size], U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
117 |
|
|
T step, T step_fast, const char* format, ImGuiInputTextFlags flags, |
118 |
|
|
int combo_popup_max_height_in_items) |
119 |
|
|
{ |
120 |
|
✗ |
InputWithUnitChange retVal = InputWithUnitChange_None; |
121 |
|
|
|
122 |
|
✗ |
ImGui::SetNextItemWidth(itemWidth - unitWidth); |
123 |
|
|
if constexpr (_Size == 1) |
124 |
|
|
{ |
125 |
|
✗ |
flags |= ImGuiInputTextFlags_CharsScientific; |
126 |
|
✗ |
if (ImGui::InputScalar(fmt::format("##{} - input", label).c_str(), _Scalar, static_cast<void*>(v), static_cast<void*>(step > 0.0 ? &step : nullptr), static_cast<void*>(step_fast > 0.0 ? &step_fast : nullptr), format, flags)) |
127 |
|
|
{ |
128 |
|
✗ |
retVal = InputWithUnitChange_Input; |
129 |
|
|
} |
130 |
|
|
} |
131 |
|
|
else |
132 |
|
|
{ |
133 |
|
✗ |
if (ImGui::InputScalarN(fmt::format("##{} - input", label).c_str(), _Scalar, v, _Size, nullptr, nullptr, format, flags)) |
134 |
|
|
{ |
135 |
|
✗ |
retVal = InputWithUnitChange_Input; |
136 |
|
|
} |
137 |
|
|
} |
138 |
|
✗ |
ImGui::SameLine(); |
139 |
|
✗ |
retVal = static_cast<InputWithUnitChange>(retVal | Unit(label, unitWidth, combo_current_item, combo_items_separated_by_zeros, combo_popup_max_height_in_items)); |
140 |
|
|
|
141 |
|
✗ |
return retVal; |
142 |
|
|
} |
143 |
|
|
|
144 |
|
|
/// @brief Shows an Slider GUI element to modify the provided value and also set its unit |
145 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
146 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
147 |
|
|
/// @param[in] unitWidth Width of the unit combo |
148 |
|
|
/// @param[in, out] v Pointer to the value to modify |
149 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
150 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
151 |
|
|
/// @param[in] min Minimum value allowed |
152 |
|
|
/// @param[in] max Maximum value allowed |
153 |
|
|
/// @param[in] format Printf format to display the value with |
154 |
|
|
/// @param[in] flags Slider flags to modify the behavior |
155 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
156 |
|
|
/// @return Returns if the value or unit was changed |
157 |
|
|
template<ImGuiDataType_ _Scalar, unsigned int _Size, typename T, typename U> |
158 |
|
✗ |
InputWithUnitChange SliderWithUnit(const char* label, float itemWidth, float unitWidth, |
159 |
|
|
T v[_Size], U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
160 |
|
|
T min, T max, const char* format, ImGuiInputTextFlags flags, |
161 |
|
|
int combo_popup_max_height_in_items) |
162 |
|
|
{ |
163 |
|
✗ |
InputWithUnitChange retVal = InputWithUnitChange_None; |
164 |
|
|
|
165 |
|
✗ |
ImGui::SetNextItemWidth(itemWidth - unitWidth); |
166 |
|
|
if constexpr (_Size == 1) |
167 |
|
|
{ |
168 |
|
✗ |
flags |= ImGuiInputTextFlags_CharsScientific; |
169 |
|
✗ |
if (ImGui::SliderScalar(fmt::format("##{} - input", label).c_str(), _Scalar, static_cast<void*>(v), &min, &max, format, flags)) |
170 |
|
|
{ |
171 |
|
✗ |
retVal = InputWithUnitChange_Input; |
172 |
|
|
} |
173 |
|
|
} |
174 |
|
|
else |
175 |
|
|
{ |
176 |
|
|
if (ImGui::SliderScalarN(fmt::format("##{} - input", label).c_str(), _Scalar, v, _Size, &min, &max, format, flags)) |
177 |
|
|
{ |
178 |
|
|
retVal = InputWithUnitChange_Input; |
179 |
|
|
} |
180 |
|
|
} |
181 |
|
✗ |
ImGui::SameLine(); |
182 |
|
✗ |
retVal = static_cast<InputWithUnitChange>(retVal | Unit(label, unitWidth, combo_current_item, combo_items_separated_by_zeros, combo_popup_max_height_in_items)); |
183 |
|
|
|
184 |
|
✗ |
return retVal; |
185 |
|
|
} |
186 |
|
|
|
187 |
|
|
} // namespace internal |
188 |
|
|
|
189 |
|
|
/// @brief Shows an InputText GUI element to modify the provided value and also set its unit |
190 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
191 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
192 |
|
|
/// @param[in] unitWidth Width of the unit combo |
193 |
|
|
/// @param[in, out] v Pointer to the value to modify |
194 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
195 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
196 |
|
|
/// @param[in] step Step size of the InputText |
197 |
|
|
/// @param[in] step_fast Fast step size of the InputText |
198 |
|
|
/// @param[in] format Printf format to display the value with |
199 |
|
|
/// @param[in] flags InputText flags to modify the behavior |
200 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
201 |
|
|
/// @return Returns if the value or unit was changed |
202 |
|
|
template<typename U> |
203 |
|
|
InputWithUnitChange InputFloatWithUnit(const char* label, float itemWidth, float unitWidth, |
204 |
|
|
float* v, U& combo_current_item, const char* combo_items_separated_by_zeros, |
205 |
|
|
float step = 0.0, float step_fast = 0.0, const char* format = "%.3f", ImGuiInputTextFlags flags = 0, |
206 |
|
|
int combo_popup_max_height_in_items = -1) |
207 |
|
|
{ |
208 |
|
|
return internal::InputWithUnit<ImGuiDataType_Float, 1, float>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, step, step_fast, format, flags, combo_popup_max_height_in_items); |
209 |
|
|
} |
210 |
|
|
|
211 |
|
|
/// @brief Shows an InputText GUI element to modify the provided value and also set its unit |
212 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
213 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
214 |
|
|
/// @param[in] unitWidth Width of the unit combo |
215 |
|
|
/// @param[in, out] v Pointer to the value to modify |
216 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
217 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
218 |
|
|
/// @param[in] format Printf format to display the value with |
219 |
|
|
/// @param[in] flags InputText flags to modify the behavior |
220 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
221 |
|
|
/// @return Returns if the value or unit was changed |
222 |
|
|
template<typename U> |
223 |
|
|
InputWithUnitChange InputFloat2WithUnit(const char* label, float itemWidth, float unitWidth, |
224 |
|
|
float v[2], U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
225 |
|
|
const char* format = "%.3f", ImGuiInputTextFlags flags = 0, |
226 |
|
|
int combo_popup_max_height_in_items = -1) |
227 |
|
|
{ |
228 |
|
|
return internal::InputWithUnit<ImGuiDataType_Float, 2, float>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, 0.0, 0.0, format, flags, combo_popup_max_height_in_items); |
229 |
|
|
} |
230 |
|
|
|
231 |
|
|
/// @brief Shows an InputText GUI element to modify the provided value and also set its unit |
232 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
233 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
234 |
|
|
/// @param[in] unitWidth Width of the unit combo |
235 |
|
|
/// @param[in, out] v Pointer to the value to modify |
236 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
237 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
238 |
|
|
/// @param[in] format Printf format to display the value with |
239 |
|
|
/// @param[in] flags InputText flags to modify the behavior |
240 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
241 |
|
|
/// @return Returns if the value or unit was changed |
242 |
|
|
template<typename U> |
243 |
|
|
InputWithUnitChange InputFloat3WithUnit(const char* label, float itemWidth, float unitWidth, |
244 |
|
|
float v[3], U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
245 |
|
|
const char* format = "%.3f", ImGuiInputTextFlags flags = 0, |
246 |
|
|
int combo_popup_max_height_in_items = -1) |
247 |
|
|
{ |
248 |
|
|
return internal::InputWithUnit<ImGuiDataType_Float, 3, float>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, 0.0, 0.0, format, flags, combo_popup_max_height_in_items); |
249 |
|
|
} |
250 |
|
|
|
251 |
|
|
/// @brief Shows an InputText GUI element to modify the provided value and also set its unit |
252 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
253 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
254 |
|
|
/// @param[in] unitWidth Width of the unit combo |
255 |
|
|
/// @param[in, out] v Pointer to the value to modify |
256 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
257 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
258 |
|
|
/// @param[in] format Printf format to display the value with |
259 |
|
|
/// @param[in] flags InputText flags to modify the behavior |
260 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
261 |
|
|
/// @return Returns if the value or unit was changed |
262 |
|
|
template<typename U> |
263 |
|
|
InputWithUnitChange InputFloat4WithUnit(const char* label, float itemWidth, float unitWidth, |
264 |
|
|
float v[4], U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
265 |
|
|
const char* format = "%.3f", ImGuiInputTextFlags flags = 0, |
266 |
|
|
int combo_popup_max_height_in_items = -1) |
267 |
|
|
{ |
268 |
|
|
return internal::InputWithUnit<ImGuiDataType_Float, 4, float>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, 0.0, 0.0, format, flags, combo_popup_max_height_in_items); |
269 |
|
|
} |
270 |
|
|
|
271 |
|
|
/// @brief Shows an InputText GUI element to modify the provided value and also set its unit |
272 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
273 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
274 |
|
|
/// @param[in] unitWidth Width of the unit combo |
275 |
|
|
/// @param[in, out] v Pointer to the value to modify |
276 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
277 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
278 |
|
|
/// @param[in] step Step size of the InputText |
279 |
|
|
/// @param[in] step_fast Fast step size of the InputText |
280 |
|
|
/// @param[in] format Printf format to display the value with |
281 |
|
|
/// @param[in] flags InputText flags to modify the behavior |
282 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
283 |
|
|
/// @return Returns if the value or unit was changed |
284 |
|
|
template<typename U> |
285 |
|
✗ |
InputWithUnitChange InputDoubleWithUnit(const char* label, float itemWidth, float unitWidth, |
286 |
|
|
double* v, U& combo_current_item, const char* combo_items_separated_by_zeros, |
287 |
|
|
double step = 0.0, double step_fast = 0.0, const char* format = "%.6f", ImGuiInputTextFlags flags = 0, |
288 |
|
|
int combo_popup_max_height_in_items = -1) |
289 |
|
|
{ |
290 |
|
✗ |
return internal::InputWithUnit<ImGuiDataType_Double, 1, double>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, step, step_fast, format, flags, combo_popup_max_height_in_items); |
291 |
|
|
} |
292 |
|
|
|
293 |
|
|
/// @brief Shows an InputText GUI element to modify the provided value and also set its unit |
294 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
295 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
296 |
|
|
/// @param[in] unitWidth Width of the unit combo |
297 |
|
|
/// @param[in, out] v Pointer to the value to modify |
298 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
299 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
300 |
|
|
/// @param[in] format Printf format to display the value with |
301 |
|
|
/// @param[in] flags InputText flags to modify the behavior |
302 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
303 |
|
|
/// @return Returns if the value or unit was changed |
304 |
|
|
template<typename U> |
305 |
|
✗ |
InputWithUnitChange InputDouble2WithUnit(const char* label, float itemWidth, float unitWidth, |
306 |
|
|
double v[2], U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
307 |
|
|
const char* format = "%.6f", ImGuiInputTextFlags flags = 0, |
308 |
|
|
int combo_popup_max_height_in_items = -1) |
309 |
|
|
{ |
310 |
|
✗ |
return internal::InputWithUnit<ImGuiDataType_Double, 2, double>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, 0.0, 0.0, format, flags, combo_popup_max_height_in_items); |
311 |
|
|
} |
312 |
|
|
|
313 |
|
|
/// @brief Shows an InputText GUI element to modify the provided value and also set its unit |
314 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
315 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
316 |
|
|
/// @param[in] unitWidth Width of the unit combo |
317 |
|
|
/// @param[in, out] v Pointer to the value to modify |
318 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
319 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
320 |
|
|
/// @param[in] format Printf format to display the value with |
321 |
|
|
/// @param[in] flags InputText flags to modify the behavior |
322 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
323 |
|
|
/// @return Returns if the value or unit was changed |
324 |
|
|
template<typename U> |
325 |
|
✗ |
InputWithUnitChange InputDouble3WithUnit(const char* label, float itemWidth, float unitWidth, |
326 |
|
|
double v[3], U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
327 |
|
|
const char* format = "%.6f", ImGuiInputTextFlags flags = 0, |
328 |
|
|
int combo_popup_max_height_in_items = -1) |
329 |
|
|
{ |
330 |
|
✗ |
return internal::InputWithUnit<ImGuiDataType_Double, 3, double>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, 0.0, 0.0, format, flags, combo_popup_max_height_in_items); |
331 |
|
|
} |
332 |
|
|
|
333 |
|
|
/// @brief Shows an InputText GUI element to modify the provided value and also set its unit |
334 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
335 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
336 |
|
|
/// @param[in] unitWidth Width of the unit combo |
337 |
|
|
/// @param[in, out] v Pointer to the value to modify |
338 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
339 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
340 |
|
|
/// @param[in] format Printf format to display the value with |
341 |
|
|
/// @param[in] flags InputText flags to modify the behavior |
342 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
343 |
|
|
/// @return Returns if the value or unit was changed |
344 |
|
|
template<typename U> |
345 |
|
|
InputWithUnitChange InputDouble4WithUnit(const char* label, float itemWidth, float unitWidth, |
346 |
|
|
double v[4], U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
347 |
|
|
const char* format = "%.6f", ImGuiInputTextFlags flags = 0, |
348 |
|
|
int combo_popup_max_height_in_items = -1) |
349 |
|
|
{ |
350 |
|
|
return internal::InputWithUnit<ImGuiDataType_Double, 4, double>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, 0.0, 0.0, format, flags, combo_popup_max_height_in_items); |
351 |
|
|
} |
352 |
|
|
|
353 |
|
|
// ########################################################################################################### |
354 |
|
|
|
355 |
|
|
/// @brief Shows an InputText GUI element to modify the provided value and also set its unit |
356 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
357 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
358 |
|
|
/// @param[in] unitWidth Width of the unit combo |
359 |
|
|
/// @param[in, out] v Pointer to the value to modify |
360 |
|
|
/// @param[in] v_min Minimum value allowed |
361 |
|
|
/// @param[in] v_max Maximum value allowed |
362 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
363 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
364 |
|
|
/// @param[in] step Step size of the InputText |
365 |
|
|
/// @param[in] step_fast Fast step size of the InputText |
366 |
|
|
/// @param[in] format Printf format to display the value with |
367 |
|
|
/// @param[in] flags InputText flags to modify the behavior |
368 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
369 |
|
|
/// @return Returns if the value or unit was changed |
370 |
|
|
template<typename U> |
371 |
|
|
InputWithUnitChange InputFloatLWithUnit(const char* label, float itemWidth, float unitWidth, |
372 |
|
|
float* v, float v_min, float v_max, U& combo_current_item, const char* combo_items_separated_by_zeros, |
373 |
|
|
float step = 0.0, float step_fast = 0.0, const char* format = "%.3f", ImGuiInputTextFlags flags = 0, |
374 |
|
|
int combo_popup_max_height_in_items = -1) |
375 |
|
|
{ |
376 |
|
|
auto change = internal::InputWithUnit<ImGuiDataType_Float, 1, float>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, step, step_fast, format, flags, combo_popup_max_height_in_items); |
377 |
|
|
if (change == InputWithUnitChange::InputWithUnitChange_Input) |
378 |
|
|
{ |
379 |
|
|
*v = std::clamp(*v, v_min, v_max); |
380 |
|
|
} |
381 |
|
|
return change; |
382 |
|
|
} |
383 |
|
|
|
384 |
|
|
/// @brief Shows an InputText GUI element to modify the provided value and also set its unit |
385 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
386 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
387 |
|
|
/// @param[in] unitWidth Width of the unit combo |
388 |
|
|
/// @param[in, out] v Pointer to the value to modify |
389 |
|
|
/// @param[in] v_min Minimum value allowed |
390 |
|
|
/// @param[in] v_max Maximum value allowed |
391 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
392 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
393 |
|
|
/// @param[in] format Printf format to display the value with |
394 |
|
|
/// @param[in] flags InputText flags to modify the behavior |
395 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
396 |
|
|
/// @return Returns if the value or unit was changed |
397 |
|
|
template<typename U> |
398 |
|
|
InputWithUnitChange InputFloat2LWithUnit(const char* label, float itemWidth, float unitWidth, |
399 |
|
|
float v[2], float v_min, float v_max, U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
400 |
|
|
const char* format = "%.3f", ImGuiInputTextFlags flags = 0, |
401 |
|
|
int combo_popup_max_height_in_items = -1) |
402 |
|
|
{ |
403 |
|
|
auto change = internal::InputWithUnit<ImGuiDataType_Float, 2, float>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, 0.0, 0.0, format, flags, combo_popup_max_height_in_items); |
404 |
|
|
if (change == InputWithUnitChange::InputWithUnitChange_Input) |
405 |
|
|
{ |
406 |
|
|
for (size_t i = 0; i < 2; i++) |
407 |
|
|
{ |
408 |
|
|
v[i] = std::clamp(v[i], v_min, v_max); |
409 |
|
|
} |
410 |
|
|
} |
411 |
|
|
return change; |
412 |
|
|
} |
413 |
|
|
|
414 |
|
|
/// @brief Shows an InputText GUI element to modify the provided value and also set its unit |
415 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
416 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
417 |
|
|
/// @param[in] unitWidth Width of the unit combo |
418 |
|
|
/// @param[in, out] v Pointer to the value to modify |
419 |
|
|
/// @param[in] v_min Minimum value allowed |
420 |
|
|
/// @param[in] v_max Maximum value allowed |
421 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
422 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
423 |
|
|
/// @param[in] format Printf format to display the value with |
424 |
|
|
/// @param[in] flags InputText flags to modify the behavior |
425 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
426 |
|
|
/// @return Returns if the value or unit was changed |
427 |
|
|
template<typename U> |
428 |
|
|
InputWithUnitChange InputFloat3LWithUnit(const char* label, float itemWidth, float unitWidth, |
429 |
|
|
float v[3], float v_min, float v_max, U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
430 |
|
|
const char* format = "%.3f", ImGuiInputTextFlags flags = 0, |
431 |
|
|
int combo_popup_max_height_in_items = -1) |
432 |
|
|
{ |
433 |
|
|
auto change = internal::InputWithUnit<ImGuiDataType_Float, 3, float>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, 0.0, 0.0, format, flags, combo_popup_max_height_in_items); |
434 |
|
|
if (change == InputWithUnitChange::InputWithUnitChange_Input) |
435 |
|
|
{ |
436 |
|
|
for (size_t i = 0; i < 3; i++) |
437 |
|
|
{ |
438 |
|
|
v[i] = std::clamp(v[i], v_min, v_max); |
439 |
|
|
} |
440 |
|
|
} |
441 |
|
|
return change; |
442 |
|
|
} |
443 |
|
|
|
444 |
|
|
/// @brief Shows an InputText GUI element to modify the provided value and also set its unit |
445 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
446 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
447 |
|
|
/// @param[in] unitWidth Width of the unit combo |
448 |
|
|
/// @param[in, out] v Pointer to the value to modify |
449 |
|
|
/// @param[in] v_min Minimum value allowed |
450 |
|
|
/// @param[in] v_max Maximum value allowed |
451 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
452 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
453 |
|
|
/// @param[in] format Printf format to display the value with |
454 |
|
|
/// @param[in] flags InputText flags to modify the behavior |
455 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
456 |
|
|
/// @return Returns if the value or unit was changed |
457 |
|
|
template<typename U> |
458 |
|
|
InputWithUnitChange InputFloat4LWithUnit(const char* label, float itemWidth, float unitWidth, |
459 |
|
|
float v[4], float v_min, float v_max, U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
460 |
|
|
const char* format = "%.3f", ImGuiInputTextFlags flags = 0, |
461 |
|
|
int combo_popup_max_height_in_items = -1) |
462 |
|
|
{ |
463 |
|
|
auto change = internal::InputWithUnit<ImGuiDataType_Float, 4, float>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, 0.0, 0.0, format, flags, combo_popup_max_height_in_items); |
464 |
|
|
if (change == InputWithUnitChange::InputWithUnitChange_Input) |
465 |
|
|
{ |
466 |
|
|
for (size_t i = 0; i < 4; i++) |
467 |
|
|
{ |
468 |
|
|
v[i] = std::clamp(v[i], v_min, v_max); |
469 |
|
|
} |
470 |
|
|
} |
471 |
|
|
return change; |
472 |
|
|
} |
473 |
|
|
|
474 |
|
|
/// @brief Shows an InputText GUI element to modify the provided value and also set its unit |
475 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
476 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
477 |
|
|
/// @param[in] unitWidth Width of the unit combo |
478 |
|
|
/// @param[in, out] v Pointer to the value to modify |
479 |
|
|
/// @param[in] v_min Minimum value allowed |
480 |
|
|
/// @param[in] v_max Maximum value allowed |
481 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
482 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
483 |
|
|
/// @param[in] step Step size of the InputText |
484 |
|
|
/// @param[in] step_fast Fast step size of the InputText |
485 |
|
|
/// @param[in] format Printf format to display the value with |
486 |
|
|
/// @param[in] flags InputText flags to modify the behavior |
487 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
488 |
|
|
/// @return Returns if the value or unit was changed |
489 |
|
|
template<typename U> |
490 |
|
|
InputWithUnitChange InputDoubleLWithUnit(const char* label, float itemWidth, float unitWidth, |
491 |
|
|
double* v, double v_min, double v_max, U& combo_current_item, const char* combo_items_separated_by_zeros, |
492 |
|
|
double step = 0.0, double step_fast = 0.0, const char* format = "%.6f", ImGuiInputTextFlags flags = 0, |
493 |
|
|
int combo_popup_max_height_in_items = -1) |
494 |
|
|
{ |
495 |
|
|
auto change = internal::InputWithUnit<ImGuiDataType_Double, 1, double>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, step, step_fast, format, flags, combo_popup_max_height_in_items); |
496 |
|
|
if (change == InputWithUnitChange::InputWithUnitChange_Input) |
497 |
|
|
{ |
498 |
|
|
*v = std::clamp(*v, v_min, v_max); |
499 |
|
|
} |
500 |
|
|
return change; |
501 |
|
|
} |
502 |
|
|
|
503 |
|
|
/// @brief Shows an InputText GUI element to modify the provided value and also set its unit |
504 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
505 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
506 |
|
|
/// @param[in] unitWidth Width of the unit combo |
507 |
|
|
/// @param[in, out] v Pointer to the value to modify |
508 |
|
|
/// @param[in] v_min Minimum value allowed |
509 |
|
|
/// @param[in] v_max Maximum value allowed |
510 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
511 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
512 |
|
|
/// @param[in] format Printf format to display the value with |
513 |
|
|
/// @param[in] flags InputText flags to modify the behavior |
514 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
515 |
|
|
/// @return Returns if the value or unit was changed |
516 |
|
|
template<typename U> |
517 |
|
|
InputWithUnitChange InputDouble2LWithUnit(const char* label, float itemWidth, float unitWidth, |
518 |
|
|
double v[2], double v_min, double v_max, U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
519 |
|
|
const char* format = "%.6f", ImGuiInputTextFlags flags = 0, |
520 |
|
|
int combo_popup_max_height_in_items = -1) |
521 |
|
|
{ |
522 |
|
|
auto change = internal::InputWithUnit<ImGuiDataType_Double, 2, double>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, 0.0, 0.0, format, flags, combo_popup_max_height_in_items); |
523 |
|
|
if (change == InputWithUnitChange::InputWithUnitChange_Input) |
524 |
|
|
{ |
525 |
|
|
for (size_t i = 0; i < 2; i++) |
526 |
|
|
{ |
527 |
|
|
v[i] = std::clamp(v[i], v_min, v_max); |
528 |
|
|
} |
529 |
|
|
} |
530 |
|
|
return change; |
531 |
|
|
} |
532 |
|
|
|
533 |
|
|
/// @brief Shows an InputText GUI element to modify the provided value and also set its unit |
534 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
535 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
536 |
|
|
/// @param[in] unitWidth Width of the unit combo |
537 |
|
|
/// @param[in, out] v Pointer to the value to modify |
538 |
|
|
/// @param[in] v_min Minimum value allowed |
539 |
|
|
/// @param[in] v_max Maximum value allowed |
540 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
541 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
542 |
|
|
/// @param[in] format Printf format to display the value with |
543 |
|
|
/// @param[in] flags InputText flags to modify the behavior |
544 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
545 |
|
|
/// @return Returns if the value or unit was changed |
546 |
|
|
template<typename U> |
547 |
|
✗ |
InputWithUnitChange InputDouble3LWithUnit(const char* label, float itemWidth, float unitWidth, |
548 |
|
|
double v[3], double v_min, double v_max, U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
549 |
|
|
const char* format = "%.6f", ImGuiInputTextFlags flags = 0, |
550 |
|
|
int combo_popup_max_height_in_items = -1) |
551 |
|
|
{ |
552 |
|
✗ |
auto change = internal::InputWithUnit<ImGuiDataType_Double, 3, double>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, 0.0, 0.0, format, flags, combo_popup_max_height_in_items); |
553 |
|
✗ |
if (change == InputWithUnitChange::InputWithUnitChange_Input) |
554 |
|
|
{ |
555 |
|
✗ |
for (size_t i = 0; i < 3; i++) |
556 |
|
|
{ |
557 |
|
✗ |
v[i] = std::clamp(v[i], v_min, v_max); |
558 |
|
|
} |
559 |
|
|
} |
560 |
|
✗ |
return change; |
561 |
|
|
} |
562 |
|
|
|
563 |
|
|
/// @brief Shows an InputText GUI element to modify the provided value and also set its unit |
564 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
565 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
566 |
|
|
/// @param[in] unitWidth Width of the unit combo |
567 |
|
|
/// @param[in, out] v Pointer to the value to modify |
568 |
|
|
/// @param[in] v_min Minimum value allowed |
569 |
|
|
/// @param[in] v_max Maximum value allowed |
570 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
571 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
572 |
|
|
/// @param[in] format Printf format to display the value with |
573 |
|
|
/// @param[in] flags InputText flags to modify the behavior |
574 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
575 |
|
|
/// @return Returns if the value or unit was changed |
576 |
|
|
template<typename U> |
577 |
|
|
InputWithUnitChange InputDouble4LWithUnit(const char* label, float itemWidth, float unitWidth, |
578 |
|
|
double v[4], double v_min, double v_max, U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
579 |
|
|
const char* format = "%.6f", ImGuiInputTextFlags flags = 0, |
580 |
|
|
int combo_popup_max_height_in_items = -1) |
581 |
|
|
{ |
582 |
|
|
auto change = internal::InputWithUnit<ImGuiDataType_Double, 4, double>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, 0.0, 0.0, format, flags, combo_popup_max_height_in_items); |
583 |
|
|
if (change == InputWithUnitChange::InputWithUnitChange_Input) |
584 |
|
|
{ |
585 |
|
|
for (size_t i = 0; i < 4; i++) |
586 |
|
|
{ |
587 |
|
|
v[i] = std::clamp(v[i], v_min, v_max); |
588 |
|
|
} |
589 |
|
|
} |
590 |
|
|
return change; |
591 |
|
|
} |
592 |
|
|
|
593 |
|
|
// ########################################################################################################### |
594 |
|
|
|
595 |
|
|
/// @brief Shows an Slider GUI element to modify the provided value and also set its unit |
596 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
597 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
598 |
|
|
/// @param[in] unitWidth Width of the unit combo |
599 |
|
|
/// @param[in, out] v Pointer to the value to modify |
600 |
|
|
/// @param[in] v_min Minimum value allowed |
601 |
|
|
/// @param[in] v_max Maximum value allowed |
602 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
603 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
604 |
|
|
/// @param[in] format Printf format to display the value with |
605 |
|
|
/// @param[in] flags Slider flags to modify the behavior |
606 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
607 |
|
|
/// @return Returns if the value or unit was changed |
608 |
|
|
template<typename U> |
609 |
|
|
InputWithUnitChange SliderFloatWithUnit(const char* label, float itemWidth, float unitWidth, |
610 |
|
|
float* v, float v_min, float v_max, U& combo_current_item, const char* combo_items_separated_by_zeros, |
611 |
|
|
const char* format = "%.3f", ImGuiSliderFlags flags = 0, |
612 |
|
|
int combo_popup_max_height_in_items = -1) |
613 |
|
|
{ |
614 |
|
|
return internal::SliderWithUnit<ImGuiDataType_Float, 1, float>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, v_min, v_max, format, flags, combo_popup_max_height_in_items); |
615 |
|
|
} |
616 |
|
|
|
617 |
|
|
/// @brief Shows an Slider GUI element to modify the provided value and also set its unit |
618 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
619 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
620 |
|
|
/// @param[in] unitWidth Width of the unit combo |
621 |
|
|
/// @param[in, out] v Pointer to the value to modify |
622 |
|
|
/// @param[in] v_min Minimum value allowed |
623 |
|
|
/// @param[in] v_max Maximum value allowed |
624 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
625 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
626 |
|
|
/// @param[in] format Printf format to display the value with |
627 |
|
|
/// @param[in] flags Slider flags to modify the behavior |
628 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
629 |
|
|
/// @return Returns if the value or unit was changed |
630 |
|
|
template<typename U> |
631 |
|
|
InputWithUnitChange SliderFloat2WithUnit(const char* label, float itemWidth, float unitWidth, |
632 |
|
|
float v[2], float v_min, float v_max, U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
633 |
|
|
const char* format = "%.3f", ImGuiSliderFlags flags = 0, |
634 |
|
|
int combo_popup_max_height_in_items = -1) |
635 |
|
|
{ |
636 |
|
|
return internal::SliderWithUnit<ImGuiDataType_Float, 2, float>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, v_min, v_max, format, flags, combo_popup_max_height_in_items); |
637 |
|
|
} |
638 |
|
|
|
639 |
|
|
/// @brief Shows an Slider GUI element to modify the provided value and also set its unit |
640 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
641 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
642 |
|
|
/// @param[in] unitWidth Width of the unit combo |
643 |
|
|
/// @param[in, out] v Pointer to the value to modify |
644 |
|
|
/// @param[in] v_min Minimum value allowed |
645 |
|
|
/// @param[in] v_max Maximum value allowed |
646 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
647 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
648 |
|
|
/// @param[in] format Printf format to display the value with |
649 |
|
|
/// @param[in] flags Slider flags to modify the behavior |
650 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
651 |
|
|
/// @return Returns if the value or unit was changed |
652 |
|
|
template<typename U> |
653 |
|
|
InputWithUnitChange SliderFloat3WithUnit(const char* label, float itemWidth, float unitWidth, |
654 |
|
|
float v[3], float v_min, float v_max, U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
655 |
|
|
const char* format = "%.3f", ImGuiSliderFlags flags = 0, |
656 |
|
|
int combo_popup_max_height_in_items = -1) |
657 |
|
|
{ |
658 |
|
|
return internal::SliderWithUnit<ImGuiDataType_Float, 3, float>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, v_min, v_max, format, flags, combo_popup_max_height_in_items); |
659 |
|
|
} |
660 |
|
|
|
661 |
|
|
/// @brief Shows an Slider GUI element to modify the provided value and also set its unit |
662 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
663 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
664 |
|
|
/// @param[in] unitWidth Width of the unit combo |
665 |
|
|
/// @param[in, out] v Pointer to the value to modify |
666 |
|
|
/// @param[in] v_min Minimum value allowed |
667 |
|
|
/// @param[in] v_max Maximum value allowed |
668 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
669 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
670 |
|
|
/// @param[in] format Printf format to display the value with |
671 |
|
|
/// @param[in] flags Slider flags to modify the behavior |
672 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
673 |
|
|
/// @return Returns if the value or unit was changed |
674 |
|
|
template<typename U> |
675 |
|
|
InputWithUnitChange SliderFloat4WithUnit(const char* label, float itemWidth, float unitWidth, |
676 |
|
|
float v[4], float v_min, float v_max, U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
677 |
|
|
const char* format = "%.3f", ImGuiSliderFlags flags = 0, |
678 |
|
|
int combo_popup_max_height_in_items = -1) |
679 |
|
|
{ |
680 |
|
|
return internal::SliderWithUnit<ImGuiDataType_Float, 4, float>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, v_min, v_max, format, flags, combo_popup_max_height_in_items); |
681 |
|
|
} |
682 |
|
|
|
683 |
|
|
/// @brief Shows an Slider GUI element to modify the provided value and also set its unit |
684 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
685 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
686 |
|
|
/// @param[in] unitWidth Width of the unit combo |
687 |
|
|
/// @param[in, out] v Pointer to the value to modify |
688 |
|
|
/// @param[in] v_min Minimum value allowed |
689 |
|
|
/// @param[in] v_max Maximum value allowed |
690 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
691 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
692 |
|
|
/// @param[in] format Printf format to display the value with |
693 |
|
|
/// @param[in] flags Slider flags to modify the behavior |
694 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
695 |
|
|
/// @return Returns if the value or unit was changed |
696 |
|
|
template<typename U> |
697 |
|
✗ |
InputWithUnitChange SliderDoubleWithUnit(const char* label, float itemWidth, float unitWidth, |
698 |
|
|
double* v, double v_min, double v_max, U& combo_current_item, const char* combo_items_separated_by_zeros, |
699 |
|
|
const char* format = "%.6f", ImGuiSliderFlags flags = 0, |
700 |
|
|
int combo_popup_max_height_in_items = -1) |
701 |
|
|
{ |
702 |
|
✗ |
return internal::SliderWithUnit<ImGuiDataType_Double, 1, double>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, v_min, v_max, format, flags, combo_popup_max_height_in_items); |
703 |
|
|
} |
704 |
|
|
|
705 |
|
|
/// @brief Shows an Slider GUI element to modify the provided value and also set its unit |
706 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
707 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
708 |
|
|
/// @param[in] unitWidth Width of the unit combo |
709 |
|
|
/// @param[in, out] v Pointer to the value to modify |
710 |
|
|
/// @param[in] v_min Minimum value allowed |
711 |
|
|
/// @param[in] v_max Maximum value allowed |
712 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
713 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
714 |
|
|
/// @param[in] format Printf format to display the value with |
715 |
|
|
/// @param[in] flags Slider flags to modify the behavior |
716 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
717 |
|
|
/// @return Returns if the value or unit was changed |
718 |
|
|
template<typename U> |
719 |
|
|
InputWithUnitChange SliderDouble2WithUnit(const char* label, float itemWidth, float unitWidth, |
720 |
|
|
double v[2], double v_min, double v_max, U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
721 |
|
|
const char* format = "%.6f", ImGuiSliderFlags flags = 0, |
722 |
|
|
int combo_popup_max_height_in_items = -1) |
723 |
|
|
{ |
724 |
|
|
return internal::SliderWithUnit<ImGuiDataType_Double, 2, double>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, v_min, v_max, format, flags, combo_popup_max_height_in_items); |
725 |
|
|
} |
726 |
|
|
|
727 |
|
|
/// @brief Shows an Slider GUI element to modify the provided value and also set its unit |
728 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
729 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
730 |
|
|
/// @param[in] unitWidth Width of the unit combo |
731 |
|
|
/// @param[in, out] v Pointer to the value to modify |
732 |
|
|
/// @param[in] v_min Minimum value allowed |
733 |
|
|
/// @param[in] v_max Maximum value allowed |
734 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
735 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
736 |
|
|
/// @param[in] format Printf format to display the value with |
737 |
|
|
/// @param[in] flags Slider flags to modify the behavior |
738 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
739 |
|
|
/// @return Returns if the value or unit was changed |
740 |
|
|
template<typename U> |
741 |
|
|
InputWithUnitChange SliderDouble3WithUnit(const char* label, float itemWidth, float unitWidth, |
742 |
|
|
double v[3], double v_min, double v_max, U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
743 |
|
|
const char* format = "%.6f", ImGuiSliderFlags flags = 0, |
744 |
|
|
int combo_popup_max_height_in_items = -1) |
745 |
|
|
{ |
746 |
|
|
return internal::SliderWithUnit<ImGuiDataType_Double, 3, double>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, v_min, v_max, format, flags, combo_popup_max_height_in_items); |
747 |
|
|
} |
748 |
|
|
|
749 |
|
|
/// @brief Shows an Slider GUI element to modify the provided value and also set its unit |
750 |
|
|
/// @param[in] label Label to display beside the input. Has to be unique (use # to hide text afterwards to append an uid) |
751 |
|
|
/// @param[in] itemWidth Width of the input element(s) + unit combo |
752 |
|
|
/// @param[in] unitWidth Width of the unit combo |
753 |
|
|
/// @param[in, out] v Pointer to the value to modify |
754 |
|
|
/// @param[in] v_min Minimum value allowed |
755 |
|
|
/// @param[in] v_max Maximum value allowed |
756 |
|
|
/// @param[in, out] combo_current_item The selected item in the unit combo |
757 |
|
|
/// @param[in] combo_items_separated_by_zeros Items to display in the unit combo (separated by \0 and ends with \0\0) |
758 |
|
|
/// @param[in] format Printf format to display the value with |
759 |
|
|
/// @param[in] flags Slider flags to modify the behavior |
760 |
|
|
/// @param[in] combo_popup_max_height_in_items Maximum height of the combo in number of items |
761 |
|
|
/// @return Returns if the value or unit was changed |
762 |
|
|
template<typename U> |
763 |
|
|
InputWithUnitChange SliderDouble4WithUnit(const char* label, float itemWidth, float unitWidth, |
764 |
|
|
double v[4], double v_min, double v_max, U& combo_current_item, const char* combo_items_separated_by_zeros, // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) |
765 |
|
|
const char* format = "%.6f", ImGuiSliderFlags flags = 0, |
766 |
|
|
int combo_popup_max_height_in_items = -1) |
767 |
|
|
{ |
768 |
|
|
return internal::SliderWithUnit<ImGuiDataType_Double, 4, double>(label, itemWidth, unitWidth, v, combo_current_item, combo_items_separated_by_zeros, v_min, v_max, format, flags, combo_popup_max_height_in_items); |
769 |
|
|
} |
770 |
|
|
|
771 |
|
|
} // namespace gui::widgets |
772 |
|
|
} // namespace NAV |
773 |
|
|
|