@ -964,6 +964,7 @@ void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars)
// HELPERS
// HELPERS
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
# define IM_STATIC_ASSERT(_COND) typedef char static_assertion_##__line__[(_COND)?1:-1]
# define IM_F32_TO_INT8_UNBOUND(_VAL) ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f))) // Unsaturated, for display purpose
# define IM_F32_TO_INT8_UNBOUND(_VAL) ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f))) // Unsaturated, for display purpose
# define IM_F32_TO_INT8_SAT(_VAL) ((int)(ImSaturate(_VAL) * 255.0f + 0.5f)) // Saturated, always output 0..255
# define IM_F32_TO_INT8_SAT(_VAL) ((int)(ImSaturate(_VAL) * 255.0f + 0.5f)) // Saturated, always output 0..255
@ -8509,6 +8510,7 @@ static inline int DataTypeFormatString(char* buf, int buf_size, ImGuiDataType da
return 0 ;
return 0 ;
}
}
// FIXME: Adding support for clamping on boundaries of the data type would be nice.
static void DataTypeApplyOp ( ImGuiDataType data_type , int op , void * output , void * arg1 , const void * arg2 )
static void DataTypeApplyOp ( ImGuiDataType data_type , int op , void * output , void * arg1 , const void * arg2 )
{
{
IM_ASSERT ( op = = ' + ' | | op = = ' - ' ) ;
IM_ASSERT ( op = = ' + ' | | op = = ' - ' ) ;
@ -8540,6 +8542,7 @@ static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, void*
return ;
return ;
case ImGuiDataType_COUNT : break ;
case ImGuiDataType_COUNT : break ;
}
}
IM_ASSERT ( 0 ) ;
}
}
struct ImGuiDataTypeInfo
struct ImGuiDataTypeInfo
@ -8549,7 +8552,7 @@ struct ImGuiDataTypeInfo
const char * ScanFmt ;
const char * ScanFmt ;
} ;
} ;
static const ImGuiDataTypeInfo GDataTypeInfo [ ImGuiDataType_COUNT ] =
static const ImGuiDataTypeInfo GDataTypeInfo [ ] =
{
{
{ sizeof ( int ) , " %d " , " %d " } ,
{ sizeof ( int ) , " %d " , " %d " } ,
{ sizeof ( unsigned int ) , " %u " , " %u " } ,
{ sizeof ( unsigned int ) , " %u " , " %u " } ,
@ -8563,6 +8566,7 @@ static const ImGuiDataTypeInfo GDataTypeInfo[ImGuiDataType_COUNT] =
{ sizeof ( float ) , " %f " , " %f " } , // float are promoted to double in va_arg
{ sizeof ( float ) , " %f " , " %f " } , // float are promoted to double in va_arg
{ sizeof ( double ) , " %f " , " %lf " } ,
{ sizeof ( double ) , " %f " , " %lf " } ,
} ;
} ;
IM_STATIC_ASSERT ( IM_ARRAYSIZE ( GDataTypeInfo ) = = ImGuiDataType_COUNT ) ;
// User can input math operators (e.g. +100) to edit a numerical values.
// 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 and replace this dumb mess..
// NB: This is _not_ a full expression evaluator. We should probably add one and replace this dumb mess..
@ -8975,6 +8979,9 @@ static bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType d
return value_changed ;
return value_changed ;
}
}
// For 32-bits and larger types, slider bounds are limited to half the natural type range.
// So e.g. an integer Slider between INT_MAX-10 and INT_MAX will fail, but an integer Slider between INT_MAX/2-10 and INT_MAX/2.
// It would be possible to life that limitation with some work but it doesn't seem to be work it for sliders.
bool ImGui : : SliderBehavior ( const ImRect & bb , ImGuiID id , ImGuiDataType data_type , void * v , const void * v_min , const void * v_max , const char * format , float power , ImGuiSliderFlags flags )
bool ImGui : : SliderBehavior ( const ImRect & bb , ImGuiID id , ImGuiDataType data_type , void * v , const void * v_min , const void * v_max , const char * format , float power , ImGuiSliderFlags flags )
{
{
switch ( data_type )
switch ( data_type )
@ -8997,8 +9004,7 @@ bool ImGui::SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type
case ImGuiDataType_Double :
case ImGuiDataType_Double :
IM_ASSERT ( * ( const double * ) v_min > = - DBL_MAX / 2.0f & & * ( const double * ) v_max < = DBL_MAX / 2.0f ) ;
IM_ASSERT ( * ( const double * ) v_min > = - DBL_MAX / 2.0f & & * ( const double * ) v_max < = DBL_MAX / 2.0f ) ;
return SliderBehaviorT < double , double , double > ( bb , id , data_type , ( double * ) v , * ( const double * ) v_min , * ( const double * ) v_max , format , power , flags ) ;
return SliderBehaviorT < double , double , double > ( bb , id , data_type , ( double * ) v , * ( const double * ) v_min , * ( const double * ) v_max , format , power , flags ) ;
case ImGuiDataType_COUNT :
case ImGuiDataType_COUNT : break ;
break ;
}
}
IM_ASSERT ( 0 ) ;
IM_ASSERT ( 0 ) ;
return false ;
return false ;