38 const void* p_step,
const void* p_step_fast,
39 const char* format,
float input_width,
40 ImGuiInputTextFlags flags,
bool no_step =
false) {
41 ImGuiWindow* window = ImGui::GetCurrentWindow();
42 if (window->SkipItems)
45 ImGuiContext& g = *GImGui;
46 ImGuiStyle& style = g.Style;
49 format = DataTypeGetInfo(data_type)->PrintFmt;
52 DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format);
54 if (g.ActiveId == 0 && (flags & (ImGuiInputTextFlags_CharsDecimal |
55 ImGuiInputTextFlags_CharsHexadecimal |
56 ImGuiInputTextFlags_CharsScientific)) == 0)
57 flags |= InputScalar_DefaultCharsFilter(data_type, format);
58 flags |= ImGuiInputTextFlags_AutoSelectAll;
60 bool value_changed =
false;
61 const float button_size = GetFrameHeight();
64 bool invisible_label = IsInvisibleLabel(label);
66 if (!invisible_label) {
67 AlignTextToFramePadding();
75 SetNextItemWidth(ImMax(
76 1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2));
79 PushStyleVar(ImGuiStyleVar_ItemSpacing,
80 ImVec2{style.ItemSpacing.x, style.ItemSpacing.y});
81 PushStyleVar(ImGuiStyleVar_FramePadding,
82 ImVec2{style.FramePadding.x, style.FramePadding.y});
84 SetNextItemWidth(input_width);
85 if (InputText(
"", buf, IM_ARRAYSIZE(buf),
88 value_changed = DataTypeApplyFromText(buf, data_type, p_data, format);
89 IMGUI_TEST_ENGINE_ITEM_INFO(
90 g.LastItemData.ID, label,
91 g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Inputable);
94 if (IsItemHovered() && g.IO.MouseWheel != 0.0f) {
95 float scroll_amount = g.IO.MouseWheel;
96 float scroll_speed = 0.25f;
98 if (g.IO.KeyCtrl && p_step_fast)
99 scroll_amount *= *(
const float*)p_step_fast;
101 scroll_amount *= *(
const float*)p_step;
103 if (scroll_amount > 0.0f) {
104 scroll_amount *= scroll_speed;
105 DataTypeApplyOp(data_type,
'+', p_data, p_data, &scroll_amount);
106 value_changed =
true;
107 }
else if (scroll_amount < 0.0f) {
108 scroll_amount *= -scroll_speed;
109 DataTypeApplyOp(data_type,
'-', p_data, p_data, &scroll_amount);
110 value_changed =
true;
116 const ImVec2 backup_frame_padding = style.FramePadding;
117 style.FramePadding.x = style.FramePadding.y;
118 ImGuiButtonFlags button_flags = ImGuiButtonFlags_PressedOnClick;
119 if (flags & ImGuiInputTextFlags_ReadOnly)
121 SameLine(0, style.ItemInnerSpacing.x);
122 if (ButtonEx(
"-", ImVec2(button_size, button_size), button_flags)) {
123 DataTypeApplyOp(data_type,
'-', p_data, p_data,
124 g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step);
125 value_changed =
true;
127 SameLine(0, style.ItemInnerSpacing.x);
128 if (ButtonEx(
"+", ImVec2(button_size, button_size), button_flags)) {
129 DataTypeApplyOp(data_type,
'+', p_data, p_data,
130 g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step);
131 value_changed =
true;
134 if (flags & ImGuiInputTextFlags_ReadOnly)
137 style.FramePadding = backup_frame_padding;
141 ImGui::PopStyleVar(2);
144 MarkItemEdited(g.LastItemData.ID);
146 return value_changed;