@@ -1148,6 +1148,7 @@ struct ImGuiState
1148
1148
ImGuiID ActiveComboID;
1149
1149
float DragCurrentValue; // current dragged value, always float, not rounded by end-user precision settings
1150
1150
ImVec2 DragLastMouseDelta;
1151
+ float DragSpeedDefaultRatio; // if speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
1151
1152
float DragSpeedScaleSlow;
1152
1153
float DragSpeedScaleFast;
1153
1154
float ScrollbarClickDeltaToGrabCenter; // distance between mouse and center of grab box, normalized in parent space
@@ -1205,6 +1206,7 @@ struct ImGuiState
1205
1206
ActiveComboID = 0;
1206
1207
DragCurrentValue = 0.0f;
1207
1208
DragLastMouseDelta = ImVec2(0.0f, 0.0f);
1209
+ DragSpeedDefaultRatio = 0.01f;
1208
1210
DragSpeedScaleSlow = 0.01f;
1209
1211
DragSpeedScaleFast = 10.0f;
1210
1212
ScrollbarClickDeltaToGrabCenter = 0.0f;
@@ -5536,10 +5538,12 @@ static bool DragScalarBehavior(const ImRect& frame_bb, ImGuiID id, float* v, flo
5536
5538
if (fabsf(mouse_drag_delta.x - g.DragLastMouseDelta.x) > 0.0f)
5537
5539
{
5538
5540
float speed = v_speed;
5541
+ if (speed == 0.0f && (v_max - v_min) != 0.0f && (v_max - v_min) < FLT_MAX)
5542
+ speed = (v_max - v_min) * g.DragSpeedDefaultRatio;
5539
5543
if (g.IO.KeyShift && g.DragSpeedScaleFast >= 0.0f)
5540
- speed = v_speed * g.DragSpeedScaleFast;
5544
+ speed = speed * g.DragSpeedScaleFast;
5541
5545
if (g.IO.KeyAlt && g.DragSpeedScaleSlow >= 0.0f)
5542
- speed = v_speed * g.DragSpeedScaleSlow;
5546
+ speed = speed * g.DragSpeedScaleSlow;
5543
5547
5544
5548
float v_cur = g.DragCurrentValue;
5545
5549
float delta = (mouse_drag_delta.x - g.DragLastMouseDelta.x) * speed;
0 commit comments