mirror of https://github.com/bkaradzic/bgfx
Updated ImGui.
This commit is contained in:
parent
8c93e4a4ae
commit
8e6450de15
|
@ -728,7 +728,7 @@ static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const
|
|||
|
||||
static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr, const char* display_format, char* buf, int buf_size);
|
||||
static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr, int decimal_precision, char* buf, int buf_size);
|
||||
static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* value1, const void* value2);
|
||||
static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, void* arg_1, const void* arg_2);
|
||||
static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format);
|
||||
|
||||
namespace ImGui
|
||||
|
@ -2323,7 +2323,9 @@ static void NavRestoreLayer(int layer)
|
|||
static inline void NavUpdateAnyRequestFlag()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.NavAnyRequest = g.NavMoveRequest || g.NavInitRequest || IMGUI_DEBUG_NAV_SCORING;
|
||||
g.NavAnyRequest = g.NavMoveRequest || g.NavInitRequest || (IMGUI_DEBUG_NAV_SCORING && g.NavWindow != NULL);
|
||||
if (g.NavAnyRequest)
|
||||
IM_ASSERT(g.NavWindow != NULL);
|
||||
}
|
||||
|
||||
static bool NavMoveRequestButNoResultYet()
|
||||
|
@ -6571,34 +6573,35 @@ void ImGui::PopStyleColor(int count)
|
|||
struct ImGuiStyleVarInfo
|
||||
{
|
||||
ImGuiDataType Type;
|
||||
ImU32 Count;
|
||||
ImU32 Offset;
|
||||
void* GetVarPtr(ImGuiStyle* style) const { return (void*)((unsigned char*)style + Offset); }
|
||||
};
|
||||
|
||||
static const ImGuiStyleVarInfo GStyleVarInfo[] =
|
||||
{
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, Alpha) }, // ImGuiStyleVar_Alpha
|
||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowRounding) }, // ImGuiStyleVar_WindowRounding
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowBorderSize) }, // ImGuiStyleVar_WindowBorderSize
|
||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowMinSize) }, // ImGuiStyleVar_WindowMinSize
|
||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowTitleAlign) }, // ImGuiStyleVar_WindowTitleAlign
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildRounding) }, // ImGuiStyleVar_ChildRounding
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildBorderSize) }, // ImGuiStyleVar_ChildBorderSize
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupRounding) }, // ImGuiStyleVar_PopupRounding
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupBorderSize) }, // ImGuiStyleVar_PopupBorderSize
|
||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, FramePadding) }, // ImGuiStyleVar_FramePadding
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameRounding) }, // ImGuiStyleVar_FrameRounding
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameBorderSize) }, // ImGuiStyleVar_FrameBorderSize
|
||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing
|
||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing) }, // ImGuiStyleVar_IndentSpacing
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarSize) }, // ImGuiStyleVar_ScrollbarSize
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarRounding) }, // ImGuiStyleVar_ScrollbarRounding
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding
|
||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ViewId) },
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, Alpha) }, // ImGuiStyleVar_Alpha
|
||||
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowRounding) }, // ImGuiStyleVar_WindowRounding
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowBorderSize) }, // ImGuiStyleVar_WindowBorderSize
|
||||
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowMinSize) }, // ImGuiStyleVar_WindowMinSize
|
||||
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowTitleAlign) }, // ImGuiStyleVar_WindowTitleAlign
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildRounding) }, // ImGuiStyleVar_ChildRounding
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildBorderSize) }, // ImGuiStyleVar_ChildBorderSize
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupRounding) }, // ImGuiStyleVar_PopupRounding
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupBorderSize) }, // ImGuiStyleVar_PopupBorderSize
|
||||
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, FramePadding) }, // ImGuiStyleVar_FramePadding
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameRounding) }, // ImGuiStyleVar_FrameRounding
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameBorderSize) }, // ImGuiStyleVar_FrameBorderSize
|
||||
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing
|
||||
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing) }, // ImGuiStyleVar_IndentSpacing
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarSize) }, // ImGuiStyleVar_ScrollbarSize
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarRounding) }, // ImGuiStyleVar_ScrollbarRounding
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding
|
||||
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ViewId) },
|
||||
};
|
||||
|
||||
static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx)
|
||||
|
@ -6611,7 +6614,7 @@ static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx)
|
|||
void ImGui::PushStyleVar(ImGuiStyleVar idx, float val)
|
||||
{
|
||||
const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx);
|
||||
if (var_info->Type == ImGuiDataType_Float)
|
||||
if (var_info->Type == ImGuiDataType_Float && var_info->Count == 1)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
float* pvar = (float*)var_info->GetVarPtr(&g.Style);
|
||||
|
@ -6625,7 +6628,7 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, float val)
|
|||
void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val)
|
||||
{
|
||||
const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx);
|
||||
if (var_info->Type == ImGuiDataType_Float2)
|
||||
if (var_info->Type == ImGuiDataType_Float && var_info->Count == 2)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImVec2* pvar = (ImVec2*)var_info->GetVarPtr(&g.Style);
|
||||
|
@ -6641,11 +6644,12 @@ void ImGui::PopStyleVar(int count)
|
|||
ImGuiContext& g = *GImGui;
|
||||
while (count > 0)
|
||||
{
|
||||
// We avoid a generic memcpy(data, &backup.Backup.., GDataTypeSize[info->Type] * info->Count), the overhead in Debug is not worth it.
|
||||
ImGuiStyleMod& backup = g.StyleModifiers.back();
|
||||
const ImGuiStyleVarInfo* info = GetStyleVarInfo(backup.VarIdx);
|
||||
if (info->Type == ImGuiDataType_Float) (*(float*)info->GetVarPtr(&g.Style)) = backup.BackupFloat[0];
|
||||
else if (info->Type == ImGuiDataType_Float2) (*(ImVec2*)info->GetVarPtr(&g.Style)) = ImVec2(backup.BackupFloat[0], backup.BackupFloat[1]);
|
||||
else if (info->Type == ImGuiDataType_Int) (*(int*)info->GetVarPtr(&g.Style)) = backup.BackupInt[0];
|
||||
void* data = info->GetVarPtr(&g.Style);
|
||||
if (info->Type == ImGuiDataType_Float && info->Count == 1) { ((float*)data)[0] = backup.BackupFloat[0]; }
|
||||
else if (info->Type == ImGuiDataType_Float && info->Count == 2) { ((float*)data)[0] = backup.BackupFloat[0]; ((float*)data)[1] = backup.BackupFloat[1]; }
|
||||
g.StyleModifiers.pop_back();
|
||||
count--;
|
||||
}
|
||||
|
@ -8382,6 +8386,8 @@ static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr,
|
|||
ImFormatString(buf, buf_size, display_format, *(int*)data_ptr);
|
||||
else if (data_type == ImGuiDataType_Float)
|
||||
ImFormatString(buf, buf_size, display_format, *(float*)data_ptr);
|
||||
else if (data_type == ImGuiDataType_Double)
|
||||
ImFormatString(buf, buf_size, display_format, *(double*)data_ptr);
|
||||
}
|
||||
|
||||
static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr, int decimal_precision, char* buf, int buf_size)
|
||||
|
@ -8400,27 +8406,44 @@ static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr,
|
|||
else
|
||||
ImFormatString(buf, buf_size, "%.*f", decimal_precision, *(float*)data_ptr);
|
||||
}
|
||||
else if (data_type == ImGuiDataType_Double)
|
||||
{
|
||||
if (decimal_precision < 0)
|
||||
ImFormatString(buf, buf_size, "%f", *(double*)data_ptr);
|
||||
else
|
||||
ImFormatString(buf, buf_size, "%.*f", decimal_precision, *(double*)data_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* value1, const void* value2)// Store into value1
|
||||
static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, void* arg1, const void* arg2)
|
||||
{
|
||||
IM_ASSERT(op == '+' || op == '-');
|
||||
if (data_type == ImGuiDataType_Int)
|
||||
{
|
||||
if (op == '+')
|
||||
*(int*)value1 = *(int*)value1 + *(const int*)value2;
|
||||
else if (op == '-')
|
||||
*(int*)value1 = *(int*)value1 - *(const int*)value2;
|
||||
if (op == '+') *(int*)output = *(int*)arg1 + *(const int*)arg2;
|
||||
else if (op == '-') *(int*)output = *(int*)arg1 - *(const int*)arg2;
|
||||
}
|
||||
else if (data_type == ImGuiDataType_Float)
|
||||
{
|
||||
if (op == '+')
|
||||
*(float*)value1 = *(float*)value1 + *(const float*)value2;
|
||||
else if (op == '-')
|
||||
*(float*)value1 = *(float*)value1 - *(const float*)value2;
|
||||
if (op == '+') *(float*)output = *(float*)arg1 + *(const float*)arg2;
|
||||
else if (op == '-') *(float*)output = *(float*)arg1 - *(const float*)arg2;
|
||||
}
|
||||
else if (data_type == ImGuiDataType_Double)
|
||||
{
|
||||
if (op == '+') *(double*)output = *(double*)arg1 + *(const double*)arg2;
|
||||
else if (op == '-') *(double*)output = *(double*)arg1 - *(const double*)arg2;
|
||||
}
|
||||
}
|
||||
|
||||
static size_t GDataTypeSize[ImGuiDataType_COUNT] =
|
||||
{
|
||||
sizeof(int),
|
||||
sizeof(float),
|
||||
sizeof(double)
|
||||
};
|
||||
|
||||
// User can input math operators (e.g. +100) to edit a numerical values.
|
||||
// NB: This is _not_ a full expression evaluator. We should probably add one though..
|
||||
static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format)
|
||||
{
|
||||
while (ImCharIsSpace(*buf))
|
||||
|
@ -8442,45 +8465,56 @@ static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
|||
if (!buf[0])
|
||||
return false;
|
||||
|
||||
IM_ASSERT(data_type < ImGuiDataType_COUNT);
|
||||
int data_backup[2];
|
||||
IM_ASSERT(GDataTypeSize[data_type] <= sizeof(data_backup));
|
||||
memcpy(data_backup, data_ptr, GDataTypeSize[data_type]);
|
||||
|
||||
if (data_type == ImGuiDataType_Int)
|
||||
{
|
||||
if (!scalar_format)
|
||||
scalar_format = "%d";
|
||||
int* v = (int*)data_ptr;
|
||||
const int old_v = *v;
|
||||
int arg0i = *v;
|
||||
if (op && sscanf(initial_value_buf, scalar_format, &arg0i) < 1)
|
||||
return false;
|
||||
|
||||
// Store operand in a float so we can use fractional value for multipliers (*1.1), but constant always parsed as integer so we can fit big integers (e.g. 2000000003) past float precision
|
||||
float arg1f = 0.0f;
|
||||
if (op == '+') { if (sscanf(buf, "%f", &arg1f) == 1) *v = (int)(arg0i + arg1f); } // Add (use "+-" to subtract)
|
||||
else if (op == '*') { if (sscanf(buf, "%f", &arg1f) == 1) *v = (int)(arg0i * arg1f); } // Multiply
|
||||
else if (op == '/') { if (sscanf(buf, "%f", &arg1f) == 1 && arg1f != 0.0f) *v = (int)(arg0i / arg1f); }// Divide
|
||||
else { if (sscanf(buf, scalar_format, &arg0i) == 1) *v = arg0i; } // Assign constant (read as integer so big values are not lossy)
|
||||
return (old_v != *v);
|
||||
else { if (sscanf(buf, scalar_format, &arg0i) == 1) *v = arg0i; } // Assign integer constant
|
||||
}
|
||||
else if (data_type == ImGuiDataType_Float)
|
||||
{
|
||||
// For floats we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in
|
||||
scalar_format = "%f";
|
||||
float* v = (float*)data_ptr;
|
||||
const float old_v = *v;
|
||||
float arg0f = *v;
|
||||
float arg0f = *v, arg1f = 0.0f;
|
||||
if (op && sscanf(initial_value_buf, scalar_format, &arg0f) < 1)
|
||||
return false;
|
||||
|
||||
float arg1f = 0.0f;
|
||||
if (sscanf(buf, scalar_format, &arg1f) < 1)
|
||||
return false;
|
||||
if (op == '+') { *v = arg0f + arg1f; } // Add (use "+-" to subtract)
|
||||
else if (op == '*') { *v = arg0f * arg1f; } // Multiply
|
||||
else if (op == '/') { if (arg1f != 0.0f) *v = arg0f / arg1f; } // Divide
|
||||
else { *v = arg1f; } // Assign constant
|
||||
return (old_v != *v);
|
||||
}
|
||||
|
||||
return false;
|
||||
else if (data_type == ImGuiDataType_Double)
|
||||
{
|
||||
scalar_format = "%lf";
|
||||
double* v = (double*)data_ptr;
|
||||
double arg0f = *v, arg1f = 0.0f;
|
||||
if (op && sscanf(initial_value_buf, scalar_format, &arg0f) < 1)
|
||||
return false;
|
||||
if (sscanf(buf, scalar_format, &arg1f) < 1)
|
||||
return false;
|
||||
if (op == '+') { *v = arg0f + arg1f; } // Add (use "+-" to subtract)
|
||||
else if (op == '*') { *v = arg0f * arg1f; } // Multiply
|
||||
else if (op == '/') { if (arg1f != 0.0f) *v = arg0f / arg1f; } // Divide
|
||||
else { *v = arg1f; } // Assign constant
|
||||
}
|
||||
return memcmp(data_backup, data_ptr, GDataTypeSize[data_type]) != 0;
|
||||
}
|
||||
|
||||
// Create text input in place of a slider (when CTRL+Clicking on slider)
|
||||
|
@ -9781,12 +9815,16 @@ static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags f
|
|||
if (c >= 0xE000 && c <= 0xF8FF) // Filter private Unicode range. I don't imagine anybody would want to input them. GLFW on OSX seems to send private characters for special keys like arrow keys.
|
||||
return false;
|
||||
|
||||
if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank))
|
||||
if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank | ImGuiInputTextFlags_CharsScientific))
|
||||
{
|
||||
if (flags & ImGuiInputTextFlags_CharsDecimal)
|
||||
if (!(c >= '0' && c <= '9') && (c != '.') && (c != '-') && (c != '+') && (c != '*') && (c != '/'))
|
||||
return false;
|
||||
|
||||
if (flags & ImGuiInputTextFlags_CharsScientific)
|
||||
if (!(c >= '0' && c <= '9') && (c != '.') && (c != '-') && (c != '+') && (c != '*') && (c != '/') && (c != 'e') && (c != 'E'))
|
||||
return false;
|
||||
|
||||
if (flags & ImGuiInputTextFlags_CharsHexadecimal)
|
||||
if (!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f') && !(c >= 'A' && c <= 'F'))
|
||||
return false;
|
||||
|
@ -10448,7 +10486,7 @@ bool ImGui::InputScalarEx(const char* label, ImGuiDataType data_type, void* data
|
|||
DataTypeFormatString(data_type, data_ptr, scalar_format, buf, IM_ARRAYSIZE(buf));
|
||||
|
||||
bool value_changed = false;
|
||||
if (!(extra_flags & ImGuiInputTextFlags_CharsHexadecimal))
|
||||
if ((extra_flags & (ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsScientific)) == 0)
|
||||
extra_flags |= ImGuiInputTextFlags_CharsDecimal;
|
||||
extra_flags |= ImGuiInputTextFlags_AutoSelectAll;
|
||||
if (InputText("", buf, IM_ARRAYSIZE(buf), extra_flags)) // PushId(label) + "" gives us the expected ID from outside point of view
|
||||
|
@ -10461,13 +10499,13 @@ bool ImGui::InputScalarEx(const char* label, ImGuiDataType data_type, void* data
|
|||
SameLine(0, style.ItemInnerSpacing.x);
|
||||
if (ButtonEx("-", button_sz, ImGuiButtonFlags_Repeat | ImGuiButtonFlags_DontClosePopups))
|
||||
{
|
||||
DataTypeApplyOp(data_type, '-', data_ptr, g.IO.KeyCtrl && step_fast_ptr ? step_fast_ptr : step_ptr);
|
||||
DataTypeApplyOp(data_type, '-', data_ptr, data_ptr, g.IO.KeyCtrl && step_fast_ptr ? step_fast_ptr : step_ptr);
|
||||
value_changed = true;
|
||||
}
|
||||
SameLine(0, style.ItemInnerSpacing.x);
|
||||
if (ButtonEx("+", button_sz, ImGuiButtonFlags_Repeat | ImGuiButtonFlags_DontClosePopups))
|
||||
{
|
||||
DataTypeApplyOp(data_type, '+', data_ptr, g.IO.KeyCtrl && step_fast_ptr ? step_fast_ptr : step_ptr);
|
||||
DataTypeApplyOp(data_type, '+', data_ptr, data_ptr, g.IO.KeyCtrl && step_fast_ptr ? step_fast_ptr : step_ptr);
|
||||
value_changed = true;
|
||||
}
|
||||
}
|
||||
|
@ -10486,19 +10524,31 @@ bool ImGui::InputScalarEx(const char* label, ImGuiDataType data_type, void* data
|
|||
|
||||
bool ImGui::InputFloat(const char* label, float* v, float step, float step_fast, int decimal_precision, ImGuiInputTextFlags extra_flags)
|
||||
{
|
||||
char display_format[16];
|
||||
extra_flags |= ImGuiInputTextFlags_CharsScientific;
|
||||
if (decimal_precision < 0)
|
||||
strcpy(display_format, "%f"); // Ideally we'd have a minimum decimal precision of 1 to visually denote that this is a float, while hiding non-significant digits? %f doesn't have a minimum of 1
|
||||
{
|
||||
// Ideally we'd have a minimum decimal precision of 1 to visually denote that this is a float, while hiding non-significant digits? %f doesn't have a minimum of 1
|
||||
return InputScalarEx(label, ImGuiDataType_Float, (void*)v, (void*)(step>0.0f ? &step : NULL), (void*)(step_fast>0.0f ? &step_fast : NULL), "%f", extra_flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
char display_format[16];
|
||||
ImFormatString(display_format, IM_ARRAYSIZE(display_format), "%%.%df", decimal_precision);
|
||||
return InputScalarEx(label, ImGuiDataType_Float, (void*)v, (void*)(step>0.0f ? &step : NULL), (void*)(step_fast>0.0f ? &step_fast : NULL), display_format, extra_flags);
|
||||
return InputScalarEx(label, ImGuiDataType_Float, (void*)v, (void*)(step>0.0f ? &step : NULL), (void*)(step_fast>0.0f ? &step_fast : NULL), display_format, extra_flags);
|
||||
}
|
||||
}
|
||||
|
||||
bool ImGui::InputDouble(const char* label, double* v, double step, double step_fast, const char* display_format, ImGuiInputTextFlags extra_flags)
|
||||
{
|
||||
extra_flags |= ImGuiInputTextFlags_CharsScientific;
|
||||
return InputScalarEx(label, ImGuiDataType_Double, (void*)v, (void*)(step>0.0 ? &step : NULL), (void*)(step_fast>0.0 ? &step_fast : NULL), display_format, extra_flags);
|
||||
}
|
||||
|
||||
bool ImGui::InputInt(const char* label, int* v, int step, int step_fast, ImGuiInputTextFlags extra_flags)
|
||||
{
|
||||
// Hexadecimal input provided as a convenience but the flag name is awkward. Typically you'd use InputText() to parse your own data, if you want to handle prefixes.
|
||||
const char* scalar_format = (extra_flags & ImGuiInputTextFlags_CharsHexadecimal) ? "%08X" : "%d";
|
||||
return InputScalarEx(label, ImGuiDataType_Int, (void*)v, (void*)(step>0.0f ? &step : NULL), (void*)(step_fast>0.0f ? &step_fast : NULL), scalar_format, extra_flags);
|
||||
return InputScalarEx(label, ImGuiDataType_Int, (void*)v, (void*)(step>0 ? &step : NULL), (void*)(step_fast>0 ? &step_fast : NULL), scalar_format, extra_flags);
|
||||
}
|
||||
|
||||
bool ImGui::InputFloatN(const char* label, float* v, int components, int decimal_precision, ImGuiInputTextFlags extra_flags)
|
||||
|
@ -13262,6 +13312,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||
ImGui::Text("HoveredId: 0x%08X/0x%08X (%.2f sec)", g.HoveredId, g.HoveredIdPreviousFrame, g.HoveredIdTimer); // Data is "in-flight" so depending on when the Metrics window is called we may see current frame information or not
|
||||
ImGui::Text("ActiveId: 0x%08X/0x%08X (%.2f sec), ActiveIdSource: %s", g.ActiveId, g.ActiveIdPreviousFrame, g.ActiveIdTimer, input_source_names[g.ActiveIdSource]);
|
||||
ImGui::Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL");
|
||||
ImGui::Text("MovingWindow: '%s'", g.MovingWindow ? g.MovingWindow->Name : "NULL");
|
||||
ImGui::Text("NavWindow: '%s'", g.NavWindow ? g.NavWindow->Name : "NULL");
|
||||
ImGui::Text("NavId: 0x%08X, NavLayer: %d", g.NavId, g.NavLayer);
|
||||
ImGui::Text("NavInputSource: %s", input_source_names[g.NavInputSource]);
|
||||
|
|
|
@ -358,6 +358,7 @@ namespace ImGui
|
|||
IMGUI_API bool InputInt2(const char* label, int v[2], ImGuiInputTextFlags extra_flags = 0);
|
||||
IMGUI_API bool InputInt3(const char* label, int v[3], ImGuiInputTextFlags extra_flags = 0);
|
||||
IMGUI_API bool InputInt4(const char* label, int v[4], ImGuiInputTextFlags extra_flags = 0);
|
||||
IMGUI_API bool InputDouble(const char* label, double* v, double step = 0.0f, double step_fast = 0.0f, const char* display_format = "%.6f", ImGuiInputTextFlags extra_flags = 0);
|
||||
|
||||
// Widgets: Sliders (tip: ctrl+click on a slider to input with keyboard. manually input values aren't clamped, can go off-bounds)
|
||||
IMGUI_API bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); // adjust display_format to decorate the value with a prefix or a suffix for in-slider labels or unit display. Use power!=1.0 for logarithmic sliders
|
||||
|
@ -604,6 +605,7 @@ enum ImGuiInputTextFlags_
|
|||
ImGuiInputTextFlags_ReadOnly = 1 << 14, // Read-only mode
|
||||
ImGuiInputTextFlags_Password = 1 << 15, // Password mode, display all characters as '*'
|
||||
ImGuiInputTextFlags_NoUndoRedo = 1 << 16, // Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID().
|
||||
ImGuiInputTextFlags_CharsScientific = 1 << 17, // Allow 0123456789.+-*/eE (Scientific notation input)
|
||||
// [Internal]
|
||||
ImGuiInputTextFlags_Multiline = 1 << 20 // For internal use by InputTextMultiline()
|
||||
};
|
||||
|
|
|
@ -335,8 +335,8 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||
|
||||
{
|
||||
static char str0[128] = "Hello, world!";
|
||||
static int i0=123;
|
||||
static float f0=0.001f;
|
||||
static int i0 = 123;
|
||||
static float f0 = 0.001f;
|
||||
ImGui::InputText("input text", str0, IM_ARRAYSIZE(str0));
|
||||
ImGui::SameLine(); ShowHelpMarker("Hold SHIFT or use mouse to select text.\n" "CTRL+Left/Right to word jump.\n" "CTRL+A or double-click to select all.\n" "CTRL+X,CTRL+C,CTRL+V clipboard.\n" "CTRL+Z,CTRL+Y undo/redo.\n" "ESCAPE to revert.\n");
|
||||
|
||||
|
@ -345,12 +345,17 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||
|
||||
ImGui::InputFloat("input float", &f0, 0.01f, 1.0f);
|
||||
|
||||
// NB: You can use the %e notation as well.
|
||||
static double d0 = 999999.000001;
|
||||
ImGui::InputDouble("input double", &d0, 0.01f, 1.0f, "%.6f");
|
||||
ImGui::SameLine(); ShowHelpMarker("You can input value using the scientific notation,\n e.g. \"1e+8\" becomes \"100000000\".\n");
|
||||
|
||||
static float vec4a[4] = { 0.10f, 0.20f, 0.30f, 0.44f };
|
||||
ImGui::InputFloat3("input float3", vec4a);
|
||||
}
|
||||
|
||||
{
|
||||
static int i1=50, i2=42;
|
||||
static int i1 = 50, i2 = 42;
|
||||
ImGui::DragInt("drag int", &i1, 1);
|
||||
ImGui::SameLine(); ShowHelpMarker("Click and drag to edit value.\nHold SHIFT/ALT for faster/slower edit.\nDouble-click or CTRL+click to input value.");
|
||||
|
||||
|
|
|
@ -248,7 +248,8 @@ enum ImGuiDataType
|
|||
{
|
||||
ImGuiDataType_Int,
|
||||
ImGuiDataType_Float,
|
||||
ImGuiDataType_Float2
|
||||
ImGuiDataType_Double,
|
||||
ImGuiDataType_COUNT
|
||||
};
|
||||
|
||||
enum ImGuiInputSource
|
||||
|
@ -258,7 +259,7 @@ enum ImGuiInputSource
|
|||
ImGuiInputSource_Nav,
|
||||
ImGuiInputSource_NavKeyboard, // Only used occasionally for storage, not tested/handled by most code
|
||||
ImGuiInputSource_NavGamepad, // "
|
||||
ImGuiInputSource_COUNT,
|
||||
ImGuiInputSource_COUNT
|
||||
};
|
||||
|
||||
// FIXME-NAV: Clarify/expose various repeat delay/rate
|
||||
|
|
|
@ -18,7 +18,7 @@ extern "C"
|
|||
#define BGFX_CHUNK_MAGIC_VSH BX_MAKEFOURCC('V', 'S', 'H', 0x5)
|
||||
|
||||
#define BGFX_SHADERC_VERSION_MAJOR 1
|
||||
#define BGFX_SHADERC_VERSION_MINOR 10
|
||||
#define BGFX_SHADERC_VERSION_MINOR 12
|
||||
|
||||
namespace bgfx
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue