Fix DragScalar for unsigned types (#2780)

decreasing the value was broken on arm64
This commit is contained in:
Bagrat Dabaghyan 2019-09-16 06:03:42 +04:00 committed by omar
parent cc288e073c
commit 3cf519c9cb
2 changed files with 3 additions and 2 deletions

View File

@ -46,6 +46,7 @@ Other Changes:
Individuals tabs are given integer-rounded width and remainder is spread between tabs left-to-right. Individuals tabs are given integer-rounded width and remainder is spread between tabs left-to-right.
- SliderScalar: Improved assert when using U32 or U64 types with a large v_max value. (#2765) [@loicmouton] - SliderScalar: Improved assert when using U32 or U64 types with a large v_max value. (#2765) [@loicmouton]
- DragInt, DragFloat, DragScalar: Using (v_min > v_max) allows locking any edit to the value. - DragInt, DragFloat, DragScalar: Using (v_min > v_max) allows locking any edit to the value.
- DragScalar: Fixed dragging of unsigned values on ARM cpu. (#2780) [@dBagrat]
- ImDrawList: clarified the name of many parameters so reading the code is a little easier. (#2740) - ImDrawList: clarified the name of many parameters so reading the code is a little easier. (#2740)
- Using offsetof() when available in C++11. Avoids Clang sanitizer complaining about old-style macros. (#94) - Using offsetof() when available in C++11. Avoids Clang sanitizer complaining about old-style macros. (#94)
- Added a mechanism to compact/free the larger allocations of unused windows (buffers are compacted when - Added a mechanism to compact/free the larger allocations of unused windows (buffers are compacted when

View File

@ -1975,12 +1975,12 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const
// Offset + round to user desired precision, with a curve on the v_min..v_max range to get more precision on one side of the range // Offset + round to user desired precision, with a curve on the v_min..v_max range to get more precision on one side of the range
FLOATTYPE v_old_norm_curved = ImPow((FLOATTYPE)(v_cur - v_min) / (FLOATTYPE)(v_max - v_min), (FLOATTYPE)1.0f / power); FLOATTYPE v_old_norm_curved = ImPow((FLOATTYPE)(v_cur - v_min) / (FLOATTYPE)(v_max - v_min), (FLOATTYPE)1.0f / power);
FLOATTYPE v_new_norm_curved = v_old_norm_curved + (g.DragCurrentAccum / (v_max - v_min)); FLOATTYPE v_new_norm_curved = v_old_norm_curved + (g.DragCurrentAccum / (v_max - v_min));
v_cur = v_min + (TYPE)ImPow(ImSaturate((float)v_new_norm_curved), power) * (v_max - v_min); v_cur = v_min + (SIGNEDTYPE)ImPow(ImSaturate((float)v_new_norm_curved), power) * (v_max - v_min);
v_old_ref_for_accum_remainder = v_old_norm_curved; v_old_ref_for_accum_remainder = v_old_norm_curved;
} }
else else
{ {
v_cur += (TYPE)g.DragCurrentAccum; v_cur += (SIGNEDTYPE)g.DragCurrentAccum;
} }
// Round to user desired precision based on format string // Round to user desired precision based on format string