|
|
@ -105,7 +105,6 @@ static const ImU64 IM_U64_MAX = (2ULL * 9223372036854775807LL + 1);
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
// Data Type helpers
|
|
|
|
// Data Type helpers
|
|
|
|
static inline int DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* data_ptr, const char* format);
|
|
|
|
|
|
|
|
static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, void* arg_1, const void* arg_2);
|
|
|
|
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* format);
|
|
|
|
static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* format);
|
|
|
|
|
|
|
|
|
|
|
@ -1539,6 +1538,7 @@ bool ImGui::Combo(const char* label, int* current_item, const char* items_separa
|
|
|
|
// [SECTION] Data Type and Data Formatting Helpers [Internal]
|
|
|
|
// [SECTION] Data Type and Data Formatting Helpers [Internal]
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// - PatchFormatStringFloatToInt()
|
|
|
|
// - PatchFormatStringFloatToInt()
|
|
|
|
|
|
|
|
// - DataTypeGetInfo()
|
|
|
|
// - DataTypeFormatString()
|
|
|
|
// - DataTypeFormatString()
|
|
|
|
// - DataTypeApplyOp()
|
|
|
|
// - DataTypeApplyOp()
|
|
|
|
// - DataTypeApplyOpFromText()
|
|
|
|
// - DataTypeApplyOpFromText()
|
|
|
@ -1546,13 +1546,6 @@ bool ImGui::Combo(const char* label, int* current_item, const char* items_separa
|
|
|
|
// - RoundScalarWithFormat<>()
|
|
|
|
// - RoundScalarWithFormat<>()
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
struct ImGuiDataTypeInfo
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
size_t Size;
|
|
|
|
|
|
|
|
const char* PrintFmt; // Unused
|
|
|
|
|
|
|
|
const char* ScanFmt;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const ImGuiDataTypeInfo GDataTypeInfo[] =
|
|
|
|
static const ImGuiDataTypeInfo GDataTypeInfo[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ sizeof(char), "%d", "%d" }, // ImGuiDataType_S8
|
|
|
|
{ sizeof(char), "%d", "%d" }, // ImGuiDataType_S8
|
|
|
@ -1597,7 +1590,13 @@ static const char* PatchFormatStringFloatToInt(const char* fmt)
|
|
|
|
return fmt;
|
|
|
|
return fmt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline int DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* data_ptr, const char* format)
|
|
|
|
const ImGuiDataTypeInfo* ImGui::DataTypeGetInfo(ImGuiDataType data_type)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT);
|
|
|
|
|
|
|
|
return &GDataTypeInfo[data_type];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ImGui::DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* data_ptr, const char* format)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Signedness doesn't matter when pushing integer arguments
|
|
|
|
// Signedness doesn't matter when pushing integer arguments
|
|
|
|
if (data_type == ImGuiDataType_S32 || data_type == ImGuiDataType_U32)
|
|
|
|
if (data_type == ImGuiDataType_S32 || data_type == ImGuiDataType_U32)
|
|
|
@ -1696,11 +1695,12 @@ static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
|
|
|
// Copy the value in an opaque buffer so we can compare at the end of the function if it changed at all.
|
|
|
|
// Copy the value in an opaque buffer so we can compare at the end of the function if it changed at all.
|
|
|
|
IM_ASSERT(data_type < ImGuiDataType_COUNT);
|
|
|
|
IM_ASSERT(data_type < ImGuiDataType_COUNT);
|
|
|
|
int data_backup[2];
|
|
|
|
int data_backup[2];
|
|
|
|
IM_ASSERT(GDataTypeInfo[data_type].Size <= sizeof(data_backup));
|
|
|
|
const ImGuiDataTypeInfo* type_info = ImGui::DataTypeGetInfo(data_type);
|
|
|
|
memcpy(data_backup, data_ptr, GDataTypeInfo[data_type].Size);
|
|
|
|
IM_ASSERT(type_info->Size <= sizeof(data_backup));
|
|
|
|
|
|
|
|
memcpy(data_backup, data_ptr, type_info->Size);
|
|
|
|
|
|
|
|
|
|
|
|
if (format == NULL)
|
|
|
|
if (format == NULL)
|
|
|
|
format = GDataTypeInfo[data_type].ScanFmt;
|
|
|
|
format = type_info->ScanFmt;
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME-LEGACY: The aim is to remove those operators and write a proper expression evaluator at some point..
|
|
|
|
// FIXME-LEGACY: The aim is to remove those operators and write a proper expression evaluator at some point..
|
|
|
|
int arg1i = 0;
|
|
|
|
int arg1i = 0;
|
|
|
@ -1769,7 +1769,7 @@ static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
|
|
|
IM_ASSERT(0);
|
|
|
|
IM_ASSERT(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return memcmp(data_backup, data_ptr, GDataTypeInfo[data_type].Size) != 0;
|
|
|
|
return memcmp(data_backup, data_ptr, type_info->Size) != 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static float GetMinimumStepAtDecimalPrecision(int decimal_precision)
|
|
|
|
static float GetMinimumStepAtDecimalPrecision(int decimal_precision)
|
|
|
@ -1990,11 +1990,9 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* v, floa
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Default format string when passing NULL
|
|
|
|
// Default format string when passing NULL
|
|
|
|
// Patch old "%.0f" format string to use "%d", read function comments for more details.
|
|
|
|
|
|
|
|
IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT);
|
|
|
|
|
|
|
|
if (format == NULL)
|
|
|
|
if (format == NULL)
|
|
|
|
format = GDataTypeInfo[data_type].PrintFmt;
|
|
|
|
format = DataTypeGetInfo(data_type)->PrintFmt;
|
|
|
|
else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0)
|
|
|
|
else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0) // (FIXME-LEGACY: Patch old "%.0f" format string to use "%d", read function more details.)
|
|
|
|
format = PatchFormatStringFloatToInt(format);
|
|
|
|
format = PatchFormatStringFloatToInt(format);
|
|
|
|
|
|
|
|
|
|
|
|
// Tabbing or CTRL-clicking on Drag turns it into an input box
|
|
|
|
// Tabbing or CTRL-clicking on Drag turns it into an input box
|
|
|
@ -2435,11 +2433,9 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* v, co
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Default format string when passing NULL
|
|
|
|
// Default format string when passing NULL
|
|
|
|
// Patch old "%.0f" format string to use "%d", read function comments for more details.
|
|
|
|
|
|
|
|
IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT);
|
|
|
|
|
|
|
|
if (format == NULL)
|
|
|
|
if (format == NULL)
|
|
|
|
format = GDataTypeInfo[data_type].PrintFmt;
|
|
|
|
format = DataTypeGetInfo(data_type)->PrintFmt;
|
|
|
|
else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0)
|
|
|
|
else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0) // (FIXME-LEGACY: Patch old "%.0f" format string to use "%d", read function more details.)
|
|
|
|
format = PatchFormatStringFloatToInt(format);
|
|
|
|
format = PatchFormatStringFloatToInt(format);
|
|
|
|
|
|
|
|
|
|
|
|
// Tabbing or CTRL-clicking on Slider turns it into an input box
|
|
|
|
// Tabbing or CTRL-clicking on Slider turns it into an input box
|
|
|
@ -2591,11 +2587,9 @@ bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType d
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Default format string when passing NULL
|
|
|
|
// Default format string when passing NULL
|
|
|
|
// Patch old "%.0f" format string to use "%d", read function comments for more details.
|
|
|
|
|
|
|
|
IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT);
|
|
|
|
|
|
|
|
if (format == NULL)
|
|
|
|
if (format == NULL)
|
|
|
|
format = GDataTypeInfo[data_type].PrintFmt;
|
|
|
|
format = DataTypeGetInfo(data_type)->PrintFmt;
|
|
|
|
else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0)
|
|
|
|
else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0) // (FIXME-LEGACY: Patch old "%.0f" format string to use "%d", read function more details.)
|
|
|
|
format = PatchFormatStringFloatToInt(format);
|
|
|
|
format = PatchFormatStringFloatToInt(format);
|
|
|
|
|
|
|
|
|
|
|
|
const bool hovered = ItemHoverable(frame_bb, id);
|
|
|
|
const bool hovered = ItemHoverable(frame_bb, id);
|
|
|
@ -2777,9 +2771,8 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* data_p
|
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
ImGuiStyle& style = g.Style;
|
|
|
|
ImGuiStyle& style = g.Style;
|
|
|
|
|
|
|
|
|
|
|
|
IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT);
|
|
|
|
|
|
|
|
if (format == NULL)
|
|
|
|
if (format == NULL)
|
|
|
|
format = GDataTypeInfo[data_type].PrintFmt;
|
|
|
|
format = DataTypeGetInfo(data_type)->PrintFmt;
|
|
|
|
|
|
|
|
|
|
|
|
char buf[64];
|
|
|
|
char buf[64];
|
|
|
|
DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, data_ptr, format);
|
|
|
|
DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, data_ptr, format);
|
|
|
|