@@ -873,10 +873,9 @@ ImGuiIO::ImGuiIO()
873
873
MousePos = ImVec2 (-1 ,-1 );
874
874
MousePosPrev = ImVec2 (-1 ,-1 );
875
875
MouseDragThreshold = 6 .0f ;
876
- for (int i = 0 ; i < IM_ARRAYSIZE (MouseDownDuration); i++)
877
- MouseDownDuration[i] = MouseDownDurationPrev[i] = -1 .0f ;
878
- for (int i = 0 ; i < IM_ARRAYSIZE (KeysDownDuration); i++)
879
- KeysDownDuration[i] = KeysDownDurationPrev[i] = -1 .0f ;
876
+ for (int i = 0 ; i < IM_ARRAYSIZE (MouseDownDuration); i++) MouseDownDuration[i] = MouseDownDurationPrev[i] = -1 .0f ;
877
+ for (int i = 0 ; i < IM_ARRAYSIZE (KeysDownDuration); i++) KeysDownDuration[i] = KeysDownDurationPrev[i] = -1 .0f ;
878
+ for (int i = 0 ; i < IM_ARRAYSIZE (NavInputsDownDuration); i++) NavInputsDownDuration[i] = -1 .0f ;
880
879
881
880
// Set OS X style defaults based on __APPLE__ compile time flag
882
881
#ifdef __APPLE__
@@ -2378,6 +2377,60 @@ static ImGuiWindow* FindWindowNavigable(int i_start, int i_stop, int dir) // FIX
2378
2377
return NULL ;
2379
2378
}
2380
2379
2380
+ enum ImGuiNavReadMode
2381
+ {
2382
+ ImGuiNavReadMode_Down,
2383
+ ImGuiNavReadMode_Pressed,
2384
+ ImGuiNavReadMode_Repeat,
2385
+ ImGuiNavReadMode_RepeatSlow,
2386
+ ImGuiNavReadMode_RepeatFast
2387
+ };
2388
+
2389
+ // FIXME-NAVIGATION: Expose navigation repeat delay/rate
2390
+ static float GetNavInputAmount (ImGuiNavInput n, ImGuiNavReadMode mode)
2391
+ {
2392
+ ImGuiContext& g = *GImGui;
2393
+ if (mode == ImGuiNavReadMode_Down)
2394
+ return g.IO .NavInputs [n]; // Instant, read analog input (0.0f..1.0f, as provided by user)
2395
+ const float t = g.IO .NavInputsDownDuration [n]; // Duration pressed
2396
+ if (mode == ImGuiNavReadMode_Pressed) // Return 1.0f when just pressed, no repeat, ignore analog input (we don't need it for Pressed logic)
2397
+ return (t == 0 .0f ) ? 1 .0f : 0 .0f ;
2398
+ if (mode == ImGuiNavReadMode_Repeat)
2399
+ return (float )ImGui::CalcTypematicPressedRepeatAmount (t, t - g.IO .DeltaTime , g.IO .KeyRepeatDelay * 0 .80f , g.IO .KeyRepeatRate * 0 .80f );
2400
+ if (mode == ImGuiNavReadMode_RepeatSlow)
2401
+ return (float )ImGui::CalcTypematicPressedRepeatAmount (t, t - g.IO .DeltaTime , g.IO .KeyRepeatDelay * 1 .00f , g.IO .KeyRepeatRate * 2 .00f );
2402
+ if (mode == ImGuiNavReadMode_RepeatFast)
2403
+ return (float )ImGui::CalcTypematicPressedRepeatAmount (t, t - g.IO .DeltaTime , g.IO .KeyRepeatDelay * 0 .80f , g.IO .KeyRepeatRate * 0 .30f );
2404
+ return 0 .0f ;
2405
+ }
2406
+
2407
+ // Equivalent of IsKeyDown() for NavInputs[]
2408
+ static bool IsNavInputDown (ImGuiNavInput n)
2409
+ {
2410
+ return GImGui->IO .NavInputs [n] > 0 .0f ;
2411
+ }
2412
+
2413
+ // Equivalent of IsKeyPressed() for NavInputs[]
2414
+ static bool IsNavInputPressed (ImGuiNavInput n, ImGuiNavReadMode mode)// = ImGuiNavReadMode_Re)
2415
+ {
2416
+ return GetNavInputAmount (n, mode) > 0 .0f ;
2417
+ }
2418
+
2419
+ static ImVec2 GetNavInputAmount2d (int stick_no, ImGuiNavReadMode mode, float slow_factor = 0 .0f , float fast_factor = 0 .0f )
2420
+ {
2421
+ IM_ASSERT (ImGuiNavInput_PadScrollUp == ImGuiNavInput_PadUp + 4 );
2422
+ IM_ASSERT (stick_no >= 0 && stick_no < 2 );
2423
+
2424
+ ImVec2 delta;
2425
+ delta.x = GetNavInputAmount (ImGuiNavInput_PadRight + stick_no*4 , mode) - GetNavInputAmount (ImGuiNavInput_PadLeft + stick_no*4 , mode);
2426
+ delta.y = GetNavInputAmount (ImGuiNavInput_PadDown + stick_no*4 , mode) - GetNavInputAmount (ImGuiNavInput_PadUp + stick_no*4 , mode);
2427
+ if (slow_factor != 0 .0f && IsNavInputDown (ImGuiNavInput_PadTweakSlow))
2428
+ delta *= slow_factor;
2429
+ if (fast_factor != 0 .0f && IsNavInputDown (ImGuiNavInput_PadTweakFast))
2430
+ delta *= fast_factor;
2431
+ return delta;
2432
+ }
2433
+
2381
2434
static void NavUpdate ()
2382
2435
{
2383
2436
ImGuiContext& g = *GImGui;
@@ -2452,7 +2505,7 @@ static void NavUpdate()
2452
2505
}
2453
2506
2454
2507
// Navigation windowing mode (change focus, move/resize window)
2455
- if (!g.NavWindowingTarget && IsKeyPressedMap (ImGuiKey_NavMenu, false ))
2508
+ if (!g.NavWindowingTarget && IsNavInputPressed (ImGuiNavInput_PadMenu, ImGuiNavReadMode_Pressed ))
2456
2509
{
2457
2510
ImGuiWindow* window = g.NavWindow ;
2458
2511
if (!window)
@@ -2467,13 +2520,13 @@ static void NavUpdate()
2467
2520
if (g.NavWindowingTarget )
2468
2521
{
2469
2522
// Visuals only appears after a brief time holding the button, so that a fast tap (to toggle NavLayer) doesn't add visual noise
2470
- const float pressed_duration = g.IO .KeysDownDuration [g. IO . KeyMap [ImGuiKey_NavMenu] ];
2523
+ const float pressed_duration = g.IO .NavInputsDownDuration [ImGuiNavInput_PadMenu ];
2471
2524
g.NavWindowingDisplayAlpha = ImMax (g.NavWindowingDisplayAlpha , ImSaturate ((pressed_duration - 0 .20f ) / 0 .05f ));
2472
2525
g.NavWindowingToggleLayer &= (g.NavWindowingDisplayAlpha < 1 .0f ); // Once button is held long enough we don't consider it a tag-to-toggle-layer press anymore.
2473
2526
2474
2527
// Select window to focus
2475
2528
// FIXME-NAVIGATION: Need to clarify input semantic, naming is misleading/incorrect here.
2476
- int focus_change_dir = IsKeyPressedMap (ImGuiKey_NavTweakFaster, true ) ? - 1 : IsKeyPressedMap (ImGuiKey_NavTweakSlower, true ) ? + 1 : 0 ;
2529
+ const int focus_change_dir = ( int ) IsNavInputPressed (ImGuiNavInput_PadFocusPrev, ImGuiNavReadMode_RepeatSlow) - ( int ) IsNavInputPressed (ImGuiNavInput_PadFocusNext, ImGuiNavReadMode_RepeatSlow) ;
2477
2530
if (focus_change_dir != 0 && !(g.NavWindowingTarget ->Flags & ImGuiWindowFlags_Modal))
2478
2531
{
2479
2532
const int i_current = FindWindowIndex (g.NavWindowingTarget );
@@ -2488,7 +2541,7 @@ static void NavUpdate()
2488
2541
// Move window
2489
2542
if (g.NavWindowingTarget && !(g.NavWindowingTarget ->Flags & ImGuiWindowFlags_NoMove))
2490
2543
{
2491
- const ImVec2 move_delta = ImGui::NavGetMovingDir ( 1 );
2544
+ const ImVec2 move_delta = GetNavInputAmount2d ( 1 , ImGuiNavReadMode_Down );
2492
2545
if (move_delta.x != 0 .0f || move_delta.y != 0 .0f )
2493
2546
{
2494
2547
const float move_speed = ImFloor (600 * g.IO .DeltaTime * ImMin (g.IO .DisplayFramebufferScale .x , g.IO .DisplayFramebufferScale .y ));
@@ -2498,7 +2551,7 @@ static void NavUpdate()
2498
2551
}
2499
2552
}
2500
2553
2501
- if (!IsKeyDownMap (ImGuiKey_NavMenu ))
2554
+ if (!IsNavInputDown (ImGuiNavInput_PadMenu ))
2502
2555
{
2503
2556
// Apply actual focus only when releasing the NavMenu button (until then the window was merely rendered front-most)
2504
2557
if (g.NavWindowingTarget && !g.NavWindowingToggleLayer && (!g.NavWindow || g.NavWindowingTarget != g.NavWindow ->RootNonPopupWindow ))
@@ -2532,7 +2585,7 @@ static void NavUpdate()
2532
2585
g.IO .NavActive = (g.IO .NavUsable && g.NavId != 0 && !g.NavDisableHighlight ) || (g.NavWindowingTarget != NULL ) || g.NavInitDefaultRequest ;
2533
2586
2534
2587
// Process NavCancel input (to close a popup, get back to parent, clear focus)
2535
- if (IsKeyPressedMap (ImGuiKey_NavCancel ))
2588
+ if (IsNavInputPressed (ImGuiNavInput_PadCancel, ImGuiNavReadMode_Pressed ))
2536
2589
{
2537
2590
if (g.ActiveId != 0 )
2538
2591
{
@@ -2577,8 +2630,8 @@ static void NavUpdate()
2577
2630
}
2578
2631
}
2579
2632
2580
- g.NavActivateId = (g.NavId && !g.NavDisableHighlight && !g.NavWindowingTarget && g.ActiveId == 0 && IsKeyPressedMap (ImGuiKey_NavActivate )) ? g.NavId : 0 ;
2581
- g.NavInputId = (g.NavId && !g.NavDisableHighlight && !g.NavWindowingTarget && g.ActiveId == 0 && IsKeyPressedMap (ImGuiKey_NavInput )) ? g.NavId : 0 ;
2633
+ g.NavActivateId = (g.NavId && !g.NavDisableHighlight && !g.NavWindowingTarget && g.ActiveId == 0 && IsNavInputPressed (ImGuiNavInput_PadActivate, ImGuiNavReadMode_Repeat )) ? g.NavId : 0 ;
2634
+ g.NavInputId = (g.NavId && !g.NavDisableHighlight && !g.NavWindowingTarget && g.ActiveId == 0 && IsNavInputPressed (ImGuiNavInput_PadInput, ImGuiNavReadMode_Repeat )) ? g.NavId : 0 ;
2582
2635
if (g.NavWindow && (g.NavWindow ->Flags & ImGuiWindowFlags_NoNavInputs))
2583
2636
{
2584
2637
g.NavActivateId = g.NavInputId = 0 ;
@@ -2591,10 +2644,10 @@ static void NavUpdate()
2591
2644
g.NavMoveDir = ImGuiNavDir_None;
2592
2645
if (g.NavWindow && !g.NavWindowingTarget && allowed_dir_flags && !(g.NavWindow ->Flags & ImGuiWindowFlags_NoNavInputs))
2593
2646
{
2594
- if ((allowed_dir_flags & (1 <<ImGuiNavDir_Left)) && IsKeyPressedMap (ImGuiKey_NavLeft , true )) g.NavMoveDir = ImGuiNavDir_Left;
2595
- if ((allowed_dir_flags & (1 <<ImGuiNavDir_Right)) && IsKeyPressedMap (ImGuiKey_NavRight, true )) g.NavMoveDir = ImGuiNavDir_Right;
2596
- if ((allowed_dir_flags & (1 <<ImGuiNavDir_Up)) && IsKeyPressedMap (ImGuiKey_NavUp , true )) g.NavMoveDir = ImGuiNavDir_Up;
2597
- if ((allowed_dir_flags & (1 <<ImGuiNavDir_Down)) && IsKeyPressedMap (ImGuiKey_NavDown , true )) g.NavMoveDir = ImGuiNavDir_Down;
2647
+ if ((allowed_dir_flags & (1 <<ImGuiNavDir_Left)) && IsNavInputPressed (ImGuiNavInput_PadLeft , ImGuiNavReadMode_Repeat )) g.NavMoveDir = ImGuiNavDir_Left;
2648
+ if ((allowed_dir_flags & (1 <<ImGuiNavDir_Right)) && IsNavInputPressed (ImGuiNavInput_PadRight, ImGuiNavReadMode_Repeat )) g.NavMoveDir = ImGuiNavDir_Right;
2649
+ if ((allowed_dir_flags & (1 <<ImGuiNavDir_Up)) && IsNavInputPressed (ImGuiNavInput_PadUp , ImGuiNavReadMode_Repeat )) g.NavMoveDir = ImGuiNavDir_Up;
2650
+ if ((allowed_dir_flags & (1 <<ImGuiNavDir_Down)) && IsNavInputPressed (ImGuiNavInput_PadDown , ImGuiNavReadMode_Repeat )) g.NavMoveDir = ImGuiNavDir_Down;
2598
2651
}
2599
2652
if (g.NavMoveDir != ImGuiNavDir_None)
2600
2653
g.NavMoveRequest = true ;
@@ -2608,7 +2661,7 @@ static void NavUpdate()
2608
2661
SetWindowScrollY (g.NavWindow , ImFloor (g.NavWindow ->Scroll .y + ((g.NavMoveDir == ImGuiNavDir_Up) ? -1 .0f : +1 .0f ) * scroll_speed));
2609
2662
2610
2663
// Manual scroll with NavScrollXXX keys
2611
- ImVec2 scroll_dir = ImGui::NavGetMovingDir ( 1 , 1 .0f /10 .0f , 10 .0f );
2664
+ ImVec2 scroll_dir = GetNavInputAmount2d ( 1 , ImGuiNavReadMode_Down , 1 .0f /10 .0f , 10 .0f );
2612
2665
if (scroll_dir.x != 0 .0f && g.NavWindow ->ScrollbarX )
2613
2666
{
2614
2667
SetWindowScrollX (g.NavWindow , ImFloor (g.NavWindow ->Scroll .x + scroll_dir.x * scroll_speed));
@@ -2695,6 +2748,9 @@ void ImGui::NewFrame()
2695
2748
memcpy (g.IO .KeysDownDurationPrev , g.IO .KeysDownDuration , sizeof (g.IO .KeysDownDuration ));
2696
2749
for (int i = 0 ; i < IM_ARRAYSIZE (g.IO .KeysDown ); i++)
2697
2750
g.IO .KeysDownDuration [i] = g.IO .KeysDown [i] ? (g.IO .KeysDownDuration [i] < 0 .0f ? 0 .0f : g.IO .KeysDownDuration [i] + g.IO .DeltaTime ) : -1 .0f ;
2751
+ memcpy (g.IO .NavInputsPrev , g.IO .NavInputs , sizeof (g.IO .NavInputs ));
2752
+ for (int i = 0 ; i < IM_ARRAYSIZE (g.IO .NavInputs ); i++)
2753
+ g.IO .NavInputsDownDuration [i] = (g.IO .NavInputs [i] > 0 .0f ) ? (g.IO .NavInputsDownDuration [i] < 0 .0f ? 0 .0f : g.IO .NavInputsDownDuration [i] + g.IO .DeltaTime ) : -1 .0f ;
2698
2754
2699
2755
// Update directional navigation which may override MousePos if 'NavMovesMouse=true'
2700
2756
NavUpdate ();
@@ -3708,20 +3764,23 @@ bool ImGui::IsKeyDown(int key_index)
3708
3764
return GImGui->IO .KeysDown [key_index];
3709
3765
}
3710
3766
3767
+ int ImGui::CalcTypematicPressedRepeatAmount (float t, float t_prev, float repeat_delay, float repeat_rate)
3768
+ {
3769
+ if (t == 0 .0f )
3770
+ return 1 ;
3771
+ if (t <= repeat_delay || repeat_rate <= 0 .0f )
3772
+ return 0 ;
3773
+ const int count = (int )((t - repeat_delay) / repeat_rate) - (int )((t_prev - repeat_delay) / repeat_rate);
3774
+ return (count > 0 ) ? count : 0 ;
3775
+ }
3776
+
3711
3777
int ImGui::GetKeyPressedAmount (int key_index, float repeat_delay, float repeat_rate)
3712
3778
{
3713
3779
ImGuiContext& g = *GImGui;
3714
3780
if (key_index < 0 ) return false ;
3715
3781
IM_ASSERT (key_index >= 0 && key_index < IM_ARRAYSIZE (g.IO .KeysDown ));
3716
3782
const float t = g.IO .KeysDownDuration [key_index];
3717
- if (t == 0 .0f )
3718
- return 1 ;
3719
- if (t > repeat_delay && repeat_rate > 0 .0f )
3720
- {
3721
- int count = (int )((t - repeat_delay) / repeat_rate) - (int )((t - repeat_delay - g.IO .DeltaTime ) / repeat_rate);
3722
- return (count > 0 ) ? count : 0 ;
3723
- }
3724
- return 0 ;
3783
+ return CalcTypematicPressedRepeatAmount (t, t - g.IO .DeltaTime , repeat_delay, repeat_rate);
3725
3784
}
3726
3785
3727
3786
bool ImGui::IsKeyPressed (int key_index, bool repeat)
@@ -4823,9 +4882,13 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
4823
4882
ImVec2 nav_resize_delta (0 .0f , 0 .0f );
4824
4883
if (g.NavWindowingTarget == window)
4825
4884
{
4826
- const float resize_speed = ImFloor (600 * g.IO .DeltaTime * ImMin (g.IO .DisplayFramebufferScale .x , g.IO .DisplayFramebufferScale .y ));
4827
- nav_resize_delta = NavGetMovingDir (0 ) * resize_speed;
4828
- held |= (nav_resize_delta.x != 0 .0f || nav_resize_delta.y != 0 .0f ); // For coloring
4885
+ nav_resize_delta = GetNavInputAmount2d (0 , ImGuiNavReadMode_Down);
4886
+ if (nav_resize_delta.x != 0 .0f || nav_resize_delta.y != 0 .0f )
4887
+ {
4888
+ nav_resize_delta *= ImFloor (600 * g.IO .DeltaTime * ImMin (g.IO .DisplayFramebufferScale .x , g.IO .DisplayFramebufferScale .y ));
4889
+ g.NavDisableMouseHover = true ;
4890
+ held = true ; // For coloring
4891
+ }
4829
4892
}
4830
4893
4831
4894
ImVec2 size_target (FLT_MAX,FLT_MAX);
@@ -6267,13 +6330,13 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
6267
6330
{
6268
6331
// We report navigated item as hovered but we don't set g.HoveredId to not interfere with mouse
6269
6332
hovered = true ;
6270
- if (!g.NavWindowingTarget && IsKeyDownMap (ImGuiKey_NavActivate ))
6333
+ if (!g.NavWindowingTarget && IsNavInputDown (ImGuiNavInput_PadActivate ))
6271
6334
{
6272
6335
// Set active id so it can be queried by user via IsItemActive(), etc. but don't react to it ourselves
6273
- g.NavActivateId = g. NavId ;
6274
- SetActiveID (g. NavId , window);
6336
+ g.NavActivateId = id ;
6337
+ SetActiveID (id , window);
6275
6338
g.ActiveIdAllowNavDirFlags = (1 << ImGuiNavDir_Left) | (1 << ImGuiNavDir_Right) | (1 << ImGuiNavDir_Up) | (1 << ImGuiNavDir_Down);
6276
- if (IsKeyPressedMap (ImGuiKey_NavActivate , (flags & ImGuiButtonFlags_Repeat) != 0 ))
6339
+ if (IsNavInputPressed (ImGuiNavInput_PadActivate , (flags & ImGuiButtonFlags_Repeat) ? ImGuiNavReadMode_Repeat : ImGuiNavReadMode_Pressed ))
6277
6340
pressed = true ;
6278
6341
}
6279
6342
}
@@ -6296,7 +6359,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
6296
6359
g.NavDisableHighlight = true ;
6297
6360
}
6298
6361
if (g.ActiveId == id && g.ActiveIdSource == ImGuiInputSource_Nav)
6299
- if (!IsKeyDownMap (ImGuiKey_NavActivate ))
6362
+ if (!IsNavInputDown (ImGuiNavInput_PadActivate ))
6300
6363
SetActiveID (0 );
6301
6364
6302
6365
// AllowOverlap mode (rarely used) requires previous frame HoveredId to be null or to match. This allows using patterns where a later submitted widget overlaps a previous one.
@@ -7136,47 +7199,6 @@ int ImGui::ParseFormatPrecision(const char* fmt, int default_precision)
7136
7199
return precision;
7137
7200
}
7138
7201
7139
- ImVec2 ImGui::NavGetMovingDir (int stick_no, float slow_factor, float fast_factor)
7140
- {
7141
- IM_ASSERT (stick_no >= 0 && stick_no < 2 );
7142
- ImVec2 dir (0 .0f , 0 .0f );
7143
- if (stick_no == 0 )
7144
- {
7145
- if (IsKeyDownMap (ImGuiKey_NavLeft)) dir.x -= 1 .0f ;
7146
- if (IsKeyDownMap (ImGuiKey_NavRight)) dir.x += 1 .0f ;
7147
- if (IsKeyDownMap (ImGuiKey_NavUp)) dir.y -= 1 .0f ;
7148
- if (IsKeyDownMap (ImGuiKey_NavDown)) dir.y += 1 .0f ;
7149
- }
7150
- if (stick_no == 1 )
7151
- {
7152
- if (IsKeyDownMap (ImGuiKey_NavScrollLeft)) dir.x -= 1 .0f ;
7153
- if (IsKeyDownMap (ImGuiKey_NavScrollRight)) dir.x += 1 .0f ;
7154
- if (IsKeyDownMap (ImGuiKey_NavScrollUp)) dir.y -= 1 .0f ;
7155
- if (IsKeyDownMap (ImGuiKey_NavScrollDown)) dir.y += 1 .0f ;
7156
- }
7157
- if (slow_factor != 0 .0f && IsKeyDownMap (ImGuiKey_NavTweakSlower))
7158
- dir *= slow_factor;
7159
- if (fast_factor != 0 .0f && IsKeyDownMap (ImGuiKey_NavTweakFaster))
7160
- dir *= fast_factor;
7161
- return dir;
7162
- }
7163
-
7164
- // Adjustment delta for slider/drag/etc.
7165
- // FIXME-NAVIGATION: Accelerate over time? Expose more settings? Handle faster/slower modifiers here instead of widget level?
7166
- ImVec2 ImGui::NavGetTweakDelta ()
7167
- {
7168
- ImGuiContext& g = *GImGui;
7169
- float repeat_delay = g.IO .KeyRepeatDelay * 0 .80f ;
7170
- float repeat_rate = g.IO .KeyRepeatRate * 0 .30f ;
7171
-
7172
- ImVec2 delta (0 .0f , 0 .0f );
7173
- if (int count = GetKeyPressedAmount (g.IO .KeyMap [ImGuiKey_NavLeft], repeat_delay, repeat_rate)) delta.x = (float )-count;
7174
- if (int count = GetKeyPressedAmount (g.IO .KeyMap [ImGuiKey_NavRight], repeat_delay, repeat_rate)) delta.x = (float )+count;
7175
- if (int count = GetKeyPressedAmount (g.IO .KeyMap [ImGuiKey_NavUp], repeat_delay, repeat_rate)) delta.y = (float )-count;
7176
- if (int count = GetKeyPressedAmount (g.IO .KeyMap [ImGuiKey_NavDown], repeat_delay, repeat_rate)) delta.y = (float )+count;
7177
- return delta;
7178
- }
7179
-
7180
7202
static float GetMinimumStepAtDecimalPrecision (int decimal_precision)
7181
7203
{
7182
7204
static const float min_steps[10 ] = { 1 .0f , 0 .1f , 0 .01f , 0 .001f , 0 .0001f , 0 .00001f , 0 .000001f , 0 .0000001f , 0 .00000001f , 0 .000000001f };
@@ -7275,26 +7297,26 @@ bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v
7275
7297
normalized_pos = 1 .0f - normalized_pos;
7276
7298
set_new_value = true ;
7277
7299
}
7278
- else if (g.ActiveIdSource == ImGuiInputSource_Nav && IsKeyDownMap (ImGuiKey_NavActivate ))
7300
+ else if (g.ActiveIdSource == ImGuiInputSource_Nav && IsNavInputDown (ImGuiNavInput_PadActivate ))
7279
7301
{
7280
- const ImVec2 delta2 = NavGetTweakDelta ( );
7302
+ const ImVec2 delta2 = GetNavInputAmount2d ( 0 , ImGuiNavReadMode_RepeatFast, 0 . 0f , 0 . 0f );
7281
7303
if (float delta = is_horizontal ? delta2.x : -delta2.y )
7282
7304
{
7283
7305
normalized_pos = SliderBehaviorCalcRatioFromValue (*v, v_min, v_max, power, linear_zero_pos);
7284
7306
if (decimal_precision == 0 && !is_non_linear)
7285
7307
{
7286
- if (fabsf (v_max - v_min) <= 100 .0f || IsKeyDownMap (ImGuiKey_NavTweakSlower ))
7308
+ if (fabsf (v_max - v_min) <= 100 .0f || IsNavInputDown (ImGuiNavInput_PadTweakSlow ))
7287
7309
delta = ((delta < 0 .0f ) ? -1 .0f : +1 .0f ) / (v_max - v_min); // Gamepad/keyboard tweak speeds in integer steps
7288
7310
else
7289
7311
delta /= 100 .0f ;
7290
7312
}
7291
7313
else
7292
7314
{
7293
7315
delta /= 100 .0f ; // Gamepad/keyboard tweak speeds in % of slider bounds
7294
- if (IsKeyDownMap (ImGuiKey_NavTweakSlower ))
7316
+ if (IsNavInputDown (ImGuiNavInput_PadTweakSlow ))
7295
7317
delta /= 10 .0f ;
7296
7318
}
7297
- if (IsKeyDownMap (ImGuiKey_NavTweakFaster ))
7319
+ if (IsNavInputDown (ImGuiNavInput_PadTweakFast ))
7298
7320
delta *= 10 .0f ;
7299
7321
normalized_pos = ImSaturate (normalized_pos + delta); // FIXME-NAVIGATION: todo: cancel adjustment if current value already past edge and we are moving in edge direction, to avoid clamping value to edge.
7300
7322
set_new_value = true ;
@@ -7602,7 +7624,7 @@ bool ImGui::DragBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_s
7602
7624
// Process clicking on the drag
7603
7625
if (g.ActiveId == id)
7604
7626
{
7605
- if (g.IO .MouseDown [0 ] || IsKeyDownMap (ImGuiKey_NavActivate ))
7627
+ if (g.IO .MouseDown [0 ] || IsNavInputDown (ImGuiNavInput_PadActivate ))
7606
7628
{
7607
7629
if (g.ActiveIdIsJustActivated )
7608
7630
{
@@ -7627,11 +7649,7 @@ bool ImGui::DragBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_s
7627
7649
}
7628
7650
if (g.ActiveIdSource == ImGuiInputSource_Nav)
7629
7651
{
7630
- adjust_delta = NavGetTweakDelta ().x ;
7631
- if (IsKeyDownMap (ImGuiKey_NavTweakFaster))
7632
- adjust_delta *= 10 .0f ;
7633
- if (IsKeyDownMap (ImGuiKey_NavTweakSlower))
7634
- adjust_delta /= 10 .0f ;
7652
+ adjust_delta = GetNavInputAmount2d (0 , ImGuiNavReadMode_RepeatFast, 1 .0f /10 .0f , 1 .0f ).x ;
7635
7653
}
7636
7654
adjust_delta *= v_speed;
7637
7655
g.DragLastMouseDelta .x = mouse_drag_delta.x ;
0 commit comments