mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 20:07:01 +00:00
IO: remove ImGuiInputEvent::IgnoredAsSame (revert part of 839c3100
), will filter earlier in next commit. (#5599)
Making it a separate commit as this leads to much indentation change.
This commit is contained in:
parent
9e7f460c09
commit
fac8295d6e
26
imgui.cpp
26
imgui.cpp
@ -8121,37 +8121,26 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
|||||||
ImGuiInputEvent* e = &g.InputEventsQueue[event_n];
|
ImGuiInputEvent* e = &g.InputEventsQueue[event_n];
|
||||||
if (e->Type == ImGuiInputEventType_MousePos)
|
if (e->Type == ImGuiInputEventType_MousePos)
|
||||||
{
|
{
|
||||||
|
// Trickling Rule: Stop processing queued events if we already handled a mouse button change
|
||||||
ImVec2 event_pos(e->MousePos.PosX, e->MousePos.PosY);
|
ImVec2 event_pos(e->MousePos.PosX, e->MousePos.PosY);
|
||||||
if (IsMousePosValid(&event_pos))
|
if (IsMousePosValid(&event_pos))
|
||||||
event_pos = ImVec2(ImFloorSigned(event_pos.x), ImFloorSigned(event_pos.y)); // Apply same flooring as UpdateMouseInputs()
|
event_pos = ImVec2(ImFloorSigned(event_pos.x), ImFloorSigned(event_pos.y)); // Apply same flooring as UpdateMouseInputs()
|
||||||
e->IgnoredAsSame = (io.MousePos.x == event_pos.x && io.MousePos.y == event_pos.y);
|
|
||||||
if (!e->IgnoredAsSame)
|
|
||||||
{
|
|
||||||
// Trickling Rule: Stop processing queued events if we already handled a mouse button change
|
|
||||||
if (trickle_fast_inputs && (mouse_button_changed != 0 || mouse_wheeled || key_changed || text_inputted))
|
if (trickle_fast_inputs && (mouse_button_changed != 0 || mouse_wheeled || key_changed || text_inputted))
|
||||||
break;
|
break;
|
||||||
io.MousePos = event_pos;
|
io.MousePos = event_pos;
|
||||||
mouse_moved = true;
|
mouse_moved = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (e->Type == ImGuiInputEventType_MouseButton)
|
else if (e->Type == ImGuiInputEventType_MouseButton)
|
||||||
{
|
{
|
||||||
|
// Trickling Rule: Stop processing queued events if we got multiple action on the same button
|
||||||
const ImGuiMouseButton button = e->MouseButton.Button;
|
const ImGuiMouseButton button = e->MouseButton.Button;
|
||||||
IM_ASSERT(button >= 0 && button < ImGuiMouseButton_COUNT);
|
IM_ASSERT(button >= 0 && button < ImGuiMouseButton_COUNT);
|
||||||
e->IgnoredAsSame = (io.MouseDown[button] == e->MouseButton.Down);
|
|
||||||
if (!e->IgnoredAsSame)
|
|
||||||
{
|
|
||||||
// Trickling Rule: Stop processing queued events if we got multiple action on the same button
|
|
||||||
if (trickle_fast_inputs && ((mouse_button_changed & (1 << button)) || mouse_wheeled))
|
if (trickle_fast_inputs && ((mouse_button_changed & (1 << button)) || mouse_wheeled))
|
||||||
break;
|
break;
|
||||||
io.MouseDown[button] = e->MouseButton.Down;
|
io.MouseDown[button] = e->MouseButton.Down;
|
||||||
mouse_button_changed |= (1 << button);
|
mouse_button_changed |= (1 << button);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (e->Type == ImGuiInputEventType_MouseWheel)
|
else if (e->Type == ImGuiInputEventType_MouseWheel)
|
||||||
{
|
|
||||||
e->IgnoredAsSame = (e->MouseWheel.WheelX == 0.0f && e->MouseWheel.WheelY == 0.0f);
|
|
||||||
if (!e->IgnoredAsSame)
|
|
||||||
{
|
{
|
||||||
// Trickling Rule: Stop processing queued events if we got multiple action on the event
|
// Trickling Rule: Stop processing queued events if we got multiple action on the event
|
||||||
if (trickle_fast_inputs && (mouse_moved || mouse_button_changed != 0))
|
if (trickle_fast_inputs && (mouse_moved || mouse_button_changed != 0))
|
||||||
@ -8160,17 +8149,13 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
|||||||
io.MouseWheel += e->MouseWheel.WheelY;
|
io.MouseWheel += e->MouseWheel.WheelY;
|
||||||
mouse_wheeled = true;
|
mouse_wheeled = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (e->Type == ImGuiInputEventType_Key)
|
else if (e->Type == ImGuiInputEventType_Key)
|
||||||
{
|
{
|
||||||
|
// Trickling Rule: Stop processing queued events if we got multiple action on the same button
|
||||||
ImGuiKey key = e->Key.Key;
|
ImGuiKey key = e->Key.Key;
|
||||||
IM_ASSERT(key != ImGuiKey_None);
|
IM_ASSERT(key != ImGuiKey_None);
|
||||||
ImGuiKeyData* key_data = GetKeyData(key);
|
ImGuiKeyData* key_data = GetKeyData(key);
|
||||||
const int key_data_index = (int)(key_data - g.IO.KeysData);
|
const int key_data_index = (int)(key_data - g.IO.KeysData);
|
||||||
e->IgnoredAsSame = (key_data->Down == e->Key.Down && key_data->AnalogValue == e->Key.AnalogValue);
|
|
||||||
if (!e->IgnoredAsSame)
|
|
||||||
{
|
|
||||||
// Trickling Rule: Stop processing queued events if we got multiple action on the same button
|
|
||||||
if (trickle_fast_inputs && key_data->Down != e->Key.Down && (key_changed_mask.TestBit(key_data_index) || text_inputted || mouse_button_changed != 0))
|
if (trickle_fast_inputs && key_data->Down != e->Key.Down && (key_changed_mask.TestBit(key_data_index) || text_inputted || mouse_button_changed != 0))
|
||||||
break;
|
break;
|
||||||
key_data->Down = e->Key.Down;
|
key_data->Down = e->Key.Down;
|
||||||
@ -8194,7 +8179,6 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
|||||||
io.KeysDown[io.KeyMap[key_data_index]] = key_data->Down;
|
io.KeysDown[io.KeyMap[key_data_index]] = key_data->Down;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (e->Type == ImGuiInputEventType_Text)
|
else if (e->Type == ImGuiInputEventType_Text)
|
||||||
{
|
{
|
||||||
// Trickling Rule: Stop processing queued events if keys/mouse have been interacted with
|
// Trickling Rule: Stop processing queued events if keys/mouse have been interacted with
|
||||||
@ -8210,8 +8194,6 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
|||||||
// We intentionally overwrite this and process in NewFrame(), in order to give a chance
|
// We intentionally overwrite this and process in NewFrame(), in order to give a chance
|
||||||
// to multi-viewports backends to queue AddFocusEvent(false) + AddFocusEvent(true) in same frame.
|
// to multi-viewports backends to queue AddFocusEvent(false) + AddFocusEvent(true) in same frame.
|
||||||
const bool focus_lost = !e->AppFocused.Focused;
|
const bool focus_lost = !e->AppFocused.Focused;
|
||||||
e->IgnoredAsSame = (io.AppFocusLost == focus_lost);
|
|
||||||
if (!e->IgnoredAsSame)
|
|
||||||
io.AppFocusLost = focus_lost;
|
io.AppFocusLost = focus_lost;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -8229,7 +8211,7 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
|||||||
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
|
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
|
||||||
if (event_n != 0 && (g.DebugLogFlags & ImGuiDebugLogFlags_EventIO))
|
if (event_n != 0 && (g.DebugLogFlags & ImGuiDebugLogFlags_EventIO))
|
||||||
for (int n = 0; n < g.InputEventsQueue.Size; n++)
|
for (int n = 0; n < g.InputEventsQueue.Size; n++)
|
||||||
DebugPrintInputEvent(n < event_n ? (g.InputEventsQueue[n].IgnoredAsSame ? "Processed (Same)" : "Processed") : "Remaining", &g.InputEventsQueue[n]);
|
DebugPrintInputEvent(n < event_n ? "Processed" : "Remaining", &g.InputEventsQueue[n]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Remaining events will be processed on the next frame
|
// Remaining events will be processed on the next frame
|
||||||
|
@ -1245,7 +1245,6 @@ struct ImGuiInputEvent
|
|||||||
ImGuiInputEventText Text; // if Type == ImGuiInputEventType_Text
|
ImGuiInputEventText Text; // if Type == ImGuiInputEventType_Text
|
||||||
ImGuiInputEventAppFocused AppFocused; // if Type == ImGuiInputEventType_Focus
|
ImGuiInputEventAppFocused AppFocused; // if Type == ImGuiInputEventType_Focus
|
||||||
};
|
};
|
||||||
bool IgnoredAsSame;
|
|
||||||
bool AddedByTestEngine;
|
bool AddedByTestEngine;
|
||||||
|
|
||||||
ImGuiInputEvent() { memset(this, 0, sizeof(*this)); }
|
ImGuiInputEvent() { memset(this, 0, sizeof(*this)); }
|
||||||
|
Loading…
Reference in New Issue
Block a user