mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-10 00:15:57 +01:00
Internals, Inputs: declaring FindLatestInputEvent() in imgui_internal.h.
Might facilitate late-latching experiments? (#9594)
This commit is contained in:
parent
5554e8e476
commit
8ba9eb061f
12
imgui.cpp
12
imgui.cpp
@ -1920,7 +1920,7 @@ void ImGuiIO::ClearInputMouse()
|
||||
MouseWheel = MouseWheelH = 0.0f;
|
||||
}
|
||||
|
||||
static ImGuiInputEvent* FindLatestInputEvent(ImGuiContext* ctx, ImGuiInputEventType type, int arg = -1)
|
||||
ImGuiInputEvent* ImGui::FindLatestInputEvent(ImGuiContext* ctx, ImGuiInputEventType type, int arg)
|
||||
{
|
||||
ImGuiContext& g = *ctx;
|
||||
for (int n = g.InputEventsQueue.Size - 1; n >= 0; n--)
|
||||
@ -1965,7 +1965,7 @@ void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value)
|
||||
}
|
||||
|
||||
// Filter duplicate (in particular: key mods and gamepad analog values are commonly spammed)
|
||||
const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_Key, (int)key);
|
||||
const ImGuiInputEvent* latest_event = ImGui::FindLatestInputEvent(&g, ImGuiInputEventType_Key, (int)key);
|
||||
const ImGuiKeyData* key_data = ImGui::GetKeyData(&g, key);
|
||||
const bool latest_key_down = latest_event ? latest_event->Key.Down : key_data->Down;
|
||||
const float latest_key_analog = latest_event ? latest_event->Key.AnalogValue : key_data->AnalogValue;
|
||||
@ -2023,7 +2023,7 @@ void ImGuiIO::AddMousePosEvent(float x, float y)
|
||||
ImVec2 pos((x > -FLT_MAX) ? ImFloor(x) : x, (y > -FLT_MAX) ? ImFloor(y) : y);
|
||||
|
||||
// Filter duplicate
|
||||
const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_MousePos);
|
||||
const ImGuiInputEvent* latest_event = ImGui::FindLatestInputEvent(&g, ImGuiInputEventType_MousePos);
|
||||
const ImVec2 latest_pos = latest_event ? ImVec2(latest_event->MousePos.PosX, latest_event->MousePos.PosY) : g.IO.MousePos;
|
||||
if (latest_pos.x == pos.x && latest_pos.y == pos.y)
|
||||
return;
|
||||
@ -2056,7 +2056,7 @@ void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down)
|
||||
}
|
||||
|
||||
// Filter duplicate
|
||||
const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_MouseButton, (int)mouse_button);
|
||||
const ImGuiInputEvent* latest_event = ImGui::FindLatestInputEvent(&g, ImGuiInputEventType_MouseButton, (int)mouse_button);
|
||||
const bool latest_button_down = latest_event ? latest_event->MouseButton.Down : g.IO.MouseDown[mouse_button];
|
||||
if (latest_button_down == down)
|
||||
return;
|
||||
@ -2066,7 +2066,7 @@ void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down)
|
||||
// - At this point we want from !down to down, so this is handling the initial press.
|
||||
if (ConfigMacOSXBehaviors && mouse_button == 0 && down)
|
||||
{
|
||||
const ImGuiInputEvent* latest_super_event = FindLatestInputEvent(&g, ImGuiInputEventType_Key, (int)ImGuiMod_Super);
|
||||
const ImGuiInputEvent* latest_super_event = ImGui::FindLatestInputEvent(&g, ImGuiInputEventType_Key, (int)ImGuiMod_Super);
|
||||
if (latest_super_event ? latest_super_event->Key.Down : g.IO.KeySuper)
|
||||
{
|
||||
IMGUI_DEBUG_LOG_IO("[io] Super+Left Click aliased into Right Click\n");
|
||||
@ -2121,7 +2121,7 @@ void ImGuiIO::AddFocusEvent(bool focused)
|
||||
ImGuiContext& g = *Ctx;
|
||||
|
||||
// Filter duplicate
|
||||
const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_Focus);
|
||||
const ImGuiInputEvent* latest_event = ImGui::FindLatestInputEvent(&g, ImGuiInputEventType_Focus);
|
||||
const bool latest_focused = latest_event ? latest_event->AppFocused.Focused : !g.IO.AppFocusLost;
|
||||
if (latest_focused == focused || (ConfigDebugIgnoreFocusLoss && !focused))
|
||||
return;
|
||||
|
||||
@ -3499,6 +3499,7 @@ namespace ImGui
|
||||
IMGUI_API void StopMouseMovingWindow();
|
||||
IMGUI_API void UpdateMouseMovingWindowNewFrame();
|
||||
IMGUI_API void UpdateMouseMovingWindowEndFrame();
|
||||
IMGUI_API ImGuiInputEvent* FindLatestInputEvent(ImGuiContext* ctx, ImGuiInputEventType type, int arg = -1);
|
||||
|
||||
// Viewports
|
||||
inline ImGuiViewport* GetWindowViewport() { return GetMainViewport(); } // For code consistency. This is public API in docking branch.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user