mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Internals: renamed ImGuiInputReadMode to ImGuiNavReadMode (internals) to avoid ambiguity with upcoming flags. + minor tweak
This commit is contained in:
44
imgui.cpp
44
imgui.cpp
@ -3975,9 +3975,9 @@ static void ImGui::UpdateKeyboardInputs()
|
||||
// Update keys
|
||||
for (int i = 0; i < IM_ARRAYSIZE(io.KeysData); i++)
|
||||
{
|
||||
ImGuiKeyData& key_data = io.KeysData[i];
|
||||
key_data.DownDurationPrev = key_data.DownDuration;
|
||||
key_data.DownDuration = key_data.Down ? (key_data.DownDuration < 0.0f ? 0.0f : key_data.DownDuration + io.DeltaTime) : -1.0f;
|
||||
ImGuiKeyData* key_data = &io.KeysData[i];
|
||||
key_data->DownDurationPrev = key_data->DownDuration;
|
||||
key_data->DownDuration = key_data->Down ? (key_data->DownDuration < 0.0f ? 0.0f : key_data->DownDuration + io.DeltaTime) : -1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5656,9 +5656,9 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s
|
||||
{
|
||||
ImVec2 nav_resize_delta;
|
||||
if (g.NavInputSource == ImGuiInputSource_Keyboard && g.IO.KeyShift)
|
||||
nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_RawKeyboard, ImGuiInputReadMode_Down);
|
||||
nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_RawKeyboard, ImGuiNavReadMode_Down);
|
||||
if (g.NavInputSource == ImGuiInputSource_Gamepad)
|
||||
nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_Down);
|
||||
nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadDPad, ImGuiNavReadMode_Down);
|
||||
if (nav_resize_delta.x != 0.0f || nav_resize_delta.y != 0.0f)
|
||||
{
|
||||
const float NAV_RESIZE_SPEED = 600.0f;
|
||||
@ -10024,29 +10024,29 @@ const char* ImGui::GetNavInputName(ImGuiNavInput n)
|
||||
return names[n];
|
||||
}
|
||||
|
||||
float ImGui::GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode)
|
||||
float ImGui::GetNavInputAmount(ImGuiNavInput n, ImGuiNavReadMode mode)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (mode == ImGuiInputReadMode_Down)
|
||||
if (mode == ImGuiNavReadMode_Down)
|
||||
return g.IO.NavInputs[n]; // Instant, read analog input (0.0f..1.0f, as provided by user)
|
||||
|
||||
const float t = g.IO.NavInputsDownDuration[n];
|
||||
if (t < 0.0f && mode == ImGuiInputReadMode_Released) // Return 1.0f when just released, no repeat, ignore analog input.
|
||||
if (t < 0.0f && mode == ImGuiNavReadMode_Released) // Return 1.0f when just released, no repeat, ignore analog input.
|
||||
return (g.IO.NavInputsDownDurationPrev[n] >= 0.0f ? 1.0f : 0.0f);
|
||||
if (t < 0.0f)
|
||||
return 0.0f;
|
||||
if (mode == ImGuiInputReadMode_Pressed) // Return 1.0f when just pressed, no repeat, ignore analog input.
|
||||
if (mode == ImGuiNavReadMode_Pressed) // Return 1.0f when just pressed, no repeat, ignore analog input.
|
||||
return (t == 0.0f) ? 1.0f : 0.0f;
|
||||
if (mode == ImGuiInputReadMode_Repeat)
|
||||
if (mode == ImGuiNavReadMode_Repeat)
|
||||
return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 0.72f, g.IO.KeyRepeatRate * 0.80f);
|
||||
if (mode == ImGuiInputReadMode_RepeatSlow)
|
||||
if (mode == ImGuiNavReadMode_RepeatSlow)
|
||||
return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 1.25f, g.IO.KeyRepeatRate * 2.00f);
|
||||
if (mode == ImGuiInputReadMode_RepeatFast)
|
||||
if (mode == ImGuiNavReadMode_RepeatFast)
|
||||
return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 0.72f, g.IO.KeyRepeatRate * 0.30f);
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
ImVec2 ImGui::GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor, float fast_factor)
|
||||
ImVec2 ImGui::GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiNavReadMode mode, float slow_factor, float fast_factor)
|
||||
{
|
||||
ImVec2 delta(0.0f, 0.0f);
|
||||
if (dir_sources & ImGuiNavDirSourceFlags_RawKeyboard)
|
||||
@ -10166,8 +10166,8 @@ static void ImGui::NavUpdate()
|
||||
{
|
||||
bool activate_down = IsNavInputDown(ImGuiNavInput_Activate);
|
||||
bool input_down = IsNavInputDown(ImGuiNavInput_Input);
|
||||
bool activate_pressed = activate_down && IsNavInputTest(ImGuiNavInput_Activate, ImGuiInputReadMode_Pressed);
|
||||
bool input_pressed = input_down && IsNavInputTest(ImGuiNavInput_Input, ImGuiInputReadMode_Pressed);
|
||||
bool activate_pressed = activate_down && IsNavInputTest(ImGuiNavInput_Activate, ImGuiNavReadMode_Pressed);
|
||||
bool input_pressed = input_down && IsNavInputTest(ImGuiNavInput_Input, ImGuiNavReadMode_Pressed);
|
||||
if (g.ActiveId == 0 && activate_pressed)
|
||||
{
|
||||
g.NavActivateId = g.NavId;
|
||||
@ -10224,7 +10224,7 @@ static void ImGui::NavUpdate()
|
||||
|
||||
// *Normal* Manual scroll with NavScrollXXX keys
|
||||
// Next movement request will clamp the NavId reference rectangle to the visible area, so navigation will resume within those bounds.
|
||||
ImVec2 scroll_dir = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down, 1.0f / 10.0f, 10.0f);
|
||||
ImVec2 scroll_dir = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiNavReadMode_Down, 1.0f / 10.0f, 10.0f);
|
||||
if (scroll_dir.x != 0.0f && window->ScrollbarX)
|
||||
SetScrollX(window, ImFloor(window->Scroll.x + scroll_dir.x * scroll_speed));
|
||||
if (scroll_dir.y != 0.0f)
|
||||
@ -10297,7 +10297,7 @@ void ImGui::NavUpdateCreateMoveRequest()
|
||||
g.NavMoveScrollFlags = ImGuiScrollFlags_None;
|
||||
if (window && !g.NavWindowingTarget && !(window->Flags & ImGuiWindowFlags_NoNavInputs))
|
||||
{
|
||||
const ImGuiInputReadMode read_mode = ImGuiInputReadMode_Repeat;
|
||||
const ImGuiNavReadMode read_mode = ImGuiNavReadMode_Repeat;
|
||||
if (!IsActiveIdUsingNavDir(ImGuiDir_Left) && (IsNavInputTest(ImGuiNavInput_DpadLeft, read_mode) || IsNavInputTest(ImGuiNavInput_KeyLeft_, read_mode))) { g.NavMoveDir = ImGuiDir_Left; }
|
||||
if (!IsActiveIdUsingNavDir(ImGuiDir_Right) && (IsNavInputTest(ImGuiNavInput_DpadRight, read_mode) || IsNavInputTest(ImGuiNavInput_KeyRight_, read_mode))) { g.NavMoveDir = ImGuiDir_Right; }
|
||||
if (!IsActiveIdUsingNavDir(ImGuiDir_Up) && (IsNavInputTest(ImGuiNavInput_DpadUp, read_mode) || IsNavInputTest(ImGuiNavInput_KeyUp_, read_mode))) { g.NavMoveDir = ImGuiDir_Up; }
|
||||
@ -10504,7 +10504,7 @@ void ImGui::NavMoveRequestApplyResult()
|
||||
static void ImGui::NavUpdateCancelRequest()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (!IsNavInputTest(ImGuiNavInput_Cancel, ImGuiInputReadMode_Pressed))
|
||||
if (!IsNavInputTest(ImGuiNavInput_Cancel, ImGuiNavReadMode_Pressed))
|
||||
return;
|
||||
|
||||
IMGUI_DEBUG_LOG_NAV("[nav] ImGuiNavInput_Cancel\n");
|
||||
@ -10754,7 +10754,7 @@ static void ImGui::NavUpdateWindowing()
|
||||
}
|
||||
|
||||
// Start CTRL+Tab or Square+L/R window selection
|
||||
const bool start_windowing_with_gamepad = allow_windowing && !g.NavWindowingTarget && IsNavInputTest(ImGuiNavInput_Menu, ImGuiInputReadMode_Pressed);
|
||||
const bool start_windowing_with_gamepad = allow_windowing && !g.NavWindowingTarget && IsNavInputTest(ImGuiNavInput_Menu, ImGuiNavReadMode_Pressed);
|
||||
const bool start_windowing_with_keyboard = allow_windowing && !g.NavWindowingTarget && io.KeyCtrl && IsKeyPressed(ImGuiKey_Tab);
|
||||
if (start_windowing_with_gamepad || start_windowing_with_keyboard)
|
||||
if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1))
|
||||
@ -10773,7 +10773,7 @@ static void ImGui::NavUpdateWindowing()
|
||||
g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f));
|
||||
|
||||
// Select window to focus
|
||||
const int focus_change_dir = (int)IsNavInputTest(ImGuiNavInput_FocusPrev, ImGuiInputReadMode_RepeatSlow) - (int)IsNavInputTest(ImGuiNavInput_FocusNext, ImGuiInputReadMode_RepeatSlow);
|
||||
const int focus_change_dir = (int)IsNavInputTest(ImGuiNavInput_FocusPrev, ImGuiNavReadMode_RepeatSlow) - (int)IsNavInputTest(ImGuiNavInput_FocusNext, ImGuiNavReadMode_RepeatSlow);
|
||||
if (focus_change_dir != 0)
|
||||
{
|
||||
NavUpdateWindowingHighlightWindow(focus_change_dir);
|
||||
@ -10834,9 +10834,9 @@ static void ImGui::NavUpdateWindowing()
|
||||
{
|
||||
ImVec2 move_delta;
|
||||
if (g.NavInputSource == ImGuiInputSource_Keyboard && !io.KeyShift)
|
||||
move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_RawKeyboard, ImGuiInputReadMode_Down);
|
||||
move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_RawKeyboard, ImGuiNavReadMode_Down);
|
||||
if (g.NavInputSource == ImGuiInputSource_Gamepad)
|
||||
move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down);
|
||||
move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiNavReadMode_Down);
|
||||
if (move_delta.x != 0.0f || move_delta.y != 0.0f)
|
||||
{
|
||||
const float NAV_MOVE_SPEED = 800.0f;
|
||||
|
Reference in New Issue
Block a user