@ -2143,9 +2143,9 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const
{
ImGuiContext & g = * GImGui ;
const ImGuiAxis axis = ( flags & ImGuiSliderFlags_Vertical ) ? ImGuiAxis_Y : ImGuiAxis_X ;
const bool is_decimal = ( data_type = = ImGuiDataType_Float ) | | ( data_type = = ImGuiDataType_Double ) ;
const bool is_clamped = ( v_min < v_max ) ;
const bool is_logarithmic = ( flags & ImGuiSliderFlags_Logarithmic ) & & is_decimal ;
const bool is_logarithmic = ( flags & ImGuiSliderFlags_Logarithmic ) ! = 0 ;
const bool is_floating_point = ( data_type = = ImGuiDataType_Float ) | | ( data_type = = ImGuiDataType_Double ) ;
// Default tweak speed
if ( v_speed = = 0.0f & & is_clamped & & ( v_max - v_min < FLT_MAX ) )
@ -2163,7 +2163,7 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const
}
else if ( g . ActiveIdSource = = ImGuiInputSource_Nav )
{
int decimal_precision = is_ decimal ? ImParseFormatPrecision ( format , 3 ) : 0 ;
const int decimal_precision = is_ floating_point ? ImParseFormatPrecision ( format , 3 ) : 0 ;
adjust_delta = GetNavInputAmount2d ( ImGuiNavDirSourceFlags_Keyboard | ImGuiNavDirSourceFlags_PadDPad , ImGuiInputReadMode_RepeatFast , 1.0f / 10.0f , 10.0f ) [ axis ] ;
v_speed = ImMax ( v_speed , GetMinimumStepAtDecimalPrecision ( decimal_precision ) ) ;
}
@ -2203,7 +2203,7 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const
if ( is_logarithmic )
{
// When using logarithmic sliders, we need to clamp to avoid hitting zero, but our choice of clamp value greatly affects slider precision. We attempt to use the specified precision to estimate a good lower bound.
const int decimal_precision = is_ decimal ? ImParseFormatPrecision ( format , 3 ) : 1 ;
const int decimal_precision = is_ floating_point ? ImParseFormatPrecision ( format , 3 ) : 1 ;
logarithmic_zero_epsilon = ImPow ( 0.1f , ( float ) decimal_precision ) ;
// Convert to parametric space, apply delta, convert back
@ -2241,9 +2241,9 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const
// Clamp values (+ handle overflow/wrap-around for integer types)
if ( * v ! = v_cur & & is_clamped )
{
if ( v_cur < v_min | | ( v_cur > * v & & adjust_delta < 0.0f & & ! is_ decimal ) )
if ( v_cur < v_min | | ( v_cur > * v & & adjust_delta < 0.0f & & ! is_ floating_point ) )
v_cur = v_min ;
if ( v_cur > v_max | | ( v_cur < * v & & adjust_delta > 0.0f & & ! is_ decimal ) )
if ( v_cur > v_max | | ( v_cur < * v & & adjust_delta > 0.0f & & ! is_ floating_point ) )
v_cur = v_max ;
}
@ -2634,7 +2634,7 @@ TYPE ImGui::ScaleValueFromRatioT(ImGuiDataType data_type, float t, TYPE v_min, T
{
if ( v_min = = v_max )
return v_min ;
const bool is_ decimal = ( data_type = = ImGuiDataType_Float ) | | ( data_type = = ImGuiDataType_Double ) ;
const bool is_ floating_point = ( data_type = = ImGuiDataType_Float ) | | ( data_type = = ImGuiDataType_Double ) ;
TYPE result ;
if ( is_logarithmic )
@ -2682,7 +2682,7 @@ TYPE ImGui::ScaleValueFromRatioT(ImGuiDataType data_type, float t, TYPE v_min, T
else
{
// Linear slider
if ( is_ decimal )
if ( is_ floating_point )
{
result = ImLerp ( v_min , v_max , t ) ;
}
@ -2715,14 +2715,14 @@ bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_typ
const ImGuiStyle & style = g . Style ;
const ImGuiAxis axis = ( flags & ImGuiSliderFlags_Vertical ) ? ImGuiAxis_Y : ImGuiAxis_X ;
const bool is_ decimal = ( data_type = = ImGuiDataType_Float ) | | ( data_type = = ImGuiDataType_Double ) ;
const bool is_ logarithmic = ( flags & ImGuiSliderFlags_Logarithmic ) & & is_decimal ;
const bool is_ logarithmic = ( flags & ImGuiSliderFlags_Logarithmic ) ! = 0 ;
const bool is_ floating_point = ( data_type = = ImGuiDataType_Float ) | | ( data_type = = ImGuiDataType_Double ) ;
const float grab_padding = 2.0f ;
const float slider_sz = ( bb . Max [ axis ] - bb . Min [ axis ] ) - grab_padding * 2.0f ;
float grab_sz = style . GrabMinSize ;
SIGNEDTYPE v_range = ( v_min < v_max ? v_max - v_min : v_min - v_max ) ;
if ( ! is_ decimal & & v_range > = 0 ) // v_range < 0 may happen on integer overflows
if ( ! is_ floating_point & & v_range > = 0 ) // v_range < 0 may happen on integer overflows
grab_sz = ImMax ( ( float ) ( slider_sz / ( v_range + 1 ) ) , style . GrabMinSize ) ; // For integer sliders: if possible have the grab size represent 1 unit
grab_sz = ImMin ( grab_sz , slider_sz ) ;
const float slider_usable_sz = slider_sz - grab_sz ;
@ -2734,7 +2734,7 @@ bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_typ
if ( is_logarithmic )
{
// When using logarithmic sliders, we need to clamp to avoid hitting zero, but our choice of clamp value greatly affects slider precision. We attempt to use the specified precision to estimate a good lower bound.
const int decimal_precision = is_ decimal ? ImParseFormatPrecision ( format , 3 ) : 1 ;
const int decimal_precision = is_ floating_point ? ImParseFormatPrecision ( format , 3 ) : 1 ;
logarithmic_zero_epsilon = ImPow ( 0.1f , ( float ) decimal_precision ) ;
zero_deadzone_halfsize = ( style . LogSliderDeadzone * 0.5f ) / ImMax ( slider_usable_sz , 1.0f ) ;
}
@ -2772,7 +2772,7 @@ bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_typ
float input_delta = ( axis = = ImGuiAxis_X ) ? input_delta2 . x : - input_delta2 . y ;
if ( input_delta ! = 0.0f )
{
const int decimal_precision = is_ decimal ? ImParseFormatPrecision ( format , 3 ) : 0 ;
const int decimal_precision = is_ floating_point ? ImParseFormatPrecision ( format , 3 ) : 0 ;
if ( decimal_precision > 0 )
{
input_delta / = 100.0f ; // Gamepad/keyboard tweak speeds in % of slider bounds