49 const void* p_step,
const void* p_step_fast,
50 const char* format,
float input_width,
51 ImGuiInputTextFlags flags,
bool no_step =
false) {
56 ImGuiWindow* window = ImGui::GetCurrentWindow();
57 if (window->SkipItems)
60 ImGuiContext& g = *GImGui;
61 ImGuiStyle& style = g.Style;
64 format = DataTypeGetInfo(data_type)->PrintFmt;
67 DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format);
69 if (g.ActiveId == 0 && (flags & (ImGuiInputTextFlags_CharsDecimal |
70 ImGuiInputTextFlags_CharsHexadecimal |
71 ImGuiInputTextFlags_CharsScientific)) == 0)
72 flags |= InputScalar_DefaultCharsFilter(data_type, format);
73 flags |= ImGuiInputTextFlags_AutoSelectAll;
75 bool value_changed =
false;
76 const float button_size = GetFrameHeight();
80 bool invisible_label = IsInvisibleLabel(label);
82 if (!invisible_label) {
83 AlignTextToFramePadding();
91 SetNextItemWidth(ImMax(
92 1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2));
95 PushStyleVar(ImGuiStyleVar_ItemSpacing,
96 ImVec2{style.ItemSpacing.x, style.ItemSpacing.y});
97 PushStyleVar(ImGuiStyleVar_FramePadding,
98 ImVec2{style.FramePadding.x, style.FramePadding.y});
100 SetNextItemWidth(input_width);
101 if (InputText(
"", buf, IM_ARRAYSIZE(buf),
104 value_changed = DataTypeApplyFromText(buf, data_type, p_data, format);
105 IMGUI_TEST_ENGINE_ITEM_INFO(
106 g.LastItemData.ID, label,
107 g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Inputable);
110 if (IsItemHovered() && g.IO.MouseWheel != 0.0f) {
111 float scroll_amount = g.IO.MouseWheel;
112 float scroll_speed = 0.25f;
114 if (g.IO.KeyCtrl && p_step_fast)
115 scroll_amount *= *(
const float*)p_step_fast;
117 scroll_amount *= *(
const float*)p_step;
119 if (scroll_amount > 0.0f) {
120 scroll_amount *= scroll_speed;
121 DataTypeApplyOp(data_type,
'+', p_data, p_data, &scroll_amount);
122 value_changed =
true;
123 }
else if (scroll_amount < 0.0f) {
124 scroll_amount *= -scroll_speed;
125 DataTypeApplyOp(data_type,
'-', p_data, p_data, &scroll_amount);
126 value_changed =
true;
132 const ImVec2 backup_frame_padding = style.FramePadding;
133 style.FramePadding.x = style.FramePadding.y;
134 ImGuiButtonFlags button_flags = ImGuiButtonFlags_PressedOnClick;
135 if (flags & ImGuiInputTextFlags_ReadOnly)
137 SameLine(0, style.ItemInnerSpacing.x);
138 if (ButtonEx(
"-", ImVec2(button_size, button_size), button_flags)) {
139 DataTypeApplyOp(data_type,
'-', p_data, p_data,
140 g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step);
141 value_changed =
true;
143 SameLine(0, style.ItemInnerSpacing.x);
144 if (ButtonEx(
"+", ImVec2(button_size, button_size), button_flags)) {
145 DataTypeApplyOp(data_type,
'+', p_data, p_data,
146 g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step);
147 value_changed =
true;
150 if (flags & ImGuiInputTextFlags_ReadOnly)
153 style.FramePadding = backup_frame_padding;
157 ImGui::PopStyleVar(2);
160 MarkItemEdited(g.LastItemData.ID);
162 return value_changed;
167 void* p_data,
const void* p_step,
168 const void* p_step_fast,
const char* format,
170 ImGuiInputTextFlags flags,
171 bool no_step =
false) {
174 ImGuiWindow* window = ImGui::GetCurrentWindow();
175 if (window->SkipItems)
178 ImGuiContext& g = *GImGui;
179 ImGuiStyle& style = g.Style;
182 format = DataTypeGetInfo(data_type)->PrintFmt;
185 DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format);
187 if (g.ActiveId == 0 && (flags & (ImGuiInputTextFlags_CharsDecimal |
188 ImGuiInputTextFlags_CharsHexadecimal |
189 ImGuiInputTextFlags_CharsScientific)) == 0)
190 flags |= InputScalar_DefaultCharsFilter(data_type, format);
191 flags |= ImGuiInputTextFlags_AutoSelectAll;
193 const float button_size = GetFrameHeight();
197 bool invisible_label = IsInvisibleLabel(label);
199 if (!invisible_label) {
200 AlignTextToFramePadding();
207 SetNextItemWidth(ImMax(
208 1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2));
210 PushStyleVar(ImGuiStyleVar_ItemSpacing,
211 ImVec2{style.ItemSpacing.x, style.ItemSpacing.y});
212 PushStyleVar(ImGuiStyleVar_FramePadding,
213 ImVec2{style.FramePadding.x, style.FramePadding.y});
215 SetNextItemWidth(input_width);
216 if (InputText(
"", buf, IM_ARRAYSIZE(buf), flags)) {
217 if (DataTypeApplyFromText(buf, data_type, p_data, format)) {
224 if (IsItemDeactivatedAfterEdit()) {
228 IMGUI_TEST_ENGINE_ITEM_INFO(
229 g.LastItemData.ID, label,
230 g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Inputable);
233 if (IsItemHovered() && g.IO.MouseWheel != 0.0f) {
234 float scroll_amount = g.IO.MouseWheel;
235 float scroll_speed = 0.25f;
237 if (g.IO.KeyCtrl && p_step_fast)
238 scroll_amount *= *(
const float*)p_step_fast;
240 scroll_amount *= *(
const float*)p_step;
242 if (scroll_amount > 0.0f) {
243 scroll_amount *= scroll_speed;
244 DataTypeApplyOp(data_type,
'+', p_data, p_data, &scroll_amount);
247 }
else if (scroll_amount < 0.0f) {
248 scroll_amount *= -scroll_speed;
249 DataTypeApplyOp(data_type,
'-', p_data, p_data, &scroll_amount);
257 const ImVec2 backup_frame_padding = style.FramePadding;
258 style.FramePadding.x = style.FramePadding.y;
259 ImGuiButtonFlags button_flags = ImGuiButtonFlags_PressedOnClick;
260 if (flags & ImGuiInputTextFlags_ReadOnly)
262 SameLine(0, style.ItemInnerSpacing.x);
263 if (ButtonEx(
"-", ImVec2(button_size, button_size), button_flags)) {
264 DataTypeApplyOp(data_type,
'-', p_data, p_data,
265 g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step);
269 SameLine(0, style.ItemInnerSpacing.x);
270 if (ButtonEx(
"+", ImVec2(button_size, button_size), button_flags)) {
271 DataTypeApplyOp(data_type,
'+', p_data, p_data,
272 g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step);
277 if (flags & ImGuiInputTextFlags_ReadOnly)
280 style.FramePadding = backup_frame_padding;
284 ImGui::PopStyleVar(2);
287 MarkItemEdited(g.LastItemData.ID);