mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-14 17:07:01 +00:00
Inputs: added a unique event identifier in ImGuiInputEvent.
This commit is contained in:
parent
506f7e0074
commit
18d72a9142
@ -1269,6 +1269,7 @@ void ImGuiIO::AddInputCharacter(unsigned int c)
|
||||
ImGuiInputEvent e;
|
||||
e.Type = ImGuiInputEventType_Text;
|
||||
e.Source = ImGuiInputSource_Keyboard;
|
||||
e.EventId = g.InputEventsNextEventId++;
|
||||
e.Text.Char = c;
|
||||
g.InputEventsQueue.push_back(e);
|
||||
}
|
||||
@ -1407,6 +1408,7 @@ void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value)
|
||||
ImGuiInputEvent e;
|
||||
e.Type = ImGuiInputEventType_Key;
|
||||
e.Source = ImGui::IsGamepadKey(key) ? ImGuiInputSource_Gamepad : ImGuiInputSource_Keyboard;
|
||||
e.EventId = g.InputEventsNextEventId++;
|
||||
e.Key.Key = key;
|
||||
e.Key.Down = down;
|
||||
e.Key.AnalogValue = analog_value;
|
||||
@ -1471,6 +1473,7 @@ void ImGuiIO::AddMousePosEvent(float x, float y)
|
||||
ImGuiInputEvent e;
|
||||
e.Type = ImGuiInputEventType_MousePos;
|
||||
e.Source = ImGuiInputSource_Mouse;
|
||||
e.EventId = g.InputEventsNextEventId++;
|
||||
e.MousePos.PosX = pos.x;
|
||||
e.MousePos.PosY = pos.y;
|
||||
e.MouseWheel.MouseSource = g.InputEventsNextMouseSource;
|
||||
@ -1494,6 +1497,7 @@ void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down)
|
||||
ImGuiInputEvent e;
|
||||
e.Type = ImGuiInputEventType_MouseButton;
|
||||
e.Source = ImGuiInputSource_Mouse;
|
||||
e.EventId = g.InputEventsNextEventId++;
|
||||
e.MouseButton.Button = mouse_button;
|
||||
e.MouseButton.Down = down;
|
||||
e.MouseWheel.MouseSource = g.InputEventsNextMouseSource;
|
||||
@ -1513,6 +1517,7 @@ void ImGuiIO::AddMouseWheelEvent(float wheel_x, float wheel_y)
|
||||
ImGuiInputEvent e;
|
||||
e.Type = ImGuiInputEventType_MouseWheel;
|
||||
e.Source = ImGuiInputSource_Mouse;
|
||||
e.EventId = g.InputEventsNextEventId++;
|
||||
e.MouseWheel.WheelX = wheel_x;
|
||||
e.MouseWheel.WheelY = wheel_y;
|
||||
e.MouseWheel.MouseSource = g.InputEventsNextMouseSource;
|
||||
@ -1541,6 +1546,7 @@ void ImGuiIO::AddFocusEvent(bool focused)
|
||||
|
||||
ImGuiInputEvent e;
|
||||
e.Type = ImGuiInputEventType_Focus;
|
||||
e.EventId = g.InputEventsNextEventId++;
|
||||
e.AppFocused.Focused = focused;
|
||||
g.InputEventsQueue.push_back(e);
|
||||
}
|
||||
|
@ -1284,6 +1284,7 @@ struct ImGuiInputEvent
|
||||
{
|
||||
ImGuiInputEventType Type;
|
||||
ImGuiInputSource Source;
|
||||
ImU32 EventId; // Unique, sequential increasing integer to identify an event (if you need to correlate them to other data).
|
||||
union
|
||||
{
|
||||
ImGuiInputEventMousePos MousePos; // if Type == ImGuiInputEventType_MousePos
|
||||
@ -1739,9 +1740,6 @@ struct ImGuiContext
|
||||
bool Initialized;
|
||||
bool FontAtlasOwnedByContext; // IO.Fonts-> is owned by the ImGuiContext and will be destructed along with it.
|
||||
ImGuiIO IO;
|
||||
ImVector<ImGuiInputEvent> InputEventsQueue; // Input events which will be tricked/written into IO structure.
|
||||
ImVector<ImGuiInputEvent> InputEventsTrail; // Past input events processed in NewFrame(). This is to allow domain-specific application to access e.g mouse/pen trail.
|
||||
ImGuiMouseSource InputEventsNextMouseSource;
|
||||
ImGuiStyle Style;
|
||||
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
|
||||
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
|
||||
@ -1758,6 +1756,12 @@ struct ImGuiContext
|
||||
bool TestEngineHookItems; // Will call test engine hooks: ImGuiTestEngineHook_ItemAdd(), ImGuiTestEngineHook_ItemInfo(), ImGuiTestEngineHook_Log()
|
||||
void* TestEngine; // Test engine user data
|
||||
|
||||
// Inputs
|
||||
ImVector<ImGuiInputEvent> InputEventsQueue; // Input events which will be trickled/written into IO structure.
|
||||
ImVector<ImGuiInputEvent> InputEventsTrail; // Past input events processed in NewFrame(). This is to allow domain-specific application to access e.g mouse/pen trail.
|
||||
ImGuiMouseSource InputEventsNextMouseSource;
|
||||
ImU32 InputEventsNextEventId;
|
||||
|
||||
// Windows state
|
||||
ImVector<ImGuiWindow*> Windows; // Windows, sorted in display order, back to front
|
||||
ImVector<ImGuiWindow*> WindowsFocusOrder; // Root windows, sorted in focus order, back to front.
|
||||
@ -2028,7 +2032,6 @@ struct ImGuiContext
|
||||
{
|
||||
IO.Ctx = this;
|
||||
InputTextState.Ctx = this;
|
||||
InputEventsNextMouseSource = ImGuiMouseSource_Mouse;
|
||||
|
||||
Initialized = false;
|
||||
FontAtlasOwnedByContext = shared_font_atlas ? false : true;
|
||||
@ -2043,6 +2046,9 @@ struct ImGuiContext
|
||||
TestEngineHookItems = false;
|
||||
TestEngine = NULL;
|
||||
|
||||
InputEventsNextMouseSource = ImGuiMouseSource_Mouse;
|
||||
InputEventsNextEventId = 1;
|
||||
|
||||
WindowsActiveCount = 0;
|
||||
CurrentWindow = NULL;
|
||||
HoveredWindow = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user