@ -93,18 +93,6 @@ static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInpu
static int InputTextCalcTextLenAndLineCount ( const char * text_begin , const char * * out_text_end ) ;
static int InputTextCalcTextLenAndLineCount ( const char * text_begin , const char * * out_text_end ) ;
static ImVec2 InputTextCalcTextSizeW ( const ImWchar * text_begin , const ImWchar * text_end , const ImWchar * * remaining = NULL , ImVec2 * out_offset = NULL , bool stop_on_new_line = false ) ;
static ImVec2 InputTextCalcTextSizeW ( const ImWchar * text_begin , const ImWchar * text_end , const ImWchar * * remaining = NULL , ImVec2 * out_offset = NULL , bool stop_on_new_line = false ) ;
namespace ImGui
{
// Template widget behaviors
template < typename TYPE , typename SIGNEDTYPE , typename FLOATTYPE >
static bool DragBehaviorT ( ImGuiDataType data_type , TYPE * v , float v_speed , const TYPE v_min , const TYPE v_max , const char * format , float power ) ;
template < typename TYPE , typename SIGNEDTYPE , typename FLOATTYPE >
static bool SliderBehaviorT ( const ImRect & bb , ImGuiID id , ImGuiDataType data_type , TYPE * v , const TYPE v_min , const TYPE v_max , const char * format , float power , ImGuiSliderFlags flags , ImRect * out_grab_bb ) ;
}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// WIDGETS: Text
// WIDGETS: Text
// - TextUnformatted()
// - TextUnformatted()
@ -1489,7 +1477,7 @@ static const char* ImAtoi(const char* src, TYPE* output)
}
}
template < typename TYPE , typename SIGNEDTYPE >
template < typename TYPE , typename SIGNEDTYPE >
static inline TYPE RoundScalarWithFormat ( const char * format , ImGuiDataType data_type , TYPE v )
TYPE ImGui : : RoundScalarWithFormat T ( const char * format , ImGuiDataType data_type , TYPE v )
{
{
const char * fmt_start = ImParseFormatFindStart ( format ) ;
const char * fmt_start = ImParseFormatFindStart ( format ) ;
if ( fmt_start [ 0 ] ! = ' % ' | | fmt_start [ 1 ] = = ' % ' ) // Don't apply if the value is not visible in the format string
if ( fmt_start [ 0 ] ! = ' % ' | | fmt_start [ 1 ] = = ' % ' ) // Don't apply if the value is not visible in the format string
@ -1526,7 +1514,7 @@ static inline TYPE RoundScalarWithFormat(const char* format, ImGuiDataType data_
// This is called by DragBehavior() when the widget is active (held by mouse or being manipulated with Nav controls)
// This is called by DragBehavior() when the widget is active (held by mouse or being manipulated with Nav controls)
template < typename TYPE , typename SIGNEDTYPE , typename FLOATTYPE >
template < typename TYPE , typename SIGNEDTYPE , typename FLOATTYPE >
static bool ImGui : : DragBehaviorT ( ImGuiDataType data_type , TYPE * v , float v_speed , const TYPE v_min , const TYPE v_max , const char * format , float power )
bool ImGui : : DragBehaviorT ( ImGuiDataType data_type , TYPE * v , float v_speed , const TYPE v_min , const TYPE v_max , const char * format , float power )
{
{
ImGuiContext & g = * GImGui ;
ImGuiContext & g = * GImGui ;
@ -1589,7 +1577,7 @@ static bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed
}
}
// Round to user desired precision based on format string
// Round to user desired precision based on format string
v_cur = RoundScalarWithFormat < TYPE , SIGNEDTYPE > ( format , data_type , v_cur ) ;
v_cur = RoundScalarWithFormat T < TYPE , SIGNEDTYPE > ( format , data_type , v_cur ) ;
// Preserve remainder after rounding has been applied. This also allow slow tweaking of values.
// Preserve remainder after rounding has been applied. This also allow slow tweaking of values.
g . DragCurrentAccumDirty = false ;
g . DragCurrentAccumDirty = false ;
@ -1864,7 +1852,7 @@ bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
template < typename TYPE , typename FLOATTYPE >
template < typename TYPE , typename FLOATTYPE >
static inline float SliderBehavio rCalcRatioFromValue( ImGuiDataType data_type , TYPE v , TYPE v_min , TYPE v_max , float power , float linear_zero_pos )
float ImGui: : SliderCalcRatioFromValueT ( ImGuiDataType data_type , TYPE v , TYPE v_min , TYPE v_max , float power , float linear_zero_pos )
{
{
if ( v_min = = v_max )
if ( v_min = = v_max )
return 0.0f ;
return 0.0f ;
@ -1891,7 +1879,7 @@ static inline float SliderBehaviorCalcRatioFromValue(ImGuiDataType data_type, TY
// FIXME: Move some of the code into SliderBehavior(). Current responsability is larger than what the equivalent DragBehaviorT<> does, we also do some rendering, etc.
// FIXME: Move some of the code into SliderBehavior(). Current responsability is larger than what the equivalent DragBehaviorT<> does, we also do some rendering, etc.
template < typename TYPE , typename SIGNEDTYPE , typename FLOATTYPE >
template < typename TYPE , typename SIGNEDTYPE , typename FLOATTYPE >
static bool ImGui : : SliderBehaviorT ( const ImRect & bb , ImGuiID id , ImGuiDataType data_type , TYPE * v , const TYPE v_min , const TYPE v_max , const char * format , float power , ImGuiSliderFlags flags , ImRect * out_grab_bb )
bool ImGui : : SliderBehaviorT ( const ImRect & bb , ImGuiID id , ImGuiDataType data_type , TYPE * v , const TYPE v_min , const TYPE v_max , const char * format , float power , ImGuiSliderFlags flags , ImRect * out_grab_bb )
{
{
ImGuiContext & g = * GImGui ;
ImGuiContext & g = * GImGui ;
const ImGuiStyle & style = g . Style ;
const ImGuiStyle & style = g . Style ;
@ -1957,7 +1945,7 @@ static bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType d
}
}
else if ( delta ! = 0.0f )
else if ( delta ! = 0.0f )
{
{
clicked_t = Slider Behavior CalcRatioFromValue< TYPE , FLOATTYPE > ( data_type , * v , v_min , v_max , power , linear_zero_pos ) ;
clicked_t = Slider CalcRatioFromValueT < TYPE , FLOATTYPE > ( data_type , * v , v_min , v_max , power , linear_zero_pos ) ;
const int decimal_precision = is_decimal ? ImParseFormatPrecision ( format , 3 ) : 0 ;
const int decimal_precision = is_decimal ? ImParseFormatPrecision ( format , 3 ) : 0 ;
if ( ( decimal_precision > 0 ) | | is_power )
if ( ( decimal_precision > 0 ) | | is_power )
{
{
@ -2029,7 +2017,7 @@ static bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType d
}
}
// Round to user desired precision based on format string
// Round to user desired precision based on format string
v_new = RoundScalarWithFormat < TYPE , SIGNEDTYPE > ( format , data_type , v_new ) ;
v_new = RoundScalarWithFormat T < TYPE , SIGNEDTYPE > ( format , data_type , v_new ) ;
// Apply result
// Apply result
if ( * v ! = v_new )
if ( * v ! = v_new )
@ -2041,7 +2029,7 @@ static bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType d
}
}
// Output grab position so it can be displayed by the caller
// Output grab position so it can be displayed by the caller
float grab_t = Slider Behavior CalcRatioFromValue< TYPE , FLOATTYPE > ( data_type , * v , v_min , v_max , power , linear_zero_pos ) ;
float grab_t = Slider CalcRatioFromValueT < TYPE , FLOATTYPE > ( data_type , * v , v_min , v_max , power , linear_zero_pos ) ;
if ( ! is_horizontal )
if ( ! is_horizontal )
grab_t = 1.0f - grab_t ;
grab_t = 1.0f - grab_t ;
const float grab_pos = ImLerp ( slider_usable_pos_min , slider_usable_pos_max , grab_t ) ;
const float grab_pos = ImLerp ( slider_usable_pos_min , slider_usable_pos_max , grab_t ) ;