mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-26 05:27:01 +00:00
parent
17b8c3b6ea
commit
65c4c0a490
@ -65,6 +65,9 @@ Other Changes:
|
|||||||
or interacting with a game/3D view).
|
or interacting with a game/3D view).
|
||||||
- IO: Fixed input queue trickling of mouse wheel events: multiple wheel events are merged, while
|
- IO: Fixed input queue trickling of mouse wheel events: multiple wheel events are merged, while
|
||||||
a mouse pos followed by a mouse wheel are now trickled. (#4921, #4821)
|
a mouse pos followed by a mouse wheel are now trickled. (#4921, #4821)
|
||||||
|
- IO: Added io.SetAppAcceptingEvents() to set a master flag for accepting key/mouse/characters
|
||||||
|
events (default to true). Useful if you have native dialog boxes that are interrupting your
|
||||||
|
application loop/refresh, and you want to disable events being queued while your app is frozen.
|
||||||
- Windows: Fixed first-time windows appearing in negative coordinates from being initialized
|
- Windows: Fixed first-time windows appearing in negative coordinates from being initialized
|
||||||
with a wrong size. This would most often be noticeable in multi-viewport mode (docking branch)
|
with a wrong size. This would most often be noticeable in multi-viewport mode (docking branch)
|
||||||
when spawning a window in a monitor with negative coordinates. (#5215, #3414) [@DimaKoltun]
|
when spawning a window in a monitor with negative coordinates. (#5215, #3414) [@DimaKoltun]
|
||||||
|
23
imgui.cpp
23
imgui.cpp
@ -1169,6 +1169,7 @@ ImGuiIO::ImGuiIO()
|
|||||||
for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++) MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f;
|
for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++) MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f;
|
||||||
for (int i = 0; i < IM_ARRAYSIZE(KeysData); i++) { KeysData[i].DownDuration = KeysData[i].DownDurationPrev = -1.0f; }
|
for (int i = 0; i < IM_ARRAYSIZE(KeysData); i++) { KeysData[i].DownDuration = KeysData[i].DownDurationPrev = -1.0f; }
|
||||||
for (int i = 0; i < IM_ARRAYSIZE(NavInputsDownDuration); i++) NavInputsDownDuration[i] = -1.0f;
|
for (int i = 0; i < IM_ARRAYSIZE(NavInputsDownDuration); i++) NavInputsDownDuration[i] = -1.0f;
|
||||||
|
AppAcceptingEvents = true;
|
||||||
BackendUsingLegacyKeyArrays = (ImS8)-1;
|
BackendUsingLegacyKeyArrays = (ImS8)-1;
|
||||||
BackendUsingLegacyNavInputArray = true; // assume using legacy array until proven wrong
|
BackendUsingLegacyNavInputArray = true; // assume using legacy array until proven wrong
|
||||||
}
|
}
|
||||||
@ -1181,7 +1182,7 @@ void ImGuiIO::AddInputCharacter(unsigned int c)
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
||||||
if (c == 0)
|
if (c == 0 || !AppAcceptingEvents)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImGuiInputEvent e;
|
ImGuiInputEvent e;
|
||||||
@ -1195,7 +1196,7 @@ void ImGuiIO::AddInputCharacter(unsigned int c)
|
|||||||
// we should save the high surrogate.
|
// we should save the high surrogate.
|
||||||
void ImGuiIO::AddInputCharacterUTF16(ImWchar16 c)
|
void ImGuiIO::AddInputCharacterUTF16(ImWchar16 c)
|
||||||
{
|
{
|
||||||
if (c == 0 && InputQueueSurrogate == 0)
|
if ((c == 0 && InputQueueSurrogate == 0) || !AppAcceptingEvents)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((c & 0xFC00) == 0xD800) // High surrogate, must save
|
if ((c & 0xFC00) == 0xD800) // High surrogate, must save
|
||||||
@ -1229,6 +1230,8 @@ void ImGuiIO::AddInputCharacterUTF16(ImWchar16 c)
|
|||||||
|
|
||||||
void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars)
|
void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars)
|
||||||
{
|
{
|
||||||
|
if (!AppAcceptingEvents)
|
||||||
|
return;
|
||||||
while (*utf8_chars != 0)
|
while (*utf8_chars != 0)
|
||||||
{
|
{
|
||||||
unsigned int c = 0;
|
unsigned int c = 0;
|
||||||
@ -1267,7 +1270,7 @@ void ImGuiIO::ClearInputKeys()
|
|||||||
void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value)
|
void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value)
|
||||||
{
|
{
|
||||||
//if (e->Down) { IMGUI_DEBUG_LOG("AddKeyEvent() Key='%s' %d, NativeKeycode = %d, NativeScancode = %d\n", ImGui::GetKeyName(e->Key), e->Down, e->NativeKeycode, e->NativeScancode); }
|
//if (e->Down) { IMGUI_DEBUG_LOG("AddKeyEvent() Key='%s' %d, NativeKeycode = %d, NativeScancode = %d\n", ImGui::GetKeyName(e->Key), e->Down, e->NativeKeycode, e->NativeScancode); }
|
||||||
if (key == ImGuiKey_None)
|
if (key == ImGuiKey_None || !AppAcceptingEvents)
|
||||||
return;
|
return;
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
||||||
@ -1308,6 +1311,8 @@ void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value)
|
|||||||
|
|
||||||
void ImGuiIO::AddKeyEvent(ImGuiKey key, bool down)
|
void ImGuiIO::AddKeyEvent(ImGuiKey key, bool down)
|
||||||
{
|
{
|
||||||
|
if (!AppAcceptingEvents)
|
||||||
|
return;
|
||||||
AddKeyAnalogEvent(key, down, down ? 1.0f : 0.0f);
|
AddKeyAnalogEvent(key, down, down ? 1.0f : 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1336,11 +1341,19 @@ void ImGuiIO::SetKeyEventNativeData(ImGuiKey key, int native_keycode, int native
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set master flag for accepting key/mouse/text events (default to true). Useful if you have native dialog boxes that are interrupting your application loop/refresh, and you want to disable events being queued while your app is frozen.
|
||||||
|
void ImGuiIO::SetAppAcceptingEvents(bool accepting_events)
|
||||||
|
{
|
||||||
|
AppAcceptingEvents = accepting_events;
|
||||||
|
}
|
||||||
|
|
||||||
// Queue a mouse move event
|
// Queue a mouse move event
|
||||||
void ImGuiIO::AddMousePosEvent(float x, float y)
|
void ImGuiIO::AddMousePosEvent(float x, float y)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
||||||
|
if (!AppAcceptingEvents)
|
||||||
|
return;
|
||||||
|
|
||||||
ImGuiInputEvent e;
|
ImGuiInputEvent e;
|
||||||
e.Type = ImGuiInputEventType_MousePos;
|
e.Type = ImGuiInputEventType_MousePos;
|
||||||
@ -1355,6 +1368,8 @@ void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down)
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
||||||
IM_ASSERT(mouse_button >= 0 && mouse_button < ImGuiMouseButton_COUNT);
|
IM_ASSERT(mouse_button >= 0 && mouse_button < ImGuiMouseButton_COUNT);
|
||||||
|
if (!AppAcceptingEvents)
|
||||||
|
return;
|
||||||
|
|
||||||
ImGuiInputEvent e;
|
ImGuiInputEvent e;
|
||||||
e.Type = ImGuiInputEventType_MouseButton;
|
e.Type = ImGuiInputEventType_MouseButton;
|
||||||
@ -1369,7 +1384,7 @@ void ImGuiIO::AddMouseWheelEvent(float wheel_x, float wheel_y)
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
||||||
if (wheel_x == 0.0f && wheel_y == 0.0f)
|
if ((wheel_x == 0.0f && wheel_y == 0.0f) || !AppAcceptingEvents)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImGuiInputEvent e;
|
ImGuiInputEvent e;
|
||||||
|
8
imgui.h
8
imgui.h
@ -65,7 +65,7 @@ Index of this file:
|
|||||||
// Version
|
// Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
||||||
#define IMGUI_VERSION "1.88 WIP"
|
#define IMGUI_VERSION "1.88 WIP"
|
||||||
#define IMGUI_VERSION_NUM 18725
|
#define IMGUI_VERSION_NUM 18726
|
||||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
||||||
#define IMGUI_HAS_TABLE
|
#define IMGUI_HAS_TABLE
|
||||||
|
|
||||||
@ -1975,9 +1975,10 @@ struct ImGuiIO
|
|||||||
IMGUI_API void AddInputCharacterUTF16(ImWchar16 c); // Queue a new character input from an UTF-16 character, it can be a surrogate
|
IMGUI_API void AddInputCharacterUTF16(ImWchar16 c); // Queue a new character input from an UTF-16 character, it can be a surrogate
|
||||||
IMGUI_API void AddInputCharactersUTF8(const char* str); // Queue a new characters input from an UTF-8 string
|
IMGUI_API void AddInputCharactersUTF8(const char* str); // Queue a new characters input from an UTF-8 string
|
||||||
|
|
||||||
|
IMGUI_API void SetKeyEventNativeData(ImGuiKey key, int native_keycode, int native_scancode, int native_legacy_index = -1); // [Optional] Specify index for legacy <1.87 IsKeyXXX() functions with native indices + specify native keycode, scancode.
|
||||||
|
IMGUI_API void SetAppAcceptingEvents(bool accepting_events); // Set master flag for accepting key/mouse/text events (default to true). Useful if you have native dialog boxes that are interrupting your application loop/refresh, and you want to disable events being queued while your app is frozen.
|
||||||
IMGUI_API void ClearInputCharacters(); // [Internal] Clear the text input buffer manually
|
IMGUI_API void ClearInputCharacters(); // [Internal] Clear the text input buffer manually
|
||||||
IMGUI_API void ClearInputKeys(); // [Internal] Release all keys
|
IMGUI_API void ClearInputKeys(); // [Internal] Release all keys
|
||||||
IMGUI_API void SetKeyEventNativeData(ImGuiKey key, int native_keycode, int native_scancode, int native_legacy_index = -1); // [Optional] Specify index for legacy <1.87 IsKeyXXX() functions with native indices + specify native keycode, scancode.
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Output - Updated by NewFrame() or EndFrame()/Render()
|
// Output - Updated by NewFrame() or EndFrame()/Render()
|
||||||
@ -2044,7 +2045,8 @@ struct ImGuiIO
|
|||||||
float NavInputsDownDuration[ImGuiNavInput_COUNT];
|
float NavInputsDownDuration[ImGuiNavInput_COUNT];
|
||||||
float NavInputsDownDurationPrev[ImGuiNavInput_COUNT];
|
float NavInputsDownDurationPrev[ImGuiNavInput_COUNT];
|
||||||
float PenPressure; // Touch/Pen pressure (0.0f to 1.0f, should be >0.0f only when MouseDown[0] == true). Helper storage currently unused by Dear ImGui.
|
float PenPressure; // Touch/Pen pressure (0.0f to 1.0f, should be >0.0f only when MouseDown[0] == true). Helper storage currently unused by Dear ImGui.
|
||||||
bool AppFocusLost;
|
bool AppFocusLost; // Only modify via AddFocusEvent()
|
||||||
|
bool AppAcceptingEvents; // Only modify via SetAppAcceptingEvents()
|
||||||
ImS8 BackendUsingLegacyKeyArrays; // -1: unknown, 0: using AddKeyEvent(), 1: using legacy io.KeysDown[]
|
ImS8 BackendUsingLegacyKeyArrays; // -1: unknown, 0: using AddKeyEvent(), 1: using legacy io.KeysDown[]
|
||||||
bool BackendUsingLegacyNavInputArray; // 0: using AddKeyAnalogEvent(), 1: writing to legacy io.NavInputs[] directly
|
bool BackendUsingLegacyNavInputArray; // 0: using AddKeyAnalogEvent(), 1: writing to legacy io.NavInputs[] directly
|
||||||
ImWchar16 InputQueueSurrogate; // For AddInputCharacterUTF16()
|
ImWchar16 InputQueueSurrogate; // For AddInputCharacterUTF16()
|
||||||
|
Loading…
Reference in New Issue
Block a user