48 const void* p_step,
const void* p_step_fast,
49 const char* format,
float input_width,
50 ImGuiInputTextFlags flags,
bool no_step =
false) {
55 ImGuiWindow* window = ImGui::GetCurrentWindow();
56 if (window->SkipItems)
59 ImGuiContext& g = *GImGui;
60 ImGuiStyle& style = g.Style;
63 format = DataTypeGetInfo(data_type)->PrintFmt;
66 DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format);
68 if (g.ActiveId == 0 && (flags & (ImGuiInputTextFlags_CharsDecimal |
69 ImGuiInputTextFlags_CharsHexadecimal |
70 ImGuiInputTextFlags_CharsScientific)) == 0)
71 flags |= InputScalar_DefaultCharsFilter(data_type, format);
72 flags |= ImGuiInputTextFlags_AutoSelectAll;
74 bool value_changed =
false;
75 const float button_size = GetFrameHeight();
79 bool invisible_label = IsInvisibleLabel(label);
81 if (!invisible_label) {
82 AlignTextToFramePadding();
90 SetNextItemWidth(ImMax(
91 1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2));
94 PushStyleVar(ImGuiStyleVar_ItemSpacing,
95 ImVec2{style.ItemSpacing.x, style.ItemSpacing.y});
96 PushStyleVar(ImGuiStyleVar_FramePadding,
97 ImVec2{style.FramePadding.x, style.FramePadding.y});
99 SetNextItemWidth(input_width);
100 if (InputText(
"", buf, IM_ARRAYSIZE(buf),
103 value_changed = DataTypeApplyFromText(buf, data_type, p_data, format);
104 IMGUI_TEST_ENGINE_ITEM_INFO(
105 g.LastItemData.ID, label,
106 g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Inputable);
109 if (IsItemHovered() && g.IO.MouseWheel != 0.0f) {
110 float scroll_amount = g.IO.MouseWheel;
111 float scroll_speed = 0.25f;
113 if (g.IO.KeyCtrl && p_step_fast)
114 scroll_amount *= *(
const float*)p_step_fast;
116 scroll_amount *= *(
const float*)p_step;
118 if (scroll_amount > 0.0f) {
119 scroll_amount *= scroll_speed;
120 DataTypeApplyOp(data_type,
'+', p_data, p_data, &scroll_amount);
121 value_changed =
true;
122 }
else if (scroll_amount < 0.0f) {
123 scroll_amount *= -scroll_speed;
124 DataTypeApplyOp(data_type,
'-', p_data, p_data, &scroll_amount);
125 value_changed =
true;
131 const ImVec2 backup_frame_padding = style.FramePadding;
132 style.FramePadding.x = style.FramePadding.y;
133 ImGuiButtonFlags button_flags = ImGuiButtonFlags_PressedOnClick;
134 if (flags & ImGuiInputTextFlags_ReadOnly)
136 SameLine(0, style.ItemInnerSpacing.x);
137 if (ButtonEx(
"-", ImVec2(button_size, button_size), button_flags)) {
138 DataTypeApplyOp(data_type,
'-', p_data, p_data,
139 g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step);
140 value_changed =
true;
142 SameLine(0, style.ItemInnerSpacing.x);
143 if (ButtonEx(
"+", ImVec2(button_size, button_size), button_flags)) {
144 DataTypeApplyOp(data_type,
'+', p_data, p_data,
145 g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step);
146 value_changed =
true;
149 if (flags & ImGuiInputTextFlags_ReadOnly)
152 style.FramePadding = backup_frame_padding;
156 ImGui::PopStyleVar(2);
159 MarkItemEdited(g.LastItemData.ID);
161 return value_changed;
166 void* p_data,
const void* p_step,
167 const void* p_step_fast,
const char* format,
168 float input_width, ImGuiInputTextFlags flags,
169 bool no_step =
false) {
172 ImGuiWindow* window = ImGui::GetCurrentWindow();
173 if (window->SkipItems)
176 ImGuiContext& g = *GImGui;
177 ImGuiStyle& style = g.Style;
180 format = DataTypeGetInfo(data_type)->PrintFmt;
183 DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format);
185 if (g.ActiveId == 0 && (flags & (ImGuiInputTextFlags_CharsDecimal |
186 ImGuiInputTextFlags_CharsHexadecimal |
187 ImGuiInputTextFlags_CharsScientific)) == 0)
188 flags |= InputScalar_DefaultCharsFilter(data_type, format);
189 flags |= ImGuiInputTextFlags_AutoSelectAll;
191 const float button_size = GetFrameHeight();
195 bool invisible_label = IsInvisibleLabel(label);
197 if (!invisible_label) {
198 AlignTextToFramePadding();
205 SetNextItemWidth(ImMax(
206 1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2));
208 PushStyleVar(ImGuiStyleVar_ItemSpacing,
209 ImVec2{style.ItemSpacing.x, style.ItemSpacing.y});
210 PushStyleVar(ImGuiStyleVar_FramePadding,
211 ImVec2{style.FramePadding.x, style.FramePadding.y});
213 SetNextItemWidth(input_width);
214 if (InputText(
"", buf, IM_ARRAYSIZE(buf), flags)) {
215 if (DataTypeApplyFromText(buf, data_type, p_data, format)) {
222 if (IsItemDeactivatedAfterEdit()) {
226 IMGUI_TEST_ENGINE_ITEM_INFO(
227 g.LastItemData.ID, label,
228 g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Inputable);
231 if (IsItemHovered() && g.IO.MouseWheel != 0.0f) {
232 float scroll_amount = g.IO.MouseWheel;
233 float scroll_speed = 0.25f;
235 if (g.IO.KeyCtrl && p_step_fast)
236 scroll_amount *= *(
const float*)p_step_fast;
238 scroll_amount *= *(
const float*)p_step;
240 if (scroll_amount > 0.0f) {
241 scroll_amount *= scroll_speed;
242 DataTypeApplyOp(data_type,
'+', p_data, p_data, &scroll_amount);
245 }
else if (scroll_amount < 0.0f) {
246 scroll_amount *= -scroll_speed;
247 DataTypeApplyOp(data_type,
'-', p_data, p_data, &scroll_amount);
255 const ImVec2 backup_frame_padding = style.FramePadding;
256 style.FramePadding.x = style.FramePadding.y;
257 ImGuiButtonFlags button_flags = ImGuiButtonFlags_PressedOnClick;
258 if (flags & ImGuiInputTextFlags_ReadOnly)
260 SameLine(0, style.ItemInnerSpacing.x);
261 if (ButtonEx(
"-", ImVec2(button_size, button_size), button_flags)) {
262 DataTypeApplyOp(data_type,
'-', p_data, p_data,
263 g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step);
267 SameLine(0, style.ItemInnerSpacing.x);
268 if (ButtonEx(
"+", ImVec2(button_size, button_size), button_flags)) {
269 DataTypeApplyOp(data_type,
'+', p_data, p_data,
270 g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step);
275 if (flags & ImGuiInputTextFlags_ReadOnly)
278 style.FramePadding = backup_frame_padding;
282 ImGui::PopStyleVar(2);
285 MarkItemEdited(g.LastItemData.ID);