mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-24 07:40:22 +01:00
Added extra_flags parameters to InputInt(), InputFloat(). Used in example code. Commented out broken ImGuiInputTextFlags_AlignCenter.
This commit is contained in:
parent
3cdb4fa456
commit
62d233aaab
13
imgui.cpp
13
imgui.cpp
@ -3279,7 +3279,7 @@ bool SliderFloat(const char* label, float* v, float v_min, float v_max, const ch
|
||||
g.ActiveId = g.SliderAsInputTextId;
|
||||
g.HoveredId = 0;
|
||||
window->FocusItemUnregister(); // Our replacement slider will override the focus ID (that we needed to declare previously to allow for a TAB focus to happen before we got selected)
|
||||
value_changed = ImGui::InputText(label, text_buf, IM_ARRAYSIZE(text_buf), ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_AlignCenter);
|
||||
value_changed = ImGui::InputText(label, text_buf, IM_ARRAYSIZE(text_buf), ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_AutoSelectAll);
|
||||
if (g.SliderAsInputTextId == 0)
|
||||
{
|
||||
// First frame
|
||||
@ -3834,7 +3834,7 @@ void ImGuiTextEditState::RenderTextScrolledClipped(ImFont font, float font_size,
|
||||
namespace ImGui
|
||||
{
|
||||
|
||||
bool InputFloat(const char* label, float *v, float step, float step_fast, int decimal_precision)
|
||||
bool InputFloat(const char* label, float *v, float step, float step_fast, int decimal_precision, ImGuiInputTextFlags extra_flags)
|
||||
{
|
||||
ImGuiState& g = GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
@ -3857,7 +3857,8 @@ bool InputFloat(const char* label, float *v, float step, float step_fast, int de
|
||||
else
|
||||
ImFormatString(buf, IM_ARRAYSIZE(buf), "%.*f", decimal_precision, *v);
|
||||
bool value_changed = false;
|
||||
if (ImGui::InputText("", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsDecimal|ImGuiInputTextFlags_AlignCenter|ImGuiInputTextFlags_AutoSelectAll))
|
||||
const ImGuiInputTextFlags flags = extra_flags | (ImGuiInputTextFlags_CharsDecimal|ImGuiInputTextFlags_AutoSelectAll);
|
||||
if (ImGui::InputText("", buf, IM_ARRAYSIZE(buf), flags))
|
||||
{
|
||||
ApplyNumericalTextInput(buf, v);
|
||||
value_changed = true;
|
||||
@ -3891,10 +3892,10 @@ bool InputFloat(const char* label, float *v, float step, float step_fast, int de
|
||||
return value_changed;
|
||||
}
|
||||
|
||||
bool InputInt(const char* label, int *v, int step, int step_fast)
|
||||
bool InputInt(const char* label, int *v, int step, int step_fast, ImGuiInputTextFlags extra_flags)
|
||||
{
|
||||
float f = (float)*v;
|
||||
const bool value_changed = ImGui::InputFloat(label, &f, (float)step, (float)step_fast, 0);
|
||||
const bool value_changed = ImGui::InputFloat(label, &f, (float)step, (float)step_fast, 0, extra_flags);
|
||||
*v = (int)f;
|
||||
return value_changed;
|
||||
}
|
||||
@ -5871,7 +5872,7 @@ void ShowTestWindow(bool* open)
|
||||
bool goto_line = ImGui::Button("Goto");
|
||||
ImGui::SameLine();
|
||||
ImGui::PushItemWidth(100);
|
||||
ImGui::InputInt("##Line", &line, 0);
|
||||
goto_line |= ImGui::InputInt("##Line", &line, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue);
|
||||
ImGui::PopItemWidth();
|
||||
ImGui::BeginChild("Sub1", ImVec2(ImGui::GetWindowWidth()*0.5f,300));
|
||||
for (int i = 0; i < 100; i++)
|
||||
|
12
imgui.h
12
imgui.h
@ -215,12 +215,12 @@ namespace ImGui
|
||||
bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
|
||||
bool RadioButton(const char* label, bool active);
|
||||
bool RadioButton(const char* label, int* v, int v_button);
|
||||
bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1);
|
||||
bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0);
|
||||
bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0);
|
||||
bool InputFloat2(const char* label, float v[2], int decimal_precision = -1);
|
||||
bool InputFloat3(const char* label, float v[3], int decimal_precision = -1);
|
||||
bool InputFloat4(const char* label, float v[4], int decimal_precision = -1);
|
||||
bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100);
|
||||
bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0);
|
||||
bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags extra_flags = 0);
|
||||
bool Combo(const char* label, int* current_item, const char** items, int items_count, int popup_height_items = 7);
|
||||
bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_height_items = 7); // Separate items with \0, end item-list with \0\0
|
||||
bool Combo(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int popup_height_items = 7);
|
||||
@ -292,9 +292,9 @@ enum ImGuiInputTextFlags_
|
||||
// Default: 0
|
||||
ImGuiInputTextFlags_CharsDecimal = 1 << 0, // Allow 0123456789.+-*/
|
||||
ImGuiInputTextFlags_CharsHexadecimal = 1 << 1, // Allow 0123456789ABCDEFabcdef
|
||||
ImGuiInputTextFlags_AutoSelectAll = 1 << 2,
|
||||
ImGuiInputTextFlags_AlignCenter = 1 << 3,
|
||||
ImGuiInputTextFlags_EnterReturnsTrue = 1 << 4,
|
||||
ImGuiInputTextFlags_AutoSelectAll = 1 << 2, // Select entire text when first taking focus
|
||||
ImGuiInputTextFlags_EnterReturnsTrue = 1 << 3, // Return 'true' when Enter is pressed (as opposed to when the value was modified)
|
||||
//ImGuiInputTextFlags_AlignCenter = 1 << 3,
|
||||
};
|
||||
|
||||
// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
|
||||
|
Loading…
Reference in New Issue
Block a user