@ -2633,7 +2633,7 @@ bool ImGui::InputScalarAsWidgetReplacement(const ImRect& bb, ImGuiID id, const c
return false ;
return false ;
}
}
bool ImGui : : InputScalar ( const char * label , ImGuiDataType data_type , void * data_ptr , const void * step , const void * step_fast , const char * format , ImGuiInputTextFlags extra_ flags)
bool ImGui : : InputScalar ( const char * label , ImGuiDataType data_type , void * data_ptr , const void * step , const void * step_fast , const char * format , ImGuiInputTextFlags flags)
{
{
ImGuiWindow * window = GetCurrentWindow ( ) ;
ImGuiWindow * window = GetCurrentWindow ( ) ;
if ( window - > SkipItems )
if ( window - > SkipItems )
@ -2650,9 +2650,9 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* data_p
DataTypeFormatString ( buf , IM_ARRAYSIZE ( buf ) , data_type , data_ptr , format ) ;
DataTypeFormatString ( buf , IM_ARRAYSIZE ( buf ) , data_type , data_ptr , format ) ;
bool value_changed = false ;
bool value_changed = false ;
if ( ( extra_ flags & ( ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsScientific ) ) = = 0 )
if ( ( flags & ( ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsScientific ) ) = = 0 )
extra_ flags | = ImGuiInputTextFlags_CharsDecimal ;
flags | = ImGuiInputTextFlags_CharsDecimal ;
extra_ flags | = ImGuiInputTextFlags_AutoSelectAll ;
flags | = ImGuiInputTextFlags_AutoSelectAll ;
if ( step ! = NULL )
if ( step ! = NULL )
{
{
@ -2661,13 +2661,13 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* data_p
BeginGroup ( ) ; // The only purpose of the group here is to allow the caller to query item data e.g. IsItemActive()
BeginGroup ( ) ; // The only purpose of the group here is to allow the caller to query item data e.g. IsItemActive()
PushID ( label ) ;
PushID ( label ) ;
PushItemWidth ( ImMax ( 1.0f , CalcItemWidth ( ) - ( button_size + style . ItemInnerSpacing . x ) * 2 ) ) ;
PushItemWidth ( ImMax ( 1.0f , CalcItemWidth ( ) - ( button_size + style . ItemInnerSpacing . x ) * 2 ) ) ;
if ( InputText ( " " , buf , IM_ARRAYSIZE ( buf ) , extra_ flags) ) // PushId(label) + "" gives us the expected ID from outside point of view
if ( InputText ( " " , buf , IM_ARRAYSIZE ( buf ) , flags) ) // PushId(label) + "" gives us the expected ID from outside point of view
value_changed = DataTypeApplyOpFromText ( buf , g . InputTextState . InitialText . Data , data_type , data_ptr , format ) ;
value_changed = DataTypeApplyOpFromText ( buf , g . InputTextState . InitialText . Data , data_type , data_ptr , format ) ;
PopItemWidth ( ) ;
PopItemWidth ( ) ;
// Step buttons
// Step buttons
ImGuiButtonFlags button_flags = ImGuiButtonFlags_Repeat | ImGuiButtonFlags_DontClosePopups ;
ImGuiButtonFlags button_flags = ImGuiButtonFlags_Repeat | ImGuiButtonFlags_DontClosePopups ;
if ( extra_ flags & ImGuiInputTextFlags_ReadOnly )
if ( flags & ImGuiInputTextFlags_ReadOnly )
button_flags | = ImGuiButtonFlags_Disabled ;
button_flags | = ImGuiButtonFlags_Disabled ;
SameLine ( 0 , style . ItemInnerSpacing . x ) ;
SameLine ( 0 , style . ItemInnerSpacing . x ) ;
if ( ButtonEx ( " - " , ImVec2 ( button_size , button_size ) , button_flags ) )
if ( ButtonEx ( " - " , ImVec2 ( button_size , button_size ) , button_flags ) )
@ -2689,14 +2689,14 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* data_p
}
}
else
else
{
{
if ( InputText ( label , buf , IM_ARRAYSIZE ( buf ) , extra_ flags) )
if ( InputText ( label , buf , IM_ARRAYSIZE ( buf ) , flags) )
value_changed = DataTypeApplyOpFromText ( buf , g . InputTextState . InitialText . Data , data_type , data_ptr , format ) ;
value_changed = DataTypeApplyOpFromText ( buf , g . InputTextState . InitialText . Data , data_type , data_ptr , format ) ;
}
}
return value_changed ;
return value_changed ;
}
}
bool ImGui : : InputScalarN ( const char * label , ImGuiDataType data_type , void * v , int components , const void * step , const void * step_fast , const char * format , ImGuiInputTextFlags extra_ flags)
bool ImGui : : InputScalarN ( const char * label , ImGuiDataType data_type , void * v , int components , const void * step , const void * step_fast , const char * format , ImGuiInputTextFlags flags)
{
{
ImGuiWindow * window = GetCurrentWindow ( ) ;
ImGuiWindow * window = GetCurrentWindow ( ) ;
if ( window - > SkipItems )
if ( window - > SkipItems )
@ -2711,7 +2711,7 @@ bool ImGui::InputScalarN(const char* label, ImGuiDataType data_type, void* v, in
for ( int i = 0 ; i < components ; i + + )
for ( int i = 0 ; i < components ; i + + )
{
{
PushID ( i ) ;
PushID ( i ) ;
value_changed | = InputScalar ( " ##v " , data_type , v , step , step_fast , format , extra_ flags) ;
value_changed | = InputScalar ( " ##v " , data_type , v , step , step_fast , format , flags) ;
SameLine ( 0 , g . Style . ItemInnerSpacing . x ) ;
SameLine ( 0 , g . Style . ItemInnerSpacing . x ) ;
PopID ( ) ;
PopID ( ) ;
PopItemWidth ( ) ;
PopItemWidth ( ) ;
@ -2724,88 +2724,88 @@ bool ImGui::InputScalarN(const char* label, ImGuiDataType data_type, void* v, in
return value_changed ;
return value_changed ;
}
}
bool ImGui : : InputFloat ( const char * label , float * v , float step , float step_fast , const char * format , ImGuiInputTextFlags extra_ flags)
bool ImGui : : InputFloat ( const char * label , float * v , float step , float step_fast , const char * format , ImGuiInputTextFlags flags)
{
{
extra_ flags | = ImGuiInputTextFlags_CharsScientific ;
flags | = ImGuiInputTextFlags_CharsScientific ;
return InputScalar ( label , ImGuiDataType_Float , ( void * ) v , ( void * ) ( step > 0.0f ? & step : NULL ) , ( void * ) ( step_fast > 0.0f ? & step_fast : NULL ) , format , extra_ flags) ;
return InputScalar ( label , ImGuiDataType_Float , ( void * ) v , ( void * ) ( step > 0.0f ? & step : NULL ) , ( void * ) ( step_fast > 0.0f ? & step_fast : NULL ) , format , flags) ;
}
}
bool ImGui : : InputFloat2 ( const char * label , float v [ 2 ] , const char * format , ImGuiInputTextFlags extra_ flags)
bool ImGui : : InputFloat2 ( const char * label , float v [ 2 ] , const char * format , ImGuiInputTextFlags flags)
{
{
return InputScalarN ( label , ImGuiDataType_Float , v , 2 , NULL , NULL , format , extra_ flags) ;
return InputScalarN ( label , ImGuiDataType_Float , v , 2 , NULL , NULL , format , flags) ;
}
}
bool ImGui : : InputFloat3 ( const char * label , float v [ 3 ] , const char * format , ImGuiInputTextFlags extra_ flags)
bool ImGui : : InputFloat3 ( const char * label , float v [ 3 ] , const char * format , ImGuiInputTextFlags flags)
{
{
return InputScalarN ( label , ImGuiDataType_Float , v , 3 , NULL , NULL , format , extra_ flags) ;
return InputScalarN ( label , ImGuiDataType_Float , v , 3 , NULL , NULL , format , flags) ;
}
}
bool ImGui : : InputFloat4 ( const char * label , float v [ 4 ] , const char * format , ImGuiInputTextFlags extra_ flags)
bool ImGui : : InputFloat4 ( const char * label , float v [ 4 ] , const char * format , ImGuiInputTextFlags flags)
{
{
return InputScalarN ( label , ImGuiDataType_Float , v , 4 , NULL , NULL , format , extra_ flags) ;
return InputScalarN ( label , ImGuiDataType_Float , v , 4 , NULL , NULL , format , flags) ;
}
}
// Prefer using "const char* format" directly, which is more flexible and consistent with other API.
// Prefer using "const char* format" directly, which is more flexible and consistent with other API.
# ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
# ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
bool ImGui : : InputFloat ( const char * label , float * v , float step , float step_fast , int decimal_precision , ImGuiInputTextFlags extra_ flags)
bool ImGui : : InputFloat ( const char * label , float * v , float step , float step_fast , int decimal_precision , ImGuiInputTextFlags flags)
{
{
char format [ 16 ] = " %f " ;
char format [ 16 ] = " %f " ;
if ( decimal_precision > = 0 )
if ( decimal_precision > = 0 )
ImFormatString ( format , IM_ARRAYSIZE ( format ) , " %%.%df " , decimal_precision ) ;
ImFormatString ( format , IM_ARRAYSIZE ( format ) , " %%.%df " , decimal_precision ) ;
return InputFloat ( label , v , step , step_fast , format , extra_ flags) ;
return InputFloat ( label , v , step , step_fast , format , flags) ;
}
}
bool ImGui : : InputFloat2 ( const char * label , float v [ 2 ] , int decimal_precision , ImGuiInputTextFlags extra_ flags)
bool ImGui : : InputFloat2 ( const char * label , float v [ 2 ] , int decimal_precision , ImGuiInputTextFlags flags)
{
{
char format [ 16 ] = " %f " ;
char format [ 16 ] = " %f " ;
if ( decimal_precision > = 0 )
if ( decimal_precision > = 0 )
ImFormatString ( format , IM_ARRAYSIZE ( format ) , " %%.%df " , decimal_precision ) ;
ImFormatString ( format , IM_ARRAYSIZE ( format ) , " %%.%df " , decimal_precision ) ;
return InputScalarN ( label , ImGuiDataType_Float , v , 2 , NULL , NULL , format , extra_ flags) ;
return InputScalarN ( label , ImGuiDataType_Float , v , 2 , NULL , NULL , format , flags) ;
}
}
bool ImGui : : InputFloat3 ( const char * label , float v [ 3 ] , int decimal_precision , ImGuiInputTextFlags extra_ flags)
bool ImGui : : InputFloat3 ( const char * label , float v [ 3 ] , int decimal_precision , ImGuiInputTextFlags flags)
{
{
char format [ 16 ] = " %f " ;
char format [ 16 ] = " %f " ;
if ( decimal_precision > = 0 )
if ( decimal_precision > = 0 )
ImFormatString ( format , IM_ARRAYSIZE ( format ) , " %%.%df " , decimal_precision ) ;
ImFormatString ( format , IM_ARRAYSIZE ( format ) , " %%.%df " , decimal_precision ) ;
return InputScalarN ( label , ImGuiDataType_Float , v , 3 , NULL , NULL , format , extra_ flags) ;
return InputScalarN ( label , ImGuiDataType_Float , v , 3 , NULL , NULL , format , flags) ;
}
}
bool ImGui : : InputFloat4 ( const char * label , float v [ 4 ] , int decimal_precision , ImGuiInputTextFlags extra_ flags)
bool ImGui : : InputFloat4 ( const char * label , float v [ 4 ] , int decimal_precision , ImGuiInputTextFlags flags)
{
{
char format [ 16 ] = " %f " ;
char format [ 16 ] = " %f " ;
if ( decimal_precision > = 0 )
if ( decimal_precision > = 0 )
ImFormatString ( format , IM_ARRAYSIZE ( format ) , " %%.%df " , decimal_precision ) ;
ImFormatString ( format , IM_ARRAYSIZE ( format ) , " %%.%df " , decimal_precision ) ;
return InputScalarN ( label , ImGuiDataType_Float , v , 4 , NULL , NULL , format , extra_ flags) ;
return InputScalarN ( label , ImGuiDataType_Float , v , 4 , NULL , NULL , format , flags) ;
}
}
# endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS
# endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS
bool ImGui : : InputInt ( const char * label , int * v , int step , int step_fast , ImGuiInputTextFlags extra_ flags)
bool ImGui : : InputInt ( const char * label , int * v , int step , int step_fast , ImGuiInputTextFlags 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.
// 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 * format = ( extra_ flags & ImGuiInputTextFlags_CharsHexadecimal ) ? " %08X " : " %d " ;
const char * format = ( flags & ImGuiInputTextFlags_CharsHexadecimal ) ? " %08X " : " %d " ;
return InputScalar ( label , ImGuiDataType_S32 , ( void * ) v , ( void * ) ( step > 0 ? & step : NULL ) , ( void * ) ( step_fast > 0 ? & step_fast : NULL ) , format , extra_ flags) ;
return InputScalar ( label , ImGuiDataType_S32 , ( void * ) v , ( void * ) ( step > 0 ? & step : NULL ) , ( void * ) ( step_fast > 0 ? & step_fast : NULL ) , format , flags) ;
}
}
bool ImGui : : InputInt2 ( const char * label , int v [ 2 ] , ImGuiInputTextFlags extra_ flags)
bool ImGui : : InputInt2 ( const char * label , int v [ 2 ] , ImGuiInputTextFlags flags)
{
{
return InputScalarN ( label , ImGuiDataType_S32 , v , 2 , NULL , NULL , " %d " , extra_ flags) ;
return InputScalarN ( label , ImGuiDataType_S32 , v , 2 , NULL , NULL , " %d " , flags) ;
}
}
bool ImGui : : InputInt3 ( const char * label , int v [ 3 ] , ImGuiInputTextFlags extra_ flags)
bool ImGui : : InputInt3 ( const char * label , int v [ 3 ] , ImGuiInputTextFlags flags)
{
{
return InputScalarN ( label , ImGuiDataType_S32 , v , 3 , NULL , NULL , " %d " , extra_ flags) ;
return InputScalarN ( label , ImGuiDataType_S32 , v , 3 , NULL , NULL , " %d " , flags) ;
}
}
bool ImGui : : InputInt4 ( const char * label , int v [ 4 ] , ImGuiInputTextFlags extra_ flags)
bool ImGui : : InputInt4 ( const char * label , int v [ 4 ] , ImGuiInputTextFlags flags)
{
{
return InputScalarN ( label , ImGuiDataType_S32 , v , 4 , NULL , NULL , " %d " , extra_ flags) ;
return InputScalarN ( label , ImGuiDataType_S32 , v , 4 , NULL , NULL , " %d " , flags) ;
}
}
bool ImGui : : InputDouble ( const char * label , double * v , double step , double step_fast , const char * format , ImGuiInputTextFlags extra_ flags)
bool ImGui : : InputDouble ( const char * label , double * v , double step , double step_fast , const char * format , ImGuiInputTextFlags flags)
{
{
extra_ flags | = ImGuiInputTextFlags_CharsScientific ;
flags | = ImGuiInputTextFlags_CharsScientific ;
return InputScalar ( label , ImGuiDataType_Double , ( void * ) v , ( void * ) ( step > 0.0 ? & step : NULL ) , ( void * ) ( step_fast > 0.0 ? & step_fast : NULL ) , format , extra_ flags) ;
return InputScalar ( label , ImGuiDataType_Double , ( void * ) v , ( void * ) ( step > 0.0 ? & step : NULL ) , ( void * ) ( step_fast > 0.0 ? & step_fast : NULL ) , format , flags) ;
}
}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------