mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-13 08:19:55 +02:00
Compare commits
99 Commits
Author | SHA1 | Date | |
---|---|---|---|
c71a50deb5 | |||
e52bb147a7 | |||
732bc2058e | |||
40fd163a3b | |||
2554b512c0 | |||
c6cab1f352 | |||
c39192ba64 | |||
43177324c0 | |||
6f73dbea80 | |||
35e197f413 | |||
551ab84c2d | |||
422902dbda | |||
64d910ad37 | |||
49e38a5b32 | |||
9def2b04d7 | |||
5429f0f6b5 | |||
c906c65cac | |||
718daa153d | |||
075f4ac661 | |||
8555335935 | |||
08f3aa8972 | |||
4caf1e9b59 | |||
b17b2fb732 | |||
cda3db1449 | |||
dd6a44abb1 | |||
4fb0c1f963 | |||
cff0342454 | |||
c2db4c2462 | |||
69b697378b | |||
26e59c8742 | |||
62d6be3747 | |||
5ea47d9560 | |||
39c3412f91 | |||
3d85433748 | |||
9f8c599ca7 | |||
f33bb99821 | |||
6e63fcaca3 | |||
ceb26bac48 | |||
29f104319e | |||
19471da3fd | |||
7ad42ff431 | |||
26d04c948f | |||
97b1ffcb3b | |||
91ae56af45 | |||
673f5e588d | |||
90a6961638 | |||
7374b96f5c | |||
b8e56dce83 | |||
b6582a471a | |||
92c4ff1c2f | |||
0755767440 | |||
eb823655af | |||
f84c93d834 | |||
45c4365ec3 | |||
6188e94108 | |||
553b04883e | |||
9551635684 | |||
200a8f1ea2 | |||
98ce013242 | |||
bf4de2a46b | |||
7f8a89c25c | |||
457d4b7b72 | |||
290c51735e | |||
0818a42396 | |||
96186a93b9 | |||
956e03009a | |||
e8172fdfbc | |||
b2e2cc44c2 | |||
790132a672 | |||
1797135db5 | |||
ee436aa803 | |||
da1864d79e | |||
1bfe4a75be | |||
fe646ea591 | |||
ecd212c01d | |||
746c9f76e4 | |||
bf08c13e9b | |||
3b66929301 | |||
afffcd5810 | |||
100ede5764 | |||
4d023bd7fe | |||
de36ff043e | |||
29a8ee0826 | |||
1cbfe93520 | |||
2706c9d66e | |||
3a90dc3893 | |||
04bc0b0bb8 | |||
28eabcb099 | |||
206b9ead8f | |||
c5a3cae83a | |||
efa50f72a7 | |||
b0a6cd6305 | |||
2402958aec | |||
92d7869fc7 | |||
83d22f4e48 | |||
41e39ea6e1 | |||
dbeea7220f | |||
89a28209e8 | |||
980deb4c9e |
12
.github/workflows/build.yml
vendored
12
.github/workflows/build.yml
vendored
@ -301,6 +301,18 @@ jobs:
|
|||||||
EOF
|
EOF
|
||||||
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
|
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
|
||||||
|
|
||||||
|
- name: Build example_null (with IMGUI_DISABLE_OBSOLETE_KEYIO)
|
||||||
|
run: |
|
||||||
|
cat > example_single_file.cpp <<'EOF'
|
||||||
|
|
||||||
|
#define IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||||
|
#define IMGUI_IMPLEMENTATION
|
||||||
|
#include "misc/single_file/imgui_single_file.h"
|
||||||
|
#include "examples/example_null/main.cpp"
|
||||||
|
|
||||||
|
EOF
|
||||||
|
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
|
||||||
|
|
||||||
- name: Build example_null (with IMGUI_DISABLE_DEMO_WINDOWS and IMGUI_DISABLE_METRICS_WINDOW)
|
- name: Build example_null (with IMGUI_DISABLE_DEMO_WINDOWS and IMGUI_DISABLE_METRICS_WINDOW)
|
||||||
run: |
|
run: |
|
||||||
cat > example_single_file.cpp <<'EOF'
|
cat > example_single_file.cpp <<'EOF'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2014-2021 Omar Cornut
|
Copyright (c) 2014-2022 Omar Cornut
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Clipboard support (from Allegro 5.1.12)
|
// [X] Platform: Clipboard support (from Allegro 5.1.12)
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// Issues:
|
// Issues:
|
||||||
@ -16,6 +17,10 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago)with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
||||||
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
|
// 2022-01-17: Inputs: always calling io.AddKeyModsEvent() next and before key event (not in NewFrame) to fix input queue with very low framerates.
|
||||||
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
// 2021-12-08: Renderer: Fixed mishandling of the the ImDrawCmd::IdxOffset field! This is an old bug but it never had an effect until some internal rendering changes in 1.86.
|
// 2021-12-08: Renderer: Fixed mishandling of the the ImDrawCmd::IdxOffset field! This is an old bug but it never had an effect until some internal rendering changes in 1.86.
|
||||||
// 2021-08-17: Calling io.AddFocusEvent() on ALLEGRO_EVENT_DISPLAY_SWITCH_OUT/ALLEGRO_EVENT_DISPLAY_SWITCH_IN events.
|
// 2021-08-17: Calling io.AddFocusEvent() on ALLEGRO_EVENT_DISPLAY_SWITCH_OUT/ALLEGRO_EVENT_DISPLAY_SWITCH_IN events.
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
@ -274,6 +279,119 @@ static void ImGui_ImplAllegro5_SetClipboardText(void*, const char* text)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static ImGuiKey ImGui_ImplAllegro5_KeyCodeToImGuiKey(int key_code)
|
||||||
|
{
|
||||||
|
switch (key_code)
|
||||||
|
{
|
||||||
|
case ALLEGRO_KEY_TAB: return ImGuiKey_Tab;
|
||||||
|
case ALLEGRO_KEY_LEFT: return ImGuiKey_LeftArrow;
|
||||||
|
case ALLEGRO_KEY_RIGHT: return ImGuiKey_RightArrow;
|
||||||
|
case ALLEGRO_KEY_UP: return ImGuiKey_UpArrow;
|
||||||
|
case ALLEGRO_KEY_DOWN: return ImGuiKey_DownArrow;
|
||||||
|
case ALLEGRO_KEY_PGUP: return ImGuiKey_PageUp;
|
||||||
|
case ALLEGRO_KEY_PGDN: return ImGuiKey_PageDown;
|
||||||
|
case ALLEGRO_KEY_HOME: return ImGuiKey_Home;
|
||||||
|
case ALLEGRO_KEY_END: return ImGuiKey_End;
|
||||||
|
case ALLEGRO_KEY_INSERT: return ImGuiKey_Insert;
|
||||||
|
case ALLEGRO_KEY_DELETE: return ImGuiKey_Delete;
|
||||||
|
case ALLEGRO_KEY_BACKSPACE: return ImGuiKey_Backspace;
|
||||||
|
case ALLEGRO_KEY_SPACE: return ImGuiKey_Space;
|
||||||
|
case ALLEGRO_KEY_ENTER: return ImGuiKey_Enter;
|
||||||
|
case ALLEGRO_KEY_ESCAPE: return ImGuiKey_Escape;
|
||||||
|
case ALLEGRO_KEY_QUOTE: return ImGuiKey_Apostrophe;
|
||||||
|
case ALLEGRO_KEY_COMMA: return ImGuiKey_Comma;
|
||||||
|
case ALLEGRO_KEY_MINUS: return ImGuiKey_Minus;
|
||||||
|
case ALLEGRO_KEY_FULLSTOP: return ImGuiKey_Period;
|
||||||
|
case ALLEGRO_KEY_SLASH: return ImGuiKey_Slash;
|
||||||
|
case ALLEGRO_KEY_SEMICOLON: return ImGuiKey_Semicolon;
|
||||||
|
case ALLEGRO_KEY_EQUALS: return ImGuiKey_Equal;
|
||||||
|
case ALLEGRO_KEY_OPENBRACE: return ImGuiKey_LeftBracket;
|
||||||
|
case ALLEGRO_KEY_BACKSLASH: return ImGuiKey_Backslash;
|
||||||
|
case ALLEGRO_KEY_CLOSEBRACE: return ImGuiKey_RightBracket;
|
||||||
|
case ALLEGRO_KEY_TILDE: return ImGuiKey_GraveAccent;
|
||||||
|
case ALLEGRO_KEY_CAPSLOCK: return ImGuiKey_CapsLock;
|
||||||
|
case ALLEGRO_KEY_SCROLLLOCK: return ImGuiKey_ScrollLock;
|
||||||
|
case ALLEGRO_KEY_NUMLOCK: return ImGuiKey_NumLock;
|
||||||
|
case ALLEGRO_KEY_PRINTSCREEN: return ImGuiKey_PrintScreen;
|
||||||
|
case ALLEGRO_KEY_PAUSE: return ImGuiKey_Pause;
|
||||||
|
case ALLEGRO_KEY_PAD_0: return ImGuiKey_Keypad0;
|
||||||
|
case ALLEGRO_KEY_PAD_1: return ImGuiKey_Keypad1;
|
||||||
|
case ALLEGRO_KEY_PAD_2: return ImGuiKey_Keypad2;
|
||||||
|
case ALLEGRO_KEY_PAD_3: return ImGuiKey_Keypad3;
|
||||||
|
case ALLEGRO_KEY_PAD_4: return ImGuiKey_Keypad4;
|
||||||
|
case ALLEGRO_KEY_PAD_5: return ImGuiKey_Keypad5;
|
||||||
|
case ALLEGRO_KEY_PAD_6: return ImGuiKey_Keypad6;
|
||||||
|
case ALLEGRO_KEY_PAD_7: return ImGuiKey_Keypad7;
|
||||||
|
case ALLEGRO_KEY_PAD_8: return ImGuiKey_Keypad8;
|
||||||
|
case ALLEGRO_KEY_PAD_9: return ImGuiKey_Keypad9;
|
||||||
|
case ALLEGRO_KEY_PAD_DELETE: return ImGuiKey_KeypadDecimal;
|
||||||
|
case ALLEGRO_KEY_PAD_SLASH: return ImGuiKey_KeypadDivide;
|
||||||
|
case ALLEGRO_KEY_PAD_ASTERISK: return ImGuiKey_KeypadMultiply;
|
||||||
|
case ALLEGRO_KEY_PAD_MINUS: return ImGuiKey_KeypadSubtract;
|
||||||
|
case ALLEGRO_KEY_PAD_PLUS: return ImGuiKey_KeypadAdd;
|
||||||
|
case ALLEGRO_KEY_PAD_ENTER: return ImGuiKey_KeypadEnter;
|
||||||
|
case ALLEGRO_KEY_PAD_EQUALS: return ImGuiKey_KeypadEqual;
|
||||||
|
case ALLEGRO_KEY_LCTRL: return ImGuiKey_LeftCtrl;
|
||||||
|
case ALLEGRO_KEY_LSHIFT: return ImGuiKey_LeftShift;
|
||||||
|
case ALLEGRO_KEY_ALT: return ImGuiKey_LeftAlt;
|
||||||
|
case ALLEGRO_KEY_LWIN: return ImGuiKey_LeftSuper;
|
||||||
|
case ALLEGRO_KEY_RCTRL: return ImGuiKey_RightCtrl;
|
||||||
|
case ALLEGRO_KEY_RSHIFT: return ImGuiKey_RightShift;
|
||||||
|
case ALLEGRO_KEY_ALTGR: return ImGuiKey_RightAlt;
|
||||||
|
case ALLEGRO_KEY_RWIN: return ImGuiKey_RightSuper;
|
||||||
|
case ALLEGRO_KEY_MENU: return ImGuiKey_Menu;
|
||||||
|
case ALLEGRO_KEY_0: return ImGuiKey_0;
|
||||||
|
case ALLEGRO_KEY_1: return ImGuiKey_1;
|
||||||
|
case ALLEGRO_KEY_2: return ImGuiKey_2;
|
||||||
|
case ALLEGRO_KEY_3: return ImGuiKey_3;
|
||||||
|
case ALLEGRO_KEY_4: return ImGuiKey_4;
|
||||||
|
case ALLEGRO_KEY_5: return ImGuiKey_5;
|
||||||
|
case ALLEGRO_KEY_6: return ImGuiKey_6;
|
||||||
|
case ALLEGRO_KEY_7: return ImGuiKey_7;
|
||||||
|
case ALLEGRO_KEY_8: return ImGuiKey_8;
|
||||||
|
case ALLEGRO_KEY_9: return ImGuiKey_9;
|
||||||
|
case ALLEGRO_KEY_A: return ImGuiKey_A;
|
||||||
|
case ALLEGRO_KEY_B: return ImGuiKey_B;
|
||||||
|
case ALLEGRO_KEY_C: return ImGuiKey_C;
|
||||||
|
case ALLEGRO_KEY_D: return ImGuiKey_D;
|
||||||
|
case ALLEGRO_KEY_E: return ImGuiKey_E;
|
||||||
|
case ALLEGRO_KEY_F: return ImGuiKey_F;
|
||||||
|
case ALLEGRO_KEY_G: return ImGuiKey_G;
|
||||||
|
case ALLEGRO_KEY_H: return ImGuiKey_H;
|
||||||
|
case ALLEGRO_KEY_I: return ImGuiKey_I;
|
||||||
|
case ALLEGRO_KEY_J: return ImGuiKey_J;
|
||||||
|
case ALLEGRO_KEY_K: return ImGuiKey_K;
|
||||||
|
case ALLEGRO_KEY_L: return ImGuiKey_L;
|
||||||
|
case ALLEGRO_KEY_M: return ImGuiKey_M;
|
||||||
|
case ALLEGRO_KEY_N: return ImGuiKey_N;
|
||||||
|
case ALLEGRO_KEY_O: return ImGuiKey_O;
|
||||||
|
case ALLEGRO_KEY_P: return ImGuiKey_P;
|
||||||
|
case ALLEGRO_KEY_Q: return ImGuiKey_Q;
|
||||||
|
case ALLEGRO_KEY_R: return ImGuiKey_R;
|
||||||
|
case ALLEGRO_KEY_S: return ImGuiKey_S;
|
||||||
|
case ALLEGRO_KEY_T: return ImGuiKey_T;
|
||||||
|
case ALLEGRO_KEY_U: return ImGuiKey_U;
|
||||||
|
case ALLEGRO_KEY_V: return ImGuiKey_V;
|
||||||
|
case ALLEGRO_KEY_W: return ImGuiKey_W;
|
||||||
|
case ALLEGRO_KEY_X: return ImGuiKey_X;
|
||||||
|
case ALLEGRO_KEY_Y: return ImGuiKey_Y;
|
||||||
|
case ALLEGRO_KEY_Z: return ImGuiKey_Z;
|
||||||
|
case ALLEGRO_KEY_F1: return ImGuiKey_F1;
|
||||||
|
case ALLEGRO_KEY_F2: return ImGuiKey_F2;
|
||||||
|
case ALLEGRO_KEY_F3: return ImGuiKey_F3;
|
||||||
|
case ALLEGRO_KEY_F4: return ImGuiKey_F4;
|
||||||
|
case ALLEGRO_KEY_F5: return ImGuiKey_F5;
|
||||||
|
case ALLEGRO_KEY_F6: return ImGuiKey_F6;
|
||||||
|
case ALLEGRO_KEY_F7: return ImGuiKey_F7;
|
||||||
|
case ALLEGRO_KEY_F8: return ImGuiKey_F8;
|
||||||
|
case ALLEGRO_KEY_F9: return ImGuiKey_F9;
|
||||||
|
case ALLEGRO_KEY_F10: return ImGuiKey_F10;
|
||||||
|
case ALLEGRO_KEY_F11: return ImGuiKey_F11;
|
||||||
|
case ALLEGRO_KEY_F12: return ImGuiKey_F12;
|
||||||
|
default: return ImGuiKey_None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
|
bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@ -299,30 +417,6 @@ bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
|
|||||||
};
|
};
|
||||||
bd->VertexDecl = al_create_vertex_decl(elems, sizeof(ImDrawVertAllegro));
|
bd->VertexDecl = al_create_vertex_decl(elems, sizeof(ImDrawVertAllegro));
|
||||||
|
|
||||||
io.KeyMap[ImGuiKey_Tab] = ALLEGRO_KEY_TAB;
|
|
||||||
io.KeyMap[ImGuiKey_LeftArrow] = ALLEGRO_KEY_LEFT;
|
|
||||||
io.KeyMap[ImGuiKey_RightArrow] = ALLEGRO_KEY_RIGHT;
|
|
||||||
io.KeyMap[ImGuiKey_UpArrow] = ALLEGRO_KEY_UP;
|
|
||||||
io.KeyMap[ImGuiKey_DownArrow] = ALLEGRO_KEY_DOWN;
|
|
||||||
io.KeyMap[ImGuiKey_PageUp] = ALLEGRO_KEY_PGUP;
|
|
||||||
io.KeyMap[ImGuiKey_PageDown] = ALLEGRO_KEY_PGDN;
|
|
||||||
io.KeyMap[ImGuiKey_Home] = ALLEGRO_KEY_HOME;
|
|
||||||
io.KeyMap[ImGuiKey_End] = ALLEGRO_KEY_END;
|
|
||||||
io.KeyMap[ImGuiKey_Insert] = ALLEGRO_KEY_INSERT;
|
|
||||||
io.KeyMap[ImGuiKey_Delete] = ALLEGRO_KEY_DELETE;
|
|
||||||
io.KeyMap[ImGuiKey_Backspace] = ALLEGRO_KEY_BACKSPACE;
|
|
||||||
io.KeyMap[ImGuiKey_Space] = ALLEGRO_KEY_SPACE;
|
|
||||||
io.KeyMap[ImGuiKey_Enter] = ALLEGRO_KEY_ENTER;
|
|
||||||
io.KeyMap[ImGuiKey_Escape] = ALLEGRO_KEY_ESCAPE;
|
|
||||||
io.KeyMap[ImGuiKey_KeyPadEnter] = ALLEGRO_KEY_PAD_ENTER;
|
|
||||||
io.KeyMap[ImGuiKey_A] = ALLEGRO_KEY_A;
|
|
||||||
io.KeyMap[ImGuiKey_C] = ALLEGRO_KEY_C;
|
|
||||||
io.KeyMap[ImGuiKey_V] = ALLEGRO_KEY_V;
|
|
||||||
io.KeyMap[ImGuiKey_X] = ALLEGRO_KEY_X;
|
|
||||||
io.KeyMap[ImGuiKey_Y] = ALLEGRO_KEY_Y;
|
|
||||||
io.KeyMap[ImGuiKey_Z] = ALLEGRO_KEY_Z;
|
|
||||||
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
|
||||||
|
|
||||||
#if ALLEGRO_HAS_CLIPBOARD
|
#if ALLEGRO_HAS_CLIPBOARD
|
||||||
io.SetClipboardTextFn = ImGui_ImplAllegro5_SetClipboardText;
|
io.SetClipboardTextFn = ImGui_ImplAllegro5_SetClipboardText;
|
||||||
io.GetClipboardTextFn = ImGui_ImplAllegro5_GetClipboardText;
|
io.GetClipboardTextFn = ImGui_ImplAllegro5_GetClipboardText;
|
||||||
@ -349,6 +443,18 @@ void ImGui_ImplAllegro5_Shutdown()
|
|||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ev->keyboard.modifiers seems always zero so using that...
|
||||||
|
static void ImGui_ImplAllegro5_UpdateKeyModifiers()
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ALLEGRO_KEYBOARD_STATE keys;
|
||||||
|
al_get_keyboard_state(&keys);
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModCtrl, al_key_down(&keys, ALLEGRO_KEY_LCTRL) || al_key_down(&keys, ALLEGRO_KEY_RCTRL));
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModShift, al_key_down(&keys, ALLEGRO_KEY_LSHIFT) || al_key_down(&keys, ALLEGRO_KEY_RSHIFT));
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModAlt, al_key_down(&keys, ALLEGRO_KEY_ALT) || al_key_down(&keys, ALLEGRO_KEY_ALTGR));
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModSuper, al_key_down(&keys, ALLEGRO_KEY_LWIN) || al_key_down(&keys, ALLEGRO_KEY_RWIN));
|
||||||
|
}
|
||||||
|
|
||||||
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||||
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||||
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
||||||
@ -363,29 +469,28 @@ bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT* ev)
|
|||||||
case ALLEGRO_EVENT_MOUSE_AXES:
|
case ALLEGRO_EVENT_MOUSE_AXES:
|
||||||
if (ev->mouse.display == bd->Display)
|
if (ev->mouse.display == bd->Display)
|
||||||
{
|
{
|
||||||
io.MouseWheel += ev->mouse.dz;
|
io.AddMousePosEvent(ev->mouse.x, ev->mouse.y);
|
||||||
io.MouseWheelH -= ev->mouse.dw;
|
io.AddMouseWheelEvent(-ev->mouse.dw, ev->mouse.dz);
|
||||||
io.MousePos = ImVec2(ev->mouse.x, ev->mouse.y);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case ALLEGRO_EVENT_MOUSE_BUTTON_DOWN:
|
case ALLEGRO_EVENT_MOUSE_BUTTON_DOWN:
|
||||||
case ALLEGRO_EVENT_MOUSE_BUTTON_UP:
|
case ALLEGRO_EVENT_MOUSE_BUTTON_UP:
|
||||||
if (ev->mouse.display == bd->Display && ev->mouse.button <= 5)
|
if (ev->mouse.display == bd->Display && ev->mouse.button > 0 && ev->mouse.button <= 5)
|
||||||
io.MouseDown[ev->mouse.button - 1] = (ev->type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN);
|
io.AddMouseButtonEvent(ev->mouse.button - 1, ev->type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN);
|
||||||
return true;
|
return true;
|
||||||
case ALLEGRO_EVENT_TOUCH_MOVE:
|
case ALLEGRO_EVENT_TOUCH_MOVE:
|
||||||
if (ev->touch.display == bd->Display)
|
if (ev->touch.display == bd->Display)
|
||||||
io.MousePos = ImVec2(ev->touch.x, ev->touch.y);
|
io.AddMousePosEvent(ev->touch.x, ev->touch.y);
|
||||||
return true;
|
return true;
|
||||||
case ALLEGRO_EVENT_TOUCH_BEGIN:
|
case ALLEGRO_EVENT_TOUCH_BEGIN:
|
||||||
case ALLEGRO_EVENT_TOUCH_END:
|
case ALLEGRO_EVENT_TOUCH_END:
|
||||||
case ALLEGRO_EVENT_TOUCH_CANCEL:
|
case ALLEGRO_EVENT_TOUCH_CANCEL:
|
||||||
if (ev->touch.display == bd->Display && ev->touch.primary)
|
if (ev->touch.display == bd->Display && ev->touch.primary)
|
||||||
io.MouseDown[0] = (ev->type == ALLEGRO_EVENT_TOUCH_BEGIN);
|
io.AddMouseButtonEvent(0, ev->type == ALLEGRO_EVENT_TOUCH_BEGIN);
|
||||||
return true;
|
return true;
|
||||||
case ALLEGRO_EVENT_MOUSE_LEAVE_DISPLAY:
|
case ALLEGRO_EVENT_MOUSE_LEAVE_DISPLAY:
|
||||||
if (ev->mouse.display == bd->Display)
|
if (ev->mouse.display == bd->Display)
|
||||||
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
||||||
return true;
|
return true;
|
||||||
case ALLEGRO_EVENT_KEY_CHAR:
|
case ALLEGRO_EVENT_KEY_CHAR:
|
||||||
if (ev->keyboard.display == bd->Display)
|
if (ev->keyboard.display == bd->Display)
|
||||||
@ -395,7 +500,12 @@ bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT* ev)
|
|||||||
case ALLEGRO_EVENT_KEY_DOWN:
|
case ALLEGRO_EVENT_KEY_DOWN:
|
||||||
case ALLEGRO_EVENT_KEY_UP:
|
case ALLEGRO_EVENT_KEY_UP:
|
||||||
if (ev->keyboard.display == bd->Display)
|
if (ev->keyboard.display == bd->Display)
|
||||||
io.KeysDown[ev->keyboard.keycode] = (ev->type == ALLEGRO_EVENT_KEY_DOWN);
|
{
|
||||||
|
ImGui_ImplAllegro5_UpdateKeyModifiers();
|
||||||
|
ImGuiKey key = ImGui_ImplAllegro5_KeyCodeToImGuiKey(ev->keyboard.keycode);
|
||||||
|
io.AddKeyEvent(key, (ev->type == ALLEGRO_EVENT_KEY_DOWN));
|
||||||
|
io.SetKeyEventNativeData(key, ev->keyboard.keycode, -1); // To support legacy indexing (<1.87 user code)
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
case ALLEGRO_EVENT_DISPLAY_SWITCH_OUT:
|
case ALLEGRO_EVENT_DISPLAY_SWITCH_OUT:
|
||||||
if (ev->display.source == bd->Display)
|
if (ev->display.source == bd->Display)
|
||||||
@ -465,13 +575,6 @@ void ImGui_ImplAllegro5_NewFrame()
|
|||||||
io.DeltaTime = bd->Time > 0.0 ? (float)(current_time - bd->Time) : (float)(1.0f / 60.0f);
|
io.DeltaTime = bd->Time > 0.0 ? (float)(current_time - bd->Time) : (float)(1.0f / 60.0f);
|
||||||
bd->Time = current_time;
|
bd->Time = current_time;
|
||||||
|
|
||||||
// Setup inputs
|
// Setup mouse cursor shape
|
||||||
ALLEGRO_KEYBOARD_STATE keys;
|
|
||||||
al_get_keyboard_state(&keys);
|
|
||||||
io.KeyCtrl = al_key_down(&keys, ALLEGRO_KEY_LCTRL) || al_key_down(&keys, ALLEGRO_KEY_RCTRL);
|
|
||||||
io.KeyShift = al_key_down(&keys, ALLEGRO_KEY_LSHIFT) || al_key_down(&keys, ALLEGRO_KEY_RSHIFT);
|
|
||||||
io.KeyAlt = al_key_down(&keys, ALLEGRO_KEY_ALT) || al_key_down(&keys, ALLEGRO_KEY_ALTGR);
|
|
||||||
io.KeySuper = al_key_down(&keys, ALLEGRO_KEY_LWIN) || al_key_down(&keys, ALLEGRO_KEY_RWIN);
|
|
||||||
|
|
||||||
ImGui_ImplAllegro5_UpdateMouseCursor();
|
ImGui_ImplAllegro5_UpdateMouseCursor();
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,14 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Clipboard support (from Allegro 5.1.12)
|
// [X] Platform: Clipboard support (from Allegro 5.1.12)
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// Issues:
|
// Issues:
|
||||||
// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually.
|
// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually.
|
||||||
// [ ] Platform: Missing gamepad support.
|
// [ ] Platform: Missing gamepad support.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
@ -2,29 +2,31 @@
|
|||||||
// This needs to be used along with the OpenGL 3 Renderer (imgui_impl_opengl3)
|
// This needs to be used along with the OpenGL 3 Renderer (imgui_impl_opengl3)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Keyboard arrays indexed using AKEYCODE_* codes, e.g. ImGui::IsKeyPressed(AKEYCODE_SPACE).
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy AKEYCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// Missing features:
|
// Missing features:
|
||||||
// [ ] Platform: Clipboard support.
|
// [ ] Platform: Clipboard support.
|
||||||
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
|
// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
|
||||||
// Important:
|
// Important:
|
||||||
|
// - Consider using SDL or GLFW backend on Android, which will be more full-featured than this.
|
||||||
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)
|
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)
|
||||||
// - FIXME: Unicode character inputs needs to be passed by Dear ImGui by the application (see examples/ and issue #3446)
|
// - FIXME: Unicode character inputs needs to be passed by Dear ImGui by the application (see examples/ and issue #3446)
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago)with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
||||||
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
// 2021-03-04: Initial version.
|
// 2021-03-04: Initial version.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_android.h"
|
#include "imgui_impl_android.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <map>
|
|
||||||
#include <queue>
|
|
||||||
#include <android/native_window.h>
|
#include <android/native_window.h>
|
||||||
#include <android/input.h>
|
#include <android/input.h>
|
||||||
#include <android/keycodes.h>
|
#include <android/keycodes.h>
|
||||||
@ -34,7 +36,119 @@
|
|||||||
static double g_Time = 0.0;
|
static double g_Time = 0.0;
|
||||||
static ANativeWindow* g_Window;
|
static ANativeWindow* g_Window;
|
||||||
static char g_LogTag[] = "ImGuiExample";
|
static char g_LogTag[] = "ImGuiExample";
|
||||||
static std::map<int32_t, std::queue<int32_t>> g_KeyEventQueues; // FIXME: Remove dependency on map and queue once we use upcoming input queue.
|
|
||||||
|
static ImGuiKey ImGui_ImplAndroid_KeyCodeToImGuiKey(int32_t key_code)
|
||||||
|
{
|
||||||
|
switch (key_code)
|
||||||
|
{
|
||||||
|
case AKEYCODE_TAB: return ImGuiKey_Tab;
|
||||||
|
case AKEYCODE_DPAD_LEFT: return ImGuiKey_LeftArrow;
|
||||||
|
case AKEYCODE_DPAD_RIGHT: return ImGuiKey_RightArrow;
|
||||||
|
case AKEYCODE_DPAD_UP: return ImGuiKey_UpArrow;
|
||||||
|
case AKEYCODE_DPAD_DOWN: return ImGuiKey_DownArrow;
|
||||||
|
case AKEYCODE_PAGE_UP: return ImGuiKey_PageUp;
|
||||||
|
case AKEYCODE_PAGE_DOWN: return ImGuiKey_PageDown;
|
||||||
|
case AKEYCODE_MOVE_HOME: return ImGuiKey_Home;
|
||||||
|
case AKEYCODE_MOVE_END: return ImGuiKey_End;
|
||||||
|
case AKEYCODE_INSERT: return ImGuiKey_Insert;
|
||||||
|
case AKEYCODE_FORWARD_DEL: return ImGuiKey_Delete;
|
||||||
|
case AKEYCODE_DEL: return ImGuiKey_Backspace;
|
||||||
|
case AKEYCODE_SPACE: return ImGuiKey_Space;
|
||||||
|
case AKEYCODE_ENTER: return ImGuiKey_Enter;
|
||||||
|
case AKEYCODE_ESCAPE: return ImGuiKey_Escape;
|
||||||
|
case AKEYCODE_APOSTROPHE: return ImGuiKey_Apostrophe;
|
||||||
|
case AKEYCODE_COMMA: return ImGuiKey_Comma;
|
||||||
|
case AKEYCODE_MINUS: return ImGuiKey_Minus;
|
||||||
|
case AKEYCODE_PERIOD: return ImGuiKey_Period;
|
||||||
|
case AKEYCODE_SLASH: return ImGuiKey_Slash;
|
||||||
|
case AKEYCODE_SEMICOLON: return ImGuiKey_Semicolon;
|
||||||
|
case AKEYCODE_EQUALS: return ImGuiKey_Equal;
|
||||||
|
case AKEYCODE_LEFT_BRACKET: return ImGuiKey_LeftBracket;
|
||||||
|
case AKEYCODE_BACKSLASH: return ImGuiKey_Backslash;
|
||||||
|
case AKEYCODE_RIGHT_BRACKET: return ImGuiKey_RightBracket;
|
||||||
|
case AKEYCODE_GRAVE: return ImGuiKey_GraveAccent;
|
||||||
|
case AKEYCODE_CAPS_LOCK: return ImGuiKey_CapsLock;
|
||||||
|
case AKEYCODE_SCROLL_LOCK: return ImGuiKey_ScrollLock;
|
||||||
|
case AKEYCODE_NUM_LOCK: return ImGuiKey_NumLock;
|
||||||
|
case AKEYCODE_SYSRQ: return ImGuiKey_PrintScreen;
|
||||||
|
case AKEYCODE_BREAK: return ImGuiKey_Pause;
|
||||||
|
case AKEYCODE_NUMPAD_0: return ImGuiKey_Keypad0;
|
||||||
|
case AKEYCODE_NUMPAD_1: return ImGuiKey_Keypad1;
|
||||||
|
case AKEYCODE_NUMPAD_2: return ImGuiKey_Keypad2;
|
||||||
|
case AKEYCODE_NUMPAD_3: return ImGuiKey_Keypad3;
|
||||||
|
case AKEYCODE_NUMPAD_4: return ImGuiKey_Keypad4;
|
||||||
|
case AKEYCODE_NUMPAD_5: return ImGuiKey_Keypad5;
|
||||||
|
case AKEYCODE_NUMPAD_6: return ImGuiKey_Keypad6;
|
||||||
|
case AKEYCODE_NUMPAD_7: return ImGuiKey_Keypad7;
|
||||||
|
case AKEYCODE_NUMPAD_8: return ImGuiKey_Keypad8;
|
||||||
|
case AKEYCODE_NUMPAD_9: return ImGuiKey_Keypad9;
|
||||||
|
case AKEYCODE_NUMPAD_DOT: return ImGuiKey_KeypadDecimal;
|
||||||
|
case AKEYCODE_NUMPAD_DIVIDE: return ImGuiKey_KeypadDivide;
|
||||||
|
case AKEYCODE_NUMPAD_MULTIPLY: return ImGuiKey_KeypadMultiply;
|
||||||
|
case AKEYCODE_NUMPAD_SUBTRACT: return ImGuiKey_KeypadSubtract;
|
||||||
|
case AKEYCODE_NUMPAD_ADD: return ImGuiKey_KeypadAdd;
|
||||||
|
case AKEYCODE_NUMPAD_ENTER: return ImGuiKey_KeypadEnter;
|
||||||
|
case AKEYCODE_NUMPAD_EQUALS: return ImGuiKey_KeypadEqual;
|
||||||
|
case AKEYCODE_CTRL_LEFT: return ImGuiKey_LeftCtrl;
|
||||||
|
case AKEYCODE_SHIFT_LEFT: return ImGuiKey_LeftShift;
|
||||||
|
case AKEYCODE_ALT_LEFT: return ImGuiKey_LeftAlt;
|
||||||
|
case AKEYCODE_META_LEFT: return ImGuiKey_LeftSuper;
|
||||||
|
case AKEYCODE_CTRL_RIGHT: return ImGuiKey_RightCtrl;
|
||||||
|
case AKEYCODE_SHIFT_RIGHT: return ImGuiKey_RightShift;
|
||||||
|
case AKEYCODE_ALT_RIGHT: return ImGuiKey_RightAlt;
|
||||||
|
case AKEYCODE_META_RIGHT: return ImGuiKey_RightSuper;
|
||||||
|
case AKEYCODE_MENU: return ImGuiKey_Menu;
|
||||||
|
case AKEYCODE_0: return ImGuiKey_0;
|
||||||
|
case AKEYCODE_1: return ImGuiKey_1;
|
||||||
|
case AKEYCODE_2: return ImGuiKey_2;
|
||||||
|
case AKEYCODE_3: return ImGuiKey_3;
|
||||||
|
case AKEYCODE_4: return ImGuiKey_4;
|
||||||
|
case AKEYCODE_5: return ImGuiKey_5;
|
||||||
|
case AKEYCODE_6: return ImGuiKey_6;
|
||||||
|
case AKEYCODE_7: return ImGuiKey_7;
|
||||||
|
case AKEYCODE_8: return ImGuiKey_8;
|
||||||
|
case AKEYCODE_9: return ImGuiKey_9;
|
||||||
|
case AKEYCODE_A: return ImGuiKey_A;
|
||||||
|
case AKEYCODE_B: return ImGuiKey_B;
|
||||||
|
case AKEYCODE_C: return ImGuiKey_C;
|
||||||
|
case AKEYCODE_D: return ImGuiKey_D;
|
||||||
|
case AKEYCODE_E: return ImGuiKey_E;
|
||||||
|
case AKEYCODE_F: return ImGuiKey_F;
|
||||||
|
case AKEYCODE_G: return ImGuiKey_G;
|
||||||
|
case AKEYCODE_H: return ImGuiKey_H;
|
||||||
|
case AKEYCODE_I: return ImGuiKey_I;
|
||||||
|
case AKEYCODE_J: return ImGuiKey_J;
|
||||||
|
case AKEYCODE_K: return ImGuiKey_K;
|
||||||
|
case AKEYCODE_L: return ImGuiKey_L;
|
||||||
|
case AKEYCODE_M: return ImGuiKey_M;
|
||||||
|
case AKEYCODE_N: return ImGuiKey_N;
|
||||||
|
case AKEYCODE_O: return ImGuiKey_O;
|
||||||
|
case AKEYCODE_P: return ImGuiKey_P;
|
||||||
|
case AKEYCODE_Q: return ImGuiKey_Q;
|
||||||
|
case AKEYCODE_R: return ImGuiKey_R;
|
||||||
|
case AKEYCODE_S: return ImGuiKey_S;
|
||||||
|
case AKEYCODE_T: return ImGuiKey_T;
|
||||||
|
case AKEYCODE_U: return ImGuiKey_U;
|
||||||
|
case AKEYCODE_V: return ImGuiKey_V;
|
||||||
|
case AKEYCODE_W: return ImGuiKey_W;
|
||||||
|
case AKEYCODE_X: return ImGuiKey_X;
|
||||||
|
case AKEYCODE_Y: return ImGuiKey_Y;
|
||||||
|
case AKEYCODE_Z: return ImGuiKey_Z;
|
||||||
|
case AKEYCODE_F1: return ImGuiKey_F1;
|
||||||
|
case AKEYCODE_F2: return ImGuiKey_F2;
|
||||||
|
case AKEYCODE_F3: return ImGuiKey_F3;
|
||||||
|
case AKEYCODE_F4: return ImGuiKey_F4;
|
||||||
|
case AKEYCODE_F5: return ImGuiKey_F5;
|
||||||
|
case AKEYCODE_F6: return ImGuiKey_F6;
|
||||||
|
case AKEYCODE_F7: return ImGuiKey_F7;
|
||||||
|
case AKEYCODE_F8: return ImGuiKey_F8;
|
||||||
|
case AKEYCODE_F9: return ImGuiKey_F9;
|
||||||
|
case AKEYCODE_F10: return ImGuiKey_F10;
|
||||||
|
case AKEYCODE_F11: return ImGuiKey_F11;
|
||||||
|
case AKEYCODE_F12: return ImGuiKey_F12;
|
||||||
|
default: return ImGuiKey_None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event)
|
int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event)
|
||||||
{
|
{
|
||||||
@ -45,12 +159,14 @@ int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event)
|
|||||||
case AINPUT_EVENT_TYPE_KEY:
|
case AINPUT_EVENT_TYPE_KEY:
|
||||||
{
|
{
|
||||||
int32_t event_key_code = AKeyEvent_getKeyCode(input_event);
|
int32_t event_key_code = AKeyEvent_getKeyCode(input_event);
|
||||||
|
int32_t event_scan_code = AKeyEvent_getScanCode(input_event);
|
||||||
int32_t event_action = AKeyEvent_getAction(input_event);
|
int32_t event_action = AKeyEvent_getAction(input_event);
|
||||||
int32_t event_meta_state = AKeyEvent_getMetaState(input_event);
|
int32_t event_meta_state = AKeyEvent_getMetaState(input_event);
|
||||||
|
|
||||||
io.KeyCtrl = ((event_meta_state & AMETA_CTRL_ON) != 0);
|
io.AddKeyEvent(ImGuiKey_ModCtrl, (event_meta_state & AMETA_CTRL_ON) != 0);
|
||||||
io.KeyShift = ((event_meta_state & AMETA_SHIFT_ON) != 0);
|
io.AddKeyEvent(ImGuiKey_ModShift, (event_meta_state & AMETA_SHIFT_ON) != 0);
|
||||||
io.KeyAlt = ((event_meta_state & AMETA_ALT_ON) != 0);
|
io.AddKeyEvent(ImGuiKey_ModAlt, (event_meta_state & AMETA_ALT_ON) != 0);
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModSuper, (event_meta_state & AMETA_META_ON) != 0);
|
||||||
|
|
||||||
switch (event_action)
|
switch (event_action)
|
||||||
{
|
{
|
||||||
@ -59,8 +175,16 @@ int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event)
|
|||||||
// ImGui_ImplAndroid_NewFrame()...or consider using IO queue, if suitable: https://github.com/ocornut/imgui/issues/2787
|
// ImGui_ImplAndroid_NewFrame()...or consider using IO queue, if suitable: https://github.com/ocornut/imgui/issues/2787
|
||||||
case AKEY_EVENT_ACTION_DOWN:
|
case AKEY_EVENT_ACTION_DOWN:
|
||||||
case AKEY_EVENT_ACTION_UP:
|
case AKEY_EVENT_ACTION_UP:
|
||||||
g_KeyEventQueues[event_key_code].push(event_action);
|
{
|
||||||
|
ImGuiKey key = ImGui_ImplAndroid_KeyCodeToImGuiKey(event_key_code);
|
||||||
|
if (key != ImGuiKey_None && (event_action == AKEY_EVENT_ACTION_DOWN || event_action == AKEY_EVENT_ACTION_UP))
|
||||||
|
{
|
||||||
|
io.AddKeyEvent(key, event_action == AKEY_EVENT_ACTION_DOWN);
|
||||||
|
io.SetKeyEventNativeData(key, event_key_code, event_scan_code);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -81,26 +205,25 @@ int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event)
|
|||||||
if((AMotionEvent_getToolType(input_event, event_pointer_index) == AMOTION_EVENT_TOOL_TYPE_FINGER)
|
if((AMotionEvent_getToolType(input_event, event_pointer_index) == AMOTION_EVENT_TOOL_TYPE_FINGER)
|
||||||
|| (AMotionEvent_getToolType(input_event, event_pointer_index) == AMOTION_EVENT_TOOL_TYPE_UNKNOWN))
|
|| (AMotionEvent_getToolType(input_event, event_pointer_index) == AMOTION_EVENT_TOOL_TYPE_UNKNOWN))
|
||||||
{
|
{
|
||||||
io.MouseDown[0] = (event_action == AMOTION_EVENT_ACTION_DOWN);
|
io.AddMousePosEvent(AMotionEvent_getX(input_event, event_pointer_index), AMotionEvent_getY(input_event, event_pointer_index));
|
||||||
io.MousePos = ImVec2(AMotionEvent_getX(input_event, event_pointer_index), AMotionEvent_getY(input_event, event_pointer_index));
|
io.AddMouseButtonEvent(0, event_action == AMOTION_EVENT_ACTION_DOWN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AMOTION_EVENT_ACTION_BUTTON_PRESS:
|
case AMOTION_EVENT_ACTION_BUTTON_PRESS:
|
||||||
case AMOTION_EVENT_ACTION_BUTTON_RELEASE:
|
case AMOTION_EVENT_ACTION_BUTTON_RELEASE:
|
||||||
{
|
{
|
||||||
int32_t button_state = AMotionEvent_getButtonState(input_event);
|
int32_t button_state = AMotionEvent_getButtonState(input_event);
|
||||||
io.MouseDown[0] = ((button_state & AMOTION_EVENT_BUTTON_PRIMARY) != 0);
|
io.AddMouseButtonEvent(0, (button_state & AMOTION_EVENT_BUTTON_PRIMARY) != 0);
|
||||||
io.MouseDown[1] = ((button_state & AMOTION_EVENT_BUTTON_SECONDARY) != 0);
|
io.AddMouseButtonEvent(1, (button_state & AMOTION_EVENT_BUTTON_SECONDARY) != 0);
|
||||||
io.MouseDown[2] = ((button_state & AMOTION_EVENT_BUTTON_TERTIARY) != 0);
|
io.AddMouseButtonEvent(2, (button_state & AMOTION_EVENT_BUTTON_TERTIARY) != 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AMOTION_EVENT_ACTION_HOVER_MOVE: // Hovering: Tool moves while NOT pressed (such as a physical mouse)
|
case AMOTION_EVENT_ACTION_HOVER_MOVE: // Hovering: Tool moves while NOT pressed (such as a physical mouse)
|
||||||
case AMOTION_EVENT_ACTION_MOVE: // Touch pointer moves while DOWN
|
case AMOTION_EVENT_ACTION_MOVE: // Touch pointer moves while DOWN
|
||||||
io.MousePos = ImVec2(AMotionEvent_getX(input_event, event_pointer_index), AMotionEvent_getY(input_event, event_pointer_index));
|
io.AddMousePosEvent(AMotionEvent_getX(input_event, event_pointer_index), AMotionEvent_getY(input_event, event_pointer_index));
|
||||||
break;
|
break;
|
||||||
case AMOTION_EVENT_ACTION_SCROLL:
|
case AMOTION_EVENT_ACTION_SCROLL:
|
||||||
io.MouseWheel = AMotionEvent_getAxisValue(input_event, AMOTION_EVENT_AXIS_VSCROLL, event_pointer_index);
|
io.AddMouseWheelEvent(AMotionEvent_getAxisValue(input_event, AMOTION_EVENT_AXIS_HSCROLL, event_pointer_index), AMotionEvent_getAxisValue(input_event, AMOTION_EVENT_AXIS_VSCROLL, event_pointer_index));
|
||||||
io.MouseWheelH = AMotionEvent_getAxisValue(input_event, AMOTION_EVENT_AXIS_HSCROLL, event_pointer_index);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -123,30 +246,6 @@ bool ImGui_ImplAndroid_Init(ANativeWindow* window)
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.BackendPlatformName = "imgui_impl_android";
|
io.BackendPlatformName = "imgui_impl_android";
|
||||||
|
|
||||||
// Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeysDown[] array.
|
|
||||||
io.KeyMap[ImGuiKey_Tab] = AKEYCODE_TAB;
|
|
||||||
io.KeyMap[ImGuiKey_LeftArrow] = AKEYCODE_DPAD_LEFT; // also covers physical keyboard arrow key
|
|
||||||
io.KeyMap[ImGuiKey_RightArrow] = AKEYCODE_DPAD_RIGHT; // also covers physical keyboard arrow key
|
|
||||||
io.KeyMap[ImGuiKey_UpArrow] = AKEYCODE_DPAD_UP; // also covers physical keyboard arrow key
|
|
||||||
io.KeyMap[ImGuiKey_DownArrow] = AKEYCODE_DPAD_DOWN; // also covers physical keyboard arrow key
|
|
||||||
io.KeyMap[ImGuiKey_PageUp] = AKEYCODE_PAGE_UP;
|
|
||||||
io.KeyMap[ImGuiKey_PageDown] = AKEYCODE_PAGE_DOWN;
|
|
||||||
io.KeyMap[ImGuiKey_Home] = AKEYCODE_MOVE_HOME;
|
|
||||||
io.KeyMap[ImGuiKey_End] = AKEYCODE_MOVE_END;
|
|
||||||
io.KeyMap[ImGuiKey_Insert] = AKEYCODE_INSERT;
|
|
||||||
io.KeyMap[ImGuiKey_Delete] = AKEYCODE_FORWARD_DEL;
|
|
||||||
io.KeyMap[ImGuiKey_Backspace] = AKEYCODE_DEL;
|
|
||||||
io.KeyMap[ImGuiKey_Space] = AKEYCODE_SPACE;
|
|
||||||
io.KeyMap[ImGuiKey_Enter] = AKEYCODE_ENTER;
|
|
||||||
io.KeyMap[ImGuiKey_Escape] = AKEYCODE_ESCAPE;
|
|
||||||
io.KeyMap[ImGuiKey_KeyPadEnter] = AKEYCODE_NUMPAD_ENTER;
|
|
||||||
io.KeyMap[ImGuiKey_A] = AKEYCODE_A;
|
|
||||||
io.KeyMap[ImGuiKey_C] = AKEYCODE_C;
|
|
||||||
io.KeyMap[ImGuiKey_V] = AKEYCODE_V;
|
|
||||||
io.KeyMap[ImGuiKey_X] = AKEYCODE_X;
|
|
||||||
io.KeyMap[ImGuiKey_Y] = AKEYCODE_Y;
|
|
||||||
io.KeyMap[ImGuiKey_Z] = AKEYCODE_Z;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,16 +257,6 @@ void ImGui_ImplAndroid_NewFrame()
|
|||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
// Process queued key events
|
|
||||||
// FIXME: This is a workaround for multiple key event actions occurring at once (see above) and can be removed once we use upcoming input queue.
|
|
||||||
for (auto& key_queue : g_KeyEventQueues)
|
|
||||||
{
|
|
||||||
if (key_queue.second.empty())
|
|
||||||
continue;
|
|
||||||
io.KeysDown[key_queue.first] = (key_queue.second.front() == AKEY_EVENT_ACTION_DOWN);
|
|
||||||
key_queue.second.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup display size (every frame to accommodate for window resizing)
|
// Setup display size (every frame to accommodate for window resizing)
|
||||||
int32_t window_width = ANativeWindow_getWidth(g_Window);
|
int32_t window_width = ANativeWindow_getWidth(g_Window);
|
||||||
int32_t window_height = ANativeWindow_getHeight(g_Window);
|
int32_t window_height = ANativeWindow_getHeight(g_Window);
|
||||||
|
@ -2,16 +2,17 @@
|
|||||||
// This needs to be used along with the OpenGL 3 Renderer (imgui_impl_opengl3)
|
// This needs to be used along with the OpenGL 3 Renderer (imgui_impl_opengl3)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Keyboard arrays indexed using AKEYCODE_* codes, e.g. ImGui::IsKeyPressed(AKEYCODE_SPACE).
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy AKEYCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// Missing features:
|
// Missing features:
|
||||||
// [ ] Platform: Clipboard support.
|
// [ ] Platform: Clipboard support.
|
||||||
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
|
// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
|
||||||
// Important:
|
// Important:
|
||||||
|
// - Consider using SDL or GLFW backend on Android, which will be more full-featured than this.
|
||||||
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)
|
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)
|
||||||
// - FIXME: Unicode character inputs needs to be passed by Dear ImGui by the application (see examples/ and issue #3446)
|
// - FIXME: Unicode character inputs needs to be passed by Dear ImGui by the application (see examples/ and issue #3446)
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
@ -6,8 +6,7 @@
|
|||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||||
|
|
||||||
// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'.
|
// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'.
|
||||||
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
|
// See imgui_impl_dx12.cpp file for details.
|
||||||
// This define is set in the example .vcxproj file and need to be replicated in your app or by adding it to your imconfig.h file.
|
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Clipboard support.
|
// [X] Platform: Clipboard support.
|
||||||
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
|
||||||
// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE).
|
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -16,6 +16,14 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2022-02-07: Added ImGui_ImplGlfw_InstallCallbacks()/ImGui_ImplGlfw_RestoreCallbacks() helpers to facilitate user installing callbacks after iniitializing backend.
|
||||||
|
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago)with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
||||||
|
// 2021-01-20: Inputs: calling new io.AddKeyAnalogEvent() for gamepad support, instead of writing directly to io.NavInputs[].
|
||||||
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
|
// 2022-01-17: Inputs: always update key mods next and before key event (not in NewFrame) to fix input queue with very low framerates.
|
||||||
|
// 2022-01-12: *BREAKING CHANGE*: Now using glfwSetCursorPosCallback(). If you called ImGui_ImplGlfw_InitXXX() with install_callbacks = false, you MUST install glfwSetCursorPosCallback() and forward it to the backend via ImGui_ImplGlfw_CursorPosCallback().
|
||||||
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
|
// 2022-01-05: Inputs: Converting GLFW untranslated keycodes back to translated keycodes (in the ImGui_ImplGlfw_KeyCallback() function) in order to match the behavior of every other backend, and facilitate the use of GLFW with lettered-shortcuts API.
|
||||||
// 2021-08-17: *BREAKING CHANGE*: Now using glfwSetWindowFocusCallback() to calling io.AddFocusEvent(). If you called ImGui_ImplGlfw_InitXXX() with install_callbacks = false, you MUST install glfwSetWindowFocusCallback() and forward it to the backend via ImGui_ImplGlfw_WindowFocusCallback().
|
// 2021-08-17: *BREAKING CHANGE*: Now using glfwSetWindowFocusCallback() to calling io.AddFocusEvent(). If you called ImGui_ImplGlfw_InitXXX() with install_callbacks = false, you MUST install glfwSetWindowFocusCallback() and forward it to the backend via ImGui_ImplGlfw_WindowFocusCallback().
|
||||||
// 2021-07-29: *BREAKING CHANGE*: Now using glfwSetCursorEnterCallback(). MousePos is correctly reported when the host platform window is hovered but not focused. If you called ImGui_ImplGlfw_InitXXX() with install_callbacks = false, you MUST install glfwSetWindowFocusCallback() callback and forward it to the backend via ImGui_ImplGlfw_CursorEnterCallback().
|
// 2021-07-29: *BREAKING CHANGE*: Now using glfwSetCursorEnterCallback(). MousePos is correctly reported when the host platform window is hovered but not focused. If you called ImGui_ImplGlfw_InitXXX() with install_callbacks = false, you MUST install glfwSetWindowFocusCallback() callback and forward it to the backend via ImGui_ImplGlfw_CursorEnterCallback().
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
@ -44,6 +52,16 @@
|
|||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_glfw.h"
|
#include "imgui_impl_glfw.h"
|
||||||
|
|
||||||
|
// Clang warnings with -Weverything
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast
|
||||||
|
#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness
|
||||||
|
#if __has_warning("-Wzero-as-null-pointer-constant")
|
||||||
|
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// GLFW
|
// GLFW
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -51,16 +69,13 @@
|
|||||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||||
#include <GLFW/glfw3native.h> // for glfwGetWin32Window
|
#include <GLFW/glfw3native.h> // for glfwGetWin32Window
|
||||||
#endif
|
#endif
|
||||||
#define GLFW_HAS_WINDOW_TOPMOST (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ GLFW_FLOATING
|
|
||||||
#define GLFW_HAS_WINDOW_HOVERED (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ GLFW_HOVERED
|
|
||||||
#define GLFW_HAS_WINDOW_ALPHA (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwSetWindowOpacity
|
|
||||||
#define GLFW_HAS_PER_MONITOR_DPI (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwGetMonitorContentScale
|
|
||||||
#define GLFW_HAS_VULKAN (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ glfwCreateWindowSurface
|
|
||||||
#ifdef GLFW_RESIZE_NESW_CURSOR // Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2019-11-29 (cursors defines) // FIXME: Remove when GLFW 3.4 is released?
|
#ifdef GLFW_RESIZE_NESW_CURSOR // Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2019-11-29 (cursors defines) // FIXME: Remove when GLFW 3.4 is released?
|
||||||
#define GLFW_HAS_NEW_CURSORS (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3400) // 3.4+ GLFW_RESIZE_ALL_CURSOR, GLFW_RESIZE_NESW_CURSOR, GLFW_RESIZE_NWSE_CURSOR, GLFW_NOT_ALLOWED_CURSOR
|
#define GLFW_HAS_NEW_CURSORS (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3400) // 3.4+ GLFW_RESIZE_ALL_CURSOR, GLFW_RESIZE_NESW_CURSOR, GLFW_RESIZE_NWSE_CURSOR, GLFW_NOT_ALLOWED_CURSOR
|
||||||
#else
|
#else
|
||||||
#define GLFW_HAS_NEW_CURSORS (0)
|
#define GLFW_HAS_NEW_CURSORS (0)
|
||||||
#endif
|
#endif
|
||||||
|
#define GLFW_HAS_GAMEPAD_API (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwGetGamepadState() new api
|
||||||
|
#define GLFW_HAS_GET_KEY_NAME (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ glfwGetKeyName()
|
||||||
|
|
||||||
// GLFW data
|
// GLFW data
|
||||||
enum GlfwClientApi
|
enum GlfwClientApi
|
||||||
@ -76,12 +91,13 @@ struct ImGui_ImplGlfw_Data
|
|||||||
GlfwClientApi ClientApi;
|
GlfwClientApi ClientApi;
|
||||||
double Time;
|
double Time;
|
||||||
GLFWwindow* MouseWindow;
|
GLFWwindow* MouseWindow;
|
||||||
bool MouseJustPressed[ImGuiMouseButton_COUNT];
|
|
||||||
GLFWcursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
GLFWcursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
||||||
|
ImVec2 LastValidMousePos;
|
||||||
bool InstalledCallbacks;
|
bool InstalledCallbacks;
|
||||||
|
|
||||||
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
|
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
|
||||||
GLFWwindowfocusfun PrevUserCallbackWindowFocus;
|
GLFWwindowfocusfun PrevUserCallbackWindowFocus;
|
||||||
|
GLFWcursorposfun PrevUserCallbackCursorPos;
|
||||||
GLFWcursorenterfun PrevUserCallbackCursorEnter;
|
GLFWcursorenterfun PrevUserCallbackCursorEnter;
|
||||||
GLFWmousebuttonfun PrevUserCallbackMousebutton;
|
GLFWmousebuttonfun PrevUserCallbackMousebutton;
|
||||||
GLFWscrollfun PrevUserCallbackScroll;
|
GLFWscrollfun PrevUserCallbackScroll;
|
||||||
@ -115,14 +131,139 @@ static void ImGui_ImplGlfw_SetClipboardText(void* user_data, const char* text)
|
|||||||
glfwSetClipboardString((GLFWwindow*)user_data, text);
|
glfwSetClipboardString((GLFWwindow*)user_data, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int key)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case GLFW_KEY_TAB: return ImGuiKey_Tab;
|
||||||
|
case GLFW_KEY_LEFT: return ImGuiKey_LeftArrow;
|
||||||
|
case GLFW_KEY_RIGHT: return ImGuiKey_RightArrow;
|
||||||
|
case GLFW_KEY_UP: return ImGuiKey_UpArrow;
|
||||||
|
case GLFW_KEY_DOWN: return ImGuiKey_DownArrow;
|
||||||
|
case GLFW_KEY_PAGE_UP: return ImGuiKey_PageUp;
|
||||||
|
case GLFW_KEY_PAGE_DOWN: return ImGuiKey_PageDown;
|
||||||
|
case GLFW_KEY_HOME: return ImGuiKey_Home;
|
||||||
|
case GLFW_KEY_END: return ImGuiKey_End;
|
||||||
|
case GLFW_KEY_INSERT: return ImGuiKey_Insert;
|
||||||
|
case GLFW_KEY_DELETE: return ImGuiKey_Delete;
|
||||||
|
case GLFW_KEY_BACKSPACE: return ImGuiKey_Backspace;
|
||||||
|
case GLFW_KEY_SPACE: return ImGuiKey_Space;
|
||||||
|
case GLFW_KEY_ENTER: return ImGuiKey_Enter;
|
||||||
|
case GLFW_KEY_ESCAPE: return ImGuiKey_Escape;
|
||||||
|
case GLFW_KEY_APOSTROPHE: return ImGuiKey_Apostrophe;
|
||||||
|
case GLFW_KEY_COMMA: return ImGuiKey_Comma;
|
||||||
|
case GLFW_KEY_MINUS: return ImGuiKey_Minus;
|
||||||
|
case GLFW_KEY_PERIOD: return ImGuiKey_Period;
|
||||||
|
case GLFW_KEY_SLASH: return ImGuiKey_Slash;
|
||||||
|
case GLFW_KEY_SEMICOLON: return ImGuiKey_Semicolon;
|
||||||
|
case GLFW_KEY_EQUAL: return ImGuiKey_Equal;
|
||||||
|
case GLFW_KEY_LEFT_BRACKET: return ImGuiKey_LeftBracket;
|
||||||
|
case GLFW_KEY_BACKSLASH: return ImGuiKey_Backslash;
|
||||||
|
case GLFW_KEY_RIGHT_BRACKET: return ImGuiKey_RightBracket;
|
||||||
|
case GLFW_KEY_GRAVE_ACCENT: return ImGuiKey_GraveAccent;
|
||||||
|
case GLFW_KEY_CAPS_LOCK: return ImGuiKey_CapsLock;
|
||||||
|
case GLFW_KEY_SCROLL_LOCK: return ImGuiKey_ScrollLock;
|
||||||
|
case GLFW_KEY_NUM_LOCK: return ImGuiKey_NumLock;
|
||||||
|
case GLFW_KEY_PRINT_SCREEN: return ImGuiKey_PrintScreen;
|
||||||
|
case GLFW_KEY_PAUSE: return ImGuiKey_Pause;
|
||||||
|
case GLFW_KEY_KP_0: return ImGuiKey_Keypad0;
|
||||||
|
case GLFW_KEY_KP_1: return ImGuiKey_Keypad1;
|
||||||
|
case GLFW_KEY_KP_2: return ImGuiKey_Keypad2;
|
||||||
|
case GLFW_KEY_KP_3: return ImGuiKey_Keypad3;
|
||||||
|
case GLFW_KEY_KP_4: return ImGuiKey_Keypad4;
|
||||||
|
case GLFW_KEY_KP_5: return ImGuiKey_Keypad5;
|
||||||
|
case GLFW_KEY_KP_6: return ImGuiKey_Keypad6;
|
||||||
|
case GLFW_KEY_KP_7: return ImGuiKey_Keypad7;
|
||||||
|
case GLFW_KEY_KP_8: return ImGuiKey_Keypad8;
|
||||||
|
case GLFW_KEY_KP_9: return ImGuiKey_Keypad9;
|
||||||
|
case GLFW_KEY_KP_DECIMAL: return ImGuiKey_KeypadDecimal;
|
||||||
|
case GLFW_KEY_KP_DIVIDE: return ImGuiKey_KeypadDivide;
|
||||||
|
case GLFW_KEY_KP_MULTIPLY: return ImGuiKey_KeypadMultiply;
|
||||||
|
case GLFW_KEY_KP_SUBTRACT: return ImGuiKey_KeypadSubtract;
|
||||||
|
case GLFW_KEY_KP_ADD: return ImGuiKey_KeypadAdd;
|
||||||
|
case GLFW_KEY_KP_ENTER: return ImGuiKey_KeypadEnter;
|
||||||
|
case GLFW_KEY_KP_EQUAL: return ImGuiKey_KeypadEqual;
|
||||||
|
case GLFW_KEY_LEFT_SHIFT: return ImGuiKey_LeftShift;
|
||||||
|
case GLFW_KEY_LEFT_CONTROL: return ImGuiKey_LeftCtrl;
|
||||||
|
case GLFW_KEY_LEFT_ALT: return ImGuiKey_LeftAlt;
|
||||||
|
case GLFW_KEY_LEFT_SUPER: return ImGuiKey_LeftSuper;
|
||||||
|
case GLFW_KEY_RIGHT_SHIFT: return ImGuiKey_RightShift;
|
||||||
|
case GLFW_KEY_RIGHT_CONTROL: return ImGuiKey_RightCtrl;
|
||||||
|
case GLFW_KEY_RIGHT_ALT: return ImGuiKey_RightAlt;
|
||||||
|
case GLFW_KEY_RIGHT_SUPER: return ImGuiKey_RightSuper;
|
||||||
|
case GLFW_KEY_MENU: return ImGuiKey_Menu;
|
||||||
|
case GLFW_KEY_0: return ImGuiKey_0;
|
||||||
|
case GLFW_KEY_1: return ImGuiKey_1;
|
||||||
|
case GLFW_KEY_2: return ImGuiKey_2;
|
||||||
|
case GLFW_KEY_3: return ImGuiKey_3;
|
||||||
|
case GLFW_KEY_4: return ImGuiKey_4;
|
||||||
|
case GLFW_KEY_5: return ImGuiKey_5;
|
||||||
|
case GLFW_KEY_6: return ImGuiKey_6;
|
||||||
|
case GLFW_KEY_7: return ImGuiKey_7;
|
||||||
|
case GLFW_KEY_8: return ImGuiKey_8;
|
||||||
|
case GLFW_KEY_9: return ImGuiKey_9;
|
||||||
|
case GLFW_KEY_A: return ImGuiKey_A;
|
||||||
|
case GLFW_KEY_B: return ImGuiKey_B;
|
||||||
|
case GLFW_KEY_C: return ImGuiKey_C;
|
||||||
|
case GLFW_KEY_D: return ImGuiKey_D;
|
||||||
|
case GLFW_KEY_E: return ImGuiKey_E;
|
||||||
|
case GLFW_KEY_F: return ImGuiKey_F;
|
||||||
|
case GLFW_KEY_G: return ImGuiKey_G;
|
||||||
|
case GLFW_KEY_H: return ImGuiKey_H;
|
||||||
|
case GLFW_KEY_I: return ImGuiKey_I;
|
||||||
|
case GLFW_KEY_J: return ImGuiKey_J;
|
||||||
|
case GLFW_KEY_K: return ImGuiKey_K;
|
||||||
|
case GLFW_KEY_L: return ImGuiKey_L;
|
||||||
|
case GLFW_KEY_M: return ImGuiKey_M;
|
||||||
|
case GLFW_KEY_N: return ImGuiKey_N;
|
||||||
|
case GLFW_KEY_O: return ImGuiKey_O;
|
||||||
|
case GLFW_KEY_P: return ImGuiKey_P;
|
||||||
|
case GLFW_KEY_Q: return ImGuiKey_Q;
|
||||||
|
case GLFW_KEY_R: return ImGuiKey_R;
|
||||||
|
case GLFW_KEY_S: return ImGuiKey_S;
|
||||||
|
case GLFW_KEY_T: return ImGuiKey_T;
|
||||||
|
case GLFW_KEY_U: return ImGuiKey_U;
|
||||||
|
case GLFW_KEY_V: return ImGuiKey_V;
|
||||||
|
case GLFW_KEY_W: return ImGuiKey_W;
|
||||||
|
case GLFW_KEY_X: return ImGuiKey_X;
|
||||||
|
case GLFW_KEY_Y: return ImGuiKey_Y;
|
||||||
|
case GLFW_KEY_Z: return ImGuiKey_Z;
|
||||||
|
case GLFW_KEY_F1: return ImGuiKey_F1;
|
||||||
|
case GLFW_KEY_F2: return ImGuiKey_F2;
|
||||||
|
case GLFW_KEY_F3: return ImGuiKey_F3;
|
||||||
|
case GLFW_KEY_F4: return ImGuiKey_F4;
|
||||||
|
case GLFW_KEY_F5: return ImGuiKey_F5;
|
||||||
|
case GLFW_KEY_F6: return ImGuiKey_F6;
|
||||||
|
case GLFW_KEY_F7: return ImGuiKey_F7;
|
||||||
|
case GLFW_KEY_F8: return ImGuiKey_F8;
|
||||||
|
case GLFW_KEY_F9: return ImGuiKey_F9;
|
||||||
|
case GLFW_KEY_F10: return ImGuiKey_F10;
|
||||||
|
case GLFW_KEY_F11: return ImGuiKey_F11;
|
||||||
|
case GLFW_KEY_F12: return ImGuiKey_F12;
|
||||||
|
default: return ImGuiKey_None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_UpdateKeyModifiers(int mods)
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModCtrl, (mods & GLFW_MOD_CONTROL) != 0);
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModShift, (mods & GLFW_MOD_SHIFT) != 0);
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModAlt, (mods & GLFW_MOD_ALT) != 0);
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModSuper, (mods & GLFW_MOD_SUPER) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods)
|
void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods)
|
||||||
{
|
{
|
||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
if (bd->PrevUserCallbackMousebutton != NULL && window == bd->Window)
|
if (bd->PrevUserCallbackMousebutton != NULL && window == bd->Window)
|
||||||
bd->PrevUserCallbackMousebutton(window, button, action, mods);
|
bd->PrevUserCallbackMousebutton(window, button, action, mods);
|
||||||
|
|
||||||
if (action == GLFW_PRESS && button >= 0 && button < IM_ARRAYSIZE(bd->MouseJustPressed))
|
ImGui_ImplGlfw_UpdateKeyModifiers(mods);
|
||||||
bd->MouseJustPressed[button] = true;
|
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
if (button >= 0 && button < ImGuiMouseButton_COUNT)
|
||||||
|
io.AddMouseButtonEvent(button, action == GLFW_PRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset)
|
void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset)
|
||||||
@ -132,34 +273,53 @@ void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yo
|
|||||||
bd->PrevUserCallbackScroll(window, xoffset, yoffset);
|
bd->PrevUserCallbackScroll(window, xoffset, yoffset);
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.MouseWheelH += (float)xoffset;
|
io.AddMouseWheelEvent((float)xoffset, (float)yoffset);
|
||||||
io.MouseWheel += (float)yoffset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
static int ImGui_ImplGlfw_TranslateUntranslatedKey(int key, int scancode)
|
||||||
|
{
|
||||||
|
#if GLFW_HAS_GET_KEY_NAME && !defined(__EMSCRIPTEN__)
|
||||||
|
// GLFW 3.1+ attempts to "untranslate" keys, which goes the opposite of what every other framework does, making using lettered shortcuts difficult.
|
||||||
|
// (It had reasons to do so: namely GLFW is/was more likely to be used for WASD-type game controls rather than lettered shortcuts, but IHMO the 3.1 change could have been done differently)
|
||||||
|
// See https://github.com/glfw/glfw/issues/1502 for details.
|
||||||
|
// Adding a workaround to undo this (so our keys are translated->untranslated->translated, likely a lossy process).
|
||||||
|
// This won't cover edge cases but this is at least going to cover common cases.
|
||||||
|
if (key >= GLFW_KEY_KP_0 && key <= GLFW_KEY_KP_EQUAL)
|
||||||
|
return key;
|
||||||
|
const char* key_name = glfwGetKeyName(key, scancode);
|
||||||
|
if (key_name && key_name[0] != 0 && key_name[1] == 0)
|
||||||
|
{
|
||||||
|
const char char_names[] = "`-=[]\\,;\'./";
|
||||||
|
const int char_keys[] = { GLFW_KEY_GRAVE_ACCENT, GLFW_KEY_MINUS, GLFW_KEY_EQUAL, GLFW_KEY_LEFT_BRACKET, GLFW_KEY_RIGHT_BRACKET, GLFW_KEY_BACKSLASH, GLFW_KEY_COMMA, GLFW_KEY_SEMICOLON, GLFW_KEY_APOSTROPHE, GLFW_KEY_PERIOD, GLFW_KEY_SLASH, 0 };
|
||||||
|
IM_ASSERT(IM_ARRAYSIZE(char_names) == IM_ARRAYSIZE(char_keys));
|
||||||
|
if (key_name[0] >= '0' && key_name[0] <= '9') { key = GLFW_KEY_0 + (key_name[0] - '0'); }
|
||||||
|
else if (key_name[0] >= 'A' && key_name[0] <= 'Z') { key = GLFW_KEY_A + (key_name[0] - 'A'); }
|
||||||
|
else if (const char* p = strchr(char_names, key_name[0])) { key = char_keys[p - char_names]; }
|
||||||
|
}
|
||||||
|
// if (action == GLFW_PRESS) printf("key %d scancode %d name '%s'\n", key, scancode, key_name);
|
||||||
|
#else
|
||||||
|
IM_UNUSED(scancode);
|
||||||
|
#endif
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int keycode, int scancode, int action, int mods)
|
||||||
{
|
{
|
||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
if (bd->PrevUserCallbackKey != NULL && window == bd->Window)
|
if (bd->PrevUserCallbackKey != NULL && window == bd->Window)
|
||||||
bd->PrevUserCallbackKey(window, key, scancode, action, mods);
|
bd->PrevUserCallbackKey(window, keycode, scancode, action, mods);
|
||||||
|
|
||||||
|
if (action != GLFW_PRESS && action != GLFW_RELEASE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ImGui_ImplGlfw_UpdateKeyModifiers(mods);
|
||||||
|
|
||||||
|
keycode = ImGui_ImplGlfw_TranslateUntranslatedKey(keycode, scancode);
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
if (key >= 0 && key < IM_ARRAYSIZE(io.KeysDown))
|
ImGuiKey imgui_key = ImGui_ImplGlfw_KeyToImGuiKey(keycode);
|
||||||
{
|
io.AddKeyEvent(imgui_key, (action == GLFW_PRESS));
|
||||||
if (action == GLFW_PRESS)
|
io.SetKeyEventNativeData(imgui_key, keycode, scancode); // To support legacy indexing (<1.87 user code)
|
||||||
io.KeysDown[key] = true;
|
|
||||||
if (action == GLFW_RELEASE)
|
|
||||||
io.KeysDown[key] = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Modifiers are not reliable across systems
|
|
||||||
io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
|
|
||||||
io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
|
|
||||||
io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
|
|
||||||
#ifdef _WIN32
|
|
||||||
io.KeySuper = false;
|
|
||||||
#else
|
|
||||||
io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window, int focused)
|
void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window, int focused)
|
||||||
@ -172,16 +332,37 @@ void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window, int focused)
|
|||||||
io.AddFocusEvent(focused != 0);
|
io.AddFocusEvent(focused != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window, double x, double y)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
if (bd->PrevUserCallbackCursorPos != NULL && window == bd->Window)
|
||||||
|
bd->PrevUserCallbackCursorPos(window, x, y);
|
||||||
|
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.AddMousePosEvent((float)x, (float)y);
|
||||||
|
bd->LastValidMousePos = ImVec2((float)x, (float)y);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Workaround: X11 seems to send spurious Leave/Enter events which would make us lose our position,
|
||||||
|
// so we back it up and restore on Leave/Enter (see https://github.com/ocornut/imgui/issues/4984)
|
||||||
void ImGui_ImplGlfw_CursorEnterCallback(GLFWwindow* window, int entered)
|
void ImGui_ImplGlfw_CursorEnterCallback(GLFWwindow* window, int entered)
|
||||||
{
|
{
|
||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
if (bd->PrevUserCallbackCursorEnter != NULL && window == bd->Window)
|
if (bd->PrevUserCallbackCursorEnter != NULL && window == bd->Window)
|
||||||
bd->PrevUserCallbackCursorEnter(window, entered);
|
bd->PrevUserCallbackCursorEnter(window, entered);
|
||||||
|
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
if (entered)
|
if (entered)
|
||||||
|
{
|
||||||
bd->MouseWindow = window;
|
bd->MouseWindow = window;
|
||||||
if (!entered && bd->MouseWindow == window)
|
io.AddMousePosEvent(bd->LastValidMousePos.x, bd->LastValidMousePos.y);
|
||||||
|
}
|
||||||
|
else if (!entered && bd->MouseWindow == window)
|
||||||
|
{
|
||||||
|
bd->LastValidMousePos = io.MousePos;
|
||||||
bd->MouseWindow = NULL;
|
bd->MouseWindow = NULL;
|
||||||
|
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c)
|
void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c)
|
||||||
@ -199,6 +380,48 @@ void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor*, int)
|
|||||||
// Unused in 'master' branch but 'docking' branch will use this, so we declare it ahead of it so if you have to install callbacks you can install this one too.
|
// Unused in 'master' branch but 'docking' branch will use this, so we declare it ahead of it so if you have to install callbacks you can install this one too.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
IM_ASSERT(bd->InstalledCallbacks == false && "Callbacks already installed!");
|
||||||
|
IM_ASSERT(bd->Window == window);
|
||||||
|
|
||||||
|
bd->PrevUserCallbackWindowFocus = glfwSetWindowFocusCallback(window, ImGui_ImplGlfw_WindowFocusCallback);
|
||||||
|
bd->PrevUserCallbackCursorEnter = glfwSetCursorEnterCallback(window, ImGui_ImplGlfw_CursorEnterCallback);
|
||||||
|
bd->PrevUserCallbackCursorPos = glfwSetCursorPosCallback(window, ImGui_ImplGlfw_CursorPosCallback);
|
||||||
|
bd->PrevUserCallbackMousebutton = glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
|
||||||
|
bd->PrevUserCallbackScroll = glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
|
||||||
|
bd->PrevUserCallbackKey = glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
|
||||||
|
bd->PrevUserCallbackChar = glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
|
||||||
|
bd->PrevUserCallbackMonitor = glfwSetMonitorCallback(ImGui_ImplGlfw_MonitorCallback);
|
||||||
|
bd->InstalledCallbacks = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplGlfw_RestoreCallbacks(GLFWwindow* window)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
IM_ASSERT(bd->InstalledCallbacks == true && "Callbacks not installed!");
|
||||||
|
IM_ASSERT(bd->Window == window);
|
||||||
|
|
||||||
|
glfwSetWindowFocusCallback(window, bd->PrevUserCallbackWindowFocus);
|
||||||
|
glfwSetCursorEnterCallback(window, bd->PrevUserCallbackCursorEnter);
|
||||||
|
glfwSetCursorPosCallback(window, bd->PrevUserCallbackCursorPos);
|
||||||
|
glfwSetMouseButtonCallback(window, bd->PrevUserCallbackMousebutton);
|
||||||
|
glfwSetScrollCallback(window, bd->PrevUserCallbackScroll);
|
||||||
|
glfwSetKeyCallback(window, bd->PrevUserCallbackKey);
|
||||||
|
glfwSetCharCallback(window, bd->PrevUserCallbackChar);
|
||||||
|
glfwSetMonitorCallback(bd->PrevUserCallbackMonitor);
|
||||||
|
bd->InstalledCallbacks = false;
|
||||||
|
bd->PrevUserCallbackWindowFocus = NULL;
|
||||||
|
bd->PrevUserCallbackCursorEnter = NULL;
|
||||||
|
bd->PrevUserCallbackCursorPos = NULL;
|
||||||
|
bd->PrevUserCallbackMousebutton = NULL;
|
||||||
|
bd->PrevUserCallbackScroll = NULL;
|
||||||
|
bd->PrevUserCallbackKey = NULL;
|
||||||
|
bd->PrevUserCallbackChar = NULL;
|
||||||
|
bd->PrevUserCallbackMonitor = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, GlfwClientApi client_api)
|
static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, GlfwClientApi client_api)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@ -214,35 +437,13 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
|||||||
bd->Window = window;
|
bd->Window = window;
|
||||||
bd->Time = 0.0;
|
bd->Time = 0.0;
|
||||||
|
|
||||||
// Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeysDown[] array.
|
|
||||||
io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB;
|
|
||||||
io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
|
|
||||||
io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
|
|
||||||
io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
|
|
||||||
io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
|
|
||||||
io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
|
|
||||||
io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
|
|
||||||
io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
|
|
||||||
io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
|
|
||||||
io.KeyMap[ImGuiKey_Insert] = GLFW_KEY_INSERT;
|
|
||||||
io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
|
|
||||||
io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
|
|
||||||
io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE;
|
|
||||||
io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
|
|
||||||
io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
|
|
||||||
io.KeyMap[ImGuiKey_KeyPadEnter] = GLFW_KEY_KP_ENTER;
|
|
||||||
io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
|
|
||||||
io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
|
|
||||||
io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
|
|
||||||
io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
|
|
||||||
io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
|
|
||||||
io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
|
|
||||||
|
|
||||||
io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
|
io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
|
||||||
io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
|
io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
|
||||||
io.ClipboardUserData = bd->Window;
|
io.ClipboardUserData = bd->Window;
|
||||||
|
|
||||||
|
// Set platform dependent data in viewport
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
io.ImeWindowHandle = (void*)glfwGetWin32Window(bd->Window);
|
ImGui::GetMainViewport()->PlatformHandleRaw = (void*)glfwGetWin32Window(bd->Window);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Create mouse cursors
|
// Create mouse cursors
|
||||||
@ -269,24 +470,8 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
|||||||
glfwSetErrorCallback(prev_error_callback);
|
glfwSetErrorCallback(prev_error_callback);
|
||||||
|
|
||||||
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
|
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
|
||||||
bd->PrevUserCallbackWindowFocus = NULL;
|
|
||||||
bd->PrevUserCallbackCursorEnter = NULL;
|
|
||||||
bd->PrevUserCallbackMousebutton = NULL;
|
|
||||||
bd->PrevUserCallbackScroll = NULL;
|
|
||||||
bd->PrevUserCallbackKey = NULL;
|
|
||||||
bd->PrevUserCallbackChar = NULL;
|
|
||||||
bd->PrevUserCallbackMonitor = NULL;
|
|
||||||
if (install_callbacks)
|
if (install_callbacks)
|
||||||
{
|
ImGui_ImplGlfw_InstallCallbacks(window);
|
||||||
bd->InstalledCallbacks = true;
|
|
||||||
bd->PrevUserCallbackWindowFocus = glfwSetWindowFocusCallback(window, ImGui_ImplGlfw_WindowFocusCallback);
|
|
||||||
bd->PrevUserCallbackCursorEnter = glfwSetCursorEnterCallback(window, ImGui_ImplGlfw_CursorEnterCallback);
|
|
||||||
bd->PrevUserCallbackMousebutton = glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
|
|
||||||
bd->PrevUserCallbackScroll = glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
|
|
||||||
bd->PrevUserCallbackKey = glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
|
|
||||||
bd->PrevUserCallbackChar = glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
|
|
||||||
bd->PrevUserCallbackMonitor = glfwSetMonitorCallback(ImGui_ImplGlfw_MonitorCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
bd->ClientApi = client_api;
|
bd->ClientApi = client_api;
|
||||||
return true;
|
return true;
|
||||||
@ -314,15 +499,7 @@ void ImGui_ImplGlfw_Shutdown()
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
if (bd->InstalledCallbacks)
|
if (bd->InstalledCallbacks)
|
||||||
{
|
ImGui_ImplGlfw_RestoreCallbacks(bd->Window);
|
||||||
glfwSetWindowFocusCallback(bd->Window, bd->PrevUserCallbackWindowFocus);
|
|
||||||
glfwSetCursorEnterCallback(bd->Window, bd->PrevUserCallbackCursorEnter);
|
|
||||||
glfwSetMouseButtonCallback(bd->Window, bd->PrevUserCallbackMousebutton);
|
|
||||||
glfwSetScrollCallback(bd->Window, bd->PrevUserCallbackScroll);
|
|
||||||
glfwSetKeyCallback(bd->Window, bd->PrevUserCallbackKey);
|
|
||||||
glfwSetCharCallback(bd->Window, bd->PrevUserCallbackChar);
|
|
||||||
glfwSetMonitorCallback(bd->PrevUserCallbackMonitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
||||||
glfwDestroyCursor(bd->MouseCursors[cursor_n]);
|
glfwDestroyCursor(bd->MouseCursors[cursor_n]);
|
||||||
@ -332,39 +509,30 @@ void ImGui_ImplGlfw_Shutdown()
|
|||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplGlfw_UpdateMousePosAndButtons()
|
static void ImGui_ImplGlfw_UpdateMouseData()
|
||||||
{
|
{
|
||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
const ImVec2 mouse_pos_prev = io.MousePos;
|
|
||||||
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
|
||||||
|
|
||||||
// Update mouse buttons
|
|
||||||
// (if a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame)
|
|
||||||
for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++)
|
|
||||||
{
|
|
||||||
io.MouseDown[i] = bd->MouseJustPressed[i] || glfwGetMouseButton(bd->Window, i) != 0;
|
|
||||||
bd->MouseJustPressed[i] = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
const bool focused = true;
|
const bool is_app_focused = true;
|
||||||
#else
|
#else
|
||||||
const bool focused = glfwGetWindowAttrib(bd->Window, GLFW_FOCUSED) != 0;
|
const bool is_app_focused = glfwGetWindowAttrib(bd->Window, GLFW_FOCUSED) != 0;
|
||||||
#endif
|
#endif
|
||||||
GLFWwindow* mouse_window = (bd->MouseWindow == bd->Window || focused) ? bd->Window : NULL;
|
if (is_app_focused)
|
||||||
|
|
||||||
// Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
|
||||||
if (io.WantSetMousePos && focused)
|
|
||||||
glfwSetCursorPos(bd->Window, (double)mouse_pos_prev.x, (double)mouse_pos_prev.y);
|
|
||||||
|
|
||||||
// Set Dear ImGui mouse position from OS position
|
|
||||||
if (mouse_window != NULL)
|
|
||||||
{
|
{
|
||||||
double mouse_x, mouse_y;
|
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
||||||
glfwGetCursorPos(mouse_window, &mouse_x, &mouse_y);
|
if (io.WantSetMousePos)
|
||||||
io.MousePos = ImVec2((float)mouse_x, (float)mouse_y);
|
glfwSetCursorPos(bd->Window, (double)io.MousePos.x, (double)io.MousePos.y);
|
||||||
|
|
||||||
|
// (Optional) Fallback to provide mouse position when focused (ImGui_ImplGlfw_CursorPosCallback already provides this when hovered or captured)
|
||||||
|
if (is_app_focused && bd->MouseWindow == NULL)
|
||||||
|
{
|
||||||
|
double mouse_x, mouse_y;
|
||||||
|
glfwGetCursorPos(bd->Window, &mouse_x, &mouse_y);
|
||||||
|
io.AddMousePosEvent((float)mouse_x, (float)mouse_y);
|
||||||
|
bd->LastValidMousePos = ImVec2((float)mouse_x, (float)mouse_y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,41 +558,57 @@ static void ImGui_ImplGlfw_UpdateMouseCursor()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update gamepad inputs
|
||||||
|
static inline float Saturate(float v) { return v < 0.0f ? 0.0f : v > 1.0f ? 1.0f : v; }
|
||||||
static void ImGui_ImplGlfw_UpdateGamepads()
|
static void ImGui_ImplGlfw_UpdateGamepads()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
memset(io.NavInputs, 0, sizeof(io.NavInputs));
|
|
||||||
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Update gamepad inputs
|
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
||||||
#define MAP_BUTTON(NAV_NO, BUTTON_NO) { if (buttons_count > BUTTON_NO && buttons[BUTTON_NO] == GLFW_PRESS) io.NavInputs[NAV_NO] = 1.0f; }
|
#if GLFW_HAS_GAMEPAD_API
|
||||||
#define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1) { float v = (axes_count > AXIS_NO) ? axes[AXIS_NO] : V0; v = (v - V0) / (V1 - V0); if (v > 1.0f) v = 1.0f; if (io.NavInputs[NAV_NO] < v) io.NavInputs[NAV_NO] = v; }
|
GLFWgamepadstate gamepad;
|
||||||
|
if (!glfwGetGamepadState(GLFW_JOYSTICK_1, &gamepad))
|
||||||
|
return;
|
||||||
|
#define MAP_BUTTON(KEY_NO, BUTTON_NO, _UNUSED) do { io.AddKeyEvent(KEY_NO, gamepad.buttons[BUTTON_NO] != 0); } while (0)
|
||||||
|
#define MAP_ANALOG(KEY_NO, AXIS_NO, _UNUSED, V0, V1) do { float v = gamepad.axes[AXIS_NO]; v = (v - V0) / (V1 - V0); io.AddKeyAnalogEvent(KEY_NO, v > 0.10f, Saturate(v)); } while (0)
|
||||||
|
#else
|
||||||
int axes_count = 0, buttons_count = 0;
|
int axes_count = 0, buttons_count = 0;
|
||||||
const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &axes_count);
|
const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &axes_count);
|
||||||
const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &buttons_count);
|
const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &buttons_count);
|
||||||
MAP_BUTTON(ImGuiNavInput_Activate, 0); // Cross / A
|
if (axes_count == 0 || buttons_count == 0)
|
||||||
MAP_BUTTON(ImGuiNavInput_Cancel, 1); // Circle / B
|
return;
|
||||||
MAP_BUTTON(ImGuiNavInput_Menu, 2); // Square / X
|
#define MAP_BUTTON(KEY_NO, _UNUSED, BUTTON_NO) do { io.AddKeyEvent(KEY_NO, (buttons_count > BUTTON_NO && buttons[BUTTON_NO] == GLFW_PRESS)); } while (0)
|
||||||
MAP_BUTTON(ImGuiNavInput_Input, 3); // Triangle / Y
|
#define MAP_ANALOG(KEY_NO, _UNUSED, AXIS_NO, V0, V1) do { float v = (axes_count > AXIS_NO) ? axes[AXIS_NO] : V0; v = (v - V0) / (V1 - V0); io.AddKeyAnalogEvent(KEY_NO, v > 0.10f, Saturate(v)); } while (0)
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadLeft, 13); // D-Pad Left
|
#endif
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadRight, 11); // D-Pad Right
|
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadUp, 10); // D-Pad Up
|
MAP_BUTTON(ImGuiKey_GamepadStart, GLFW_GAMEPAD_BUTTON_START, 7);
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadDown, 12); // D-Pad Down
|
MAP_BUTTON(ImGuiKey_GamepadBack, GLFW_GAMEPAD_BUTTON_BACK, 6);
|
||||||
MAP_BUTTON(ImGuiNavInput_FocusPrev, 4); // L1 / LB
|
MAP_BUTTON(ImGuiKey_GamepadFaceDown, GLFW_GAMEPAD_BUTTON_A, 0); // Xbox A, PS Cross
|
||||||
MAP_BUTTON(ImGuiNavInput_FocusNext, 5); // R1 / RB
|
MAP_BUTTON(ImGuiKey_GamepadFaceRight, GLFW_GAMEPAD_BUTTON_B, 1); // Xbox B, PS Circle
|
||||||
MAP_BUTTON(ImGuiNavInput_TweakSlow, 4); // L1 / LB
|
MAP_BUTTON(ImGuiKey_GamepadFaceLeft, GLFW_GAMEPAD_BUTTON_X, 2); // Xbox X, PS Square
|
||||||
MAP_BUTTON(ImGuiNavInput_TweakFast, 5); // R1 / RB
|
MAP_BUTTON(ImGuiKey_GamepadFaceUp, GLFW_GAMEPAD_BUTTON_Y, 3); // Xbox Y, PS Triangle
|
||||||
MAP_ANALOG(ImGuiNavInput_LStickLeft, 0, -0.3f, -0.9f);
|
MAP_BUTTON(ImGuiKey_GamepadDpadLeft, GLFW_GAMEPAD_BUTTON_DPAD_LEFT, 13);
|
||||||
MAP_ANALOG(ImGuiNavInput_LStickRight,0, +0.3f, +0.9f);
|
MAP_BUTTON(ImGuiKey_GamepadDpadRight, GLFW_GAMEPAD_BUTTON_DPAD_RIGHT, 11);
|
||||||
MAP_ANALOG(ImGuiNavInput_LStickUp, 1, +0.3f, +0.9f);
|
MAP_BUTTON(ImGuiKey_GamepadDpadUp, GLFW_GAMEPAD_BUTTON_DPAD_UP, 10);
|
||||||
MAP_ANALOG(ImGuiNavInput_LStickDown, 1, -0.3f, -0.9f);
|
MAP_BUTTON(ImGuiKey_GamepadDpadDown, GLFW_GAMEPAD_BUTTON_DPAD_DOWN, 12);
|
||||||
|
MAP_BUTTON(ImGuiKey_GamepadL1, GLFW_GAMEPAD_BUTTON_LEFT_BUMPER, 4);
|
||||||
|
MAP_BUTTON(ImGuiKey_GamepadR1, GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER, 5);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadL2, GLFW_GAMEPAD_AXIS_LEFT_TRIGGER, 4, -0.75f, +1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadR2, GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER, 5, -0.75f, +1.0f);
|
||||||
|
MAP_BUTTON(ImGuiKey_GamepadL3, GLFW_GAMEPAD_BUTTON_LEFT_THUMB, 8);
|
||||||
|
MAP_BUTTON(ImGuiKey_GamepadR3, GLFW_GAMEPAD_BUTTON_RIGHT_THUMB, 9);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadLStickLeft, GLFW_GAMEPAD_AXIS_LEFT_X, 0, -0.25f, -1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadLStickRight, GLFW_GAMEPAD_AXIS_LEFT_X, 0, +0.25f, +1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadLStickUp, GLFW_GAMEPAD_AXIS_LEFT_Y, 1, -0.25f, -1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadLStickDown, GLFW_GAMEPAD_AXIS_LEFT_Y, 1, +0.25f, +1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickLeft, GLFW_GAMEPAD_AXIS_RIGHT_X, 2, -0.25f, -1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickRight, GLFW_GAMEPAD_AXIS_RIGHT_X, 2, +0.25f, +1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickUp, GLFW_GAMEPAD_AXIS_RIGHT_Y, 3, -0.25f, -1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickDown, GLFW_GAMEPAD_AXIS_RIGHT_Y, 3, +0.25f, +1.0f);
|
||||||
#undef MAP_BUTTON
|
#undef MAP_BUTTON
|
||||||
#undef MAP_ANALOG
|
#undef MAP_ANALOG
|
||||||
if (axes_count > 0 && buttons_count > 0)
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
|
||||||
else
|
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_NewFrame()
|
void ImGui_ImplGlfw_NewFrame()
|
||||||
@ -440,16 +624,20 @@ void ImGui_ImplGlfw_NewFrame()
|
|||||||
glfwGetFramebufferSize(bd->Window, &display_w, &display_h);
|
glfwGetFramebufferSize(bd->Window, &display_w, &display_h);
|
||||||
io.DisplaySize = ImVec2((float)w, (float)h);
|
io.DisplaySize = ImVec2((float)w, (float)h);
|
||||||
if (w > 0 && h > 0)
|
if (w > 0 && h > 0)
|
||||||
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
io.DisplayFramebufferScale = ImVec2((float)display_w / (float)w, (float)display_h / (float)h);
|
||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
double current_time = glfwGetTime();
|
double current_time = glfwGetTime();
|
||||||
io.DeltaTime = bd->Time > 0.0 ? (float)(current_time - bd->Time) : (float)(1.0f / 60.0f);
|
io.DeltaTime = bd->Time > 0.0 ? (float)(current_time - bd->Time) : (float)(1.0f / 60.0f);
|
||||||
bd->Time = current_time;
|
bd->Time = current_time;
|
||||||
|
|
||||||
ImGui_ImplGlfw_UpdateMousePosAndButtons();
|
ImGui_ImplGlfw_UpdateMouseData();
|
||||||
ImGui_ImplGlfw_UpdateMouseCursor();
|
ImGui_ImplGlfw_UpdateMouseCursor();
|
||||||
|
|
||||||
// Update game controllers (if enabled and available)
|
// Update game controllers (if enabled and available)
|
||||||
ImGui_ImplGlfw_UpdateGamepads();
|
ImGui_ImplGlfw_UpdateGamepads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Clipboard support.
|
// [X] Platform: Clipboard support.
|
||||||
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: 3 cursors types are missing from GLFW.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
|
||||||
// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE).
|
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -29,11 +29,16 @@ IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool ins
|
|||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();
|
||||||
|
|
||||||
// GLFW callbacks
|
// GLFW callbacks (installer)
|
||||||
// - When calling Init with 'install_callbacks=true': GLFW callbacks will be installed for you. They will call user's previously installed callbacks, if any.
|
// - When calling Init with 'install_callbacks=true': ImGui_ImplGlfw_InstallCallbacks() is called. GLFW callbacks will be installed for you. They will chain-call user's previously installed callbacks, if any.
|
||||||
// - When calling Init with 'install_callbacks=false': GLFW callbacks won't be installed. You will need to call those function yourself from your own GLFW callbacks.
|
// - When calling Init with 'install_callbacks=false': GLFW callbacks won't be installed. You will need to call individual function yourself from your own GLFW callbacks.
|
||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window, int focused);
|
IMGUI_IMPL_API void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window);
|
||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_CursorEnterCallback(GLFWwindow* window, int entered);
|
IMGUI_IMPL_API void ImGui_ImplGlfw_RestoreCallbacks(GLFWwindow* window);
|
||||||
|
|
||||||
|
// GLFW callbacks (individual callbacks to call if you didn't install callbacks)
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window, int focused); // Since 1.84
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGlfw_CursorEnterCallback(GLFWwindow* window, int entered); // Since 1.84
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window, double x, double y); // Since 1.87
|
||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
|
IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
|
||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||||
|
@ -5,19 +5,24 @@
|
|||||||
// !!! If someone or something is teaching you GLUT today, you are being abused. Please show some resistance. !!!
|
// !!! If someone or something is teaching you GLUT today, you are being abused. Please show some resistance. !!!
|
||||||
// !!! Nowadays, prefer using GLFW or SDL instead!
|
// !!! Nowadays, prefer using GLFW or SDL instead!
|
||||||
|
|
||||||
|
// Implemented features:
|
||||||
|
// [X] Platform: Partial keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLUT values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// Issues:
|
// Issues:
|
||||||
// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
|
// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
|
||||||
// [ ] Platform: Missing mouse cursor shape/visibility support.
|
// [ ] Platform: Missing mouse cursor shape/visibility support.
|
||||||
// [ ] Platform: Missing clipboard support (not supported by Glut).
|
// [ ] Platform: Missing clipboard support (not supported by Glut).
|
||||||
// [ ] Platform: Missing gamepad support.
|
// [ ] Platform: Missing gamepad support.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago) with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
||||||
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
// 2019-04-03: Misc: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h.
|
// 2019-04-03: Misc: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h.
|
||||||
// 2019-03-25: Misc: Made io.DeltaTime always above zero.
|
// 2019-03-25: Misc: Made io.DeltaTime always above zero.
|
||||||
// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
|
// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
|
||||||
@ -37,6 +42,120 @@
|
|||||||
|
|
||||||
static int g_Time = 0; // Current time, in milliseconds
|
static int g_Time = 0; // Current time, in milliseconds
|
||||||
|
|
||||||
|
// Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
|
||||||
|
static ImGuiKey ImGui_ImplGLUT_KeyToImGuiKey(int key)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case '\t': return ImGuiKey_Tab;
|
||||||
|
case 256 + GLUT_KEY_LEFT: return ImGuiKey_LeftArrow;
|
||||||
|
case 256 + GLUT_KEY_RIGHT: return ImGuiKey_RightArrow;
|
||||||
|
case 256 + GLUT_KEY_UP: return ImGuiKey_UpArrow;
|
||||||
|
case 256 + GLUT_KEY_DOWN: return ImGuiKey_DownArrow;
|
||||||
|
case 256 + GLUT_KEY_PAGE_UP: return ImGuiKey_PageUp;
|
||||||
|
case 256 + GLUT_KEY_PAGE_DOWN: return ImGuiKey_PageDown;
|
||||||
|
case 256 + GLUT_KEY_HOME: return ImGuiKey_Home;
|
||||||
|
case 256 + GLUT_KEY_END: return ImGuiKey_End;
|
||||||
|
case 256 + GLUT_KEY_INSERT: return ImGuiKey_Insert;
|
||||||
|
case 127: return ImGuiKey_Delete;
|
||||||
|
case 8: return ImGuiKey_Backspace;
|
||||||
|
case ' ': return ImGuiKey_Space;
|
||||||
|
case 13: return ImGuiKey_Enter;
|
||||||
|
case 27: return ImGuiKey_Escape;
|
||||||
|
case 39: return ImGuiKey_Apostrophe;
|
||||||
|
case 44: return ImGuiKey_Comma;
|
||||||
|
case 45: return ImGuiKey_Minus;
|
||||||
|
case 46: return ImGuiKey_Period;
|
||||||
|
case 47: return ImGuiKey_Slash;
|
||||||
|
case 59: return ImGuiKey_Semicolon;
|
||||||
|
case 61: return ImGuiKey_Equal;
|
||||||
|
case 91: return ImGuiKey_LeftBracket;
|
||||||
|
case 92: return ImGuiKey_Backslash;
|
||||||
|
case 93: return ImGuiKey_RightBracket;
|
||||||
|
case 96: return ImGuiKey_GraveAccent;
|
||||||
|
//case 0: return ImGuiKey_CapsLock;
|
||||||
|
//case 0: return ImGuiKey_ScrollLock;
|
||||||
|
case 256 + 0x006D: return ImGuiKey_NumLock;
|
||||||
|
//case 0: return ImGuiKey_PrintScreen;
|
||||||
|
//case 0: return ImGuiKey_Pause;
|
||||||
|
//case '0': return ImGuiKey_Keypad0;
|
||||||
|
//case '1': return ImGuiKey_Keypad1;
|
||||||
|
//case '2': return ImGuiKey_Keypad2;
|
||||||
|
//case '3': return ImGuiKey_Keypad3;
|
||||||
|
//case '4': return ImGuiKey_Keypad4;
|
||||||
|
//case '5': return ImGuiKey_Keypad5;
|
||||||
|
//case '6': return ImGuiKey_Keypad6;
|
||||||
|
//case '7': return ImGuiKey_Keypad7;
|
||||||
|
//case '8': return ImGuiKey_Keypad8;
|
||||||
|
//case '9': return ImGuiKey_Keypad9;
|
||||||
|
//case 46: return ImGuiKey_KeypadDecimal;
|
||||||
|
//case 47: return ImGuiKey_KeypadDivide;
|
||||||
|
case 42: return ImGuiKey_KeypadMultiply;
|
||||||
|
//case 45: return ImGuiKey_KeypadSubtract;
|
||||||
|
case 43: return ImGuiKey_KeypadAdd;
|
||||||
|
//case 13: return ImGuiKey_KeypadEnter;
|
||||||
|
//case 0: return ImGuiKey_KeypadEqual;
|
||||||
|
case 256 + 0x0072: return ImGuiKey_LeftCtrl;
|
||||||
|
case 256 + 0x0070: return ImGuiKey_LeftShift;
|
||||||
|
case 256 + 0x0074: return ImGuiKey_LeftAlt;
|
||||||
|
//case 0: return ImGuiKey_LeftSuper;
|
||||||
|
case 256 + 0x0073: return ImGuiKey_RightCtrl;
|
||||||
|
case 256 + 0x0071: return ImGuiKey_RightShift;
|
||||||
|
case 256 + 0x0075: return ImGuiKey_RightAlt;
|
||||||
|
//case 0: return ImGuiKey_RightSuper;
|
||||||
|
//case 0: return ImGuiKey_Menu;
|
||||||
|
case '0': return ImGuiKey_0;
|
||||||
|
case '1': return ImGuiKey_1;
|
||||||
|
case '2': return ImGuiKey_2;
|
||||||
|
case '3': return ImGuiKey_3;
|
||||||
|
case '4': return ImGuiKey_4;
|
||||||
|
case '5': return ImGuiKey_5;
|
||||||
|
case '6': return ImGuiKey_6;
|
||||||
|
case '7': return ImGuiKey_7;
|
||||||
|
case '8': return ImGuiKey_8;
|
||||||
|
case '9': return ImGuiKey_9;
|
||||||
|
case 'A': case 'a': return ImGuiKey_A;
|
||||||
|
case 'B': case 'b': return ImGuiKey_B;
|
||||||
|
case 'C': case 'c': return ImGuiKey_C;
|
||||||
|
case 'D': case 'd': return ImGuiKey_D;
|
||||||
|
case 'E': case 'e': return ImGuiKey_E;
|
||||||
|
case 'F': case 'f': return ImGuiKey_F;
|
||||||
|
case 'G': case 'g': return ImGuiKey_G;
|
||||||
|
case 'H': case 'h': return ImGuiKey_H;
|
||||||
|
case 'I': case 'i': return ImGuiKey_I;
|
||||||
|
case 'J': case 'j': return ImGuiKey_J;
|
||||||
|
case 'K': case 'k': return ImGuiKey_K;
|
||||||
|
case 'L': case 'l': return ImGuiKey_L;
|
||||||
|
case 'M': case 'm': return ImGuiKey_M;
|
||||||
|
case 'N': case 'n': return ImGuiKey_N;
|
||||||
|
case 'O': case 'o': return ImGuiKey_O;
|
||||||
|
case 'P': case 'p': return ImGuiKey_P;
|
||||||
|
case 'Q': case 'q': return ImGuiKey_Q;
|
||||||
|
case 'R': case 'r': return ImGuiKey_R;
|
||||||
|
case 'S': case 's': return ImGuiKey_S;
|
||||||
|
case 'T': case 't': return ImGuiKey_T;
|
||||||
|
case 'U': case 'u': return ImGuiKey_U;
|
||||||
|
case 'V': case 'v': return ImGuiKey_V;
|
||||||
|
case 'W': case 'w': return ImGuiKey_W;
|
||||||
|
case 'X': case 'x': return ImGuiKey_X;
|
||||||
|
case 'Y': case 'y': return ImGuiKey_Y;
|
||||||
|
case 'Z': case 'z': return ImGuiKey_Z;
|
||||||
|
case 256 + GLUT_KEY_F1: return ImGuiKey_F1;
|
||||||
|
case 256 + GLUT_KEY_F2: return ImGuiKey_F2;
|
||||||
|
case 256 + GLUT_KEY_F3: return ImGuiKey_F3;
|
||||||
|
case 256 + GLUT_KEY_F4: return ImGuiKey_F4;
|
||||||
|
case 256 + GLUT_KEY_F5: return ImGuiKey_F5;
|
||||||
|
case 256 + GLUT_KEY_F6: return ImGuiKey_F6;
|
||||||
|
case 256 + GLUT_KEY_F7: return ImGuiKey_F7;
|
||||||
|
case 256 + GLUT_KEY_F8: return ImGuiKey_F8;
|
||||||
|
case 256 + GLUT_KEY_F9: return ImGuiKey_F9;
|
||||||
|
case 256 + GLUT_KEY_F10: return ImGuiKey_F10;
|
||||||
|
case 256 + GLUT_KEY_F11: return ImGuiKey_F11;
|
||||||
|
case 256 + GLUT_KEY_F12: return ImGuiKey_F12;
|
||||||
|
default: return ImGuiKey_None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ImGui_ImplGLUT_Init()
|
bool ImGui_ImplGLUT_Init()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@ -46,33 +165,8 @@ bool ImGui_ImplGLUT_Init()
|
|||||||
#else
|
#else
|
||||||
io.BackendPlatformName = "imgui_impl_glut";
|
io.BackendPlatformName = "imgui_impl_glut";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_Time = 0;
|
g_Time = 0;
|
||||||
|
|
||||||
// Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
|
|
||||||
io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I
|
|
||||||
io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT;
|
|
||||||
io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT;
|
|
||||||
io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP;
|
|
||||||
io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN;
|
|
||||||
io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP;
|
|
||||||
io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN;
|
|
||||||
io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME;
|
|
||||||
io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END;
|
|
||||||
io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT;
|
|
||||||
io.KeyMap[ImGuiKey_Delete] = 127;
|
|
||||||
io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H
|
|
||||||
io.KeyMap[ImGuiKey_Space] = ' ';
|
|
||||||
io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
|
|
||||||
io.KeyMap[ImGuiKey_Escape] = 27;
|
|
||||||
io.KeyMap[ImGuiKey_KeyPadEnter] = 13; // == CTRL+M
|
|
||||||
io.KeyMap[ImGuiKey_A] = 'A';
|
|
||||||
io.KeyMap[ImGuiKey_C] = 'C';
|
|
||||||
io.KeyMap[ImGuiKey_V] = 'V';
|
|
||||||
io.KeyMap[ImGuiKey_X] = 'X';
|
|
||||||
io.KeyMap[ImGuiKey_Y] = 'Y';
|
|
||||||
io.KeyMap[ImGuiKey_Z] = 'Z';
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,13 +204,20 @@ void ImGui_ImplGLUT_NewFrame()
|
|||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplGLUT_UpdateKeyboardMods()
|
static void ImGui_ImplGLUT_UpdateKeyModifiers()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
int mods = glutGetModifiers();
|
int glut_key_mods = glutGetModifiers();
|
||||||
io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0;
|
io.AddKeyEvent(ImGuiKey_ModCtrl, (glut_key_mods & GLUT_ACTIVE_CTRL) != 0);
|
||||||
io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0;
|
io.AddKeyEvent(ImGuiKey_ModShift, (glut_key_mods & GLUT_ACTIVE_SHIFT) != 0);
|
||||||
io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
|
io.AddKeyEvent(ImGuiKey_ModAlt, (glut_key_mods & GLUT_ACTIVE_ALT) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGLUT_AddKeyEvent(ImGuiKey key, bool down, int native_keycode)
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.AddKeyEvent(key, down);
|
||||||
|
io.SetKeyEventNativeData(key, native_keycode, -1); // To support legacy indexing (<1.87 user code)
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y)
|
void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y)
|
||||||
@ -127,79 +228,58 @@ void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y)
|
|||||||
if (c >= 32)
|
if (c >= 32)
|
||||||
io.AddInputCharacter((unsigned int)c);
|
io.AddInputCharacter((unsigned int)c);
|
||||||
|
|
||||||
// Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
|
ImGuiKey key = ImGui_ImplGLUT_KeyToImGuiKey(c);
|
||||||
// This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
|
ImGui_ImplGLUT_AddKeyEvent(key, true, c);
|
||||||
if (c >= 1 && c <= 26)
|
ImGui_ImplGLUT_UpdateKeyModifiers();
|
||||||
io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true;
|
|
||||||
else if (c >= 'a' && c <= 'z')
|
|
||||||
io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true;
|
|
||||||
else if (c >= 'A' && c <= 'Z')
|
|
||||||
io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
|
|
||||||
else
|
|
||||||
io.KeysDown[c] = true;
|
|
||||||
ImGui_ImplGLUT_UpdateKeyboardMods();
|
|
||||||
(void)x; (void)y; // Unused
|
(void)x; (void)y; // Unused
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
|
void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
|
||||||
{
|
{
|
||||||
//printf("char_up_func %d '%c'\n", c, c);
|
//printf("char_up_func %d '%c'\n", c, c);
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiKey key = ImGui_ImplGLUT_KeyToImGuiKey(c);
|
||||||
if (c >= 1 && c <= 26)
|
ImGui_ImplGLUT_AddKeyEvent(key, false, c);
|
||||||
io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false;
|
ImGui_ImplGLUT_UpdateKeyModifiers();
|
||||||
else if (c >= 'a' && c <= 'z')
|
|
||||||
io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false;
|
|
||||||
else if (c >= 'A' && c <= 'Z')
|
|
||||||
io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
|
|
||||||
else
|
|
||||||
io.KeysDown[c] = false;
|
|
||||||
ImGui_ImplGLUT_UpdateKeyboardMods();
|
|
||||||
(void)x; (void)y; // Unused
|
(void)x; (void)y; // Unused
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y)
|
void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y)
|
||||||
{
|
{
|
||||||
//printf("key_down_func %d\n", key);
|
//printf("key_down_func %d\n", key);
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiKey imgui_key = ImGui_ImplGLUT_KeyToImGuiKey(key + 256);
|
||||||
if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
|
ImGui_ImplGLUT_AddKeyEvent(imgui_key, true, key + 256);
|
||||||
io.KeysDown[key + 256] = true;
|
ImGui_ImplGLUT_UpdateKeyModifiers();
|
||||||
ImGui_ImplGLUT_UpdateKeyboardMods();
|
|
||||||
(void)x; (void)y; // Unused
|
(void)x; (void)y; // Unused
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y)
|
void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y)
|
||||||
{
|
{
|
||||||
//printf("key_up_func %d\n", key);
|
//printf("key_up_func %d\n", key);
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiKey imgui_key = ImGui_ImplGLUT_KeyToImGuiKey(key + 256);
|
||||||
if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
|
ImGui_ImplGLUT_AddKeyEvent(imgui_key, false, key + 256);
|
||||||
io.KeysDown[key + 256] = false;
|
ImGui_ImplGLUT_UpdateKeyModifiers();
|
||||||
ImGui_ImplGLUT_UpdateKeyboardMods();
|
|
||||||
(void)x; (void)y; // Unused
|
(void)x; (void)y; // Unused
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGLUT_MouseFunc(int glut_button, int state, int x, int y)
|
void ImGui_ImplGLUT_MouseFunc(int glut_button, int state, int x, int y)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.MousePos = ImVec2((float)x, (float)y);
|
io.AddMousePosEvent((float)x, (float)y);
|
||||||
int button = -1;
|
int button = -1;
|
||||||
if (glut_button == GLUT_LEFT_BUTTON) button = 0;
|
if (glut_button == GLUT_LEFT_BUTTON) button = 0;
|
||||||
if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
|
if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
|
||||||
if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
|
if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
|
||||||
if (button != -1 && state == GLUT_DOWN)
|
if (button != -1 && state == GLUT_DOWN || state == GLUT_UP)
|
||||||
io.MouseDown[button] = true;
|
io.AddMouseButtonEvent(button, state == GLUT_DOWN);
|
||||||
if (button != -1 && state == GLUT_UP)
|
|
||||||
io.MouseDown[button] = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __FREEGLUT_EXT_H__
|
#ifdef __FREEGLUT_EXT_H__
|
||||||
void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y)
|
void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.MousePos = ImVec2((float)x, (float)y);
|
io.AddMousePosEvent((float)x, (float)y);
|
||||||
if (dir > 0)
|
if (dir != 0)
|
||||||
io.MouseWheel += 1.0;
|
io.AddMouseWheelEvent(0.0f, dir > 0 ? 1.0f : -1.0f);
|
||||||
else if (dir < 0)
|
|
||||||
io.MouseWheel -= 1.0;
|
|
||||||
(void)button; // Unused
|
(void)button; // Unused
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -213,5 +293,5 @@ void ImGui_ImplGLUT_ReshapeFunc(int w, int h)
|
|||||||
void ImGui_ImplGLUT_MotionFunc(int x, int y)
|
void ImGui_ImplGLUT_MotionFunc(int x, int y)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.MousePos = ImVec2((float)x, (float)y);
|
io.AddMousePosEvent((float)x, (float)y);
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,15 @@
|
|||||||
// !!! If someone or something is teaching you GLUT today, you are being abused. Please show some resistance. !!!
|
// !!! If someone or something is teaching you GLUT today, you are being abused. Please show some resistance. !!!
|
||||||
// !!! Nowadays, prefer using GLFW or SDL instead!
|
// !!! Nowadays, prefer using GLFW or SDL instead!
|
||||||
|
|
||||||
|
// Implemented features:
|
||||||
|
// [X] Platform: Partial keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLUT values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// Issues:
|
// Issues:
|
||||||
// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
|
// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
|
||||||
// [ ] Platform: Missing mouse cursor shape/visibility support.
|
// [ ] Platform: Missing mouse cursor shape/visibility support.
|
||||||
// [ ] Platform: Missing clipboard support (not supported by Glut).
|
// [ ] Platform: Missing clipboard support (not supported by Glut).
|
||||||
// [ ] Platform: Missing gamepad support.
|
// [ ] Platform: Missing gamepad support.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
@ -12,6 +12,12 @@
|
|||||||
|
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// ObjC API
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
|
||||||
@class MTLRenderPassDescriptor;
|
@class MTLRenderPassDescriptor;
|
||||||
@protocol MTLDevice, MTLCommandBuffer, MTLRenderCommandEncoder;
|
@protocol MTLDevice, MTLCommandBuffer, MTLRenderCommandEncoder;
|
||||||
|
|
||||||
@ -27,3 +33,35 @@ IMGUI_IMPL_API bool ImGui_ImplMetal_CreateFontsTexture(id<MTLDevice> device);
|
|||||||
IMGUI_IMPL_API void ImGui_ImplMetal_DestroyFontsTexture();
|
IMGUI_IMPL_API void ImGui_ImplMetal_DestroyFontsTexture();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(id<MTLDevice> device);
|
IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(id<MTLDevice> device);
|
||||||
IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// C++ API
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Enable Metal C++ binding support with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file
|
||||||
|
// More info about using Metal from C++: https://developer.apple.com/metal/cpp/
|
||||||
|
|
||||||
|
#ifdef IMGUI_IMPL_METAL_CPP
|
||||||
|
|
||||||
|
#include <Metal/Metal.hpp>
|
||||||
|
|
||||||
|
#ifndef __OBJC__
|
||||||
|
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplMetal_Init(MTL::Device* device);
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor);
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data,
|
||||||
|
MTL::CommandBuffer* commandBuffer,
|
||||||
|
MTL::RenderCommandEncoder* commandEncoder);
|
||||||
|
|
||||||
|
// Called by Init/NewFrame/Shutdown
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplMetal_CreateFontsTexture(MTL::Device* device);
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplMetal_DestroyFontsTexture();
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(MTL::Device* device);
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2022-01-03: Metal: Ignore ImDrawCmd where ElemCount == 0 (very rare but can technically be manufactured by user code).
|
||||||
|
// 2021-12-30: Metal: Added Metal C++ support. Enable with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file.
|
||||||
// 2021-08-24: Metal: Fixed a crash when clipping rect larger than framebuffer is submitted. (#4464)
|
// 2021-08-24: Metal: Fixed a crash when clipping rect larger than framebuffer is submitted. (#4464)
|
||||||
// 2021-05-19: Metal: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
// 2021-05-19: Metal: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
||||||
// 2021-02-18: Metal: Change blending equation to preserve alpha in output buffer.
|
// 2021-02-18: Metal: Change blending equation to preserve alpha in output buffer.
|
||||||
@ -77,7 +79,43 @@
|
|||||||
|
|
||||||
static MetalContext *g_sharedMetalContext = nil;
|
static MetalContext *g_sharedMetalContext = nil;
|
||||||
|
|
||||||
#pragma mark - ImGui API implementation
|
#ifdef IMGUI_IMPL_METAL_CPP
|
||||||
|
|
||||||
|
#pragma mark - Dear ImGui Metal C++ Backend API
|
||||||
|
|
||||||
|
bool ImGui_ImplMetal_Init(MTL::Device* device)
|
||||||
|
{
|
||||||
|
return ImGui_ImplMetal_Init((id<MTLDevice>)(device));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor)
|
||||||
|
{
|
||||||
|
ImGui_ImplMetal_NewFrame((MTLRenderPassDescriptor*)(renderPassDescriptor));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data,
|
||||||
|
MTL::CommandBuffer* commandBuffer,
|
||||||
|
MTL::RenderCommandEncoder* commandEncoder)
|
||||||
|
{
|
||||||
|
ImGui_ImplMetal_RenderDrawData(draw_data,
|
||||||
|
(id<MTLCommandBuffer>)(commandBuffer),
|
||||||
|
(id<MTLRenderCommandEncoder>)(commandEncoder));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ImGui_ImplMetal_CreateFontsTexture(MTL::Device* device)
|
||||||
|
{
|
||||||
|
return ImGui_ImplMetal_CreateFontsTexture((id<MTLDevice>)(device));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ImGui_ImplMetal_CreateDeviceObjects(MTL::Device* device)
|
||||||
|
{
|
||||||
|
return ImGui_ImplMetal_CreateDeviceObjects((id<MTLDevice>)(device));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #ifdef IMGUI_IMPL_METAL_CPP
|
||||||
|
|
||||||
|
#pragma mark - Dear ImGui Metal Backend API
|
||||||
|
|
||||||
bool ImGui_ImplMetal_Init(id<MTLDevice> device)
|
bool ImGui_ImplMetal_Init(id<MTLDevice> device)
|
||||||
{
|
{
|
||||||
@ -515,6 +553,8 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
|
|||||||
if (clip_max.y > fb_height) { clip_max.y = (float)fb_height; }
|
if (clip_max.y > fb_height) { clip_max.y = (float)fb_height; }
|
||||||
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
||||||
continue;
|
continue;
|
||||||
|
if (pcmd->ElemCount == 0) // drawIndexedPrimitives() validation doesn't accept this
|
||||||
|
continue;
|
||||||
|
|
||||||
// Apply scissor/clipping rectangle
|
// Apply scissor/clipping rectangle
|
||||||
MTLScissorRect scissorRect =
|
MTLScissorRect scissorRect =
|
||||||
|
@ -96,9 +96,23 @@
|
|||||||
#include <stdint.h> // intptr_t
|
#include <stdint.h> // intptr_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Clang warnings with -Weverything
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast
|
||||||
|
#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness
|
||||||
|
#if __has_warning("-Wzero-as-null-pointer-constant")
|
||||||
|
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// GL includes
|
// GL includes
|
||||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||||
#include <GLES2/gl2.h>
|
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV))
|
||||||
|
#include <OpenGLES/ES2/gl.h> // Use GL ES 2
|
||||||
|
#else
|
||||||
|
#include <GLES2/gl2.h> // Use GL ES 2
|
||||||
|
#endif
|
||||||
#if defined(__EMSCRIPTEN__)
|
#if defined(__EMSCRIPTEN__)
|
||||||
#ifndef GL_GLEXT_PROTOTYPES
|
#ifndef GL_GLEXT_PROTOTYPES
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#define GL_GLEXT_PROTOTYPES
|
||||||
@ -464,7 +478,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Apply scissor/clipping rectangle (Y is inverted in OpenGL)
|
// Apply scissor/clipping rectangle (Y is inverted in OpenGL)
|
||||||
glScissor((int)clip_min.x, (int)(fb_height - clip_max.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y));
|
glScissor((int)clip_min.x, (int)((float)fb_height - clip_max.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y));
|
||||||
|
|
||||||
// Bind texture, Draw
|
// Bind texture, Draw
|
||||||
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->GetTexID());
|
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->GetTexID());
|
||||||
@ -791,3 +805,7 @@ void ImGui_ImplOpenGL3_DestroyDeviceObjects()
|
|||||||
if (bd->ShaderHandle) { glDeleteProgram(bd->ShaderHandle); bd->ShaderHandle = 0; }
|
if (bd->ShaderHandle) { glDeleteProgram(bd->ShaderHandle); bd->ShaderHandle = 0; }
|
||||||
ImGui_ImplOpenGL3_DestroyFontsTexture();
|
ImGui_ImplOpenGL3_DestroyFontsTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
@ -437,7 +437,7 @@ GL3W_API GL3WglProc imgl3wGetProcAddress(const char *proc);
|
|||||||
|
|
||||||
/* gl3w internal state */
|
/* gl3w internal state */
|
||||||
union GL3WProcs {
|
union GL3WProcs {
|
||||||
GL3WglProc ptr[53];
|
GL3WglProc ptr[54];
|
||||||
struct {
|
struct {
|
||||||
PFNGLACTIVETEXTUREPROC ActiveTexture;
|
PFNGLACTIVETEXTUREPROC ActiveTexture;
|
||||||
PFNGLATTACHSHADERPROC AttachShader;
|
PFNGLATTACHSHADERPROC AttachShader;
|
||||||
|
@ -4,10 +4,11 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy kVK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend).
|
// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend).
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Keyboard arrays indexed using kVK_* codes, e.g. ImGui::IsKeyPressed(kVK_Space).
|
// [X] Platform: IME support.
|
||||||
|
//
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
||||||
|
@ -4,9 +4,10 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy kVK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend).
|
// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend).
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Keyboard arrays indexed using kVK_* codes, e.g. ImGui::IsKeyPressed(kVK_Space).
|
// [X] Platform: IME support.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -22,6 +23,13 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2022-02-07: Inputs: Forward keyDown/keyUp events to OS when unused by dear imgui.
|
||||||
|
// 2022-01-31: Fix building with old Xcode versions that are missing gamepad features.
|
||||||
|
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago)with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
||||||
|
// 2021-01-20: Inputs: calling new io.AddKeyAnalogEvent() for gamepad support, instead of writing directly to io.NavInputs[].
|
||||||
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
|
// 2022-01-12: Inputs: Added basic Platform IME support, hooking the io.SetPlatformImeDataFn() function.
|
||||||
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
// 2021-12-13: *BREAKING CHANGE* Add NSView parameter to ImGui_ImplOSX_Init(). Generally fix keyboard support. Using kVK_* codes for keyboard keys.
|
// 2021-12-13: *BREAKING CHANGE* Add NSView parameter to ImGui_ImplOSX_Init(). Generally fix keyboard support. Using kVK_* codes for keyboard keys.
|
||||||
// 2021-12-13: Add game controller support.
|
// 2021-12-13: Add game controller support.
|
||||||
// 2021-09-21: Use mach_absolute_time as CFAbsoluteTimeGetCurrent can jump backwards.
|
// 2021-09-21: Use mach_absolute_time as CFAbsoluteTimeGetCurrent can jump backwards.
|
||||||
@ -40,6 +48,10 @@
|
|||||||
// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
|
// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
|
||||||
// 2018-07-07: Initial version.
|
// 2018-07-07: Initial version.
|
||||||
|
|
||||||
|
#define APPLE_HAS_BUTTON_OPTIONS (__IPHONE_OS_VERSION_MIN_REQUIRED >= 130000 || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 || __TV_OS_VERSION_MIN_REQUIRED >= 130000)
|
||||||
|
#define APPLE_HAS_CONTROLLER (__IPHONE_OS_VERSION_MIN_REQUIRED >= 140000 || __MAC_OS_X_VERSION_MIN_REQUIRED >= 110000 || __TV_OS_VERSION_MIN_REQUIRED >= 140000)
|
||||||
|
#define APPLE_HAS_THUMBSTICKS (__IPHONE_OS_VERSION_MIN_REQUIRED >= 120100 || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101401 || __TV_OS_VERSION_MIN_REQUIRED >= 120100)
|
||||||
|
|
||||||
@class ImFocusObserver;
|
@class ImFocusObserver;
|
||||||
@class KeyEventResponder;
|
@class KeyEventResponder;
|
||||||
|
|
||||||
@ -48,10 +60,9 @@ static double g_HostClockPeriod = 0.0;
|
|||||||
static double g_Time = 0.0;
|
static double g_Time = 0.0;
|
||||||
static NSCursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {};
|
static NSCursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {};
|
||||||
static bool g_MouseCursorHidden = false;
|
static bool g_MouseCursorHidden = false;
|
||||||
static bool g_MouseJustPressed[ImGuiMouseButton_COUNT] = {};
|
|
||||||
static bool g_MouseDown[ImGuiMouseButton_COUNT] = {};
|
|
||||||
static ImFocusObserver* g_FocusObserver = nil;
|
static ImFocusObserver* g_FocusObserver = nil;
|
||||||
static KeyEventResponder* g_KeyEventResponder = nil;
|
static KeyEventResponder* g_KeyEventResponder = nil;
|
||||||
|
static NSTextInputContext* g_InputContext = nil;
|
||||||
|
|
||||||
// Undocumented methods for creating cursors.
|
// Undocumented methods for creating cursors.
|
||||||
@interface NSCursor()
|
@interface NSCursor()
|
||||||
@ -73,13 +84,6 @@ static double GetMachAbsoluteTimeInSeconds()
|
|||||||
return (double)mach_absolute_time() * g_HostClockPeriod;
|
return (double)mach_absolute_time() * g_HostClockPeriod;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resetKeys()
|
|
||||||
{
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
memset(io.KeysDown, 0, sizeof(io.KeysDown));
|
|
||||||
io.KeyCtrl = io.KeyShift = io.KeyAlt = io.KeySuper = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
KeyEventResponder implements the NSTextInputClient protocol as is required by the macOS text input manager.
|
KeyEventResponder implements the NSTextInputClient protocol as is required by the macOS text input manager.
|
||||||
|
|
||||||
@ -96,6 +100,29 @@ static void resetKeys()
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation KeyEventResponder
|
@implementation KeyEventResponder
|
||||||
|
{
|
||||||
|
float _posX;
|
||||||
|
float _posY;
|
||||||
|
NSRect _imeRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Public
|
||||||
|
|
||||||
|
- (void)setImePosX:(float)posX imePosY:(float)posY
|
||||||
|
{
|
||||||
|
_posX = posX;
|
||||||
|
_posY = posY;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)updateImePosWithView:(NSView *)view
|
||||||
|
{
|
||||||
|
NSWindow *window = view.window;
|
||||||
|
if (!window)
|
||||||
|
return;
|
||||||
|
NSRect contentRect = [window contentRectForFrameRect:window.frame];
|
||||||
|
NSRect rect = NSMakeRect(_posX, contentRect.size.height - _posY, 0, 0);
|
||||||
|
_imeRect = [window convertRectToScreen:rect];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)viewDidMoveToWindow
|
- (void)viewDidMoveToWindow
|
||||||
{
|
{
|
||||||
@ -105,10 +132,19 @@ static void resetKeys()
|
|||||||
|
|
||||||
- (void)keyDown:(NSEvent*)event
|
- (void)keyDown:(NSEvent*)event
|
||||||
{
|
{
|
||||||
|
if (!ImGui_ImplOSX_HandleEvent(event, self))
|
||||||
|
[super keyDown:event];
|
||||||
|
|
||||||
// Call to the macOS input manager system.
|
// Call to the macOS input manager system.
|
||||||
[self interpretKeyEvents:@[event]];
|
[self interpretKeyEvents:@[event]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)keyUp:(NSEvent*)event
|
||||||
|
{
|
||||||
|
if (!ImGui_ImplOSX_HandleEvent(event, self))
|
||||||
|
[super keyUp:event];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange
|
- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@ -143,7 +179,7 @@ static void resetKeys()
|
|||||||
|
|
||||||
- (NSRect)firstRectForCharacterRange:(NSRange)range actualRange:(nullable NSRangePointer)actualRange
|
- (NSRect)firstRectForCharacterRange:(NSRange)range actualRange:(nullable NSRangePointer)actualRange
|
||||||
{
|
{
|
||||||
return NSZeroRect;
|
return _imeRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)hasMarkedText
|
- (BOOL)hasMarkedText
|
||||||
@ -195,16 +231,134 @@ static void resetKeys()
|
|||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.AddFocusEvent(false);
|
io.AddFocusEvent(false);
|
||||||
|
|
||||||
// Unfocused applications do not receive input events, therefore we must manually
|
|
||||||
// release any pressed keys when application loses focus, otherwise they would remain
|
|
||||||
// stuck in a pressed state. https://github.com/ocornut/imgui/issues/3832
|
|
||||||
resetKeys();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
|
static ImGuiKey ImGui_ImplOSX_KeyCodeToImGuiKey(int key_code)
|
||||||
|
{
|
||||||
|
switch (key_code)
|
||||||
|
{
|
||||||
|
case kVK_ANSI_A: return ImGuiKey_A;
|
||||||
|
case kVK_ANSI_S: return ImGuiKey_S;
|
||||||
|
case kVK_ANSI_D: return ImGuiKey_D;
|
||||||
|
case kVK_ANSI_F: return ImGuiKey_F;
|
||||||
|
case kVK_ANSI_H: return ImGuiKey_H;
|
||||||
|
case kVK_ANSI_G: return ImGuiKey_G;
|
||||||
|
case kVK_ANSI_Z: return ImGuiKey_Z;
|
||||||
|
case kVK_ANSI_X: return ImGuiKey_X;
|
||||||
|
case kVK_ANSI_C: return ImGuiKey_C;
|
||||||
|
case kVK_ANSI_V: return ImGuiKey_V;
|
||||||
|
case kVK_ANSI_B: return ImGuiKey_B;
|
||||||
|
case kVK_ANSI_Q: return ImGuiKey_Q;
|
||||||
|
case kVK_ANSI_W: return ImGuiKey_W;
|
||||||
|
case kVK_ANSI_E: return ImGuiKey_E;
|
||||||
|
case kVK_ANSI_R: return ImGuiKey_R;
|
||||||
|
case kVK_ANSI_Y: return ImGuiKey_Y;
|
||||||
|
case kVK_ANSI_T: return ImGuiKey_T;
|
||||||
|
case kVK_ANSI_1: return ImGuiKey_1;
|
||||||
|
case kVK_ANSI_2: return ImGuiKey_2;
|
||||||
|
case kVK_ANSI_3: return ImGuiKey_3;
|
||||||
|
case kVK_ANSI_4: return ImGuiKey_4;
|
||||||
|
case kVK_ANSI_6: return ImGuiKey_6;
|
||||||
|
case kVK_ANSI_5: return ImGuiKey_5;
|
||||||
|
case kVK_ANSI_Equal: return ImGuiKey_Equal;
|
||||||
|
case kVK_ANSI_9: return ImGuiKey_9;
|
||||||
|
case kVK_ANSI_7: return ImGuiKey_7;
|
||||||
|
case kVK_ANSI_Minus: return ImGuiKey_Minus;
|
||||||
|
case kVK_ANSI_8: return ImGuiKey_8;
|
||||||
|
case kVK_ANSI_0: return ImGuiKey_0;
|
||||||
|
case kVK_ANSI_RightBracket: return ImGuiKey_RightBracket;
|
||||||
|
case kVK_ANSI_O: return ImGuiKey_O;
|
||||||
|
case kVK_ANSI_U: return ImGuiKey_U;
|
||||||
|
case kVK_ANSI_LeftBracket: return ImGuiKey_LeftBracket;
|
||||||
|
case kVK_ANSI_I: return ImGuiKey_I;
|
||||||
|
case kVK_ANSI_P: return ImGuiKey_P;
|
||||||
|
case kVK_ANSI_L: return ImGuiKey_L;
|
||||||
|
case kVK_ANSI_J: return ImGuiKey_J;
|
||||||
|
case kVK_ANSI_Quote: return ImGuiKey_Apostrophe;
|
||||||
|
case kVK_ANSI_K: return ImGuiKey_K;
|
||||||
|
case kVK_ANSI_Semicolon: return ImGuiKey_Semicolon;
|
||||||
|
case kVK_ANSI_Backslash: return ImGuiKey_Backslash;
|
||||||
|
case kVK_ANSI_Comma: return ImGuiKey_Comma;
|
||||||
|
case kVK_ANSI_Slash: return ImGuiKey_Slash;
|
||||||
|
case kVK_ANSI_N: return ImGuiKey_N;
|
||||||
|
case kVK_ANSI_M: return ImGuiKey_M;
|
||||||
|
case kVK_ANSI_Period: return ImGuiKey_Period;
|
||||||
|
case kVK_ANSI_Grave: return ImGuiKey_GraveAccent;
|
||||||
|
case kVK_ANSI_KeypadDecimal: return ImGuiKey_KeypadDecimal;
|
||||||
|
case kVK_ANSI_KeypadMultiply: return ImGuiKey_KeypadMultiply;
|
||||||
|
case kVK_ANSI_KeypadPlus: return ImGuiKey_KeypadAdd;
|
||||||
|
case kVK_ANSI_KeypadClear: return ImGuiKey_NumLock;
|
||||||
|
case kVK_ANSI_KeypadDivide: return ImGuiKey_KeypadDivide;
|
||||||
|
case kVK_ANSI_KeypadEnter: return ImGuiKey_KeypadEnter;
|
||||||
|
case kVK_ANSI_KeypadMinus: return ImGuiKey_KeypadSubtract;
|
||||||
|
case kVK_ANSI_KeypadEquals: return ImGuiKey_KeypadEqual;
|
||||||
|
case kVK_ANSI_Keypad0: return ImGuiKey_Keypad0;
|
||||||
|
case kVK_ANSI_Keypad1: return ImGuiKey_Keypad1;
|
||||||
|
case kVK_ANSI_Keypad2: return ImGuiKey_Keypad2;
|
||||||
|
case kVK_ANSI_Keypad3: return ImGuiKey_Keypad3;
|
||||||
|
case kVK_ANSI_Keypad4: return ImGuiKey_Keypad4;
|
||||||
|
case kVK_ANSI_Keypad5: return ImGuiKey_Keypad5;
|
||||||
|
case kVK_ANSI_Keypad6: return ImGuiKey_Keypad6;
|
||||||
|
case kVK_ANSI_Keypad7: return ImGuiKey_Keypad7;
|
||||||
|
case kVK_ANSI_Keypad8: return ImGuiKey_Keypad8;
|
||||||
|
case kVK_ANSI_Keypad9: return ImGuiKey_Keypad9;
|
||||||
|
case kVK_Return: return ImGuiKey_Enter;
|
||||||
|
case kVK_Tab: return ImGuiKey_Tab;
|
||||||
|
case kVK_Space: return ImGuiKey_Space;
|
||||||
|
case kVK_Delete: return ImGuiKey_Backspace;
|
||||||
|
case kVK_Escape: return ImGuiKey_Escape;
|
||||||
|
case kVK_CapsLock: return ImGuiKey_CapsLock;
|
||||||
|
case kVK_Control: return ImGuiKey_LeftCtrl;
|
||||||
|
case kVK_Shift: return ImGuiKey_LeftShift;
|
||||||
|
case kVK_Option: return ImGuiKey_LeftAlt;
|
||||||
|
case kVK_Command: return ImGuiKey_LeftSuper;
|
||||||
|
case kVK_RightControl: return ImGuiKey_RightCtrl;
|
||||||
|
case kVK_RightShift: return ImGuiKey_RightShift;
|
||||||
|
case kVK_RightOption: return ImGuiKey_RightAlt;
|
||||||
|
case kVK_RightCommand: return ImGuiKey_RightSuper;
|
||||||
|
// case kVK_Function: return ImGuiKey_;
|
||||||
|
// case kVK_F17: return ImGuiKey_;
|
||||||
|
// case kVK_VolumeUp: return ImGuiKey_;
|
||||||
|
// case kVK_VolumeDown: return ImGuiKey_;
|
||||||
|
// case kVK_Mute: return ImGuiKey_;
|
||||||
|
// case kVK_F18: return ImGuiKey_;
|
||||||
|
// case kVK_F19: return ImGuiKey_;
|
||||||
|
// case kVK_F20: return ImGuiKey_;
|
||||||
|
case kVK_F5: return ImGuiKey_F5;
|
||||||
|
case kVK_F6: return ImGuiKey_F6;
|
||||||
|
case kVK_F7: return ImGuiKey_F7;
|
||||||
|
case kVK_F3: return ImGuiKey_F3;
|
||||||
|
case kVK_F8: return ImGuiKey_F8;
|
||||||
|
case kVK_F9: return ImGuiKey_F9;
|
||||||
|
case kVK_F11: return ImGuiKey_F11;
|
||||||
|
case kVK_F13: return ImGuiKey_PrintScreen;
|
||||||
|
// case kVK_F16: return ImGuiKey_;
|
||||||
|
// case kVK_F14: return ImGuiKey_;
|
||||||
|
case kVK_F10: return ImGuiKey_F10;
|
||||||
|
case 0x6E: return ImGuiKey_Menu;
|
||||||
|
case kVK_F12: return ImGuiKey_F12;
|
||||||
|
// case kVK_F15: return ImGuiKey_;
|
||||||
|
case kVK_Help: return ImGuiKey_Insert;
|
||||||
|
case kVK_Home: return ImGuiKey_Home;
|
||||||
|
case kVK_PageUp: return ImGuiKey_PageUp;
|
||||||
|
case kVK_ForwardDelete: return ImGuiKey_Delete;
|
||||||
|
case kVK_F4: return ImGuiKey_F4;
|
||||||
|
case kVK_End: return ImGuiKey_End;
|
||||||
|
case kVK_F2: return ImGuiKey_F2;
|
||||||
|
case kVK_PageDown: return ImGuiKey_PageDown;
|
||||||
|
case kVK_F1: return ImGuiKey_F1;
|
||||||
|
case kVK_LeftArrow: return ImGuiKey_LeftArrow;
|
||||||
|
case kVK_RightArrow: return ImGuiKey_RightArrow;
|
||||||
|
case kVK_DownArrow: return ImGuiKey_DownArrow;
|
||||||
|
case kVK_UpArrow: return ImGuiKey_UpArrow;
|
||||||
|
default: return ImGuiKey_None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ImGui_ImplOSX_Init(NSView* view)
|
bool ImGui_ImplOSX_Init(NSView* view)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@ -216,30 +370,6 @@ bool ImGui_ImplOSX_Init(NSView* view)
|
|||||||
//io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can set io.MouseHoveredViewport correctly (optional, not easy)
|
//io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can set io.MouseHoveredViewport correctly (optional, not easy)
|
||||||
io.BackendPlatformName = "imgui_impl_osx";
|
io.BackendPlatformName = "imgui_impl_osx";
|
||||||
|
|
||||||
// Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeyDown[] array.
|
|
||||||
io.KeyMap[ImGuiKey_Tab] = kVK_Tab;
|
|
||||||
io.KeyMap[ImGuiKey_LeftArrow] = kVK_LeftArrow;
|
|
||||||
io.KeyMap[ImGuiKey_RightArrow] = kVK_RightArrow;
|
|
||||||
io.KeyMap[ImGuiKey_UpArrow] = kVK_UpArrow;
|
|
||||||
io.KeyMap[ImGuiKey_DownArrow] = kVK_DownArrow;
|
|
||||||
io.KeyMap[ImGuiKey_PageUp] = kVK_PageUp;
|
|
||||||
io.KeyMap[ImGuiKey_PageDown] = kVK_PageDown;
|
|
||||||
io.KeyMap[ImGuiKey_Home] = kVK_Home;
|
|
||||||
io.KeyMap[ImGuiKey_End] = kVK_End;
|
|
||||||
io.KeyMap[ImGuiKey_Insert] = kVK_F13;
|
|
||||||
io.KeyMap[ImGuiKey_Delete] = kVK_ForwardDelete;
|
|
||||||
io.KeyMap[ImGuiKey_Backspace] = kVK_Delete;
|
|
||||||
io.KeyMap[ImGuiKey_Space] = kVK_Space;
|
|
||||||
io.KeyMap[ImGuiKey_Enter] = kVK_Return;
|
|
||||||
io.KeyMap[ImGuiKey_Escape] = kVK_Escape;
|
|
||||||
io.KeyMap[ImGuiKey_KeyPadEnter] = kVK_ANSI_KeypadEnter;
|
|
||||||
io.KeyMap[ImGuiKey_A] = kVK_ANSI_A;
|
|
||||||
io.KeyMap[ImGuiKey_C] = kVK_ANSI_C;
|
|
||||||
io.KeyMap[ImGuiKey_V] = kVK_ANSI_V;
|
|
||||||
io.KeyMap[ImGuiKey_X] = kVK_ANSI_X;
|
|
||||||
io.KeyMap[ImGuiKey_Y] = kVK_ANSI_Y;
|
|
||||||
io.KeyMap[ImGuiKey_Z] = kVK_ANSI_Z;
|
|
||||||
|
|
||||||
// Load cursors. Some of them are undocumented.
|
// Load cursors. Some of them are undocumented.
|
||||||
g_MouseCursorHidden = false;
|
g_MouseCursorHidden = false;
|
||||||
g_MouseCursors[ImGuiMouseCursor_Arrow] = [NSCursor arrowCursor];
|
g_MouseCursors[ImGuiMouseCursor_Arrow] = [NSCursor arrowCursor];
|
||||||
@ -294,8 +424,33 @@ bool ImGui_ImplOSX_Init(NSView* view)
|
|||||||
// Add the NSTextInputClient to the view hierarchy,
|
// Add the NSTextInputClient to the view hierarchy,
|
||||||
// to receive keyboard events and translate them to input text.
|
// to receive keyboard events and translate them to input text.
|
||||||
g_KeyEventResponder = [[KeyEventResponder alloc] initWithFrame:NSZeroRect];
|
g_KeyEventResponder = [[KeyEventResponder alloc] initWithFrame:NSZeroRect];
|
||||||
|
g_InputContext = [[NSTextInputContext alloc] initWithClient:g_KeyEventResponder];
|
||||||
[view addSubview:g_KeyEventResponder];
|
[view addSubview:g_KeyEventResponder];
|
||||||
|
|
||||||
|
// Some events do not raise callbacks of AppView in some circumstances (for example when CMD key is held down).
|
||||||
|
// This monitor taps into global event stream and captures these events.
|
||||||
|
NSEventMask eventMask = NSEventMaskFlagsChanged;
|
||||||
|
[NSEvent addLocalMonitorForEventsMatchingMask:eventMask handler:^NSEvent * _Nullable(NSEvent *event)
|
||||||
|
{
|
||||||
|
ImGui_ImplOSX_HandleEvent(event, g_KeyEventResponder);
|
||||||
|
return event;
|
||||||
|
}];
|
||||||
|
|
||||||
|
io.SetPlatformImeDataFn = [](ImGuiViewport* viewport, ImGuiPlatformImeData* data) -> void
|
||||||
|
{
|
||||||
|
if (data->WantVisible)
|
||||||
|
{
|
||||||
|
[g_InputContext activate];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[g_InputContext discardMarkedText];
|
||||||
|
[g_InputContext invalidateCharacterCoordinates];
|
||||||
|
[g_InputContext deactivate];
|
||||||
|
}
|
||||||
|
[g_KeyEventResponder setImePosX:data->InputPos.x imePosY:data->InputPos.y + data->InputLineHeight];
|
||||||
|
};
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,17 +459,9 @@ void ImGui_ImplOSX_Shutdown()
|
|||||||
g_FocusObserver = NULL;
|
g_FocusObserver = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplOSX_UpdateMouseCursorAndButtons()
|
static void ImGui_ImplOSX_UpdateMouseCursor()
|
||||||
{
|
{
|
||||||
// Update buttons
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++)
|
|
||||||
{
|
|
||||||
// If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
|
|
||||||
io.MouseDown[i] = g_MouseJustPressed[i] || g_MouseDown[i];
|
|
||||||
g_MouseJustPressed[i] = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange)
|
if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -344,19 +491,18 @@ static void ImGui_ImplOSX_UpdateMouseCursorAndButtons()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplOSX_UpdateGamepads()
|
static void ImGui_ImplOSX_UpdateGamepads()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
memset(io.NavInputs, 0, sizeof(io.NavInputs));
|
memset(io.NavInputs, 0, sizeof(io.NavInputs));
|
||||||
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GCController* controller;
|
#if APPLE_HAS_CONTROLLER
|
||||||
if (@available(macOS 11.0, *))
|
GCController* controller = GCController.current;
|
||||||
controller = GCController.current;
|
#else
|
||||||
else
|
GCController* controller = GCController.controllers.firstObject;
|
||||||
controller = GCController.controllers.firstObject;
|
#endif
|
||||||
|
|
||||||
if (controller == nil || controller.extendedGamepad == nil)
|
if (controller == nil || controller.extendedGamepad == nil)
|
||||||
{
|
{
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
||||||
@ -365,29 +511,52 @@ void ImGui_ImplOSX_UpdateGamepads()
|
|||||||
|
|
||||||
GCExtendedGamepad* gp = controller.extendedGamepad;
|
GCExtendedGamepad* gp = controller.extendedGamepad;
|
||||||
|
|
||||||
#define MAP_BUTTON(NAV_NO, NAME) { io.NavInputs[NAV_NO] = gp.NAME.isPressed ? 1.0 : 0.0; }
|
// Update gamepad inputs
|
||||||
MAP_BUTTON(ImGuiNavInput_Activate, buttonA);
|
#define IM_SATURATE(V) (V < 0.0f ? 0.0f : V > 1.0f ? 1.0f : V)
|
||||||
MAP_BUTTON(ImGuiNavInput_Cancel, buttonB);
|
#define MAP_BUTTON(KEY_NO, BUTTON_NAME) { io.AddKeyEvent(KEY_NO, gp.BUTTON_NAME.isPressed); }
|
||||||
MAP_BUTTON(ImGuiNavInput_Menu, buttonX);
|
#define MAP_ANALOG(KEY_NO, AXIS_NAME, V0, V1) { float vn = (float)(gp.AXIS_NAME.value - V0) / (float)(V1 - V0); vn = IM_SATURATE(vn); io.AddKeyAnalogEvent(KEY_NO, vn > 0.1f, vn); }
|
||||||
MAP_BUTTON(ImGuiNavInput_Input, buttonY);
|
const float thumb_dead_zone = 0.0f;
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadLeft, dpad.left);
|
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadRight, dpad.right);
|
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadUp, dpad.up);
|
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadDown, dpad.down);
|
|
||||||
MAP_BUTTON(ImGuiNavInput_FocusPrev, leftShoulder);
|
|
||||||
MAP_BUTTON(ImGuiNavInput_FocusNext, rightShoulder);
|
|
||||||
MAP_BUTTON(ImGuiNavInput_TweakSlow, leftTrigger);
|
|
||||||
MAP_BUTTON(ImGuiNavInput_TweakFast, rightTrigger);
|
|
||||||
#undef MAP_BUTTON
|
|
||||||
|
|
||||||
io.NavInputs[ImGuiNavInput_LStickLeft] = gp.leftThumbstick.left.value;
|
#if APPLE_HAS_BUTTON_OPTIONS
|
||||||
io.NavInputs[ImGuiNavInput_LStickRight] = gp.leftThumbstick.right.value;
|
MAP_BUTTON(ImGuiKey_GamepadBack, buttonOptions);
|
||||||
io.NavInputs[ImGuiNavInput_LStickUp] = gp.leftThumbstick.up.value;
|
#endif
|
||||||
io.NavInputs[ImGuiNavInput_LStickDown] = gp.leftThumbstick.down.value;
|
MAP_BUTTON(ImGuiKey_GamepadFaceDown, buttonA); // Xbox A, PS Cross
|
||||||
|
MAP_BUTTON(ImGuiKey_GamepadFaceRight, buttonB); // Xbox B, PS Circle
|
||||||
|
MAP_BUTTON(ImGuiKey_GamepadFaceLeft, buttonX); // Xbox X, PS Square
|
||||||
|
MAP_BUTTON(ImGuiKey_GamepadFaceUp, buttonY); // Xbox Y, PS Triangle
|
||||||
|
MAP_BUTTON(ImGuiKey_GamepadDpadLeft, dpad.left);
|
||||||
|
MAP_BUTTON(ImGuiKey_GamepadDpadRight, dpad.right);
|
||||||
|
MAP_BUTTON(ImGuiKey_GamepadDpadUp, dpad.up);
|
||||||
|
MAP_BUTTON(ImGuiKey_GamepadDpadDown, dpad.down);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadL1, leftShoulder, 0.0f, 1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadR1, rightShoulder, 0.0f, 1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadL2, leftTrigger, 0.0f, 1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadR2, rightTrigger, 0.0f, 1.0f);
|
||||||
|
#if APPLE_HAS_THUMBSTICKS
|
||||||
|
MAP_BUTTON(ImGuiKey_GamepadL3, leftThumbstickButton);
|
||||||
|
MAP_BUTTON(ImGuiKey_GamepadR3, rightThumbstickButton);
|
||||||
|
#endif
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadLStickLeft, leftThumbstick.xAxis, -thumb_dead_zone, -1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadLStickRight, leftThumbstick.xAxis, +thumb_dead_zone, +1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadLStickUp, leftThumbstick.yAxis, +thumb_dead_zone, +1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadLStickDown, leftThumbstick.yAxis, -thumb_dead_zone, -1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickLeft, rightThumbstick.xAxis, -thumb_dead_zone, -1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickRight, rightThumbstick.xAxis, +thumb_dead_zone, +1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickUp, rightThumbstick.yAxis, +thumb_dead_zone, +1.0f);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickDown, rightThumbstick.yAxis, -thumb_dead_zone, -1.0f);
|
||||||
|
#undef MAP_BUTTON
|
||||||
|
#undef MAP_ANALOG
|
||||||
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_UpdateImePosWithView(NSView* view)
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
if (io.WantTextInput)
|
||||||
|
[g_KeyEventResponder updateImePosWithView:view];
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui_ImplOSX_NewFrame(NSView* view)
|
void ImGui_ImplOSX_NewFrame(NSView* view)
|
||||||
{
|
{
|
||||||
// Setup display size
|
// Setup display size
|
||||||
@ -409,26 +578,9 @@ void ImGui_ImplOSX_NewFrame(NSView* view)
|
|||||||
io.DeltaTime = (float)(current_time - g_Time);
|
io.DeltaTime = (float)(current_time - g_Time);
|
||||||
g_Time = current_time;
|
g_Time = current_time;
|
||||||
|
|
||||||
ImGui_ImplOSX_UpdateMouseCursorAndButtons();
|
ImGui_ImplOSX_UpdateMouseCursor();
|
||||||
ImGui_ImplOSX_UpdateGamepads();
|
ImGui_ImplOSX_UpdateGamepads();
|
||||||
}
|
ImGui_ImplOSX_UpdateImePosWithView(view);
|
||||||
|
|
||||||
NSString* NSStringFromPhase(NSEventPhase phase)
|
|
||||||
{
|
|
||||||
static NSString* strings[] =
|
|
||||||
{
|
|
||||||
@"none",
|
|
||||||
@"began",
|
|
||||||
@"stationary",
|
|
||||||
@"changed",
|
|
||||||
@"ended",
|
|
||||||
@"cancelled",
|
|
||||||
@"mayBegin",
|
|
||||||
};
|
|
||||||
|
|
||||||
int pos = phase == NSEventPhaseNone ? 0 : __builtin_ctzl((NSUInteger)phase) + 1;
|
|
||||||
|
|
||||||
return strings[pos];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
||||||
@ -438,16 +590,16 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
|||||||
if (event.type == NSEventTypeLeftMouseDown || event.type == NSEventTypeRightMouseDown || event.type == NSEventTypeOtherMouseDown)
|
if (event.type == NSEventTypeLeftMouseDown || event.type == NSEventTypeRightMouseDown || event.type == NSEventTypeOtherMouseDown)
|
||||||
{
|
{
|
||||||
int button = (int)[event buttonNumber];
|
int button = (int)[event buttonNumber];
|
||||||
if (button >= 0 && button < IM_ARRAYSIZE(g_MouseDown))
|
if (button >= 0 && button < ImGuiMouseButton_COUNT)
|
||||||
g_MouseDown[button] = g_MouseJustPressed[button] = true;
|
io.AddMouseButtonEvent(button, true);
|
||||||
return io.WantCaptureMouse;
|
return io.WantCaptureMouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type == NSEventTypeLeftMouseUp || event.type == NSEventTypeRightMouseUp || event.type == NSEventTypeOtherMouseUp)
|
if (event.type == NSEventTypeLeftMouseUp || event.type == NSEventTypeRightMouseUp || event.type == NSEventTypeOtherMouseUp)
|
||||||
{
|
{
|
||||||
int button = (int)[event buttonNumber];
|
int button = (int)[event buttonNumber];
|
||||||
if (button >= 0 && button < IM_ARRAYSIZE(g_MouseDown))
|
if (button >= 0 && button < ImGuiMouseButton_COUNT)
|
||||||
g_MouseDown[button] = false;
|
io.AddMouseButtonEvent(button, false);
|
||||||
return io.WantCaptureMouse;
|
return io.WantCaptureMouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,7 +608,7 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
|||||||
NSPoint mousePoint = event.locationInWindow;
|
NSPoint mousePoint = event.locationInWindow;
|
||||||
mousePoint = [view convertPoint:mousePoint fromView:nil];
|
mousePoint = [view convertPoint:mousePoint fromView:nil];
|
||||||
mousePoint = NSMakePoint(mousePoint.x, view.bounds.size.height - mousePoint.y);
|
mousePoint = NSMakePoint(mousePoint.x, view.bounds.size.height - mousePoint.y);
|
||||||
io.MousePos = ImVec2((float)mousePoint.x, (float)mousePoint.y);
|
io.AddMousePosEvent((float)mousePoint.x, (float)mousePoint.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type == NSEventTypeScrollWheel)
|
if (event.type == NSEventTypeScrollWheel)
|
||||||
@ -496,47 +648,61 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
|||||||
wheel_dx = [event deltaX];
|
wheel_dx = [event deltaX];
|
||||||
wheel_dy = [event deltaY];
|
wheel_dy = [event deltaY];
|
||||||
}
|
}
|
||||||
|
if (wheel_dx != 0.0 || wheel_dx != 0.0)
|
||||||
|
io.AddMouseWheelEvent((float)wheel_dx * 0.1f, (float)wheel_dy * 0.1f);
|
||||||
|
|
||||||
//NSLog(@"dx=%0.3ff, dy=%0.3f, phase=%@", wheel_dx, wheel_dy, NSStringFromPhase(event.phase));
|
|
||||||
|
|
||||||
if (fabs(wheel_dx) > 0.0)
|
|
||||||
io.MouseWheelH += (float)wheel_dx * 0.1f;
|
|
||||||
if (fabs(wheel_dy) > 0.0)
|
|
||||||
io.MouseWheel += (float)wheel_dy * 0.1f;
|
|
||||||
return io.WantCaptureMouse;
|
return io.WantCaptureMouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type == NSEventTypeKeyDown || event.type == NSEventTypeKeyUp)
|
if (event.type == NSEventTypeKeyDown || event.type == NSEventTypeKeyUp)
|
||||||
{
|
{
|
||||||
unsigned short code = event.keyCode;
|
if ([event isARepeat])
|
||||||
IM_ASSERT(code >= 0 && code < IM_ARRAYSIZE(io.KeysDown));
|
return io.WantCaptureKeyboard;
|
||||||
io.KeysDown[code] = event.type == NSEventTypeKeyDown;
|
|
||||||
NSEventModifierFlags flags = event.modifierFlags;
|
int key_code = (int)[event keyCode];
|
||||||
io.KeyCtrl = (flags & NSEventModifierFlagControl) != 0;
|
ImGuiKey key = ImGui_ImplOSX_KeyCodeToImGuiKey(key_code);
|
||||||
io.KeyShift = (flags & NSEventModifierFlagShift) != 0;
|
io.AddKeyEvent(key, event.type == NSEventTypeKeyDown);
|
||||||
io.KeyAlt = (flags & NSEventModifierFlagOption) != 0;
|
io.SetKeyEventNativeData(key, key_code, -1); // To support legacy indexing (<1.87 user code)
|
||||||
io.KeySuper = (flags & NSEventModifierFlagCommand) != 0;
|
|
||||||
return io.WantCaptureKeyboard;
|
return io.WantCaptureKeyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type == NSEventTypeFlagsChanged)
|
if (event.type == NSEventTypeFlagsChanged)
|
||||||
{
|
{
|
||||||
NSEventModifierFlags flags = event.modifierFlags;
|
unsigned short key_code = [event keyCode];
|
||||||
switch (event.keyCode)
|
NSEventModifierFlags modifier_flags = [event modifierFlags];
|
||||||
|
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModShift, (modifier_flags & NSEventModifierFlagShift) != 0);
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModCtrl, (modifier_flags & NSEventModifierFlagControl) != 0);
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModAlt, (modifier_flags & NSEventModifierFlagOption) != 0);
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModSuper, (modifier_flags & NSEventModifierFlagCommand) != 0);
|
||||||
|
|
||||||
|
ImGuiKey key = ImGui_ImplOSX_KeyCodeToImGuiKey(key_code);
|
||||||
|
if (key != ImGuiKey_None)
|
||||||
{
|
{
|
||||||
case kVK_Control:
|
// macOS does not generate down/up event for modifiers. We're trying
|
||||||
io.KeyCtrl = (flags & NSEventModifierFlagControl) != 0;
|
// to use hardware dependent masks to extract that information.
|
||||||
break;
|
// 'imgui_mask' is left as a fallback.
|
||||||
case kVK_Shift:
|
NSEventModifierFlags mask = 0;
|
||||||
io.KeyShift = (flags & NSEventModifierFlagShift) != 0;
|
switch (key)
|
||||||
break;
|
{
|
||||||
case kVK_Option:
|
case ImGuiKey_LeftCtrl: mask = 0x0001; break;
|
||||||
io.KeyAlt = (flags & NSEventModifierFlagOption) != 0;
|
case ImGuiKey_RightCtrl: mask = 0x2000; break;
|
||||||
break;
|
case ImGuiKey_LeftShift: mask = 0x0002; break;
|
||||||
case kVK_Command:
|
case ImGuiKey_RightShift: mask = 0x0004; break;
|
||||||
io.KeySuper = (flags & NSEventModifierFlagCommand) != 0;
|
case ImGuiKey_LeftSuper: mask = 0x0008; break;
|
||||||
break;
|
case ImGuiKey_RightSuper: mask = 0x0010; break;
|
||||||
|
case ImGuiKey_LeftAlt: mask = 0x0020; break;
|
||||||
|
case ImGuiKey_RightAlt: mask = 0x0040; break;
|
||||||
|
default:
|
||||||
|
return io.WantCaptureKeyboard;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSEventModifierFlags modifier_flags = [event modifierFlags];
|
||||||
|
io.AddKeyEvent(key, (modifier_flags & mask) != 0);
|
||||||
|
io.SetKeyEventNativeData(key, key_code, -1); // To support legacy indexing (<1.87 user code)
|
||||||
}
|
}
|
||||||
|
|
||||||
return io.WantCaptureKeyboard;
|
return io.WantCaptureKeyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
// (Prefer SDL 2.0.5+ for full feature support.)
|
// (Prefer SDL 2.0.5+ for full feature support.)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
|
||||||
// [X] Platform: Clipboard support.
|
// [X] Platform: Clipboard support.
|
||||||
// [X] Platform: Keyboard arrays indexed using SDL_SCANCODE_* codes, e.g. ImGui::IsKeyPressed(SDL_SCANCODE_SPACE).
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// Missing features:
|
// Missing features:
|
||||||
// [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
|
// [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
|
||||||
|
|
||||||
@ -18,6 +18,14 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2022-02-04: Added SDL_Renderer* parameter to ImGui_ImplSDL2_InitForSDLRenderer(), so we can use SDL_GetRendererOutputSize() instead of SDL_GL_GetDrawableSize() when bound to a SDL_Renderer.
|
||||||
|
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago)with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
||||||
|
// 2021-01-20: Inputs: calling new io.AddKeyAnalogEvent() for gamepad support, instead of writing directly to io.NavInputs[].
|
||||||
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
|
// 2022-01-17: Inputs: always update key mods next and before key event (not in NewFrame) to fix input queue with very low framerates.
|
||||||
|
// 2022-01-12: Update mouse inputs using SDL_MOUSEMOTION/SDL_WINDOWEVENT_LEAVE + fallback to provide it when focused but not hovered/captured. More standard and will allow us to pass it to future input queue API.
|
||||||
|
// 2022-01-12: Maintain our own copy of MouseButtonsDown mask instead of using ImGui::IsAnyMouseDown() which will be obsoleted.
|
||||||
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
// 2021-08-17: Calling io.AddFocusEvent() on SDL_WINDOWEVENT_FOCUS_GAINED/SDL_WINDOWEVENT_FOCUS_LOST.
|
// 2021-08-17: Calling io.AddFocusEvent() on SDL_WINDOWEVENT_FOCUS_GAINED/SDL_WINDOWEVENT_FOCUS_LOST.
|
||||||
// 2021-07-29: Inputs: MousePos is correctly reported when the host platform window is hovered but not focused (using SDL_GetMouseFocus() + SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, requires SDL 2.0.5+)
|
// 2021-07-29: Inputs: MousePos is correctly reported when the host platform window is hovered but not focused (using SDL_GetMouseFocus() + SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, requires SDL 2.0.5+)
|
||||||
// 2021-06-29: *BREAKING CHANGE* Removed 'SDL_Window* window' parameter to ImGui_ImplSDL2_NewFrame() which was unnecessary.
|
// 2021-06-29: *BREAKING CHANGE* Removed 'SDL_Window* window' parameter to ImGui_ImplSDL2_NewFrame() which was unnecessary.
|
||||||
@ -71,12 +79,13 @@
|
|||||||
// SDL Data
|
// SDL Data
|
||||||
struct ImGui_ImplSDL2_Data
|
struct ImGui_ImplSDL2_Data
|
||||||
{
|
{
|
||||||
SDL_Window* Window;
|
SDL_Window* Window;
|
||||||
Uint64 Time;
|
SDL_Renderer* Renderer;
|
||||||
bool MousePressed[3];
|
Uint64 Time;
|
||||||
SDL_Cursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
int MouseButtonsDown;
|
||||||
char* ClipboardTextData;
|
SDL_Cursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
||||||
bool MouseCanUseGlobalState;
|
char* ClipboardTextData;
|
||||||
|
bool MouseCanUseGlobalState;
|
||||||
|
|
||||||
ImGui_ImplSDL2_Data() { memset(this, 0, sizeof(*this)); }
|
ImGui_ImplSDL2_Data() { memset(this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
@ -105,6 +114,128 @@ static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text)
|
|||||||
SDL_SetClipboardText(text);
|
SDL_SetClipboardText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ImGuiKey ImGui_ImplSDL2_KeycodeToImGuiKey(int keycode)
|
||||||
|
{
|
||||||
|
switch (keycode)
|
||||||
|
{
|
||||||
|
case SDLK_TAB: return ImGuiKey_Tab;
|
||||||
|
case SDLK_LEFT: return ImGuiKey_LeftArrow;
|
||||||
|
case SDLK_RIGHT: return ImGuiKey_RightArrow;
|
||||||
|
case SDLK_UP: return ImGuiKey_UpArrow;
|
||||||
|
case SDLK_DOWN: return ImGuiKey_DownArrow;
|
||||||
|
case SDLK_PAGEUP: return ImGuiKey_PageUp;
|
||||||
|
case SDLK_PAGEDOWN: return ImGuiKey_PageDown;
|
||||||
|
case SDLK_HOME: return ImGuiKey_Home;
|
||||||
|
case SDLK_END: return ImGuiKey_End;
|
||||||
|
case SDLK_INSERT: return ImGuiKey_Insert;
|
||||||
|
case SDLK_DELETE: return ImGuiKey_Delete;
|
||||||
|
case SDLK_BACKSPACE: return ImGuiKey_Backspace;
|
||||||
|
case SDLK_SPACE: return ImGuiKey_Space;
|
||||||
|
case SDLK_RETURN: return ImGuiKey_Enter;
|
||||||
|
case SDLK_ESCAPE: return ImGuiKey_Escape;
|
||||||
|
case SDLK_QUOTE: return ImGuiKey_Apostrophe;
|
||||||
|
case SDLK_COMMA: return ImGuiKey_Comma;
|
||||||
|
case SDLK_MINUS: return ImGuiKey_Minus;
|
||||||
|
case SDLK_PERIOD: return ImGuiKey_Period;
|
||||||
|
case SDLK_SLASH: return ImGuiKey_Slash;
|
||||||
|
case SDLK_SEMICOLON: return ImGuiKey_Semicolon;
|
||||||
|
case SDLK_EQUALS: return ImGuiKey_Equal;
|
||||||
|
case SDLK_LEFTBRACKET: return ImGuiKey_LeftBracket;
|
||||||
|
case SDLK_BACKSLASH: return ImGuiKey_Backslash;
|
||||||
|
case SDLK_RIGHTBRACKET: return ImGuiKey_RightBracket;
|
||||||
|
case SDLK_BACKQUOTE: return ImGuiKey_GraveAccent;
|
||||||
|
case SDLK_CAPSLOCK: return ImGuiKey_CapsLock;
|
||||||
|
case SDLK_SCROLLLOCK: return ImGuiKey_ScrollLock;
|
||||||
|
case SDLK_NUMLOCKCLEAR: return ImGuiKey_NumLock;
|
||||||
|
case SDLK_PRINTSCREEN: return ImGuiKey_PrintScreen;
|
||||||
|
case SDLK_PAUSE: return ImGuiKey_Pause;
|
||||||
|
case SDLK_KP_0: return ImGuiKey_Keypad0;
|
||||||
|
case SDLK_KP_1: return ImGuiKey_Keypad1;
|
||||||
|
case SDLK_KP_2: return ImGuiKey_Keypad2;
|
||||||
|
case SDLK_KP_3: return ImGuiKey_Keypad3;
|
||||||
|
case SDLK_KP_4: return ImGuiKey_Keypad4;
|
||||||
|
case SDLK_KP_5: return ImGuiKey_Keypad5;
|
||||||
|
case SDLK_KP_6: return ImGuiKey_Keypad6;
|
||||||
|
case SDLK_KP_7: return ImGuiKey_Keypad7;
|
||||||
|
case SDLK_KP_8: return ImGuiKey_Keypad8;
|
||||||
|
case SDLK_KP_9: return ImGuiKey_Keypad9;
|
||||||
|
case SDLK_KP_PERIOD: return ImGuiKey_KeypadDecimal;
|
||||||
|
case SDLK_KP_DIVIDE: return ImGuiKey_KeypadDivide;
|
||||||
|
case SDLK_KP_MULTIPLY: return ImGuiKey_KeypadMultiply;
|
||||||
|
case SDLK_KP_MINUS: return ImGuiKey_KeypadSubtract;
|
||||||
|
case SDLK_KP_PLUS: return ImGuiKey_KeypadAdd;
|
||||||
|
case SDLK_KP_ENTER: return ImGuiKey_KeypadEnter;
|
||||||
|
case SDLK_KP_EQUALS: return ImGuiKey_KeypadEqual;
|
||||||
|
case SDLK_LCTRL: return ImGuiKey_LeftCtrl;
|
||||||
|
case SDLK_LSHIFT: return ImGuiKey_LeftShift;
|
||||||
|
case SDLK_LALT: return ImGuiKey_LeftAlt;
|
||||||
|
case SDLK_LGUI: return ImGuiKey_LeftSuper;
|
||||||
|
case SDLK_RCTRL: return ImGuiKey_RightCtrl;
|
||||||
|
case SDLK_RSHIFT: return ImGuiKey_RightShift;
|
||||||
|
case SDLK_RALT: return ImGuiKey_RightAlt;
|
||||||
|
case SDLK_RGUI: return ImGuiKey_RightSuper;
|
||||||
|
case SDLK_APPLICATION: return ImGuiKey_Menu;
|
||||||
|
case SDLK_0: return ImGuiKey_0;
|
||||||
|
case SDLK_1: return ImGuiKey_1;
|
||||||
|
case SDLK_2: return ImGuiKey_2;
|
||||||
|
case SDLK_3: return ImGuiKey_3;
|
||||||
|
case SDLK_4: return ImGuiKey_4;
|
||||||
|
case SDLK_5: return ImGuiKey_5;
|
||||||
|
case SDLK_6: return ImGuiKey_6;
|
||||||
|
case SDLK_7: return ImGuiKey_7;
|
||||||
|
case SDLK_8: return ImGuiKey_8;
|
||||||
|
case SDLK_9: return ImGuiKey_9;
|
||||||
|
case SDLK_a: return ImGuiKey_A;
|
||||||
|
case SDLK_b: return ImGuiKey_B;
|
||||||
|
case SDLK_c: return ImGuiKey_C;
|
||||||
|
case SDLK_d: return ImGuiKey_D;
|
||||||
|
case SDLK_e: return ImGuiKey_E;
|
||||||
|
case SDLK_f: return ImGuiKey_F;
|
||||||
|
case SDLK_g: return ImGuiKey_G;
|
||||||
|
case SDLK_h: return ImGuiKey_H;
|
||||||
|
case SDLK_i: return ImGuiKey_I;
|
||||||
|
case SDLK_j: return ImGuiKey_J;
|
||||||
|
case SDLK_k: return ImGuiKey_K;
|
||||||
|
case SDLK_l: return ImGuiKey_L;
|
||||||
|
case SDLK_m: return ImGuiKey_M;
|
||||||
|
case SDLK_n: return ImGuiKey_N;
|
||||||
|
case SDLK_o: return ImGuiKey_O;
|
||||||
|
case SDLK_p: return ImGuiKey_P;
|
||||||
|
case SDLK_q: return ImGuiKey_Q;
|
||||||
|
case SDLK_r: return ImGuiKey_R;
|
||||||
|
case SDLK_s: return ImGuiKey_S;
|
||||||
|
case SDLK_t: return ImGuiKey_T;
|
||||||
|
case SDLK_u: return ImGuiKey_U;
|
||||||
|
case SDLK_v: return ImGuiKey_V;
|
||||||
|
case SDLK_w: return ImGuiKey_W;
|
||||||
|
case SDLK_x: return ImGuiKey_X;
|
||||||
|
case SDLK_y: return ImGuiKey_Y;
|
||||||
|
case SDLK_z: return ImGuiKey_Z;
|
||||||
|
case SDLK_F1: return ImGuiKey_F1;
|
||||||
|
case SDLK_F2: return ImGuiKey_F2;
|
||||||
|
case SDLK_F3: return ImGuiKey_F3;
|
||||||
|
case SDLK_F4: return ImGuiKey_F4;
|
||||||
|
case SDLK_F5: return ImGuiKey_F5;
|
||||||
|
case SDLK_F6: return ImGuiKey_F6;
|
||||||
|
case SDLK_F7: return ImGuiKey_F7;
|
||||||
|
case SDLK_F8: return ImGuiKey_F8;
|
||||||
|
case SDLK_F9: return ImGuiKey_F9;
|
||||||
|
case SDLK_F10: return ImGuiKey_F10;
|
||||||
|
case SDLK_F11: return ImGuiKey_F11;
|
||||||
|
case SDLK_F12: return ImGuiKey_F12;
|
||||||
|
}
|
||||||
|
return ImGuiKey_None;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_UpdateKeyModifiers(SDL_Keymod sdl_key_mods)
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModCtrl, (sdl_key_mods & KMOD_CTRL) != 0);
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModShift, (sdl_key_mods & KMOD_SHIFT) != 0);
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModAlt, (sdl_key_mods & KMOD_ALT) != 0);
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModSuper, (sdl_key_mods & KMOD_GUI) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||||
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||||
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
||||||
@ -117,44 +248,49 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
|||||||
|
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
case SDL_MOUSEWHEEL:
|
case SDL_MOUSEMOTION:
|
||||||
{
|
{
|
||||||
if (event->wheel.x > 0) io.MouseWheelH += 1;
|
io.AddMousePosEvent((float)event->motion.x, (float)event->motion.y);
|
||||||
if (event->wheel.x < 0) io.MouseWheelH -= 1;
|
|
||||||
if (event->wheel.y > 0) io.MouseWheel += 1;
|
|
||||||
if (event->wheel.y < 0) io.MouseWheel -= 1;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEWHEEL:
|
||||||
{
|
{
|
||||||
if (event->button.button == SDL_BUTTON_LEFT) { bd->MousePressed[0] = true; }
|
float wheel_x = (event->wheel.x > 0) ? 1.0f : (event->wheel.x < 0) ? -1.0f : 0.0f;
|
||||||
if (event->button.button == SDL_BUTTON_RIGHT) { bd->MousePressed[1] = true; }
|
float wheel_y = (event->wheel.y > 0) ? 1.0f : (event->wheel.y < 0) ? -1.0f : 0.0f;
|
||||||
if (event->button.button == SDL_BUTTON_MIDDLE) { bd->MousePressed[2] = true; }
|
io.AddMouseWheelEvent(wheel_x, wheel_y);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case SDL_TEXTINPUT:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
case SDL_MOUSEBUTTONUP:
|
||||||
|
{
|
||||||
|
int mouse_button = -1;
|
||||||
|
if (event->button.button == SDL_BUTTON_LEFT) { mouse_button = 0; }
|
||||||
|
if (event->button.button == SDL_BUTTON_RIGHT) { mouse_button = 1; }
|
||||||
|
if (event->button.button == SDL_BUTTON_MIDDLE) { mouse_button = 2; }
|
||||||
|
if (mouse_button == -1)
|
||||||
|
break;
|
||||||
|
io.AddMouseButtonEvent(mouse_button, (event->type == SDL_MOUSEBUTTONDOWN));
|
||||||
|
bd->MouseButtonsDown = (event->type == SDL_MOUSEBUTTONDOWN) ? (bd->MouseButtonsDown | (1 << mouse_button)) : (bd->MouseButtonsDown & ~(1 << mouse_button));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case SDL_TEXTINPUT:
|
||||||
{
|
{
|
||||||
io.AddInputCharactersUTF8(event->text.text);
|
io.AddInputCharactersUTF8(event->text.text);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
{
|
{
|
||||||
int key = event->key.keysym.scancode;
|
ImGui_ImplSDL2_UpdateKeyModifiers((SDL_Keymod)event->key.keysym.mod);
|
||||||
IM_ASSERT(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown));
|
ImGuiKey key = ImGui_ImplSDL2_KeycodeToImGuiKey(event->key.keysym.sym);
|
||||||
io.KeysDown[key] = (event->type == SDL_KEYDOWN);
|
io.AddKeyEvent(key, (event->type == SDL_KEYDOWN));
|
||||||
io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0);
|
io.SetKeyEventNativeData(key, event->key.keysym.sym, event->key.keysym.scancode, event->key.keysym.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions.
|
||||||
io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0);
|
|
||||||
io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0);
|
|
||||||
#ifdef _WIN32
|
|
||||||
io.KeySuper = false;
|
|
||||||
#else
|
|
||||||
io.KeySuper = ((SDL_GetModState() & KMOD_GUI) != 0);
|
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
{
|
{
|
||||||
|
if (event->window.event == SDL_WINDOWEVENT_LEAVE)
|
||||||
|
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
||||||
if (event->window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
|
if (event->window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
|
||||||
io.AddFocusEvent(true);
|
io.AddFocusEvent(true);
|
||||||
else if (event->window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
else if (event->window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||||
@ -165,7 +301,7 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ImGui_ImplSDL2_Init(SDL_Window* window)
|
static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IM_ASSERT(io.BackendPlatformUserData == NULL && "Already initialized a platform backend!");
|
IM_ASSERT(io.BackendPlatformUserData == NULL && "Already initialized a platform backend!");
|
||||||
@ -189,32 +325,9 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window)
|
|||||||
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||||
|
|
||||||
bd->Window = window;
|
bd->Window = window;
|
||||||
|
bd->Renderer = renderer;
|
||||||
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
|
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
|
||||||
|
|
||||||
// Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeysDown[] array.
|
|
||||||
io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB;
|
|
||||||
io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
|
|
||||||
io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
|
|
||||||
io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
|
|
||||||
io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
|
|
||||||
io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP;
|
|
||||||
io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN;
|
|
||||||
io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
|
|
||||||
io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
|
|
||||||
io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT;
|
|
||||||
io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE;
|
|
||||||
io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
|
|
||||||
io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
|
|
||||||
io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
|
|
||||||
io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
|
|
||||||
io.KeyMap[ImGuiKey_KeyPadEnter] = SDL_SCANCODE_KP_ENTER;
|
|
||||||
io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
|
|
||||||
io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
|
|
||||||
io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
|
|
||||||
io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X;
|
|
||||||
io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
|
|
||||||
io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;
|
|
||||||
|
|
||||||
io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
|
io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
|
||||||
io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
|
io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
|
||||||
io.ClipboardUserData = NULL;
|
io.ClipboardUserData = NULL;
|
||||||
@ -230,11 +343,12 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window)
|
|||||||
bd->MouseCursors[ImGuiMouseCursor_Hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
|
bd->MouseCursors[ImGuiMouseCursor_Hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
|
||||||
bd->MouseCursors[ImGuiMouseCursor_NotAllowed] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO);
|
bd->MouseCursors[ImGuiMouseCursor_NotAllowed] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO);
|
||||||
|
|
||||||
|
// Set platform dependent data in viewport
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
SDL_SysWMinfo info;
|
SDL_SysWMinfo info;
|
||||||
SDL_VERSION(&info.version);
|
SDL_VERSION(&info.version);
|
||||||
if (SDL_GetWindowWMInfo(window, &info))
|
if (SDL_GetWindowWMInfo(window, &info))
|
||||||
io.ImeWindowHandle = info.info.win.window;
|
ImGui::GetMainViewport()->PlatformHandleRaw = (void*)info.info.win.window;
|
||||||
#else
|
#else
|
||||||
(void)window;
|
(void)window;
|
||||||
#endif
|
#endif
|
||||||
@ -254,7 +368,7 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window)
|
|||||||
bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
|
bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
|
||||||
{
|
{
|
||||||
IM_UNUSED(sdl_gl_context); // Viewport branch will need this.
|
IM_UNUSED(sdl_gl_context); // Viewport branch will need this.
|
||||||
return ImGui_ImplSDL2_Init(window);
|
return ImGui_ImplSDL2_Init(window, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
|
bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
|
||||||
@ -262,7 +376,7 @@ bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
|
|||||||
#if !SDL_HAS_VULKAN
|
#if !SDL_HAS_VULKAN
|
||||||
IM_ASSERT(0 && "Unsupported");
|
IM_ASSERT(0 && "Unsupported");
|
||||||
#endif
|
#endif
|
||||||
return ImGui_ImplSDL2_Init(window);
|
return ImGui_ImplSDL2_Init(window, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window)
|
bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window)
|
||||||
@ -270,17 +384,17 @@ bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window)
|
|||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
IM_ASSERT(0 && "Unsupported");
|
IM_ASSERT(0 && "Unsupported");
|
||||||
#endif
|
#endif
|
||||||
return ImGui_ImplSDL2_Init(window);
|
return ImGui_ImplSDL2_Init(window, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window)
|
bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window)
|
||||||
{
|
{
|
||||||
return ImGui_ImplSDL2_Init(window);
|
return ImGui_ImplSDL2_Init(window, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window)
|
bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer)
|
||||||
{
|
{
|
||||||
return ImGui_ImplSDL2_Init(window);
|
return ImGui_ImplSDL2_Init(window, renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDL2_Shutdown()
|
void ImGui_ImplSDL2_Shutdown()
|
||||||
@ -299,60 +413,34 @@ void ImGui_ImplSDL2_Shutdown()
|
|||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDL2_UpdateMousePosAndButtons()
|
static void ImGui_ImplSDL2_UpdateMouseData()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
ImVec2 mouse_pos_prev = io.MousePos;
|
// We forward mouse input when hovered or captured (via SDL_MOUSEMOTION) or when focused (below)
|
||||||
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
|
||||||
|
|
||||||
// Update mouse buttons
|
|
||||||
int mouse_x_local, mouse_y_local;
|
|
||||||
Uint32 mouse_buttons = SDL_GetMouseState(&mouse_x_local, &mouse_y_local);
|
|
||||||
io.MouseDown[0] = bd->MousePressed[0] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
|
|
||||||
io.MouseDown[1] = bd->MousePressed[1] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
|
|
||||||
io.MouseDown[2] = bd->MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
|
|
||||||
bd->MousePressed[0] = bd->MousePressed[1] = bd->MousePressed[2] = false;
|
|
||||||
|
|
||||||
// Obtain focused and hovered window. We forward mouse input when focused or when hovered (and no other window is capturing)
|
|
||||||
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
|
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
|
||||||
SDL_Window* focused_window = SDL_GetKeyboardFocus();
|
|
||||||
SDL_Window* hovered_window = SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH ? SDL_GetMouseFocus() : NULL; // This is better but is only reliably useful with SDL 2.0.5+ and SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH.
|
|
||||||
SDL_Window* mouse_window = NULL;
|
|
||||||
if (hovered_window && bd->Window == hovered_window)
|
|
||||||
mouse_window = hovered_window;
|
|
||||||
else if (focused_window && bd->Window == focused_window)
|
|
||||||
mouse_window = focused_window;
|
|
||||||
|
|
||||||
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
|
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
|
||||||
SDL_CaptureMouse(ImGui::IsAnyMouseDown() ? SDL_TRUE : SDL_FALSE);
|
SDL_CaptureMouse(bd->MouseButtonsDown != 0 ? SDL_TRUE : SDL_FALSE);
|
||||||
|
SDL_Window* focused_window = SDL_GetKeyboardFocus();
|
||||||
|
const bool is_app_focused = (bd->Window == focused_window);
|
||||||
#else
|
#else
|
||||||
// SDL 2.0.3 and non-windowed systems: single-viewport only
|
const bool is_app_focused = (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0; // SDL 2.0.3 and non-windowed systems: single-viewport only
|
||||||
SDL_Window* mouse_window = (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_INPUT_FOCUS) ? bd->Window : NULL;
|
|
||||||
#endif
|
#endif
|
||||||
|
if (is_app_focused)
|
||||||
if (mouse_window == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
|
||||||
if (io.WantSetMousePos)
|
|
||||||
SDL_WarpMouseInWindow(bd->Window, (int)mouse_pos_prev.x, (int)mouse_pos_prev.y);
|
|
||||||
|
|
||||||
// Set Dear ImGui mouse position from OS position + get buttons. (this is the common behavior)
|
|
||||||
if (bd->MouseCanUseGlobalState)
|
|
||||||
{
|
{
|
||||||
// Single-viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
|
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
||||||
// Unlike local position obtained earlier this will be valid when straying out of bounds.
|
if (io.WantSetMousePos)
|
||||||
int mouse_x_global, mouse_y_global;
|
SDL_WarpMouseInWindow(bd->Window, (int)io.MousePos.x, (int)io.MousePos.y);
|
||||||
SDL_GetGlobalMouseState(&mouse_x_global, &mouse_y_global);
|
|
||||||
int window_x, window_y;
|
// (Optional) Fallback to provide mouse position when focused (SDL_MOUSEMOTION already provides this when hovered or captured)
|
||||||
SDL_GetWindowPosition(mouse_window, &window_x, &window_y);
|
if (bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0)
|
||||||
io.MousePos = ImVec2((float)(mouse_x_global - window_x), (float)(mouse_y_global - window_y));
|
{
|
||||||
}
|
int window_x, window_y, mouse_x_global, mouse_y_global;
|
||||||
else
|
SDL_GetGlobalMouseState(&mouse_x_global, &mouse_y_global);
|
||||||
{
|
SDL_GetWindowPosition(bd->Window, &window_x, &window_y);
|
||||||
io.MousePos = ImVec2((float)mouse_x_local, (float)mouse_y_local);
|
io.AddMousePosEvent((float)(mouse_x_global - window_x), (float)(mouse_y_global - window_y));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,40 +468,45 @@ static void ImGui_ImplSDL2_UpdateMouseCursor()
|
|||||||
static void ImGui_ImplSDL2_UpdateGamepads()
|
static void ImGui_ImplSDL2_UpdateGamepads()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
memset(io.NavInputs, 0, sizeof(io.NavInputs));
|
|
||||||
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Get gamepad
|
// Get gamepad
|
||||||
|
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
||||||
SDL_GameController* game_controller = SDL_GameControllerOpen(0);
|
SDL_GameController* game_controller = SDL_GameControllerOpen(0);
|
||||||
if (!game_controller)
|
if (!game_controller)
|
||||||
{
|
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
|
||||||
return;
|
return;
|
||||||
}
|
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
||||||
|
|
||||||
// Update gamepad inputs
|
// Update gamepad inputs
|
||||||
#define MAP_BUTTON(NAV_NO, BUTTON_NO) { io.NavInputs[NAV_NO] = (SDL_GameControllerGetButton(game_controller, BUTTON_NO) != 0) ? 1.0f : 0.0f; }
|
#define IM_SATURATE(V) (V < 0.0f ? 0.0f : V > 1.0f ? 1.0f : V)
|
||||||
#define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1) { float vn = (float)(SDL_GameControllerGetAxis(game_controller, AXIS_NO) - V0) / (float)(V1 - V0); if (vn > 1.0f) vn = 1.0f; if (vn > 0.0f && io.NavInputs[NAV_NO] < vn) io.NavInputs[NAV_NO] = vn; }
|
#define MAP_BUTTON(KEY_NO, BUTTON_NO) { io.AddKeyEvent(KEY_NO, SDL_GameControllerGetButton(game_controller, BUTTON_NO) != 0); }
|
||||||
|
#define MAP_ANALOG(KEY_NO, AXIS_NO, V0, V1) { float vn = (float)(SDL_GameControllerGetAxis(game_controller, AXIS_NO) - V0) / (float)(V1 - V0); vn = IM_SATURATE(vn); io.AddKeyAnalogEvent(KEY_NO, vn > 0.1f, vn); }
|
||||||
const int thumb_dead_zone = 8000; // SDL_gamecontroller.h suggests using this value.
|
const int thumb_dead_zone = 8000; // SDL_gamecontroller.h suggests using this value.
|
||||||
MAP_BUTTON(ImGuiNavInput_Activate, SDL_CONTROLLER_BUTTON_A); // Cross / A
|
MAP_BUTTON(ImGuiKey_GamepadStart, SDL_CONTROLLER_BUTTON_START);
|
||||||
MAP_BUTTON(ImGuiNavInput_Cancel, SDL_CONTROLLER_BUTTON_B); // Circle / B
|
MAP_BUTTON(ImGuiKey_GamepadBack, SDL_CONTROLLER_BUTTON_BACK);
|
||||||
MAP_BUTTON(ImGuiNavInput_Menu, SDL_CONTROLLER_BUTTON_X); // Square / X
|
MAP_BUTTON(ImGuiKey_GamepadFaceDown, SDL_CONTROLLER_BUTTON_A); // Xbox A, PS Cross
|
||||||
MAP_BUTTON(ImGuiNavInput_Input, SDL_CONTROLLER_BUTTON_Y); // Triangle / Y
|
MAP_BUTTON(ImGuiKey_GamepadFaceRight, SDL_CONTROLLER_BUTTON_B); // Xbox B, PS Circle
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadLeft, SDL_CONTROLLER_BUTTON_DPAD_LEFT); // D-Pad Left
|
MAP_BUTTON(ImGuiKey_GamepadFaceLeft, SDL_CONTROLLER_BUTTON_X); // Xbox X, PS Square
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadRight, SDL_CONTROLLER_BUTTON_DPAD_RIGHT); // D-Pad Right
|
MAP_BUTTON(ImGuiKey_GamepadFaceUp, SDL_CONTROLLER_BUTTON_Y); // Xbox Y, PS Triangle
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadUp, SDL_CONTROLLER_BUTTON_DPAD_UP); // D-Pad Up
|
MAP_BUTTON(ImGuiKey_GamepadDpadLeft, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadDown, SDL_CONTROLLER_BUTTON_DPAD_DOWN); // D-Pad Down
|
MAP_BUTTON(ImGuiKey_GamepadDpadRight, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
||||||
MAP_BUTTON(ImGuiNavInput_FocusPrev, SDL_CONTROLLER_BUTTON_LEFTSHOULDER); // L1 / LB
|
MAP_BUTTON(ImGuiKey_GamepadDpadUp, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
||||||
MAP_BUTTON(ImGuiNavInput_FocusNext, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); // R1 / RB
|
MAP_BUTTON(ImGuiKey_GamepadDpadDown, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
||||||
MAP_BUTTON(ImGuiNavInput_TweakSlow, SDL_CONTROLLER_BUTTON_LEFTSHOULDER); // L1 / LB
|
MAP_BUTTON(ImGuiKey_GamepadL1, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
|
||||||
MAP_BUTTON(ImGuiNavInput_TweakFast, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); // R1 / RB
|
MAP_BUTTON(ImGuiKey_GamepadR1, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
||||||
MAP_ANALOG(ImGuiNavInput_LStickLeft, SDL_CONTROLLER_AXIS_LEFTX, -thumb_dead_zone, -32768);
|
MAP_ANALOG(ImGuiKey_GamepadL2, SDL_CONTROLLER_AXIS_TRIGGERLEFT, 0.0f, 32767);
|
||||||
MAP_ANALOG(ImGuiNavInput_LStickRight, SDL_CONTROLLER_AXIS_LEFTX, +thumb_dead_zone, +32767);
|
MAP_ANALOG(ImGuiKey_GamepadR2, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, 0.0f, 32767);
|
||||||
MAP_ANALOG(ImGuiNavInput_LStickUp, SDL_CONTROLLER_AXIS_LEFTY, -thumb_dead_zone, -32767);
|
MAP_BUTTON(ImGuiKey_GamepadL3, SDL_CONTROLLER_BUTTON_LEFTSTICK);
|
||||||
MAP_ANALOG(ImGuiNavInput_LStickDown, SDL_CONTROLLER_AXIS_LEFTY, +thumb_dead_zone, +32767);
|
MAP_BUTTON(ImGuiKey_GamepadR3, SDL_CONTROLLER_BUTTON_RIGHTSTICK);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadLStickLeft, SDL_CONTROLLER_AXIS_LEFTX, -thumb_dead_zone, -32768);
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
MAP_ANALOG(ImGuiKey_GamepadLStickRight, SDL_CONTROLLER_AXIS_LEFTX, +thumb_dead_zone, +32767);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadLStickUp, SDL_CONTROLLER_AXIS_LEFTY, -thumb_dead_zone, -32768);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadLStickDown, SDL_CONTROLLER_AXIS_LEFTY, +thumb_dead_zone, +32767);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickLeft, SDL_CONTROLLER_AXIS_RIGHTX, -thumb_dead_zone, -32768);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickRight, SDL_CONTROLLER_AXIS_RIGHTX, +thumb_dead_zone, +32767);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickUp, SDL_CONTROLLER_AXIS_RIGHTY, -thumb_dead_zone, -32768);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickDown, SDL_CONTROLLER_AXIS_RIGHTY, +thumb_dead_zone, +32767);
|
||||||
#undef MAP_BUTTON
|
#undef MAP_BUTTON
|
||||||
#undef MAP_ANALOG
|
#undef MAP_ANALOG
|
||||||
}
|
}
|
||||||
@ -430,7 +523,10 @@ void ImGui_ImplSDL2_NewFrame()
|
|||||||
SDL_GetWindowSize(bd->Window, &w, &h);
|
SDL_GetWindowSize(bd->Window, &w, &h);
|
||||||
if (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_MINIMIZED)
|
if (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_MINIMIZED)
|
||||||
w = h = 0;
|
w = h = 0;
|
||||||
SDL_GL_GetDrawableSize(bd->Window, &display_w, &display_h);
|
if (bd->Renderer != NULL)
|
||||||
|
SDL_GetRendererOutputSize(bd->Renderer, &display_w, &display_h);
|
||||||
|
else
|
||||||
|
SDL_GL_GetDrawableSize(bd->Window, &display_w, &display_h);
|
||||||
io.DisplaySize = ImVec2((float)w, (float)h);
|
io.DisplaySize = ImVec2((float)w, (float)h);
|
||||||
if (w > 0 && h > 0)
|
if (w > 0 && h > 0)
|
||||||
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
||||||
@ -441,7 +537,7 @@ void ImGui_ImplSDL2_NewFrame()
|
|||||||
io.DeltaTime = bd->Time > 0 ? (float)((double)(current_time - bd->Time) / frequency) : (float)(1.0f / 60.0f);
|
io.DeltaTime = bd->Time > 0 ? (float)((double)(current_time - bd->Time) / frequency) : (float)(1.0f / 60.0f);
|
||||||
bd->Time = current_time;
|
bd->Time = current_time;
|
||||||
|
|
||||||
ImGui_ImplSDL2_UpdateMousePosAndButtons();
|
ImGui_ImplSDL2_UpdateMouseData();
|
||||||
ImGui_ImplSDL2_UpdateMouseCursor();
|
ImGui_ImplSDL2_UpdateMouseCursor();
|
||||||
|
|
||||||
// Update game controllers (if enabled and available)
|
// Update game controllers (if enabled and available)
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
|
// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
|
||||||
// [X] Platform: Clipboard support.
|
// [X] Platform: Clipboard support.
|
||||||
// [X] Platform: Keyboard arrays indexed using SDL_SCANCODE_* codes, e.g. ImGui::IsKeyPressed(SDL_SCANCODE_SPACE).
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// Missing features:
|
// Missing features:
|
||||||
// [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
|
// [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
|
||||||
|
|
||||||
@ -19,13 +19,14 @@
|
|||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
|
||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
|
struct SDL_Renderer;
|
||||||
typedef union SDL_Event SDL_Event;
|
typedef union SDL_Event SDL_Event;
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer);
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
||||||
|
@ -210,7 +210,7 @@ bool ImGui_ImplSDLRenderer_CreateFontsTexture()
|
|||||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
|
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
|
||||||
|
|
||||||
// Upload texture to graphics system
|
// Upload texture to graphics system
|
||||||
bd->FontTexture = SDL_CreateTexture(bd->SDLRenderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_STATIC, width, height);
|
bd->FontTexture = SDL_CreateTexture(bd->SDLRenderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STATIC, width, height);
|
||||||
if (bd->FontTexture == NULL)
|
if (bd->FontTexture == NULL)
|
||||||
{
|
{
|
||||||
SDL_Log("error creating texture");
|
SDL_Log("error creating texture");
|
||||||
|
@ -3,8 +3,15 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||||
// Missing features:
|
// [!] Renderer: User texture binding. Use 'VkDescriptorSet' as ImTextureID. Read the FAQ about ImTextureID! See https://github.com/ocornut/imgui/pull/914 for discussions.
|
||||||
// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this backend! See https://github.com/ocornut/imgui/pull/914
|
|
||||||
|
// Important: on 32-bit systems, user texture binding is only supported if your imconfig file has '#define ImTextureID ImU64'.
|
||||||
|
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
|
||||||
|
// To build this on 32-bit systems and support texture changes:
|
||||||
|
// - [Solution 1] IDE/msbuild: in "Properties/C++/Preprocessor Definitions" add 'ImTextureID=ImU64' (this is what we do in our .vcxproj files)
|
||||||
|
// - [Solution 2] IDE/msbuild: in "Properties/C++/Preprocessor Definitions" add 'IMGUI_USER_CONFIG="my_imgui_config.h"' and inside 'my_imgui_config.h' add '#define ImTextureID ImU64' and as many other options as you like.
|
||||||
|
// - [Solution 3] IDE/msbuild: edit imconfig.h and add '#define ImTextureID ImU64' (prefer solution 2 to create your own config file!)
|
||||||
|
// - [Solution 4] command-line: add '/D ImTextureID=ImU64' to your cl.exe command-line (this is what we do in our batch files)
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -57,6 +64,11 @@
|
|||||||
#include "imgui_impl_vulkan.h"
|
#include "imgui_impl_vulkan.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// Visual Studio warnings
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning (disable: 4127) // condition expression is constant
|
||||||
|
#endif
|
||||||
|
|
||||||
// Reusable buffers used for rendering 1 current in-flight frame, for ImGui_ImplVulkan_RenderDrawData()
|
// Reusable buffers used for rendering 1 current in-flight frame, for ImGui_ImplVulkan_RenderDrawData()
|
||||||
// [Please zero-clear before use!]
|
// [Please zero-clear before use!]
|
||||||
struct ImGui_ImplVulkanH_FrameRenderBuffers
|
struct ImGui_ImplVulkanH_FrameRenderBuffers
|
||||||
@ -87,7 +99,6 @@ struct ImGui_ImplVulkan_Data
|
|||||||
VkPipelineCreateFlags PipelineCreateFlags;
|
VkPipelineCreateFlags PipelineCreateFlags;
|
||||||
VkDescriptorSetLayout DescriptorSetLayout;
|
VkDescriptorSetLayout DescriptorSetLayout;
|
||||||
VkPipelineLayout PipelineLayout;
|
VkPipelineLayout PipelineLayout;
|
||||||
VkDescriptorSet DescriptorSet;
|
|
||||||
VkPipeline Pipeline;
|
VkPipeline Pipeline;
|
||||||
uint32_t Subpass;
|
uint32_t Subpass;
|
||||||
VkShaderModule ShaderModuleVert;
|
VkShaderModule ShaderModuleVert;
|
||||||
@ -98,6 +109,7 @@ struct ImGui_ImplVulkan_Data
|
|||||||
VkDeviceMemory FontMemory;
|
VkDeviceMemory FontMemory;
|
||||||
VkImage FontImage;
|
VkImage FontImage;
|
||||||
VkImageView FontView;
|
VkImageView FontView;
|
||||||
|
VkDescriptorSet FontDescriptorSet;
|
||||||
VkDeviceMemory UploadBufferMemory;
|
VkDeviceMemory UploadBufferMemory;
|
||||||
VkBuffer UploadBuffer;
|
VkBuffer UploadBuffer;
|
||||||
|
|
||||||
@ -376,11 +388,9 @@ static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkPipeline
|
|||||||
{
|
{
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
|
|
||||||
// Bind pipeline and descriptor sets:
|
// Bind pipeline:
|
||||||
{
|
{
|
||||||
vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
||||||
VkDescriptorSet desc_set[1] = { bd->DescriptorSet };
|
|
||||||
vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, bd->PipelineLayout, 0, 1, desc_set, 0, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind Vertex And Index Buffer:
|
// Bind Vertex And Index Buffer:
|
||||||
@ -531,6 +541,16 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
scissor.extent.height = (uint32_t)(clip_max.y - clip_min.y);
|
scissor.extent.height = (uint32_t)(clip_max.y - clip_min.y);
|
||||||
vkCmdSetScissor(command_buffer, 0, 1, &scissor);
|
vkCmdSetScissor(command_buffer, 0, 1, &scissor);
|
||||||
|
|
||||||
|
// Bind DescriptorSet with font or user texture
|
||||||
|
VkDescriptorSet desc_set[1] = { (VkDescriptorSet)pcmd->TextureId };
|
||||||
|
if (sizeof(ImTextureID) < sizeof(ImU64))
|
||||||
|
{
|
||||||
|
// We don't support texture switches if ImTextureID hasn't been redefined to be 64-bit. Do a flaky check that other textures haven't been used.
|
||||||
|
IM_ASSERT(pcmd->TextureId == (ImTextureID)bd->FontDescriptorSet);
|
||||||
|
desc_set[0] = bd->FontDescriptorSet;
|
||||||
|
}
|
||||||
|
vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, bd->PipelineLayout, 0, 1, desc_set, 0, NULL);
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
vkCmdDrawIndexed(command_buffer, pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0);
|
vkCmdDrawIndexed(command_buffer, pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0);
|
||||||
}
|
}
|
||||||
@ -607,20 +627,8 @@ bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer)
|
|||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the Descriptor Set:
|
// Create the Descriptor Set:
|
||||||
{
|
bd->FontDescriptorSet = (VkDescriptorSet)ImGui_ImplVulkan_AddTexture(bd->FontSampler, bd->FontView, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
||||||
VkDescriptorImageInfo desc_image[1] = {};
|
|
||||||
desc_image[0].sampler = bd->FontSampler;
|
|
||||||
desc_image[0].imageView = bd->FontView;
|
|
||||||
desc_image[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
|
||||||
VkWriteDescriptorSet write_desc[1] = {};
|
|
||||||
write_desc[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
|
||||||
write_desc[0].dstSet = bd->DescriptorSet;
|
|
||||||
write_desc[0].descriptorCount = 1;
|
|
||||||
write_desc[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
|
||||||
write_desc[0].pImageInfo = desc_image;
|
|
||||||
vkUpdateDescriptorSets(v->Device, 1, write_desc, 0, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the Upload Buffer:
|
// Create the Upload Buffer:
|
||||||
{
|
{
|
||||||
@ -698,7 +706,7 @@ bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store our identifier
|
// Store our identifier
|
||||||
io.Fonts->SetTexID((ImTextureID)(intptr_t)bd->FontImage);
|
io.Fonts->SetTexID((ImTextureID)bd->FontDescriptorSet);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -937,17 +945,6 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
|||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create Descriptor Set:
|
|
||||||
{
|
|
||||||
VkDescriptorSetAllocateInfo alloc_info = {};
|
|
||||||
alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
|
||||||
alloc_info.descriptorPool = v->DescriptorPool;
|
|
||||||
alloc_info.descriptorSetCount = 1;
|
|
||||||
alloc_info.pSetLayouts = &bd->DescriptorSetLayout;
|
|
||||||
err = vkAllocateDescriptorSets(v->Device, &alloc_info, &bd->DescriptorSet);
|
|
||||||
check_vk_result(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bd->PipelineLayout)
|
if (!bd->PipelineLayout)
|
||||||
{
|
{
|
||||||
// Constants: we are using 'vec2 offset' and 'vec2 scale' instead of a full 3d projection matrix
|
// Constants: we are using 'vec2 offset' and 'vec2 scale' instead of a full 3d projection matrix
|
||||||
@ -1090,6 +1087,41 @@ void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count)
|
|||||||
bd->VulkanInitInfo.MinImageCount = min_image_count;
|
bd->VulkanInitInfo.MinImageCount = min_image_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register a texture
|
||||||
|
// FIXME: This is experimental in the sense that we are unsure how to best design/tackle this problem, please post to https://github.com/ocornut/imgui/pull/914 if you have suggestions.
|
||||||
|
VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkSampler sampler, VkImageView image_view, VkImageLayout image_layout)
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
|
|
||||||
|
// Create Descriptor Set:
|
||||||
|
VkDescriptorSet descriptor_set;
|
||||||
|
{
|
||||||
|
VkDescriptorSetAllocateInfo alloc_info = {};
|
||||||
|
alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||||
|
alloc_info.descriptorPool = v->DescriptorPool;
|
||||||
|
alloc_info.descriptorSetCount = 1;
|
||||||
|
alloc_info.pSetLayouts = &bd->DescriptorSetLayout;
|
||||||
|
VkResult err = vkAllocateDescriptorSets(v->Device, &alloc_info, &descriptor_set);
|
||||||
|
check_vk_result(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the Descriptor Set:
|
||||||
|
{
|
||||||
|
VkDescriptorImageInfo desc_image[1] = {};
|
||||||
|
desc_image[0].sampler = sampler;
|
||||||
|
desc_image[0].imageView = image_view;
|
||||||
|
desc_image[0].imageLayout = image_layout;
|
||||||
|
VkWriteDescriptorSet write_desc[1] = {};
|
||||||
|
write_desc[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||||
|
write_desc[0].dstSet = descriptor_set;
|
||||||
|
write_desc[0].descriptorCount = 1;
|
||||||
|
write_desc[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
|
write_desc[0].pImageInfo = desc_image;
|
||||||
|
vkUpdateDescriptorSets(v->Device, 1, write_desc, 0, NULL);
|
||||||
|
}
|
||||||
|
return descriptor_set;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Internal / Miscellaneous Vulkan Helpers
|
// Internal / Miscellaneous Vulkan Helpers
|
||||||
|
@ -3,10 +3,12 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||||
// Missing features:
|
// [!] Renderer: User texture binding. Use 'VkDescriptorSet' as ImTextureID. Read the FAQ about ImTextureID! See https://github.com/ocornut/imgui/pull/914 for discussions.
|
||||||
// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this backend! See https://github.com/ocornut/imgui/pull/914
|
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// Important: on 32-bit systems, user texture binding is only supported if your imconfig file has '#define ImTextureID ImU64'.
|
||||||
|
// See imgui_impl_vulkan.cpp file for details.
|
||||||
|
|
||||||
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
@ -56,23 +58,27 @@ struct ImGui_ImplVulkan_InitInfo
|
|||||||
uint32_t Subpass;
|
uint32_t Subpass;
|
||||||
uint32_t MinImageCount; // >= 2
|
uint32_t MinImageCount; // >= 2
|
||||||
uint32_t ImageCount; // >= MinImageCount
|
uint32_t ImageCount; // >= MinImageCount
|
||||||
VkSampleCountFlagBits MSAASamples; // >= VK_SAMPLE_COUNT_1_BIT
|
VkSampleCountFlagBits MSAASamples; // >= VK_SAMPLE_COUNT_1_BIT (0 -> default to VK_SAMPLE_COUNT_1_BIT)
|
||||||
const VkAllocationCallbacks* Allocator;
|
const VkAllocationCallbacks* Allocator;
|
||||||
void (*CheckVkResultFn)(VkResult err);
|
void (*CheckVkResultFn)(VkResult err);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Called by user code
|
// Called by user code
|
||||||
IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass);
|
IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass);
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline = VK_NULL_HANDLE);
|
IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline = VK_NULL_HANDLE);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer);
|
IMGUI_IMPL_API bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer);
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_DestroyFontUploadObjects();
|
IMGUI_IMPL_API void ImGui_ImplVulkan_DestroyFontUploadObjects();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
|
IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
|
||||||
|
|
||||||
|
// Register a texture (VkDescriptorSet == ImTextureID)
|
||||||
|
// FIXME: This is experimental in the sense that we are unsure how to best design/tackle this problem, please post to https://github.com/ocornut/imgui/pull/914 if you have suggestions.
|
||||||
|
IMGUI_IMPL_API VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkSampler sampler, VkImageView image_view, VkImageLayout image_layout);
|
||||||
|
|
||||||
// Optional: load Vulkan functions with a custom function loader
|
// Optional: load Vulkan functions with a custom function loader
|
||||||
// This is only useful with IMGUI_IMPL_VULKAN_NO_PROTOTYPES / VK_NO_PROTOTYPES
|
// This is only useful with IMGUI_IMPL_VULKAN_NO_PROTOTYPES / VK_NO_PROTOTYPES
|
||||||
IMGUI_IMPL_API bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const char* function_name, void* user_data), void* user_data = NULL);
|
IMGUI_IMPL_API bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const char* function_name, void* user_data), void* user_data = NULL);
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Internal / Miscellaneous Vulkan Helpers
|
// Internal / Miscellaneous Vulkan Helpers
|
||||||
|
@ -314,8 +314,8 @@ static void ImGui_ImplWGPU_SetupRenderState(ImDrawData* draw_data, WGPURenderPas
|
|||||||
wgpuRenderPassEncoderSetViewport(ctx, 0, 0, draw_data->FramebufferScale.x * draw_data->DisplaySize.x, draw_data->FramebufferScale.y * draw_data->DisplaySize.y, 0, 1);
|
wgpuRenderPassEncoderSetViewport(ctx, 0, 0, draw_data->FramebufferScale.x * draw_data->DisplaySize.x, draw_data->FramebufferScale.y * draw_data->DisplaySize.y, 0, 1);
|
||||||
|
|
||||||
// Bind shader and vertex buffers
|
// Bind shader and vertex buffers
|
||||||
wgpuRenderPassEncoderSetVertexBuffer(ctx, 0, fr->VertexBuffer, 0, fr->VertexBufferSize);
|
wgpuRenderPassEncoderSetVertexBuffer(ctx, 0, fr->VertexBuffer, 0, fr->VertexBufferSize * sizeof(ImDrawVert));
|
||||||
wgpuRenderPassEncoderSetIndexBuffer(ctx, fr->IndexBuffer, sizeof(ImDrawIdx) == 2 ? WGPUIndexFormat_Uint16 : WGPUIndexFormat_Uint32, 0, fr->IndexBufferSize);
|
wgpuRenderPassEncoderSetIndexBuffer(ctx, fr->IndexBuffer, sizeof(ImDrawIdx) == 2 ? WGPUIndexFormat_Uint16 : WGPUIndexFormat_Uint32, 0, fr->IndexBufferSize * sizeof(ImDrawIdx));
|
||||||
wgpuRenderPassEncoderSetPipeline(ctx, g_pipelineState);
|
wgpuRenderPassEncoderSetPipeline(ctx, g_pipelineState);
|
||||||
wgpuRenderPassEncoderSetBindGroup(ctx, 0, g_resources.CommonBindGroup, 0, NULL);
|
wgpuRenderPassEncoderSetBindGroup(ctx, 0, g_resources.CommonBindGroup, 0, NULL);
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui)
|
// [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui)
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE).
|
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -18,6 +18,7 @@
|
|||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#endif
|
#endif
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <windowsx.h> // GET_X_LPARAM(), GET_Y_LPARAM()
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <dwmapi.h>
|
#include <dwmapi.h>
|
||||||
|
|
||||||
@ -33,6 +34,13 @@ typedef DWORD (WINAPI *PFN_XInputGetState)(DWORD, XINPUT_STATE*);
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago)with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
||||||
|
// 2021-01-20: Inputs: calling new io.AddKeyAnalogEvent() for gamepad support, instead of writing directly to io.NavInputs[].
|
||||||
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
|
// 2022-01-17: Inputs: always update key mods next and before a key event (not in NewFrame) to fix input queue with very low framerates.
|
||||||
|
// 2022-01-12: Inputs: Update mouse inputs using WM_MOUSEMOVE/WM_MOUSELEAVE + fallback to provide it when focused but not hovered/captured. More standard and will allow us to pass it to future input queue API.
|
||||||
|
// 2022-01-12: Inputs: Maintain our own copy of MouseButtonsDown mask instead of using ImGui::IsAnyMouseDown() which will be obsoleted.
|
||||||
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
// 2021-12-16: Inputs: Fill VK_LCONTROL/VK_RCONTROL/VK_LSHIFT/VK_RSHIFT/VK_LMENU/VK_RMENU for completeness.
|
// 2021-12-16: Inputs: Fill VK_LCONTROL/VK_RCONTROL/VK_LSHIFT/VK_RSHIFT/VK_LMENU/VK_RMENU for completeness.
|
||||||
// 2021-08-17: Calling io.AddFocusEvent() on WM_SETFOCUS/WM_KILLFOCUS messages.
|
// 2021-08-17: Calling io.AddFocusEvent() on WM_SETFOCUS/WM_KILLFOCUS messages.
|
||||||
// 2021-08-02: Inputs: Fixed keyboard modifiers being reported when host window doesn't have focus.
|
// 2021-08-02: Inputs: Fixed keyboard modifiers being reported when host window doesn't have focus.
|
||||||
@ -73,6 +81,7 @@ struct ImGui_ImplWin32_Data
|
|||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
HWND MouseHwnd;
|
HWND MouseHwnd;
|
||||||
bool MouseTracked;
|
bool MouseTracked;
|
||||||
|
int MouseButtonsDown;
|
||||||
INT64 Time;
|
INT64 Time;
|
||||||
INT64 TicksPerSecond;
|
INT64 TicksPerSecond;
|
||||||
ImGuiMouseCursor LastMouseCursor;
|
ImGuiMouseCursor LastMouseCursor;
|
||||||
@ -122,31 +131,8 @@ bool ImGui_ImplWin32_Init(void* hwnd)
|
|||||||
bd->Time = perf_counter;
|
bd->Time = perf_counter;
|
||||||
bd->LastMouseCursor = ImGuiMouseCursor_COUNT;
|
bd->LastMouseCursor = ImGuiMouseCursor_COUNT;
|
||||||
|
|
||||||
io.ImeWindowHandle = hwnd;
|
// Set platform dependent data in viewport
|
||||||
|
ImGui::GetMainViewport()->PlatformHandleRaw = (void*)hwnd;
|
||||||
// Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeysDown[] array that we will update during the application lifetime.
|
|
||||||
io.KeyMap[ImGuiKey_Tab] = VK_TAB;
|
|
||||||
io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT;
|
|
||||||
io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT;
|
|
||||||
io.KeyMap[ImGuiKey_UpArrow] = VK_UP;
|
|
||||||
io.KeyMap[ImGuiKey_DownArrow] = VK_DOWN;
|
|
||||||
io.KeyMap[ImGuiKey_PageUp] = VK_PRIOR;
|
|
||||||
io.KeyMap[ImGuiKey_PageDown] = VK_NEXT;
|
|
||||||
io.KeyMap[ImGuiKey_Home] = VK_HOME;
|
|
||||||
io.KeyMap[ImGuiKey_End] = VK_END;
|
|
||||||
io.KeyMap[ImGuiKey_Insert] = VK_INSERT;
|
|
||||||
io.KeyMap[ImGuiKey_Delete] = VK_DELETE;
|
|
||||||
io.KeyMap[ImGuiKey_Backspace] = VK_BACK;
|
|
||||||
io.KeyMap[ImGuiKey_Space] = VK_SPACE;
|
|
||||||
io.KeyMap[ImGuiKey_Enter] = VK_RETURN;
|
|
||||||
io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE;
|
|
||||||
io.KeyMap[ImGuiKey_KeyPadEnter] = VK_RETURN;
|
|
||||||
io.KeyMap[ImGuiKey_A] = 'A';
|
|
||||||
io.KeyMap[ImGuiKey_C] = 'C';
|
|
||||||
io.KeyMap[ImGuiKey_V] = 'V';
|
|
||||||
io.KeyMap[ImGuiKey_X] = 'X';
|
|
||||||
io.KeyMap[ImGuiKey_Y] = 'Y';
|
|
||||||
io.KeyMap[ImGuiKey_Z] = 'Z';
|
|
||||||
|
|
||||||
// Dynamically load XInput library
|
// Dynamically load XInput library
|
||||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
@ -221,38 +207,68 @@ static bool ImGui_ImplWin32_UpdateMouseCursor()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplWin32_UpdateMousePos()
|
static bool IsVkDown(int vk)
|
||||||
|
{
|
||||||
|
return (::GetKeyState(vk) & 0x8000) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_AddKeyEvent(ImGuiKey key, bool down, int native_keycode, int native_scancode = -1)
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.AddKeyEvent(key, down);
|
||||||
|
io.SetKeyEventNativeData(key, native_keycode, native_scancode); // To support legacy indexing (<1.87 user code)
|
||||||
|
IM_UNUSED(native_scancode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_ProcessKeyEventsWorkarounds()
|
||||||
|
{
|
||||||
|
// Left & right Shift keys: when both are pressed together, Windows tend to not generate the WM_KEYUP event for the first released one.
|
||||||
|
if (ImGui::IsKeyDown(ImGuiKey_LeftShift) && !IsVkDown(VK_LSHIFT))
|
||||||
|
ImGui_ImplWin32_AddKeyEvent(ImGuiKey_LeftShift, false, VK_LSHIFT);
|
||||||
|
if (ImGui::IsKeyDown(ImGuiKey_RightShift) && !IsVkDown(VK_RSHIFT))
|
||||||
|
ImGui_ImplWin32_AddKeyEvent(ImGuiKey_RightShift, false, VK_RSHIFT);
|
||||||
|
|
||||||
|
// Sometimes WM_KEYUP for Win key is not passed down to the app (e.g. for Win+V on some setups, according to GLFW).
|
||||||
|
if (ImGui::IsKeyDown(ImGuiKey_LeftSuper) && !IsVkDown(VK_LWIN))
|
||||||
|
ImGui_ImplWin32_AddKeyEvent(ImGuiKey_LeftSuper, false, VK_LWIN);
|
||||||
|
if (ImGui::IsKeyDown(ImGuiKey_RightSuper) && !IsVkDown(VK_RWIN))
|
||||||
|
ImGui_ImplWin32_AddKeyEvent(ImGuiKey_RightSuper, false, VK_RWIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_UpdateKeyModifiers()
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModCtrl, IsVkDown(VK_CONTROL));
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModShift, IsVkDown(VK_SHIFT));
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModAlt, IsVkDown(VK_MENU));
|
||||||
|
io.AddKeyEvent(ImGuiKey_ModSuper, IsVkDown(VK_APPS));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_UpdateMouseData()
|
||||||
{
|
{
|
||||||
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IM_ASSERT(bd->hWnd != 0);
|
IM_ASSERT(bd->hWnd != 0);
|
||||||
|
|
||||||
const ImVec2 mouse_pos_prev = io.MousePos;
|
const bool is_app_focused = (::GetForegroundWindow() == bd->hWnd);
|
||||||
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
if (is_app_focused)
|
||||||
|
|
||||||
// Obtain focused and hovered window. We forward mouse input when focused or when hovered (and no other window is capturing)
|
|
||||||
HWND focused_window = ::GetForegroundWindow();
|
|
||||||
HWND hovered_window = bd->MouseHwnd;
|
|
||||||
HWND mouse_window = NULL;
|
|
||||||
if (hovered_window && (hovered_window == bd->hWnd || ::IsChild(hovered_window, bd->hWnd)))
|
|
||||||
mouse_window = hovered_window;
|
|
||||||
else if (focused_window && (focused_window == bd->hWnd || ::IsChild(focused_window, bd->hWnd)))
|
|
||||||
mouse_window = focused_window;
|
|
||||||
if (mouse_window == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
|
||||||
if (io.WantSetMousePos)
|
|
||||||
{
|
{
|
||||||
POINT pos = { (int)mouse_pos_prev.x, (int)mouse_pos_prev.y };
|
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
||||||
if (::ClientToScreen(bd->hWnd, &pos))
|
if (io.WantSetMousePos)
|
||||||
::SetCursorPos(pos.x, pos.y);
|
{
|
||||||
}
|
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
|
||||||
|
if (::ClientToScreen(bd->hWnd, &pos))
|
||||||
|
::SetCursorPos(pos.x, pos.y);
|
||||||
|
}
|
||||||
|
|
||||||
// Set Dear ImGui mouse position from OS position
|
// (Optional) Fallback to provide mouse position when focused (WM_MOUSEMOVE already provides this when hovered or captured)
|
||||||
POINT pos;
|
if (!io.WantSetMousePos && !bd->MouseTracked)
|
||||||
if (::GetCursorPos(&pos) && ::ScreenToClient(mouse_window, &pos))
|
{
|
||||||
io.MousePos = ImVec2((float)pos.x, (float)pos.y);
|
POINT pos;
|
||||||
|
if (::GetCursorPos(&pos) && ::ScreenToClient(bd->hWnd, &pos))
|
||||||
|
io.AddMousePosEvent((float)pos.x, (float)pos.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gamepad navigation mapping
|
// Gamepad navigation mapping
|
||||||
@ -261,7 +277,6 @@ static void ImGui_ImplWin32_UpdateGamepads()
|
|||||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
memset(io.NavInputs, 0, sizeof(io.NavInputs));
|
|
||||||
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -269,39 +284,47 @@ static void ImGui_ImplWin32_UpdateGamepads()
|
|||||||
// Instead we refresh gamepad availability by calling XInputGetCapabilities() _only_ after receiving WM_DEVICECHANGE.
|
// Instead we refresh gamepad availability by calling XInputGetCapabilities() _only_ after receiving WM_DEVICECHANGE.
|
||||||
if (bd->WantUpdateHasGamepad)
|
if (bd->WantUpdateHasGamepad)
|
||||||
{
|
{
|
||||||
XINPUT_CAPABILITIES caps;
|
XINPUT_CAPABILITIES caps = {};
|
||||||
bd->HasGamepad = bd->XInputGetCapabilities ? (bd->XInputGetCapabilities(0, XINPUT_FLAG_GAMEPAD, &caps) == ERROR_SUCCESS) : false;
|
bd->HasGamepad = bd->XInputGetCapabilities ? (bd->XInputGetCapabilities(0, XINPUT_FLAG_GAMEPAD, &caps) == ERROR_SUCCESS) : false;
|
||||||
bd->WantUpdateHasGamepad = false;
|
bd->WantUpdateHasGamepad = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
||||||
XINPUT_STATE xinput_state;
|
XINPUT_STATE xinput_state;
|
||||||
if (bd->HasGamepad && bd->XInputGetState && bd->XInputGetState(0, &xinput_state) == ERROR_SUCCESS)
|
XINPUT_GAMEPAD& gamepad = xinput_state.Gamepad;
|
||||||
{
|
if (!bd->HasGamepad || bd->XInputGetState == NULL || bd->XInputGetState(0, &xinput_state) != ERROR_SUCCESS)
|
||||||
const XINPUT_GAMEPAD& gamepad = xinput_state.Gamepad;
|
return;
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
||||||
|
|
||||||
#define MAP_BUTTON(NAV_NO, BUTTON_ENUM) { io.NavInputs[NAV_NO] = (gamepad.wButtons & BUTTON_ENUM) ? 1.0f : 0.0f; }
|
#define IM_SATURATE(V) (V < 0.0f ? 0.0f : V > 1.0f ? 1.0f : V)
|
||||||
#define MAP_ANALOG(NAV_NO, VALUE, V0, V1) { float vn = (float)(VALUE - V0) / (float)(V1 - V0); if (vn > 1.0f) vn = 1.0f; if (vn > 0.0f && io.NavInputs[NAV_NO] < vn) io.NavInputs[NAV_NO] = vn; }
|
#define MAP_BUTTON(KEY_NO, BUTTON_ENUM) { io.AddKeyEvent(KEY_NO, (gamepad.wButtons & BUTTON_ENUM) != 0); }
|
||||||
MAP_BUTTON(ImGuiNavInput_Activate, XINPUT_GAMEPAD_A); // Cross / A
|
#define MAP_ANALOG(KEY_NO, VALUE, V0, V1) { float vn = (float)(VALUE - V0) / (float)(V1 - V0); io.AddKeyAnalogEvent(KEY_NO, vn > 0.10f, IM_SATURATE(vn)); }
|
||||||
MAP_BUTTON(ImGuiNavInput_Cancel, XINPUT_GAMEPAD_B); // Circle / B
|
MAP_BUTTON(ImGuiKey_GamepadStart, XINPUT_GAMEPAD_START);
|
||||||
MAP_BUTTON(ImGuiNavInput_Menu, XINPUT_GAMEPAD_X); // Square / X
|
MAP_BUTTON(ImGuiKey_GamepadBack, XINPUT_GAMEPAD_BACK);
|
||||||
MAP_BUTTON(ImGuiNavInput_Input, XINPUT_GAMEPAD_Y); // Triangle / Y
|
MAP_BUTTON(ImGuiKey_GamepadFaceDown, XINPUT_GAMEPAD_A);
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadLeft, XINPUT_GAMEPAD_DPAD_LEFT); // D-Pad Left
|
MAP_BUTTON(ImGuiKey_GamepadFaceRight, XINPUT_GAMEPAD_B);
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadRight, XINPUT_GAMEPAD_DPAD_RIGHT); // D-Pad Right
|
MAP_BUTTON(ImGuiKey_GamepadFaceLeft, XINPUT_GAMEPAD_X);
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadUp, XINPUT_GAMEPAD_DPAD_UP); // D-Pad Up
|
MAP_BUTTON(ImGuiKey_GamepadFaceUp, XINPUT_GAMEPAD_Y);
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadDown, XINPUT_GAMEPAD_DPAD_DOWN); // D-Pad Down
|
MAP_BUTTON(ImGuiKey_GamepadDpadLeft, XINPUT_GAMEPAD_DPAD_LEFT);
|
||||||
MAP_BUTTON(ImGuiNavInput_FocusPrev, XINPUT_GAMEPAD_LEFT_SHOULDER); // L1 / LB
|
MAP_BUTTON(ImGuiKey_GamepadDpadRight, XINPUT_GAMEPAD_DPAD_RIGHT);
|
||||||
MAP_BUTTON(ImGuiNavInput_FocusNext, XINPUT_GAMEPAD_RIGHT_SHOULDER); // R1 / RB
|
MAP_BUTTON(ImGuiKey_GamepadDpadUp, XINPUT_GAMEPAD_DPAD_UP);
|
||||||
MAP_BUTTON(ImGuiNavInput_TweakSlow, XINPUT_GAMEPAD_LEFT_SHOULDER); // L1 / LB
|
MAP_BUTTON(ImGuiKey_GamepadDpadDown, XINPUT_GAMEPAD_DPAD_DOWN);
|
||||||
MAP_BUTTON(ImGuiNavInput_TweakFast, XINPUT_GAMEPAD_RIGHT_SHOULDER); // R1 / RB
|
MAP_BUTTON(ImGuiKey_GamepadL1, XINPUT_GAMEPAD_LEFT_SHOULDER);
|
||||||
MAP_ANALOG(ImGuiNavInput_LStickLeft, gamepad.sThumbLX, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32768);
|
MAP_BUTTON(ImGuiKey_GamepadR1, XINPUT_GAMEPAD_RIGHT_SHOULDER);
|
||||||
MAP_ANALOG(ImGuiNavInput_LStickRight, gamepad.sThumbLX, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767);
|
MAP_ANALOG(ImGuiKey_GamepadL2, gamepad.bLeftTrigger, XINPUT_GAMEPAD_TRIGGER_THRESHOLD, 255);
|
||||||
MAP_ANALOG(ImGuiNavInput_LStickUp, gamepad.sThumbLY, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767);
|
MAP_ANALOG(ImGuiKey_GamepadR2, gamepad.bRightTrigger, XINPUT_GAMEPAD_TRIGGER_THRESHOLD, 255);
|
||||||
MAP_ANALOG(ImGuiNavInput_LStickDown, gamepad.sThumbLY, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32767);
|
MAP_BUTTON(ImGuiKey_GamepadL3, XINPUT_GAMEPAD_LEFT_THUMB);
|
||||||
#undef MAP_BUTTON
|
MAP_BUTTON(ImGuiKey_GamepadR3, XINPUT_GAMEPAD_RIGHT_THUMB);
|
||||||
#undef MAP_ANALOG
|
MAP_ANALOG(ImGuiKey_GamepadLStickLeft, gamepad.sThumbLX, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32768);
|
||||||
}
|
MAP_ANALOG(ImGuiKey_GamepadLStickRight, gamepad.sThumbLX, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadLStickUp, gamepad.sThumbLY, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadLStickDown, gamepad.sThumbLY, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32768);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickLeft, gamepad.sThumbRX, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32768);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickRight, gamepad.sThumbRX, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickUp, gamepad.sThumbRY, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickDown, gamepad.sThumbRY, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32768);
|
||||||
|
#undef MAP_BUTTON
|
||||||
|
#undef MAP_ANALOG
|
||||||
#endif // #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#endif // #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,7 +346,10 @@ void ImGui_ImplWin32_NewFrame()
|
|||||||
bd->Time = current_time;
|
bd->Time = current_time;
|
||||||
|
|
||||||
// Update OS mouse position
|
// Update OS mouse position
|
||||||
ImGui_ImplWin32_UpdateMousePos();
|
ImGui_ImplWin32_UpdateMouseData();
|
||||||
|
|
||||||
|
// Process workarounds for known Windows key handling issues
|
||||||
|
ImGui_ImplWin32_ProcessKeyEventsWorkarounds();
|
||||||
|
|
||||||
// Update OS mouse cursor with the cursor requested by imgui
|
// Update OS mouse cursor with the cursor requested by imgui
|
||||||
ImGuiMouseCursor mouse_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor();
|
ImGuiMouseCursor mouse_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor();
|
||||||
@ -337,6 +363,122 @@ void ImGui_ImplWin32_NewFrame()
|
|||||||
ImGui_ImplWin32_UpdateGamepads();
|
ImGui_ImplWin32_UpdateGamepads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// There is no distinct VK_xxx for keypad enter, instead it is VK_RETURN + KF_EXTENDED, we assign it an arbitrary value to make code more readable (VK_ codes go up to 255)
|
||||||
|
#define IM_VK_KEYPAD_ENTER (VK_RETURN + 256)
|
||||||
|
|
||||||
|
// Map VK_xxx to ImGuiKey_xxx.
|
||||||
|
static ImGuiKey ImGui_ImplWin32_VirtualKeyToImGuiKey(WPARAM wParam)
|
||||||
|
{
|
||||||
|
switch (wParam)
|
||||||
|
{
|
||||||
|
case VK_TAB: return ImGuiKey_Tab;
|
||||||
|
case VK_LEFT: return ImGuiKey_LeftArrow;
|
||||||
|
case VK_RIGHT: return ImGuiKey_RightArrow;
|
||||||
|
case VK_UP: return ImGuiKey_UpArrow;
|
||||||
|
case VK_DOWN: return ImGuiKey_DownArrow;
|
||||||
|
case VK_PRIOR: return ImGuiKey_PageUp;
|
||||||
|
case VK_NEXT: return ImGuiKey_PageDown;
|
||||||
|
case VK_HOME: return ImGuiKey_Home;
|
||||||
|
case VK_END: return ImGuiKey_End;
|
||||||
|
case VK_INSERT: return ImGuiKey_Insert;
|
||||||
|
case VK_DELETE: return ImGuiKey_Delete;
|
||||||
|
case VK_BACK: return ImGuiKey_Backspace;
|
||||||
|
case VK_SPACE: return ImGuiKey_Space;
|
||||||
|
case VK_RETURN: return ImGuiKey_Enter;
|
||||||
|
case VK_ESCAPE: return ImGuiKey_Escape;
|
||||||
|
case VK_OEM_7: return ImGuiKey_Apostrophe;
|
||||||
|
case VK_OEM_COMMA: return ImGuiKey_Comma;
|
||||||
|
case VK_OEM_MINUS: return ImGuiKey_Minus;
|
||||||
|
case VK_OEM_PERIOD: return ImGuiKey_Period;
|
||||||
|
case VK_OEM_2: return ImGuiKey_Slash;
|
||||||
|
case VK_OEM_1: return ImGuiKey_Semicolon;
|
||||||
|
case VK_OEM_PLUS: return ImGuiKey_Equal;
|
||||||
|
case VK_OEM_4: return ImGuiKey_LeftBracket;
|
||||||
|
case VK_OEM_5: return ImGuiKey_Backslash;
|
||||||
|
case VK_OEM_6: return ImGuiKey_RightBracket;
|
||||||
|
case VK_OEM_3: return ImGuiKey_GraveAccent;
|
||||||
|
case VK_CAPITAL: return ImGuiKey_CapsLock;
|
||||||
|
case VK_SCROLL: return ImGuiKey_ScrollLock;
|
||||||
|
case VK_NUMLOCK: return ImGuiKey_NumLock;
|
||||||
|
case VK_SNAPSHOT: return ImGuiKey_PrintScreen;
|
||||||
|
case VK_PAUSE: return ImGuiKey_Pause;
|
||||||
|
case VK_NUMPAD0: return ImGuiKey_Keypad0;
|
||||||
|
case VK_NUMPAD1: return ImGuiKey_Keypad1;
|
||||||
|
case VK_NUMPAD2: return ImGuiKey_Keypad2;
|
||||||
|
case VK_NUMPAD3: return ImGuiKey_Keypad3;
|
||||||
|
case VK_NUMPAD4: return ImGuiKey_Keypad4;
|
||||||
|
case VK_NUMPAD5: return ImGuiKey_Keypad5;
|
||||||
|
case VK_NUMPAD6: return ImGuiKey_Keypad6;
|
||||||
|
case VK_NUMPAD7: return ImGuiKey_Keypad7;
|
||||||
|
case VK_NUMPAD8: return ImGuiKey_Keypad8;
|
||||||
|
case VK_NUMPAD9: return ImGuiKey_Keypad9;
|
||||||
|
case VK_DECIMAL: return ImGuiKey_KeypadDecimal;
|
||||||
|
case VK_DIVIDE: return ImGuiKey_KeypadDivide;
|
||||||
|
case VK_MULTIPLY: return ImGuiKey_KeypadMultiply;
|
||||||
|
case VK_SUBTRACT: return ImGuiKey_KeypadSubtract;
|
||||||
|
case VK_ADD: return ImGuiKey_KeypadAdd;
|
||||||
|
case IM_VK_KEYPAD_ENTER: return ImGuiKey_KeypadEnter;
|
||||||
|
case VK_LSHIFT: return ImGuiKey_LeftShift;
|
||||||
|
case VK_LCONTROL: return ImGuiKey_LeftCtrl;
|
||||||
|
case VK_LMENU: return ImGuiKey_LeftAlt;
|
||||||
|
case VK_LWIN: return ImGuiKey_LeftSuper;
|
||||||
|
case VK_RSHIFT: return ImGuiKey_RightShift;
|
||||||
|
case VK_RCONTROL: return ImGuiKey_RightCtrl;
|
||||||
|
case VK_RMENU: return ImGuiKey_RightAlt;
|
||||||
|
case VK_RWIN: return ImGuiKey_RightSuper;
|
||||||
|
case VK_APPS: return ImGuiKey_Menu;
|
||||||
|
case '0': return ImGuiKey_0;
|
||||||
|
case '1': return ImGuiKey_1;
|
||||||
|
case '2': return ImGuiKey_2;
|
||||||
|
case '3': return ImGuiKey_3;
|
||||||
|
case '4': return ImGuiKey_4;
|
||||||
|
case '5': return ImGuiKey_5;
|
||||||
|
case '6': return ImGuiKey_6;
|
||||||
|
case '7': return ImGuiKey_7;
|
||||||
|
case '8': return ImGuiKey_8;
|
||||||
|
case '9': return ImGuiKey_9;
|
||||||
|
case 'A': return ImGuiKey_A;
|
||||||
|
case 'B': return ImGuiKey_B;
|
||||||
|
case 'C': return ImGuiKey_C;
|
||||||
|
case 'D': return ImGuiKey_D;
|
||||||
|
case 'E': return ImGuiKey_E;
|
||||||
|
case 'F': return ImGuiKey_F;
|
||||||
|
case 'G': return ImGuiKey_G;
|
||||||
|
case 'H': return ImGuiKey_H;
|
||||||
|
case 'I': return ImGuiKey_I;
|
||||||
|
case 'J': return ImGuiKey_J;
|
||||||
|
case 'K': return ImGuiKey_K;
|
||||||
|
case 'L': return ImGuiKey_L;
|
||||||
|
case 'M': return ImGuiKey_M;
|
||||||
|
case 'N': return ImGuiKey_N;
|
||||||
|
case 'O': return ImGuiKey_O;
|
||||||
|
case 'P': return ImGuiKey_P;
|
||||||
|
case 'Q': return ImGuiKey_Q;
|
||||||
|
case 'R': return ImGuiKey_R;
|
||||||
|
case 'S': return ImGuiKey_S;
|
||||||
|
case 'T': return ImGuiKey_T;
|
||||||
|
case 'U': return ImGuiKey_U;
|
||||||
|
case 'V': return ImGuiKey_V;
|
||||||
|
case 'W': return ImGuiKey_W;
|
||||||
|
case 'X': return ImGuiKey_X;
|
||||||
|
case 'Y': return ImGuiKey_Y;
|
||||||
|
case 'Z': return ImGuiKey_Z;
|
||||||
|
case VK_F1: return ImGuiKey_F1;
|
||||||
|
case VK_F2: return ImGuiKey_F2;
|
||||||
|
case VK_F3: return ImGuiKey_F3;
|
||||||
|
case VK_F4: return ImGuiKey_F4;
|
||||||
|
case VK_F5: return ImGuiKey_F5;
|
||||||
|
case VK_F6: return ImGuiKey_F6;
|
||||||
|
case VK_F7: return ImGuiKey_F7;
|
||||||
|
case VK_F8: return ImGuiKey_F8;
|
||||||
|
case VK_F9: return ImGuiKey_F9;
|
||||||
|
case VK_F10: return ImGuiKey_F10;
|
||||||
|
case VK_F11: return ImGuiKey_F11;
|
||||||
|
case VK_F12: return ImGuiKey_F12;
|
||||||
|
default: return ImGuiKey_None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Allow compilation with old Windows SDK. MinGW doesn't have default _WIN32_WINNT/WINVER versions.
|
// Allow compilation with old Windows SDK. MinGW doesn't have default _WIN32_WINNT/WINVER versions.
|
||||||
#ifndef WM_MOUSEHWHEEL
|
#ifndef WM_MOUSEHWHEEL
|
||||||
#define WM_MOUSEHWHEEL 0x020E
|
#define WM_MOUSEHWHEEL 0x020E
|
||||||
@ -376,11 +518,13 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
|||||||
::TrackMouseEvent(&tme);
|
::TrackMouseEvent(&tme);
|
||||||
bd->MouseTracked = true;
|
bd->MouseTracked = true;
|
||||||
}
|
}
|
||||||
|
io.AddMousePosEvent((float)GET_X_LPARAM(lParam), (float)GET_Y_LPARAM(lParam));
|
||||||
break;
|
break;
|
||||||
case WM_MOUSELEAVE:
|
case WM_MOUSELEAVE:
|
||||||
if (bd->MouseHwnd == hwnd)
|
if (bd->MouseHwnd == hwnd)
|
||||||
bd->MouseHwnd = NULL;
|
bd->MouseHwnd = NULL;
|
||||||
bd->MouseTracked = false;
|
bd->MouseTracked = false;
|
||||||
|
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
||||||
break;
|
break;
|
||||||
case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK:
|
case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK:
|
||||||
case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK:
|
case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK:
|
||||||
@ -392,9 +536,10 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
|||||||
if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) { button = 1; }
|
if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) { button = 1; }
|
||||||
if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) { button = 2; }
|
if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) { button = 2; }
|
||||||
if (msg == WM_XBUTTONDOWN || msg == WM_XBUTTONDBLCLK) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; }
|
if (msg == WM_XBUTTONDOWN || msg == WM_XBUTTONDBLCLK) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; }
|
||||||
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL)
|
if (bd->MouseButtonsDown == 0 && ::GetCapture() == NULL)
|
||||||
::SetCapture(hwnd);
|
::SetCapture(hwnd);
|
||||||
io.MouseDown[button] = true;
|
bd->MouseButtonsDown |= 1 << button;
|
||||||
|
io.AddMouseButtonEvent(button, true);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
@ -407,42 +552,58 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
|||||||
if (msg == WM_RBUTTONUP) { button = 1; }
|
if (msg == WM_RBUTTONUP) { button = 1; }
|
||||||
if (msg == WM_MBUTTONUP) { button = 2; }
|
if (msg == WM_MBUTTONUP) { button = 2; }
|
||||||
if (msg == WM_XBUTTONUP) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; }
|
if (msg == WM_XBUTTONUP) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; }
|
||||||
io.MouseDown[button] = false;
|
bd->MouseButtonsDown &= ~(1 << button);
|
||||||
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd)
|
if (bd->MouseButtonsDown == 0 && ::GetCapture() == hwnd)
|
||||||
::ReleaseCapture();
|
::ReleaseCapture();
|
||||||
|
io.AddMouseButtonEvent(button, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
io.MouseWheel += (float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA;
|
io.AddMouseWheelEvent(0.0f, (float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA);
|
||||||
return 0;
|
return 0;
|
||||||
case WM_MOUSEHWHEEL:
|
case WM_MOUSEHWHEEL:
|
||||||
io.MouseWheelH += (float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA;
|
io.AddMouseWheelEvent((float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA, 0.0f);
|
||||||
return 0;
|
return 0;
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
case WM_SYSKEYDOWN:
|
case WM_SYSKEYDOWN:
|
||||||
case WM_SYSKEYUP:
|
case WM_SYSKEYUP:
|
||||||
{
|
{
|
||||||
bool down = (msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN);
|
const bool is_key_down = (msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN);
|
||||||
if (wParam < 256)
|
if (wParam < 256)
|
||||||
io.KeysDown[wParam] = down;
|
|
||||||
if (wParam == VK_CONTROL)
|
|
||||||
{
|
{
|
||||||
io.KeysDown[VK_LCONTROL] = ((::GetKeyState(VK_LCONTROL) & 0x8000) != 0);
|
// Submit modifiers
|
||||||
io.KeysDown[VK_RCONTROL] = ((::GetKeyState(VK_RCONTROL) & 0x8000) != 0);
|
ImGui_ImplWin32_UpdateKeyModifiers();
|
||||||
io.KeyCtrl = io.KeysDown[VK_LCONTROL] || io.KeysDown[VK_RCONTROL];
|
|
||||||
}
|
// Obtain virtual key code
|
||||||
if (wParam == VK_SHIFT)
|
// (keypad enter doesn't have its own... VK_RETURN with KF_EXTENDED flag means keypad enter, see IM_VK_KEYPAD_ENTER definition for details, it is mapped to ImGuiKey_KeyPadEnter.)
|
||||||
{
|
int vk = (int)wParam;
|
||||||
io.KeysDown[VK_LSHIFT] = ((::GetKeyState(VK_LSHIFT) & 0x8000) != 0);
|
if ((wParam == VK_RETURN) && (HIWORD(lParam) & KF_EXTENDED))
|
||||||
io.KeysDown[VK_RSHIFT] = ((::GetKeyState(VK_RSHIFT) & 0x8000) != 0);
|
vk = IM_VK_KEYPAD_ENTER;
|
||||||
io.KeyShift = io.KeysDown[VK_LSHIFT] || io.KeysDown[VK_RSHIFT];
|
|
||||||
}
|
// Submit key event
|
||||||
if (wParam == VK_MENU)
|
const ImGuiKey key = ImGui_ImplWin32_VirtualKeyToImGuiKey(vk);
|
||||||
{
|
const int scancode = (int)LOBYTE(HIWORD(lParam));
|
||||||
io.KeysDown[VK_LMENU] = ((::GetKeyState(VK_LMENU) & 0x8000) != 0);
|
if (key != ImGuiKey_None)
|
||||||
io.KeysDown[VK_RMENU] = ((::GetKeyState(VK_RMENU) & 0x8000) != 0);
|
ImGui_ImplWin32_AddKeyEvent(key, is_key_down, vk, scancode);
|
||||||
io.KeyAlt = io.KeysDown[VK_LMENU] || io.KeysDown[VK_RMENU];
|
|
||||||
|
// Submit individual left/right modifier events
|
||||||
|
if (vk == VK_SHIFT)
|
||||||
|
{
|
||||||
|
// Important: Shift keys tend to get stuck when pressed together, missing key-up events are corrected in ImGui_ImplWin32_ProcessKeyEventsWorkarounds()
|
||||||
|
if (IsVkDown(VK_LSHIFT) == is_key_down) { ImGui_ImplWin32_AddKeyEvent(ImGuiKey_LeftShift, is_key_down, VK_LSHIFT, scancode); }
|
||||||
|
if (IsVkDown(VK_RSHIFT) == is_key_down) { ImGui_ImplWin32_AddKeyEvent(ImGuiKey_RightShift, is_key_down, VK_RSHIFT, scancode); }
|
||||||
|
}
|
||||||
|
else if (vk == VK_CONTROL)
|
||||||
|
{
|
||||||
|
if (IsVkDown(VK_LCONTROL) == is_key_down) { ImGui_ImplWin32_AddKeyEvent(ImGuiKey_LeftCtrl, is_key_down, VK_LCONTROL, scancode); }
|
||||||
|
if (IsVkDown(VK_RCONTROL) == is_key_down) { ImGui_ImplWin32_AddKeyEvent(ImGuiKey_RightCtrl, is_key_down, VK_RCONTROL, scancode); }
|
||||||
|
}
|
||||||
|
else if (vk == VK_MENU)
|
||||||
|
{
|
||||||
|
if (IsVkDown(VK_LMENU) == is_key_down) { ImGui_ImplWin32_AddKeyEvent(ImGuiKey_LeftAlt, is_key_down, VK_LMENU, scancode); }
|
||||||
|
if (IsVkDown(VK_RMENU) == is_key_down) { ImGui_ImplWin32_AddKeyEvent(ImGuiKey_RightAlt, is_key_down, VK_RMENU, scancode); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui)
|
// [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui)
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE).
|
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
@ -9,7 +9,7 @@ your application or engine to easily integrate Dear ImGui.** Each backend is typ
|
|||||||
e.g. Windows ([imgui_impl_win32.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_win32.cpp)), GLFW ([imgui_impl_glfw.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_glfw.cpp)), SDL2 ([imgui_impl_sdl.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_sdl.cpp)), etc.
|
e.g. Windows ([imgui_impl_win32.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_win32.cpp)), GLFW ([imgui_impl_glfw.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_glfw.cpp)), SDL2 ([imgui_impl_sdl.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_sdl.cpp)), etc.
|
||||||
|
|
||||||
- The 'Renderer' backends are in charge of: creating atlas texture, rendering imgui draw data.<BR>
|
- The 'Renderer' backends are in charge of: creating atlas texture, rendering imgui draw data.<BR>
|
||||||
e.g. DirectX11 ([imgui_impl_dx11.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_dx11.cpp)), OpenGL/WebGL ([imgui_impl_opengl3.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_opengl3.cpp), Vulkan ([imgui_impl_vulkan.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_vulkan.cpp), etc.
|
e.g. DirectX11 ([imgui_impl_dx11.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_dx11.cpp)), OpenGL/WebGL ([imgui_impl_opengl3.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_opengl3.cpp)), Vulkan ([imgui_impl_vulkan.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_vulkan.cpp)), etc.
|
||||||
|
|
||||||
- For some high-level frameworks, a single backend usually handle both 'Platform' and 'Renderer' parts.<BR>
|
- For some high-level frameworks, a single backend usually handle both 'Platform' and 'Renderer' parts.<BR>
|
||||||
e.g. Allegro 5 ([imgui_impl_allegro5.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_allegro5.cpp)). If you end up creating a custom backend for your engine, you may want to do the same.
|
e.g. Allegro 5 ([imgui_impl_allegro5.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_allegro5.cpp)). If you end up creating a custom backend for your engine, you may want to do the same.
|
||||||
@ -38,7 +38,7 @@ Dear ImGui is highly portable and only requires a few things to run and render,
|
|||||||
- Optional: multi-viewports support.
|
- Optional: multi-viewports support.
|
||||||
etc.
|
etc.
|
||||||
|
|
||||||
This is essentially what each backends are doing + obligatory portability cruft. Using default backends ensure you can get all those features including the ones that would be harder to implement on your side (e.g. multi-viewports support).
|
This is essentially what each backend is doing + obligatory portability cruft. Using default backends ensure you can get all those features including the ones that would be harder to implement on your side (e.g. multi-viewports support).
|
||||||
|
|
||||||
It is important to understand the difference between the core Dear ImGui library (files in the root folder)
|
It is important to understand the difference between the core Dear ImGui library (files in the root folder)
|
||||||
and backends which we are describing here (backends/ folder).
|
and backends which we are describing here (backends/ folder).
|
||||||
@ -88,7 +88,7 @@ The [example_emscripten_opengl3](https://github.com/ocornut/imgui/tree/master/ex
|
|||||||
|
|
||||||
### Backends for third-party frameworks, graphics API or other languages
|
### Backends for third-party frameworks, graphics API or other languages
|
||||||
|
|
||||||
See https://github.com/ocornut/imgui/wiki/Bindings for the full list (e.g. Adventure Game Studio, Cinder, Cocos2d-x, Game Maker Studio2, Godot, L<EFBFBD>VE+LUA, Magnum, Monogame, Ogre, openFrameworks, OpenSceneGraph, SFML, Sokol, Unity, Unreal Engine and many others).
|
See https://github.com/ocornut/imgui/wiki/Bindings for the full list (e.g. Adventure Game Studio, Cinder, Cocos2d-x, Game Maker Studio2, Godot, LÖVE+LUA, Magnum, Monogame, Ogre, openFrameworks, OpenSceneGraph, SFML, Sokol, Unity, Unreal Engine and many others).
|
||||||
|
|
||||||
### Recommended Backends
|
### Recommended Backends
|
||||||
|
|
||||||
|
@ -30,10 +30,155 @@ HOW TO UPDATE?
|
|||||||
and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users.
|
and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users.
|
||||||
- Please report any issue!
|
- Please report any issue!
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
VERSION 1.87 (Released 2022-02-07)
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.87
|
||||||
|
|
||||||
|
Breaking Changes:
|
||||||
|
|
||||||
|
- Removed support for pre-C++11 compilers. We'll stop supporting VS2010. (#4537)
|
||||||
|
- Reworked IO mouse input API: (#4921, #4858) [@thedmd, @ocornut]
|
||||||
|
- Added io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() functions,
|
||||||
|
obsoleting writing directly to io.MousePos, io.MouseDown[], io.MouseWheel, etc.
|
||||||
|
- This enable input queue trickling to support low framerates. (#2787, #1992, #3383, #2525, #1320)
|
||||||
|
- Reworked IO keyboard input API: (#4921, #2625, #3724) [@thedmd, @ocornut]
|
||||||
|
- Added io.AddKeyEvent() function, obsoleting writing directly to io.KeyMap[], io.KeysDown[] arrays.
|
||||||
|
- For keyboard modifiers, you can call io.AddKeyEvent() with ImGuiKey_ModXXX values,
|
||||||
|
obsoleting writing directly to io.KeyCtrl, io.KeyShift etc.
|
||||||
|
- Added io.SetKeyEventNativeData() function (optional) to pass native and old legacy indices.
|
||||||
|
- Added full range of key enums in ImGuiKey (e.g. ImGuiKey_F1).
|
||||||
|
- Added GetKeyName() helper function.
|
||||||
|
- Obsoleted GetKeyIndex(): it is now unnecessary and will now return the same value.
|
||||||
|
- All keyboard related functions taking 'int user_key_index' now take 'ImGuiKey key':
|
||||||
|
- IsKeyDown(), IsKeyPressed(), IsKeyReleased(), GetKeyPressedAmount().
|
||||||
|
- Added io.ConfigInputTrickleEventQueue (defaulting to true) to disable input queue trickling.
|
||||||
|
- Backward compatibility:
|
||||||
|
- All backends updated to use new functions.
|
||||||
|
- Old backends populating those arrays should still work!
|
||||||
|
- Calling e.g. IsKeyPressed(MY_NATIVE_KEY_XXX) will still work! (for a while)
|
||||||
|
- Those legacy arrays will only be disabled if '#define IMGUI_DISABLE_OBSOLETE_KEYIO' is set in your imconfig.
|
||||||
|
In a few versions, IMGUI_DISABLE_OBSOLETE_FUNCTIONS will automatically enable IMGUI_DISABLE_OBSOLETE_KEYIO,
|
||||||
|
so this will be moved into the regular obsolescence path.
|
||||||
|
- BREAKING: If your custom backend used ImGuiKey as mock native indices (e.g. "io.KeyMap[ImGuiKey_A] = ImGuiKey_A")
|
||||||
|
this is a use case that will now assert and be breaking for your old backend.
|
||||||
|
- Transition guide:
|
||||||
|
- IsKeyPressed(MY_NATIVE_KEY_XXX) -> use IsKeyPressed(ImGuiKey_XXX)
|
||||||
|
- IsKeyPressed(GetKeyIndex(ImGuiKey_XXX)) -> use IsKeyPressed(ImGuiKey_XXX)
|
||||||
|
- Backend writing to io.KeyMap[],KeysDown[] -> backend should call io.AddKeyEvent(), if legacy indexing is desired, call io.SetKeyEventNativeData()
|
||||||
|
- Basically the trick we took advantage of is that we previously only supported native keycode from 0 to 511,
|
||||||
|
so ImGuiKey values can still express a legacy native keycode, and new named keys are all >= 512.
|
||||||
|
- This will enable a few things in the future:
|
||||||
|
- Access to portable keys allows for backend-agnostic keyboard input code. Until now it was difficult
|
||||||
|
to share code using keyboard across project because of this gap. (#2625, #3724)
|
||||||
|
- Access to full key ranges will allow us to develop a proper keyboard shortcut system. (#456)
|
||||||
|
- io.SetKeyEventNativeData() include native keycode/scancode which may later be exposed. (#3141, #2959)
|
||||||
|
- Reworked IO nav/gamepad input API and unifying inputs sources: (#4921, #4858, #787)
|
||||||
|
- Added full range of ImGuiKey_GamepadXXXX enums (e.g. ImGuiKey_GamepadDpadUp, ImGuiKey_GamepadR2) to use with
|
||||||
|
io.AddKeyEvent(), io.AddKeyAnalogEvent().
|
||||||
|
- Added io.AddKeyAnalogEvent() function, obsoleting writing directly to io.NavInputs[] arrays.
|
||||||
|
- Renamed ImGuiKey_KeyPadEnter to ImGuiKey_KeypadEnter to align with new symbols. Kept redirection enum. (#2625)
|
||||||
|
- Removed support for legacy arithmetic operators (+,+-,*,/) when inputing text into a slider/drag. (#4917, #3184)
|
||||||
|
This doesn't break any api/code but a feature that was accessible by end-users (which seemingly no one used).
|
||||||
|
(Instead you may implement custom expression evaluators to provide a better version of this).
|
||||||
|
- Backends: GLFW: backend now uses glfwSetCursorPosCallback().
|
||||||
|
- If calling ImGui_ImplGlfw_InitXXX with install_callbacks=true: nothing to do. is already done for you.
|
||||||
|
- If calling ImGui_ImplGlfw_InitXXX with install_callbacks=false: you WILL NEED to register the GLFW callback
|
||||||
|
using glfwSetCursorPosCallback() and forward it to the backend function ImGui_ImplGlfw_CursorPosCallback().
|
||||||
|
- Backends: SDL: Added SDL_Renderer* parameter to ImGui_ImplSDL2_InitForSDLRenderer(), so backend can call
|
||||||
|
SDL_GetRendererOutputSize() to obtain framebuffer size valid for hi-dpi. (#4927) [@Clownacy]
|
||||||
|
- Commented out redirecting functions/enums names that were marked obsolete in 1.69, 1.70, 1.71, 1.72 (March-July 2019)
|
||||||
|
- ImGui::SetNextTreeNodeOpen() -> use ImGui::SetNextItemOpen()
|
||||||
|
- ImGui::GetContentRegionAvailWidth() -> use ImGui::GetContentRegionAvail().x
|
||||||
|
- ImGui::TreeAdvanceToLabelPos() -> use ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetTreeNodeToLabelSpacing());
|
||||||
|
- ImFontAtlas::CustomRect -> use ImFontAtlasCustomRect
|
||||||
|
- ImGuiColorEditFlags_RGB/HSV/HEX -> use ImGuiColorEditFlags_DisplayRGB/HSV/Hex
|
||||||
|
- Removed io.ImeSetInputScreenPosFn() in favor of more flexible io.SetPlatformImeDataFn() for IME support.
|
||||||
|
Because this field was mostly only ever used by Dear ImGui internally, not by backends nor the vast majority
|
||||||
|
of user code, this should only affect a very small fraction for users who are already very IME-aware.
|
||||||
|
- Obsoleted 'void* io.ImeWindowHandle' in favor of writing to 'void* ImGuiViewport::PlatformHandleRaw'.
|
||||||
|
This removes an incompatibility between 'master' and 'multi-viewports' backends and toward enabling
|
||||||
|
better support for IME. Updated backends accordingly. Because the old field is set by existing backends,
|
||||||
|
we are keeping it (marked as obsolete).
|
||||||
|
|
||||||
|
|
||||||
|
Other Changes:
|
||||||
|
|
||||||
|
- IO: Added event based input queue API, which now trickles events to support low framerates. [@thedmd, @ocornut]
|
||||||
|
Previously the most common issue case (button presses in low framerates) was handled by backend. This is now
|
||||||
|
handled by core automatically for all kind of inputs. (#4858, #2787, #1992, #3383, #2525, #1320)
|
||||||
|
- New IO functions for keyboard/gamepad: AddKeyEvent(), AddKeyAnalogEvent().
|
||||||
|
- New IO functions for mouse: AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent().
|
||||||
|
- IO: Unified key enums allow using key functions on key mods and gamepad values.
|
||||||
|
- Fixed CTRL+Tab into an empty window causing artifacts on the highlight rectangle due to bad reordering on ImDrawCmd.
|
||||||
|
- Fixed a situation where CTRL+Tab or Modal can occasionally lead to the creation of ImDrawCmd with zero triangles,
|
||||||
|
which would makes the draw operation of some backends assert (e.g. Metal with debugging). (#4857)
|
||||||
|
- Popups: Fixed a regression crash when a new window is created after a modal on the same frame. (#4920) [@rokups]
|
||||||
|
- Popups: Fixed an issue when reopening a same popup multiple times would offset them by 1 pixel on the right. (#4936)
|
||||||
|
- Tables, ImDrawListSplitter: Fixed erroneously stripping trailing ImDrawList::AddCallback() when submitted in
|
||||||
|
last column or last channel and when there are no other drawing operation. (#4843, #4844) [@hoffstadt]
|
||||||
|
- Tables: Fixed positioning of Sort icon on right-most column with some settings (not resizable + no borders). (#4918).
|
||||||
|
- Nav: Fixed gamepad navigation in wrapping popups not wrapping all the way. (#4365)
|
||||||
|
- Sliders, Drags: Fixed text input of values with a leading sign, common when using a format enforcing sign. (#4917)
|
||||||
|
- Demo: draw a section of keyboard in "Inputs > Keyboard, Gamepad & Navigation state" to visualize keys. [@thedmd]
|
||||||
|
- Platform IME: changed io.ImeSetInputScreenPosFn() to io.SetPlatformImeDataFn() API,
|
||||||
|
now taking a ImGuiPlatformImeData structure which we can more easily extend in the future.
|
||||||
|
- Platform IME: moved io.ImeWindowHandle to GetMainViewport()->PlatformHandleRaw.
|
||||||
|
- Platform IME: add ImGuiPlatformImeData::WantVisible, hide IME composition window when not used. (#2589) [@actboy168]
|
||||||
|
- Platform IME: add ImGuiPlatformImeData::InputLineHeight. (#3113) [@liuliu]
|
||||||
|
- Platform IME: [windows] call ImmSetCandidateWindow() to position candidate window.
|
||||||
|
- Backends: GLFW: Pass localized keys (matching keyboard layout). Fix e.g. CTRL+A, CTRL+Z, CTRL+Y shortcuts.
|
||||||
|
We are now converting GLFW untranslated keycodes back to translated keycodes in order to match the behavior of
|
||||||
|
other backend, and facilitate the use of GLFW with lettered-shortcuts API. (#456, #2625)
|
||||||
|
- Backends: GLFW: Submit keys and key mods using io.AddKeyEvent(). (#2625, #4921)
|
||||||
|
- Backends: GLFW: Submit mouse data using io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() functions. (#4921)
|
||||||
|
- Backends: GLFW: Retrieve mouse position using glfwSetCursorPosCallback() + fallback when focused but not hovered/captured.
|
||||||
|
- Backends: GLFW: Submit gamepad data using io.AddKeyEvent/AddKeyAnalogEvent() functions, stopped writing to io.NavInputs[]. (#4921)
|
||||||
|
- Backends: GLFW: Added ImGui_ImplGlfw_InstallCallbacks()/ImGui_ImplGlfw_RestoreCallbacks() helpers to facilitate user installing
|
||||||
|
callbacks after iniitializing backend. (#4981)
|
||||||
|
- Backends: Win32: Submit keys and key mods using io.AddKeyEvent(). (#2625, #4921)
|
||||||
|
- Backends: Win32: Retrieve mouse position using WM_MOUSEMOVE/WM_MOUSELEAVE + fallback when focused but not hovered/captured.
|
||||||
|
- Backends: Win32: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4921)
|
||||||
|
- Backends: Win32: Maintain a MouseButtonsDown mask instead of using ImGui::IsAnyMouseDown() which will be obsoleted.
|
||||||
|
- Backends: Win32: Submit gamepad data using io.AddKeyEvent/AddKeyAnalogEvent() functions, stopped writing to io.NavInputs[]. (#4921)
|
||||||
|
- Backends: SDL: Pass localized keys (matching keyboard layout). Fix e.g. CTRL+A, CTRL+Z, CTRL+Y shortcuts. (#456, #2625)
|
||||||
|
- Backends: SDL: Submit key data using io.AddKeyEvent(). Submit keymods using io.AddKeyModsEvent() at the same time. (#2625)
|
||||||
|
- Backends: SDL: Retrieve mouse position using SDL_MOUSEMOTION/SDL_WINDOWEVENT_LEAVE + fallback when focused but not hovered/captured.
|
||||||
|
- Backends: SDL: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4921)
|
||||||
|
- Backends: SDL: Maintain a MouseButtonsDown mask instead of using ImGui::IsAnyMouseDown() which will be obsoleted.
|
||||||
|
- Backends: SDL: Submit gamepad data using io.AddKeyEvent/AddKeyAnalogEvent() functions, stopped writing to io.NavInputs[]. (#4921)
|
||||||
|
- Backends: Allegro5: Submit keys using io.AddKeyEvent(). Submit keymods using io.AddKeyModsEvent() at the same time. (#2625)
|
||||||
|
- Backends: Allegro5: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4921)
|
||||||
|
- Backends: OSX: Submit keys using io.AddKeyEvent(). Submit keymods using io.AddKeyModsEvent() at the same time. (#2625)
|
||||||
|
- Backends: OSX: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4921)
|
||||||
|
- Backends: OSX: Submit gamepad data using io.AddKeyEvent/AddKeyAnalogEvent() functions, stopped writing to io.NavInputs[]. (#4921)
|
||||||
|
- Backends: OSX: Added basic Platform IME support. (#3108, #2598) [@liuliu]
|
||||||
|
- Backends: OSX: Fix Game Controller nav mapping to use shoulder for both focusing and tweak speed. (#4759)
|
||||||
|
- Backends: OSX: Fix building with old Xcode versions that are missing gamepad features. [@rokups]
|
||||||
|
- Backends: OSX: Forward keyDown/keyUp events to OS when unused by Dear ImGui.
|
||||||
|
- Backends: Android, GLUT: Submit keys using io.AddKeyEvent(). Submit keymods using io.AddKeyModsEvent() at the same time. (#2625)
|
||||||
|
- Backends: Android, GLUT: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4858)
|
||||||
|
- Backends: OpenGL3: Fixed a buffer overflow in imgui_impl_opengl3_loader.h init (added in 1.86). (#4468, #4830) [@dymk]
|
||||||
|
It would generally not have noticeable side-effect at runtime but would be detected by runtime checkers.
|
||||||
|
- Backends: OpenGL3: Fix OpenGL ES2 includes on Apple systems. [@rokups]
|
||||||
|
- Backends: Metal: Added Apple Metal C++ API support. (#4824, #4746) [@luigifcruz]
|
||||||
|
Enable with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file.
|
||||||
|
- Backends: Metal: Ignore ImDrawCmd where ElemCount == 0, which are normally not emitted by the library but
|
||||||
|
can theoretically be created by user code manipulating a ImDrawList. (#4857)
|
||||||
|
- Backends: Vulkan: Added support for ImTextureID as VkDescriptorSet, add ImGui_ImplVulkan_AddTexture(). (#914) [@martty]
|
||||||
|
- Backends: SDL_Renderer: Fix texture atlas format on big-endian hardware (#4927) [@Clownacy]
|
||||||
|
- Backends: WebGPU: Fixed incorrect size parameters in wgpuRenderPassEncoderSetIndexBuffer() and
|
||||||
|
wgpuRenderPassEncoderSetVertexBuffer() calls. (#4891) [@FeepsDev]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.86 (Released 2021-12-22)
|
VERSION 1.86 (Released 2021-12-22)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.86
|
||||||
|
|
||||||
Breaking Changes:
|
Breaking Changes:
|
||||||
|
|
||||||
- Removed CalcListClipping() function. Prefer using ImGuiListClipper which can return non-contiguous ranges.
|
- Removed CalcListClipping() function. Prefer using ImGuiListClipper which can return non-contiguous ranges.
|
||||||
@ -130,6 +275,8 @@ Other Changes:
|
|||||||
VERSION 1.85 (Released 2021-10-12)
|
VERSION 1.85 (Released 2021-10-12)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.85
|
||||||
|
|
||||||
This is the last release officially supporting C++03 and Visual Studio 2008/2010. (#4537)
|
This is the last release officially supporting C++03 and Visual Studio 2008/2010. (#4537)
|
||||||
We expect that the next release will require a subset of the C++11 language (VS 2012~, GCC 4.8.1, Clang 3.3).
|
We expect that the next release will require a subset of the C++11 language (VS 2012~, GCC 4.8.1, Clang 3.3).
|
||||||
We may use some C++11 language features but we will not use any C++ library headers.
|
We may use some C++11 language features but we will not use any C++ library headers.
|
||||||
|
@ -72,7 +72,7 @@ Please read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup Dear ImGui
|
|||||||
Please read the comments and instruction at the top of each file.
|
Please read the comments and instruction at the top of each file.
|
||||||
Please read FAQ at http://www.dearimgui.org/faq
|
Please read FAQ at http://www.dearimgui.org/faq
|
||||||
|
|
||||||
If you are using of the backend provided here, you can add the backends/imgui_impl_xxxx(.cpp,.h)
|
If you are using any of the backends provided here, you can add the backends/imgui_impl_xxxx(.cpp,.h)
|
||||||
files to your project and use as-in. Each imgui_impl_xxxx.cpp file comes with its own individual
|
files to your project and use as-in. Each imgui_impl_xxxx.cpp file comes with its own individual
|
||||||
Changelog, so if you want to update them later it will be easier to catch up with what changed.
|
Changelog, so if you want to update them later it will be easier to catch up with what changed.
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ If you are interested in using Cmake to build and links examples, see:
|
|||||||
**About mouse cursor latency**
|
**About mouse cursor latency**
|
||||||
|
|
||||||
Dear ImGui has no particular extra lag for most behaviors,
|
Dear ImGui has no particular extra lag for most behaviors,
|
||||||
e.g. the value of 'io.MousePos' provided at the time of NewFrame() will result in windows being moved
|
e.g. the last value passed to 'io.AddMousePosEvent()' before NewFrame() will result in windows being moved
|
||||||
to the right spot at the time of EndFrame()/Render(). At 60 FPS your experience should be pleasant.
|
to the right spot at the time of EndFrame()/Render(). At 60 FPS your experience should be pleasant.
|
||||||
|
|
||||||
However, consider that OS mouse cursors are typically drawn through a very specific hardware accelerated
|
However, consider that OS mouse cursors are typically drawn through a very specific hardware accelerated
|
||||||
|
12
docs/FAQ.md
12
docs/FAQ.md
@ -114,7 +114,7 @@ void MyLowLevelMouseButtonHandler(int button, bool down)
|
|||||||
{
|
{
|
||||||
// (1) ALWAYS forward mouse data to ImGui! This is automatic with default backends. With your own backend:
|
// (1) ALWAYS forward mouse data to ImGui! This is automatic with default backends. With your own backend:
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.MouseDown[button] = down;
|
io.AddMouseButtonEvent(button, down);
|
||||||
|
|
||||||
// (2) ONLY forward mouse data to your underlying app/game.
|
// (2) ONLY forward mouse data to your underlying app/game.
|
||||||
if (!io.WantCaptureMouse)
|
if (!io.WantCaptureMouse)
|
||||||
@ -139,7 +139,7 @@ void MyLowLevelMouseButtonHandler(int button, bool down)
|
|||||||
- The gamepad/keyboard navigation is fairly functional and keeps being improved. The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable. Gamepad support is particularly useful to use Dear ImGui on a game console (e.g. PS4, Switch, XB1) without a mouse connected!
|
- The gamepad/keyboard navigation is fairly functional and keeps being improved. The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable. Gamepad support is particularly useful to use Dear ImGui on a game console (e.g. PS4, Switch, XB1) without a mouse connected!
|
||||||
- Keyboard: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard` to enable.
|
- Keyboard: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard` to enable.
|
||||||
- Gamepad: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad` to enable (with a supporting backend).
|
- Gamepad: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad` to enable (with a supporting backend).
|
||||||
- See [Control Sheets for Gamepads](http://www.dearimgui.org/controls_sheets) (reference PNG/PSD for for PS4, XB1, Switch gamepads).
|
- See [Control Sheets for Gamepads](http://www.dearimgui.org/controls_sheets) (reference PNG/PSD for PS4, XB1, Switch gamepads).
|
||||||
- See `USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) for more details.
|
- See `USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) for more details.
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
@ -463,7 +463,7 @@ draw_list->AddCircleFilled(ImVec2(p.x + 50, p.y + 50), 30.0f, IM_COL32(255, 0, 0
|
|||||||
// Draw a 3 pixel thick yellow line
|
// Draw a 3 pixel thick yellow line
|
||||||
draw_list->AddLine(ImVec2(p.x, p.y), ImVec2(p.x + 100.0f, p.y + 100.0f), IM_COL32(255, 255, 0, 255), 3.0f);
|
draw_list->AddLine(ImVec2(p.x, p.y), ImVec2(p.x + 100.0f, p.y + 100.0f), IM_COL32(255, 255, 0, 255), 3.0f);
|
||||||
|
|
||||||
// Advance the ImGui cursor to claim space in the window (otherwise the window will appears small and needs to be resized)
|
// Advance the ImGui cursor to claim space in the window (otherwise the window will appear small and needs to be resized)
|
||||||
ImGui::Dummy(ImVec2(200, 200));
|
ImGui::Dummy(ImVec2(200, 200));
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
@ -607,8 +607,8 @@ Text input: it is up to your application to pass the right character code by cal
|
|||||||
The applications in examples/ are doing that.
|
The applications in examples/ are doing that.
|
||||||
Windows: you can use the WM_CHAR or WM_UNICHAR or WM_IME_CHAR message (depending if your app is built using Unicode or MultiByte mode).
|
Windows: you can use the WM_CHAR or WM_UNICHAR or WM_IME_CHAR message (depending if your app is built using Unicode or MultiByte mode).
|
||||||
You may also use MultiByteToWideChar() or ToUnicode() to retrieve Unicode codepoints from MultiByte characters or keyboard state.
|
You may also use MultiByteToWideChar() or ToUnicode() to retrieve Unicode codepoints from MultiByte characters or keyboard state.
|
||||||
Windows: if your language is relying on an Input Method Editor (IME), you copy the HWND of your window to io.ImeWindowHandle in order for
|
Windows: if your language is relying on an Input Method Editor (IME), you can write your HWND to ImGui::GetMainViewport()->PlatformHandleRaw
|
||||||
the default implementation of io.ImeSetInputScreenPosFn() to set your Microsoft IME position correctly.
|
in order for the default the default implementation of io.SetPlatformImeDataFn() to set your Microsoft IME position correctly.
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
@ -654,7 +654,7 @@ A reasonably skinned application may look like (screenshot from [#2529](https://
|
|||||||
|
|
||||||
### Q: Why using C++ (as opposed to C)?
|
### Q: Why using C++ (as opposed to C)?
|
||||||
|
|
||||||
Dear ImGui takes advantage of a few C++ languages features for convenience but nothing anywhere Boost insanity/quagmire. Dear ImGui does NOT require C++11 so it can be used with most old C++ compilers. Dear ImGui doesn't use any C++ header file. Language-wise, function overloading and default parameters are used to make the API easier to use and code more terse. Doing so I believe the API is sitting on a sweet spot and giving up on those features would make the API more cumbersome. Other features such as namespace, constructors and templates (in the case of the ImVector<> class) are also relied on as a convenience.
|
Dear ImGui takes advantage of a few C++ languages features for convenience but nothing anywhere Boost insanity/quagmire. Dear ImGui doesn't use any C++ header file. Dear ImGui uses a very small subset of C++11 features. In particular, function overloading and default parameters are used to make the API easier to use and code more terse. Doing so I believe the API is sitting on a sweet spot and giving up on those features would make the API more cumbersome. Other features such as namespace, constructors and templates (in the case of the ImVector<> class) are also relied on as a convenience.
|
||||||
|
|
||||||
There is an auto-generated [c-api for Dear ImGui (cimgui)](https://github.com/cimgui/cimgui) by Sonoro1234 and Stephan Dilly. It is designed for creating bindings to other languages. If possible, I would suggest using your target language functionalities to try replicating the function overloading and default parameters used in C++ else the API may be harder to use. Also see [Bindings](https://github.com/ocornut/imgui/wiki/Bindings) for various third-party bindings.
|
There is an auto-generated [c-api for Dear ImGui (cimgui)](https://github.com/cimgui/cimgui) by Sonoro1234 and Stephan Dilly. It is designed for creating bindings to other languages. If possible, I would suggest using your target language functionalities to try replicating the function overloading and default parameters used in C++ else the API may be harder to use. Also see [Bindings](https://github.com/ocornut/imgui/wiki/Bindings) for various third-party bindings.
|
||||||
|
|
||||||
|
@ -292,8 +292,8 @@ for (int rect_n = 0; rect_n < IM_ARRAYSIZE(rect_ids); rect_n++)
|
|||||||
## Using Font Data Embedded In Source Code
|
## Using Font Data Embedded In Source Code
|
||||||
|
|
||||||
- Compile and use [binary_to_compressed_c.cpp](https://github.com/ocornut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp) to create a compressed C style array that you can embed in source code.
|
- Compile and use [binary_to_compressed_c.cpp](https://github.com/ocornut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp) to create a compressed C style array that you can embed in source code.
|
||||||
- See the documentation in [binary_to_compressed_c.cpp](https://github.com/ocornut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp) for instruction on how to use the tool.
|
- See the documentation in [binary_to_compressed_c.cpp](https://github.com/ocornut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp) for instructions on how to use the tool.
|
||||||
- You may find a precompiled version binary_to_compressed_c.exe for Windows instead of demo binaries package (see [README](https://github.com/ocornut/imgui/blob/master/docs/README.md)).
|
- You may find a precompiled version binary_to_compressed_c.exe for Windows inside the demo binaries package (see [README](https://github.com/ocornut/imgui/blob/master/docs/README.md)).
|
||||||
- The tool can optionally output Base85 encoding to reduce the size of _source code_ but the read-only arrays in the actual binary will be about 20% bigger.
|
- The tool can optionally output Base85 encoding to reduce the size of _source code_ but the read-only arrays in the actual binary will be about 20% bigger.
|
||||||
|
|
||||||
Then load the font with:
|
Then load the font with:
|
||||||
@ -309,7 +309,7 @@ ImFont* font = io.Fonts->AddFontFromMemoryCompressedBase85TTF(compressed_data_ba
|
|||||||
|
|
||||||
## About filenames
|
## About filenames
|
||||||
|
|
||||||
**Please note that many new C/C++ users have issues their files _because the filename they provide is wrong_.**
|
**Please note that many new C/C++ users have issues loading their files _because the filename they provide is wrong_.**
|
||||||
|
|
||||||
Two things to watch for:
|
Two things to watch for:
|
||||||
- Make sure your IDE/debugger settings starts your executable from the right working directory. In Visual Studio you can change your working directory in project `Properties > General > Debugging > Working Directory`. People assume that their execution will start from the root folder of the project, where by default it oftens start from the folder where object or executable files are stored.
|
- Make sure your IDE/debugger settings starts your executable from the right working directory. In Visual Studio you can change your working directory in project `Properties > General > Debugging > Working Directory`. People assume that their execution will start from the root folder of the project, where by default it oftens start from the folder where object or executable files are stored.
|
||||||
|
@ -132,7 +132,7 @@ Also see [Wiki](https://github.com/ocornut/imgui/wiki) for more links and ideas.
|
|||||||
|
|
||||||
### Upcoming Changes
|
### Upcoming Changes
|
||||||
|
|
||||||
Some of the goals for 2021 are:
|
Some of the goals for 2022 are:
|
||||||
- Work on Docking (see [#2109](https://github.com/ocornut/imgui/issues/2109), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch)
|
- Work on Docking (see [#2109](https://github.com/ocornut/imgui/issues/2109), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch)
|
||||||
- Work on Multi-Viewport / Multiple OS windows. (see [#1542](https://github.com/ocornut/imgui/issues/1542), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch looking for feedback)
|
- Work on Multi-Viewport / Multiple OS windows. (see [#1542](https://github.com/ocornut/imgui/issues/1542), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch looking for feedback)
|
||||||
- Work on gamepad/keyboard controls. (see [#787](https://github.com/ocornut/imgui/issues/787))
|
- Work on gamepad/keyboard controls. (see [#787](https://github.com/ocornut/imgui/issues/787))
|
||||||
|
@ -113,7 +113,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- input number: optional range min/max for Input*() functions
|
- input number: optional range min/max for Input*() functions
|
||||||
- input number: holding [-]/[+] buttons could increase the step speed non-linearly (or user-controlled)
|
- input number: holding [-]/[+] buttons could increase the step speed non-linearly (or user-controlled)
|
||||||
- input number: use mouse wheel to step up/down
|
- input number: use mouse wheel to step up/down
|
||||||
- input number: applying arithmetics ops (+,-,*,/) messes up with text edit undo stack.
|
|
||||||
|
|
||||||
- layout: helper or a way to express ImGui::SameLine(ImGui::GetCursorStartPos().x + ImGui::CalcItemWidth() + ImGui::GetStyle().ItemInnerSpacing.x); in a simpler manner.
|
- layout: helper or a way to express ImGui::SameLine(ImGui::GetCursorStartPos().x + ImGui::CalcItemWidth() + ImGui::GetStyle().ItemInnerSpacing.x); in a simpler manner.
|
||||||
- layout, font: horizontal tab support, A) text mode: forward only tabs (e.g. every 4 characters/N pixels from pos x1), B) manual mode: explicit tab stops acting as mini columns, no clipping (for menu items, many kind of uses, also vaguely relate to #267, #395)
|
- layout, font: horizontal tab support, A) text mode: forward only tabs (e.g. every 4 characters/N pixels from pos x1), B) manual mode: explicit tab stops acting as mini columns, no clipping (for menu items, many kind of uses, also vaguely relate to #267, #395)
|
||||||
|
@ -107,18 +107,6 @@
|
|||||||
userInfo:nil];
|
userInfo:nil];
|
||||||
[self.view addTrackingArea:trackingArea];
|
[self.view addTrackingArea:trackingArea];
|
||||||
|
|
||||||
// If we want to receive key events, we either need to be in the responder chain of the key view,
|
|
||||||
// or else we can install a local monitor. The consequence of this heavy-handed approach is that
|
|
||||||
// we receive events for all controls, not just Dear ImGui widgets. If we had native controls in our
|
|
||||||
// window, we'd want to be much more careful than just ingesting the complete event stream.
|
|
||||||
// To match the behavior of other backends, we pass every event down to the OS.
|
|
||||||
NSEventMask eventMask = NSEventMaskKeyDown | NSEventMaskKeyUp | NSEventMaskFlagsChanged;
|
|
||||||
[NSEvent addLocalMonitorForEventsMatchingMask:eventMask handler:^NSEvent * _Nullable(NSEvent *event)
|
|
||||||
{
|
|
||||||
ImGui_ImplOSX_HandleEvent(event, self.view);
|
|
||||||
return event;
|
|
||||||
}];
|
|
||||||
|
|
||||||
ImGui_ImplOSX_Init(self.view);
|
ImGui_ImplOSX_Init(self.view);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -223,8 +211,7 @@
|
|||||||
|
|
||||||
#if TARGET_OS_OSX
|
#if TARGET_OS_OSX
|
||||||
|
|
||||||
// Forward Mouse/Keyboard events to Dear ImGui OSX backend.
|
// Forward Mouse events to Dear ImGui OSX backend.
|
||||||
// Other events are registered via addLocalMonitorForEventsMatchingMask()
|
|
||||||
-(void)mouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); }
|
-(void)mouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); }
|
||||||
-(void)rightMouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); }
|
-(void)rightMouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); }
|
||||||
-(void)otherMouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); }
|
-(void)otherMouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); }
|
||||||
@ -251,7 +238,7 @@
|
|||||||
UITouch *anyTouch = event.allTouches.anyObject;
|
UITouch *anyTouch = event.allTouches.anyObject;
|
||||||
CGPoint touchLocation = [anyTouch locationInView:self.view];
|
CGPoint touchLocation = [anyTouch locationInView:self.view];
|
||||||
ImGuiIO &io = ImGui::GetIO();
|
ImGuiIO &io = ImGui::GetIO();
|
||||||
io.MousePos = ImVec2(touchLocation.x, touchLocation.y);
|
io.AddMousePosEvent(touchLocation.x, touchLocation.y);
|
||||||
|
|
||||||
BOOL hasActiveTouch = NO;
|
BOOL hasActiveTouch = NO;
|
||||||
for (UITouch *touch in event.allTouches)
|
for (UITouch *touch in event.allTouches)
|
||||||
@ -262,7 +249,7 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
io.MouseDown[0] = hasActiveTouch;
|
io.AddMouseButtonEvent(0, hasActiveTouch);
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { [self updateIOWithTouchEvent:event]; }
|
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { [self updateIOWithTouchEvent:event]; }
|
||||||
|
@ -36,15 +36,6 @@
|
|||||||
|
|
||||||
-(void)initialize
|
-(void)initialize
|
||||||
{
|
{
|
||||||
// Some events do not raise callbacks of AppView in some circumstances (for example when CMD key is held down).
|
|
||||||
// This monitor taps into global event stream and captures these events.
|
|
||||||
NSEventMask eventMask = NSEventMaskKeyDown | NSEventMaskKeyUp | NSEventMaskFlagsChanged;
|
|
||||||
[NSEvent addLocalMonitorForEventsMatchingMask:eventMask handler:^NSEvent * _Nullable(NSEvent *event)
|
|
||||||
{
|
|
||||||
ImGui_ImplOSX_HandleEvent(event, self);
|
|
||||||
return event;
|
|
||||||
}];
|
|
||||||
|
|
||||||
// Setup Dear ImGui context
|
// Setup Dear ImGui context
|
||||||
// FIXME: This example doesn't have proper cleanup...
|
// FIXME: This example doesn't have proper cleanup...
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
|
@ -41,3 +41,4 @@ file(GLOB sources *.cpp)
|
|||||||
|
|
||||||
add_executable(example_glfw_vulkan ${sources} ${IMGUI_DIR}/backends/imgui_impl_glfw.cpp ${IMGUI_DIR}/backends/imgui_impl_vulkan.cpp ${IMGUI_DIR}/imgui.cpp ${IMGUI_DIR}/imgui_draw.cpp ${IMGUI_DIR}/imgui_demo.cpp ${IMGUI_DIR}/imgui_tables.cpp ${IMGUI_DIR}/imgui_widgets.cpp)
|
add_executable(example_glfw_vulkan ${sources} ${IMGUI_DIR}/backends/imgui_impl_glfw.cpp ${IMGUI_DIR}/backends/imgui_impl_vulkan.cpp ${IMGUI_DIR}/imgui.cpp ${IMGUI_DIR}/imgui_draw.cpp ${IMGUI_DIR}/imgui_demo.cpp ${IMGUI_DIR}/imgui_tables.cpp ${IMGUI_DIR}/imgui_widgets.cpp)
|
||||||
target_link_libraries(example_glfw_vulkan ${LIBRARIES})
|
target_link_libraries(example_glfw_vulkan ${LIBRARIES})
|
||||||
|
target_compile_definitions(example_glfw_vulkan PUBLIC -DImTextureID=ImU64)
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
@set OUT_DIR=Debug
|
@set OUT_DIR=Debug
|
||||||
mkdir %OUT_DIR%
|
mkdir %OUT_DIR%
|
||||||
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
cl /nologo /Zi /MD %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
||||||
|
|
||||||
@set OUT_DIR=Release
|
@set OUT_DIR=Release
|
||||||
mkdir %OUT_DIR%
|
mkdir %OUT_DIR%
|
||||||
cl /nologo /Zi /MD /Ox /Oi %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
cl /nologo /Zi /MD /Ox /Oi %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
@set OUT_DIR=Debug
|
@set OUT_DIR=Debug
|
||||||
mkdir %OUT_DIR%
|
mkdir %OUT_DIR%
|
||||||
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
cl /nologo /Zi /MD %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
||||||
|
|
||||||
@set OUT_DIR=Release
|
@set OUT_DIR=Release
|
||||||
mkdir %OUT_DIR%
|
mkdir %OUT_DIR%
|
||||||
cl /nologo /Zi /MD /Ox /Oi %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
cl /nologo /Zi /MD /Ox /Oi %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
||||||
|
@ -91,6 +91,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@ -105,6 +106,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@ -122,6 +124,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<PreprocessorDefinitions>ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@ -142,6 +145,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<PreprocessorDefinitions>ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
@ -404,9 +404,11 @@ int main(int, char**)
|
|||||||
init_info.Queue = g_Queue;
|
init_info.Queue = g_Queue;
|
||||||
init_info.PipelineCache = g_PipelineCache;
|
init_info.PipelineCache = g_PipelineCache;
|
||||||
init_info.DescriptorPool = g_DescriptorPool;
|
init_info.DescriptorPool = g_DescriptorPool;
|
||||||
init_info.Allocator = g_Allocator;
|
init_info.Subpass = 0;
|
||||||
init_info.MinImageCount = g_MinImageCount;
|
init_info.MinImageCount = g_MinImageCount;
|
||||||
init_info.ImageCount = wd->ImageCount;
|
init_info.ImageCount = wd->ImageCount;
|
||||||
|
init_info.MSAASamples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
|
init_info.Allocator = g_Allocator;
|
||||||
init_info.CheckVkResultFn = check_vk_result;
|
init_info.CheckVkResultFn = check_vk_result;
|
||||||
ImGui_ImplVulkan_Init(&init_info, wd->RenderPass);
|
ImGui_ImplVulkan_Init(&init_info, wd->RenderPass);
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup window
|
// Setup window
|
||||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+SDL_Renderer example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+SDL_Renderer example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
|
||||||
|
|
||||||
// Setup SDL_Renderer instance
|
// Setup SDL_Renderer instance
|
||||||
@ -56,7 +56,7 @@ int main(int, char**)
|
|||||||
//ImGui::StyleColorsClassic();
|
//ImGui::StyleColorsClassic();
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplSDL2_InitForSDLRenderer(window);
|
ImGui_ImplSDL2_InitForSDLRenderer(window, renderer);
|
||||||
ImGui_ImplSDLRenderer_Init(renderer);
|
ImGui_ImplSDLRenderer_Init(renderer);
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
@ -100,7 +100,7 @@ int main(int, char**)
|
|||||||
|
|
||||||
// Start the Dear ImGui frame
|
// Start the Dear ImGui frame
|
||||||
ImGui_ImplSDLRenderer_NewFrame();
|
ImGui_ImplSDLRenderer_NewFrame();
|
||||||
ImGui_ImplSDL2_NewFrame(window);
|
ImGui_ImplSDL2_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
||||||
|
@ -7,4 +7,4 @@
|
|||||||
|
|
||||||
@set OUT_DIR=Debug
|
@set OUT_DIR=Debug
|
||||||
mkdir %OUT_DIR%
|
mkdir %OUT_DIR%
|
||||||
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
|
cl /nologo /Zi /MD %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
|
||||||
|
@ -91,6 +91,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@ -105,6 +106,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@ -122,6 +124,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<PreprocessorDefinitions>ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@ -142,6 +145,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<PreprocessorDefinitions>ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
@ -396,9 +396,11 @@ int main(int, char**)
|
|||||||
init_info.Queue = g_Queue;
|
init_info.Queue = g_Queue;
|
||||||
init_info.PipelineCache = g_PipelineCache;
|
init_info.PipelineCache = g_PipelineCache;
|
||||||
init_info.DescriptorPool = g_DescriptorPool;
|
init_info.DescriptorPool = g_DescriptorPool;
|
||||||
init_info.Allocator = g_Allocator;
|
init_info.Subpass = 0;
|
||||||
init_info.MinImageCount = g_MinImageCount;
|
init_info.MinImageCount = g_MinImageCount;
|
||||||
init_info.ImageCount = wd->ImageCount;
|
init_info.ImageCount = wd->ImageCount;
|
||||||
|
init_info.MSAASamples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
|
init_info.Allocator = g_Allocator;
|
||||||
init_info.CheckVkResultFn = check_vk_result;
|
init_info.CheckVkResultFn = check_vk_result;
|
||||||
ImGui_ImplVulkan_Init(&init_info, wd->RenderPass);
|
ImGui_ImplVulkan_Init(&init_info, wd->RenderPass);
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
|
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
|
||||||
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
//#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87: disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This will be folded into IMGUI_DISABLE_OBSOLETE_FUNCTIONS in a few versions.
|
||||||
|
|
||||||
//---- Disable all of Dear ImGui or don't implement standard windows.
|
//---- Disable all of Dear ImGui or don't implement standard windows.
|
||||||
// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
|
// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
|
||||||
|
446
imgui.h
446
imgui.h
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.86
|
// dear imgui, v1.87
|
||||||
// (headers)
|
// (headers)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@ -35,6 +35,7 @@ Index of this file:
|
|||||||
// [SECTION] Drawing API (ImDrawCallback, ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawFlags, ImDrawListFlags, ImDrawList, ImDrawData)
|
// [SECTION] Drawing API (ImDrawCallback, ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawFlags, ImDrawListFlags, ImDrawList, ImDrawData)
|
||||||
// [SECTION] Font API (ImFontConfig, ImFontGlyph, ImFontGlyphRangesBuilder, ImFontAtlasFlags, ImFontAtlas, ImFont)
|
// [SECTION] Font API (ImFontConfig, ImFontGlyph, ImFontGlyphRangesBuilder, ImFontAtlasFlags, ImFontAtlas, ImFont)
|
||||||
// [SECTION] Viewports (ImGuiViewportFlags, ImGuiViewport)
|
// [SECTION] Viewports (ImGuiViewportFlags, ImGuiViewport)
|
||||||
|
// [SECTION] Platform Dependent Interfaces (ImGuiPlatformImeData)
|
||||||
// [SECTION] Obsolete functions and types
|
// [SECTION] Obsolete functions and types
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@ -63,8 +64,8 @@ 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.86"
|
#define IMGUI_VERSION "1.87"
|
||||||
#define IMGUI_VERSION_NUM 18600
|
#define IMGUI_VERSION_NUM 18700
|
||||||
#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
|
||||||
|
|
||||||
@ -85,11 +86,7 @@ Index of this file:
|
|||||||
#endif
|
#endif
|
||||||
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR) / sizeof(*(_ARR)))) // Size of a static C-style array. Don't use on pointers!
|
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR) / sizeof(*(_ARR)))) // Size of a static C-style array. Don't use on pointers!
|
||||||
#define IM_UNUSED(_VAR) ((void)(_VAR)) // Used to silence "unused variable warnings". Often useful as asserts may be stripped out from final builds.
|
#define IM_UNUSED(_VAR) ((void)(_VAR)) // Used to silence "unused variable warnings". Often useful as asserts may be stripped out from final builds.
|
||||||
#if (__cplusplus >= 201100) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201100)
|
|
||||||
#define IM_OFFSETOF(_TYPE,_MEMBER) offsetof(_TYPE, _MEMBER) // Offset of _MEMBER within _TYPE. Standardized as offsetof() in C++11
|
#define IM_OFFSETOF(_TYPE,_MEMBER) offsetof(_TYPE, _MEMBER) // Offset of _MEMBER within _TYPE. Standardized as offsetof() in C++11
|
||||||
#else
|
|
||||||
#define IM_OFFSETOF(_TYPE,_MEMBER) ((size_t)&(((_TYPE*)0)->_MEMBER)) // Offset of _MEMBER within _TYPE. Old style macro.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Helper Macros - IM_FMTARGS, IM_FMTLIST: Apply printf-style warnings to our formatting functions.
|
// Helper Macros - IM_FMTARGS, IM_FMTLIST: Apply printf-style warnings to our formatting functions.
|
||||||
#if !defined(IMGUI_USE_STB_SPRINTF) && defined(__MINGW32__) && !defined(__clang__)
|
#if !defined(IMGUI_USE_STB_SPRINTF) && defined(__MINGW32__) && !defined(__clang__)
|
||||||
@ -104,7 +101,7 @@ Index of this file:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Disable some of MSVC most aggressive Debug runtime checks in function header/footer (used in some simple/low-level functions)
|
// Disable some of MSVC most aggressive Debug runtime checks in function header/footer (used in some simple/low-level functions)
|
||||||
#if defined(_MSC_VER) && !defined(__clang__) && !defined(IMGUI_DEBUG_PARANOID)
|
#if defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(IMGUI_DEBUG_PARANOID)
|
||||||
#define IM_MSVC_RUNTIME_CHECKS_OFF __pragma(runtime_checks("",off)) __pragma(check_stack(off)) __pragma(strict_gs_check(push,off))
|
#define IM_MSVC_RUNTIME_CHECKS_OFF __pragma(runtime_checks("",off)) __pragma(check_stack(off)) __pragma(strict_gs_check(push,off))
|
||||||
#define IM_MSVC_RUNTIME_CHECKS_RESTORE __pragma(runtime_checks("",restore)) __pragma(check_stack()) __pragma(strict_gs_check(pop))
|
#define IM_MSVC_RUNTIME_CHECKS_RESTORE __pragma(runtime_checks("",restore)) __pragma(check_stack()) __pragma(strict_gs_check(pop))
|
||||||
#else
|
#else
|
||||||
@ -151,9 +148,11 @@ struct ImColor; // Helper functions to create a color that c
|
|||||||
struct ImGuiContext; // Dear ImGui context (opaque structure, unless including imgui_internal.h)
|
struct ImGuiContext; // Dear ImGui context (opaque structure, unless including imgui_internal.h)
|
||||||
struct ImGuiIO; // Main configuration and I/O between your application and ImGui
|
struct ImGuiIO; // Main configuration and I/O between your application and ImGui
|
||||||
struct ImGuiInputTextCallbackData; // Shared state of InputText() when using custom ImGuiInputTextCallback (rare/advanced use)
|
struct ImGuiInputTextCallbackData; // Shared state of InputText() when using custom ImGuiInputTextCallback (rare/advanced use)
|
||||||
|
struct ImGuiKeyData; // Storage for ImGuiIO and IsKeyDown(), IsKeyPressed() etc functions.
|
||||||
struct ImGuiListClipper; // Helper to manually clip large list of items
|
struct ImGuiListClipper; // Helper to manually clip large list of items
|
||||||
struct ImGuiOnceUponAFrame; // Helper for running a block of code not more than once a frame
|
struct ImGuiOnceUponAFrame; // Helper for running a block of code not more than once a frame
|
||||||
struct ImGuiPayload; // User data payload for drag and drop operations
|
struct ImGuiPayload; // User data payload for drag and drop operations
|
||||||
|
struct ImGuiPlatformImeData; // Platform IME data for io.SetPlatformImeDataFn() function.
|
||||||
struct ImGuiSizeCallbackData; // Callback data when using SetNextWindowSizeConstraints() (rare/advanced use)
|
struct ImGuiSizeCallbackData; // Callback data when using SetNextWindowSizeConstraints() (rare/advanced use)
|
||||||
struct ImGuiStorage; // Helper for key->value storage
|
struct ImGuiStorage; // Helper for key->value storage
|
||||||
struct ImGuiStyle; // Runtime data for styling/colors
|
struct ImGuiStyle; // Runtime data for styling/colors
|
||||||
@ -171,7 +170,7 @@ typedef int ImGuiCol; // -> enum ImGuiCol_ // Enum: A
|
|||||||
typedef int ImGuiCond; // -> enum ImGuiCond_ // Enum: A condition for many Set*() functions
|
typedef int ImGuiCond; // -> enum ImGuiCond_ // Enum: A condition for many Set*() functions
|
||||||
typedef int ImGuiDataType; // -> enum ImGuiDataType_ // Enum: A primary data type
|
typedef int ImGuiDataType; // -> enum ImGuiDataType_ // Enum: A primary data type
|
||||||
typedef int ImGuiDir; // -> enum ImGuiDir_ // Enum: A cardinal direction
|
typedef int ImGuiDir; // -> enum ImGuiDir_ // Enum: A cardinal direction
|
||||||
typedef int ImGuiKey; // -> enum ImGuiKey_ // Enum: A key identifier (ImGui-side enum)
|
typedef int ImGuiKey; // -> enum ImGuiKey_ // Enum: A key identifier
|
||||||
typedef int ImGuiNavInput; // -> enum ImGuiNavInput_ // Enum: An input identifier for navigation
|
typedef int ImGuiNavInput; // -> enum ImGuiNavInput_ // Enum: An input identifier for navigation
|
||||||
typedef int ImGuiMouseButton; // -> enum ImGuiMouseButton_ // Enum: A mouse button identifier (0=left, 1=right, 2=middle)
|
typedef int ImGuiMouseButton; // -> enum ImGuiMouseButton_ // Enum: A mouse button identifier (0=left, 1=right, 2=middle)
|
||||||
typedef int ImGuiMouseCursor; // -> enum ImGuiMouseCursor_ // Enum: A mouse cursor identifier
|
typedef int ImGuiMouseCursor; // -> enum ImGuiMouseCursor_ // Enum: A mouse cursor identifier
|
||||||
@ -225,17 +224,8 @@ typedef signed short ImS16; // 16-bit signed integer
|
|||||||
typedef unsigned short ImU16; // 16-bit unsigned integer
|
typedef unsigned short ImU16; // 16-bit unsigned integer
|
||||||
typedef signed int ImS32; // 32-bit signed integer == int
|
typedef signed int ImS32; // 32-bit signed integer == int
|
||||||
typedef unsigned int ImU32; // 32-bit unsigned integer (often used to store packed colors)
|
typedef unsigned int ImU32; // 32-bit unsigned integer (often used to store packed colors)
|
||||||
#if defined(_MSC_VER) && !defined(__clang__)
|
typedef signed long long ImS64; // 64-bit signed integer
|
||||||
typedef signed __int64 ImS64; // 64-bit signed integer (pre and post C++11 with Visual Studio)
|
typedef unsigned long long ImU64; // 64-bit unsigned integer
|
||||||
typedef unsigned __int64 ImU64; // 64-bit unsigned integer (pre and post C++11 with Visual Studio)
|
|
||||||
#elif (defined(__clang__) || defined(__GNUC__)) && (__cplusplus < 201100)
|
|
||||||
#include <stdint.h>
|
|
||||||
typedef int64_t ImS64; // 64-bit signed integer (pre C++11)
|
|
||||||
typedef uint64_t ImU64; // 64-bit unsigned integer (pre C++11)
|
|
||||||
#else
|
|
||||||
typedef signed long long ImS64; // 64-bit signed integer (post C++11)
|
|
||||||
typedef unsigned long long ImU64; // 64-bit unsigned integer (post C++11)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Character types
|
// Character types
|
||||||
// (we generally use UTF-8 encoded string in the API. This is storage specifically for a decoded character used for keyboard input and display)
|
// (we generally use UTF-8 encoded string in the API. This is storage specifically for a decoded character used for keyboard input and display)
|
||||||
@ -524,7 +514,8 @@ namespace ImGui
|
|||||||
|
|
||||||
// Widgets: Drag Sliders
|
// Widgets: Drag Sliders
|
||||||
// - CTRL+Click on any drag box to turn them into an input box. Manually input values aren't clamped by default and can go off-bounds. Use ImGuiSliderFlags_AlwaysClamp to always clamp.
|
// - CTRL+Click on any drag box to turn them into an input box. Manually input values aren't clamped by default and can go off-bounds. Use ImGuiSliderFlags_AlwaysClamp to always clamp.
|
||||||
// - For all the Float2/Float3/Float4/Int2/Int3/Int4 versions of every functions, note that a 'float v[X]' function argument is the same as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. You can pass address of your first element out of a contiguous set, e.g. &myvector.x
|
// - For all the Float2/Float3/Float4/Int2/Int3/Int4 versions of every functions, note that a 'float v[X]' function argument is the same as 'float* v',
|
||||||
|
// the array syntax is just a way to document the number of elements that are expected to be accessible. You can pass address of your first element out of a contiguous set, e.g. &myvector.x
|
||||||
// - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc.
|
// - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc.
|
||||||
// - Format string may also be set to NULL or use the default format ("%f" or "%d").
|
// - Format string may also be set to NULL or use the default format ("%f" or "%d").
|
||||||
// - Speed are per-pixel of mouse movement (v_speed=0.2f: mouse needs to move by 5 pixels to increase value by 1). For gamepad/keyboard navigation, minimum speed is Max(v_speed, minimum_step_at_given_precision).
|
// - Speed are per-pixel of mouse movement (v_speed=0.2f: mouse needs to move by 5 pixels to increase value by 1). For gamepad/keyboard navigation, minimum speed is Max(v_speed, minimum_step_at_given_precision).
|
||||||
@ -690,6 +681,7 @@ namespace ImGui
|
|||||||
// - CloseCurrentPopup() is called by default by Selectable()/MenuItem() when activated (FIXME: need some options).
|
// - CloseCurrentPopup() is called by default by Selectable()/MenuItem() when activated (FIXME: need some options).
|
||||||
// - Use ImGuiPopupFlags_NoOpenOverExistingPopup to avoid opening a popup if there's already one at the same level. This is equivalent to e.g. testing for !IsAnyPopupOpen() prior to OpenPopup().
|
// - Use ImGuiPopupFlags_NoOpenOverExistingPopup to avoid opening a popup if there's already one at the same level. This is equivalent to e.g. testing for !IsAnyPopupOpen() prior to OpenPopup().
|
||||||
// - Use IsWindowAppearing() after BeginPopup() to tell if a window just opened.
|
// - Use IsWindowAppearing() after BeginPopup() to tell if a window just opened.
|
||||||
|
// - IMPORTANT: Notice that for OpenPopupOnItemClick() we exceptionally default flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter
|
||||||
IMGUI_API void OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags = 0); // call to mark popup as open (don't call every frame!).
|
IMGUI_API void OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags = 0); // call to mark popup as open (don't call every frame!).
|
||||||
IMGUI_API void OpenPopup(ImGuiID id, ImGuiPopupFlags popup_flags = 0); // id overload to facilitate calling from nested stacks
|
IMGUI_API void OpenPopup(ImGuiID id, ImGuiPopupFlags popup_flags = 0); // id overload to facilitate calling from nested stacks
|
||||||
IMGUI_API void OpenPopupOnItemClick(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // helper to open popup when clicked on last item. Default to ImGuiPopupFlags_MouseButtonRight == 1. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
|
IMGUI_API void OpenPopupOnItemClick(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // helper to open popup when clicked on last item. Default to ImGuiPopupFlags_MouseButtonRight == 1. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
|
||||||
@ -699,7 +691,7 @@ namespace ImGui
|
|||||||
// - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking.
|
// - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking.
|
||||||
// - They are convenient to easily create context menus, hence the name.
|
// - They are convenient to easily create context menus, hence the name.
|
||||||
// - IMPORTANT: Notice that BeginPopupContextXXX takes ImGuiPopupFlags just like OpenPopup() and unlike BeginPopup(). For full consistency, we may add ImGuiWindowFlags to the BeginPopupContextXXX functions in the future.
|
// - IMPORTANT: Notice that BeginPopupContextXXX takes ImGuiPopupFlags just like OpenPopup() and unlike BeginPopup(). For full consistency, we may add ImGuiWindowFlags to the BeginPopupContextXXX functions in the future.
|
||||||
// - IMPORTANT: we exceptionally default their flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter, so if you add other flags remember to re-add the ImGuiPopupFlags_MouseButtonRight.
|
// - IMPORTANT: Notice that we exceptionally default their flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter, so if you add other flags remember to re-add the ImGuiPopupFlags_MouseButtonRight.
|
||||||
IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked on last item. Use str_id==NULL to associate the popup to previous item. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
|
IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked on last item. Use str_id==NULL to associate the popup to previous item. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
|
||||||
IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1);// open+begin popup when clicked on current window.
|
IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1);// open+begin popup when clicked on current window.
|
||||||
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked in void (where there are no windows).
|
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked in void (where there are no windows).
|
||||||
@ -711,7 +703,6 @@ namespace ImGui
|
|||||||
IMGUI_API bool IsPopupOpen(const char* str_id, ImGuiPopupFlags flags = 0); // return true if the popup is open.
|
IMGUI_API bool IsPopupOpen(const char* str_id, ImGuiPopupFlags flags = 0); // return true if the popup is open.
|
||||||
|
|
||||||
// Tables
|
// Tables
|
||||||
// [BETA API] API may evolve slightly! If you use this, please update to the next version when it comes out!
|
|
||||||
// - Full-featured replacement for old Columns API.
|
// - Full-featured replacement for old Columns API.
|
||||||
// - See Demo->Tables for demo code.
|
// - See Demo->Tables for demo code.
|
||||||
// - See top of imgui_tables.cpp for general commentary.
|
// - See top of imgui_tables.cpp for general commentary.
|
||||||
@ -807,7 +798,7 @@ namespace ImGui
|
|||||||
// - If you stop calling BeginDragDropSource() the payload is preserved however it won't have a preview tooltip (we currently display a fallback "..." tooltip, see #1725)
|
// - If you stop calling BeginDragDropSource() the payload is preserved however it won't have a preview tooltip (we currently display a fallback "..." tooltip, see #1725)
|
||||||
// - An item can be both drag source and drop target.
|
// - An item can be both drag source and drop target.
|
||||||
IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags = 0); // call after submitting an item which may be dragged. when this return true, you can call SetDragDropPayload() + EndDragDropSource()
|
IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags = 0); // call after submitting an item which may be dragged. when this return true, you can call SetDragDropPayload() + EndDragDropSource()
|
||||||
IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t sz, ImGuiCond cond = 0); // type is a user defined string of maximum 32 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui.
|
IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t sz, ImGuiCond cond = 0); // type is a user defined string of maximum 32 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui. Return true when payload has been accepted.
|
||||||
IMGUI_API void EndDragDropSource(); // only call EndDragDropSource() if BeginDragDropSource() returns true!
|
IMGUI_API void EndDragDropSource(); // only call EndDragDropSource() if BeginDragDropSource() returns true!
|
||||||
IMGUI_API bool BeginDragDropTarget(); // call after submitting an item that may receive a payload. If this returns true, you can call AcceptDragDropPayload() + EndDragDropTarget()
|
IMGUI_API bool BeginDragDropTarget(); // call after submitting an item that may receive a payload. If this returns true, you can call AcceptDragDropPayload() + EndDragDropTarget()
|
||||||
IMGUI_API const ImGuiPayload* AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags = 0); // accept contents of a given type. If ImGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released.
|
IMGUI_API const ImGuiPayload* AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags = 0); // accept contents of a given type. If ImGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released.
|
||||||
@ -882,13 +873,16 @@ namespace ImGui
|
|||||||
IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
|
IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
|
||||||
|
|
||||||
// Inputs Utilities: Keyboard
|
// Inputs Utilities: Keyboard
|
||||||
// - For 'int user_key_index' you can use your own indices/enums according to how your backend/engine stored them in io.KeysDown[].
|
// Without IMGUI_DISABLE_OBSOLETE_KEYIO: (legacy support)
|
||||||
// - We don't know the meaning of those value. You can use GetKeyIndex() to map a ImGuiKey_ value into the user index.
|
// - For 'ImGuiKey key' you can still use your legacy native/user indices according to how your backend/engine stored them in io.KeysDown[].
|
||||||
IMGUI_API int GetKeyIndex(ImGuiKey imgui_key); // map ImGuiKey_* values into user's key index. == io.KeyMap[key]
|
// With IMGUI_DISABLE_OBSOLETE_KEYIO: (this is the way forward)
|
||||||
IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index].
|
// - Any use of 'ImGuiKey' will assert when key < 512 will be passed, previously reserved as native/user keys indices
|
||||||
IMGUI_API bool IsKeyPressed(int user_key_index, bool repeat = true); // was key pressed (went from !Down to Down)? if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate
|
// - GetKeyIndex() is pass-through and therefore deprecated (gone if IMGUI_DISABLE_OBSOLETE_KEYIO is defined)
|
||||||
IMGUI_API bool IsKeyReleased(int user_key_index); // was key released (went from Down to !Down)?
|
IMGUI_API bool IsKeyDown(ImGuiKey key); // is key being held.
|
||||||
IMGUI_API int GetKeyPressedAmount(int key_index, float repeat_delay, float rate); // uses provided repeat rate/delay. return a count, most often 0 or 1 but might be >1 if RepeatRate is small enough that DeltaTime > RepeatRate
|
IMGUI_API bool IsKeyPressed(ImGuiKey key, bool repeat = true); // was key pressed (went from !Down to Down)? if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate
|
||||||
|
IMGUI_API bool IsKeyReleased(ImGuiKey key); // was key released (went from Down to !Down)?
|
||||||
|
IMGUI_API int GetKeyPressedAmount(ImGuiKey key, float repeat_delay, float rate); // uses provided repeat rate/delay. return a count, most often 0 or 1 but might be >1 if RepeatRate is small enough that DeltaTime > RepeatRate
|
||||||
|
IMGUI_API const char* GetKeyName(ImGuiKey key); // [DEBUG] returns English name of the key. Those names a provided for debugging purpose and are not meant to be saved persistently not compared.
|
||||||
IMGUI_API void CaptureKeyboardFromApp(bool want_capture_keyboard_value = true); // attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle). e.g. force capture keyboard when your widget is being hovered. This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard_value"; after the next NewFrame() call.
|
IMGUI_API void CaptureKeyboardFromApp(bool want_capture_keyboard_value = true); // attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle). e.g. force capture keyboard when your widget is being hovered. This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard_value"; after the next NewFrame() call.
|
||||||
|
|
||||||
// Inputs Utilities: Mouse
|
// Inputs Utilities: Mouse
|
||||||
@ -902,7 +896,7 @@ namespace ImGui
|
|||||||
IMGUI_API int GetMouseClickedCount(ImGuiMouseButton button); // return the number of successive mouse-clicks at the time where a click happen (otherwise 0).
|
IMGUI_API int GetMouseClickedCount(ImGuiMouseButton button); // return the number of successive mouse-clicks at the time where a click happen (otherwise 0).
|
||||||
IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true);// is mouse hovering given bounding rect (in screen space). clipped by current clipping settings, but disregarding of other consideration of focus/window ordering/popup-block.
|
IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true);// is mouse hovering given bounding rect (in screen space). clipped by current clipping settings, but disregarding of other consideration of focus/window ordering/popup-block.
|
||||||
IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); // by convention we use (-FLT_MAX,-FLT_MAX) to denote that there is no mouse available
|
IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); // by convention we use (-FLT_MAX,-FLT_MAX) to denote that there is no mouse available
|
||||||
IMGUI_API bool IsAnyMouseDown(); // is any mouse button held?
|
IMGUI_API bool IsAnyMouseDown(); // [WILL OBSOLETE] is any mouse button held? This was designed for backends, but prefer having backend maintain a mask of held mouse buttons, because upcoming input queue system will make this invalid.
|
||||||
IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
|
IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
|
||||||
IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve mouse position at the time of opening popup we have BeginPopup() into (helper to avoid user backing that value themselves)
|
IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve mouse position at the time of opening popup we have BeginPopup() into (helper to avoid user backing that value themselves)
|
||||||
IMGUI_API bool IsMouseDragging(ImGuiMouseButton button, float lock_threshold = -1.0f); // is mouse dragging? (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold)
|
IMGUI_API bool IsMouseDragging(ImGuiMouseButton button, float lock_threshold = -1.0f); // is mouse dragging? (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold)
|
||||||
@ -980,9 +974,7 @@ enum ImGuiWindowFlags_
|
|||||||
ImGuiWindowFlags_Popup = 1 << 26, // Don't use! For internal use by BeginPopup()
|
ImGuiWindowFlags_Popup = 1 << 26, // Don't use! For internal use by BeginPopup()
|
||||||
ImGuiWindowFlags_Modal = 1 << 27, // Don't use! For internal use by BeginPopupModal()
|
ImGuiWindowFlags_Modal = 1 << 27, // Don't use! For internal use by BeginPopupModal()
|
||||||
ImGuiWindowFlags_ChildMenu = 1 << 28 // Don't use! For internal use by BeginMenu()
|
ImGuiWindowFlags_ChildMenu = 1 << 28 // Don't use! For internal use by BeginMenu()
|
||||||
|
//ImGuiWindowFlags_ResizeFromAnySide = 1 << 17, // [Obsolete] --> Set io.ConfigWindowsResizeFromEdges=true and make sure mouse cursors are supported by backend (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors)
|
||||||
// [Obsolete]
|
|
||||||
//ImGuiWindowFlags_ResizeFromAnySide = 1 << 17, // --> Set io.ConfigWindowsResizeFromEdges=true and make sure mouse cursors are supported by backend (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flags for ImGui::InputText()
|
// Flags for ImGui::InputText()
|
||||||
@ -1117,8 +1109,7 @@ enum ImGuiTabItemFlags_
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Flags for ImGui::BeginTable()
|
// Flags for ImGui::BeginTable()
|
||||||
// [BETA API] API may evolve slightly! If you use this, please update to the next version when it comes out!
|
// - Important! Sizing policies have complex and subtle side effects, much more so than you would expect.
|
||||||
// - Important! Sizing policies have complex and subtle side effects, more so than you would expect.
|
|
||||||
// Read comments/demos carefully + experiment with live demos to get acquainted with them.
|
// Read comments/demos carefully + experiment with live demos to get acquainted with them.
|
||||||
// - The DEFAULT sizing policies are:
|
// - The DEFAULT sizing policies are:
|
||||||
// - Default to ImGuiTableFlags_SizingFixedFit if ScrollX is on, or if host window has ImGuiWindowFlags_AlwaysAutoResize.
|
// - Default to ImGuiTableFlags_SizingFixedFit if ScrollX is on, or if host window has ImGuiWindowFlags_AlwaysAutoResize.
|
||||||
@ -1126,8 +1117,8 @@ enum ImGuiTabItemFlags_
|
|||||||
// - When ScrollX is off:
|
// - When ScrollX is off:
|
||||||
// - Table defaults to ImGuiTableFlags_SizingStretchSame -> all Columns defaults to ImGuiTableColumnFlags_WidthStretch with same weight.
|
// - Table defaults to ImGuiTableFlags_SizingStretchSame -> all Columns defaults to ImGuiTableColumnFlags_WidthStretch with same weight.
|
||||||
// - Columns sizing policy allowed: Stretch (default), Fixed/Auto.
|
// - Columns sizing policy allowed: Stretch (default), Fixed/Auto.
|
||||||
// - Fixed Columns will generally obtain their requested width (unless the table cannot fit them all).
|
// - Fixed Columns (if any) will generally obtain their requested width (unless the table cannot fit them all).
|
||||||
// - Stretch Columns will share the remaining width.
|
// - Stretch Columns will share the remaining width according to their respective weight.
|
||||||
// - Mixed Fixed/Stretch columns is possible but has various side-effects on resizing behaviors.
|
// - Mixed Fixed/Stretch columns is possible but has various side-effects on resizing behaviors.
|
||||||
// The typical use of mixing sizing policies is: any number of LEADING Fixed columns, followed by one or two TRAILING Stretch columns.
|
// The typical use of mixing sizing policies is: any number of LEADING Fixed columns, followed by one or two TRAILING Stretch columns.
|
||||||
// (this is because the visible order of columns have subtle but necessary effects on how they react to manual resizing).
|
// (this is because the visible order of columns have subtle but necessary effects on how they react to manual resizing).
|
||||||
@ -1241,7 +1232,7 @@ enum ImGuiTableColumnFlags_
|
|||||||
enum ImGuiTableRowFlags_
|
enum ImGuiTableRowFlags_
|
||||||
{
|
{
|
||||||
ImGuiTableRowFlags_None = 0,
|
ImGuiTableRowFlags_None = 0,
|
||||||
ImGuiTableRowFlags_Headers = 1 << 0 // Identify header row (set default background color + width of its contents accounted different for auto column width)
|
ImGuiTableRowFlags_Headers = 1 << 0 // Identify header row (set default background color + width of its contents accounted differently for auto column width)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Enum for ImGui::TableSetBgColor()
|
// Enum for ImGui::TableSetBgColor()
|
||||||
@ -1350,10 +1341,11 @@ enum ImGuiSortDirection_
|
|||||||
ImGuiSortDirection_Descending = 2 // Descending = 9->0, Z->A etc.
|
ImGuiSortDirection_Descending = 2 // Descending = 9->0, Z->A etc.
|
||||||
};
|
};
|
||||||
|
|
||||||
// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
|
|
||||||
enum ImGuiKey_
|
enum ImGuiKey_
|
||||||
{
|
{
|
||||||
ImGuiKey_Tab,
|
// Keyboard
|
||||||
|
ImGuiKey_None = 0,
|
||||||
|
ImGuiKey_Tab = 512, // == ImGuiKey_NamedKey_BEGIN
|
||||||
ImGuiKey_LeftArrow,
|
ImGuiKey_LeftArrow,
|
||||||
ImGuiKey_RightArrow,
|
ImGuiKey_RightArrow,
|
||||||
ImGuiKey_UpArrow,
|
ImGuiKey_UpArrow,
|
||||||
@ -1368,65 +1360,148 @@ enum ImGuiKey_
|
|||||||
ImGuiKey_Space,
|
ImGuiKey_Space,
|
||||||
ImGuiKey_Enter,
|
ImGuiKey_Enter,
|
||||||
ImGuiKey_Escape,
|
ImGuiKey_Escape,
|
||||||
ImGuiKey_KeyPadEnter,
|
ImGuiKey_LeftCtrl, ImGuiKey_LeftShift, ImGuiKey_LeftAlt, ImGuiKey_LeftSuper,
|
||||||
ImGuiKey_A, // for text edit CTRL+A: select all
|
ImGuiKey_RightCtrl, ImGuiKey_RightShift, ImGuiKey_RightAlt, ImGuiKey_RightSuper,
|
||||||
ImGuiKey_C, // for text edit CTRL+C: copy
|
ImGuiKey_Menu,
|
||||||
ImGuiKey_V, // for text edit CTRL+V: paste
|
ImGuiKey_0, ImGuiKey_1, ImGuiKey_2, ImGuiKey_3, ImGuiKey_4, ImGuiKey_5, ImGuiKey_6, ImGuiKey_7, ImGuiKey_8, ImGuiKey_9,
|
||||||
ImGuiKey_X, // for text edit CTRL+X: cut
|
ImGuiKey_A, ImGuiKey_B, ImGuiKey_C, ImGuiKey_D, ImGuiKey_E, ImGuiKey_F, ImGuiKey_G, ImGuiKey_H, ImGuiKey_I, ImGuiKey_J,
|
||||||
ImGuiKey_Y, // for text edit CTRL+Y: redo
|
ImGuiKey_K, ImGuiKey_L, ImGuiKey_M, ImGuiKey_N, ImGuiKey_O, ImGuiKey_P, ImGuiKey_Q, ImGuiKey_R, ImGuiKey_S, ImGuiKey_T,
|
||||||
ImGuiKey_Z, // for text edit CTRL+Z: undo
|
ImGuiKey_U, ImGuiKey_V, ImGuiKey_W, ImGuiKey_X, ImGuiKey_Y, ImGuiKey_Z,
|
||||||
ImGuiKey_COUNT
|
ImGuiKey_F1, ImGuiKey_F2, ImGuiKey_F3, ImGuiKey_F4, ImGuiKey_F5, ImGuiKey_F6,
|
||||||
|
ImGuiKey_F7, ImGuiKey_F8, ImGuiKey_F9, ImGuiKey_F10, ImGuiKey_F11, ImGuiKey_F12,
|
||||||
|
ImGuiKey_Apostrophe, // '
|
||||||
|
ImGuiKey_Comma, // ,
|
||||||
|
ImGuiKey_Minus, // -
|
||||||
|
ImGuiKey_Period, // .
|
||||||
|
ImGuiKey_Slash, // /
|
||||||
|
ImGuiKey_Semicolon, // ;
|
||||||
|
ImGuiKey_Equal, // =
|
||||||
|
ImGuiKey_LeftBracket, // [
|
||||||
|
ImGuiKey_Backslash, // \ (this text inhibit multiline comment caused by backslash)
|
||||||
|
ImGuiKey_RightBracket, // ]
|
||||||
|
ImGuiKey_GraveAccent, // `
|
||||||
|
ImGuiKey_CapsLock,
|
||||||
|
ImGuiKey_ScrollLock,
|
||||||
|
ImGuiKey_NumLock,
|
||||||
|
ImGuiKey_PrintScreen,
|
||||||
|
ImGuiKey_Pause,
|
||||||
|
ImGuiKey_Keypad0, ImGuiKey_Keypad1, ImGuiKey_Keypad2, ImGuiKey_Keypad3, ImGuiKey_Keypad4,
|
||||||
|
ImGuiKey_Keypad5, ImGuiKey_Keypad6, ImGuiKey_Keypad7, ImGuiKey_Keypad8, ImGuiKey_Keypad9,
|
||||||
|
ImGuiKey_KeypadDecimal,
|
||||||
|
ImGuiKey_KeypadDivide,
|
||||||
|
ImGuiKey_KeypadMultiply,
|
||||||
|
ImGuiKey_KeypadSubtract,
|
||||||
|
ImGuiKey_KeypadAdd,
|
||||||
|
ImGuiKey_KeypadEnter,
|
||||||
|
ImGuiKey_KeypadEqual,
|
||||||
|
|
||||||
|
// Gamepad (some of those are analog values, 0.0f to 1.0f) // NAVIGATION action
|
||||||
|
ImGuiKey_GamepadStart, // Menu (Xbox) + (Switch) Start/Options (PS) // --
|
||||||
|
ImGuiKey_GamepadBack, // View (Xbox) - (Switch) Share (PS) // --
|
||||||
|
ImGuiKey_GamepadFaceUp, // Y (Xbox) X (Switch) Triangle (PS) // -> ImGuiNavInput_Input
|
||||||
|
ImGuiKey_GamepadFaceDown, // A (Xbox) B (Switch) Cross (PS) // -> ImGuiNavInput_Activate
|
||||||
|
ImGuiKey_GamepadFaceLeft, // X (Xbox) Y (Switch) Square (PS) // -> ImGuiNavInput_Menu
|
||||||
|
ImGuiKey_GamepadFaceRight, // B (Xbox) A (Switch) Circle (PS) // -> ImGuiNavInput_Cancel
|
||||||
|
ImGuiKey_GamepadDpadUp, // D-pad Up // -> ImGuiNavInput_DpadUp
|
||||||
|
ImGuiKey_GamepadDpadDown, // D-pad Down // -> ImGuiNavInput_DpadDown
|
||||||
|
ImGuiKey_GamepadDpadLeft, // D-pad Left // -> ImGuiNavInput_DpadLeft
|
||||||
|
ImGuiKey_GamepadDpadRight, // D-pad Right // -> ImGuiNavInput_DpadRight
|
||||||
|
ImGuiKey_GamepadL1, // L Bumper (Xbox) L (Switch) L1 (PS) // -> ImGuiNavInput_FocusPrev + ImGuiNavInput_TweakSlow
|
||||||
|
ImGuiKey_GamepadR1, // R Bumper (Xbox) R (Switch) R1 (PS) // -> ImGuiNavInput_FocusNext + ImGuiNavInput_TweakFast
|
||||||
|
ImGuiKey_GamepadL2, // L Trigger (Xbox) ZL (Switch) L2 (PS) [Analog]
|
||||||
|
ImGuiKey_GamepadR2, // R Trigger (Xbox) ZR (Switch) R2 (PS) [Analog]
|
||||||
|
ImGuiKey_GamepadL3, // L Thumbstick (Xbox) L3 (Switch) L3 (PS)
|
||||||
|
ImGuiKey_GamepadR3, // R Thumbstick (Xbox) R3 (Switch) R3 (PS)
|
||||||
|
ImGuiKey_GamepadLStickUp, // [Analog] // -> ImGuiNavInput_LStickUp
|
||||||
|
ImGuiKey_GamepadLStickDown, // [Analog] // -> ImGuiNavInput_LStickDown
|
||||||
|
ImGuiKey_GamepadLStickLeft, // [Analog] // -> ImGuiNavInput_LStickLeft
|
||||||
|
ImGuiKey_GamepadLStickRight, // [Analog] // -> ImGuiNavInput_LStickRight
|
||||||
|
ImGuiKey_GamepadRStickUp, // [Analog]
|
||||||
|
ImGuiKey_GamepadRStickDown, // [Analog]
|
||||||
|
ImGuiKey_GamepadRStickLeft, // [Analog]
|
||||||
|
ImGuiKey_GamepadRStickRight, // [Analog]
|
||||||
|
|
||||||
|
// Keyboard Modifiers
|
||||||
|
// - This is mirroring the data also written to io.KeyCtrl, io.KeyShift, io.KeyAlt, io.KeySuper, in a format allowing
|
||||||
|
// them to be accessed via standard key API, allowing calls such as IsKeyPressed(), IsKeyReleased(), querying duration etc.
|
||||||
|
// - Code polling every keys (e.g. an interface to detect a key press for input mapping) might want to ignore those
|
||||||
|
// and prefer using the real keys (e.g. ImGuiKey_LeftCtrl, ImGuiKey_RightCtrl instead of ImGuiKey_ModCtrl).
|
||||||
|
// - In theory the value of keyboard modifiers should be roughly equivalent to a logical or of the equivalent left/right keys.
|
||||||
|
// In practice: it's complicated; mods are often provided from different sources. Keyboard layout, IME, sticky keys and
|
||||||
|
// backends tend to interfere and break that equivalence. The safer decision is to relay that ambiguity down to the end-user...
|
||||||
|
ImGuiKey_ModCtrl,
|
||||||
|
ImGuiKey_ModShift,
|
||||||
|
ImGuiKey_ModAlt,
|
||||||
|
ImGuiKey_ModSuper,
|
||||||
|
|
||||||
|
ImGuiKey_COUNT, // No valid ImGuiKey is ever greater than this value
|
||||||
|
|
||||||
|
// [Internal] Prior to 1.87 we required user to fill io.KeysDown[512] using their own native index + a io.KeyMap[] array.
|
||||||
|
// We are ditching this method but keeping a legacy path for user code doing e.g. IsKeyPressed(MY_NATIVE_KEY_CODE)
|
||||||
|
ImGuiKey_NamedKey_BEGIN = 512,
|
||||||
|
ImGuiKey_NamedKey_END = ImGuiKey_COUNT,
|
||||||
|
ImGuiKey_NamedKey_COUNT = ImGuiKey_NamedKey_END - ImGuiKey_NamedKey_BEGIN,
|
||||||
|
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||||
|
ImGuiKey_KeysData_SIZE = ImGuiKey_NamedKey_COUNT, // Size of KeysData[]: only hold named keys
|
||||||
|
ImGuiKey_KeysData_OFFSET = ImGuiKey_NamedKey_BEGIN // First key stored in KeysData[0]
|
||||||
|
#else
|
||||||
|
ImGuiKey_KeysData_SIZE = ImGuiKey_COUNT, // Size of KeysData[]: hold legacy 0..512 keycodes + named keys
|
||||||
|
ImGuiKey_KeysData_OFFSET = 0 // First key stored in KeysData[0]
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
, ImGuiKey_KeyPadEnter = ImGuiKey_KeypadEnter // Renamed in 1.87
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// To test io.KeyMods (which is a combination of individual fields io.KeyCtrl, io.KeyShift, io.KeyAlt set by user/backend)
|
// Helper "flags" version of key-mods to store and compare multiple key-mods easily. Sometimes used for storage (e.g. io.KeyMods) but otherwise not much used in public API.
|
||||||
enum ImGuiKeyModFlags_
|
enum ImGuiKeyModFlags_
|
||||||
{
|
{
|
||||||
ImGuiKeyModFlags_None = 0,
|
ImGuiKeyModFlags_None = 0,
|
||||||
ImGuiKeyModFlags_Ctrl = 1 << 0,
|
ImGuiKeyModFlags_Ctrl = 1 << 0,
|
||||||
ImGuiKeyModFlags_Shift = 1 << 1,
|
ImGuiKeyModFlags_Shift = 1 << 1,
|
||||||
ImGuiKeyModFlags_Alt = 1 << 2,
|
ImGuiKeyModFlags_Alt = 1 << 2,
|
||||||
ImGuiKeyModFlags_Super = 1 << 3
|
ImGuiKeyModFlags_Super = 1 << 3 // Cmd/Super/Windows key
|
||||||
};
|
};
|
||||||
|
|
||||||
// Gamepad/Keyboard navigation
|
// Gamepad/Keyboard navigation
|
||||||
// Keyboard: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays.
|
// Keyboard: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.AddKeyEvent() calls.
|
||||||
// Gamepad: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. Backend: set ImGuiBackendFlags_HasGamepad and fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
|
// Gamepad: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. Backend: set ImGuiBackendFlags_HasGamepad and fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
|
||||||
// Read instructions in imgui.cpp for more details. Download PNG/PSD at http://dearimgui.org/controls_sheets.
|
// Read instructions in imgui.cpp for more details. Download PNG/PSD at http://dearimgui.org/controls_sheets.
|
||||||
enum ImGuiNavInput_
|
enum ImGuiNavInput_
|
||||||
{
|
{
|
||||||
// Gamepad Mapping
|
// Gamepad Mapping
|
||||||
ImGuiNavInput_Activate, // activate / open / toggle / tweak value // e.g. Cross (PS4), A (Xbox), A (Switch), Space (Keyboard)
|
ImGuiNavInput_Activate, // Activate / Open / Toggle / Tweak value // e.g. Cross (PS4), A (Xbox), A (Switch), Space (Keyboard)
|
||||||
ImGuiNavInput_Cancel, // cancel / close / exit // e.g. Circle (PS4), B (Xbox), B (Switch), Escape (Keyboard)
|
ImGuiNavInput_Cancel, // Cancel / Close / Exit // e.g. Circle (PS4), B (Xbox), B (Switch), Escape (Keyboard)
|
||||||
ImGuiNavInput_Input, // text input / on-screen keyboard // e.g. Triang.(PS4), Y (Xbox), X (Switch), Return (Keyboard)
|
ImGuiNavInput_Input, // Text input / On-Screen keyboard // e.g. Triang.(PS4), Y (Xbox), X (Switch), Return (Keyboard)
|
||||||
ImGuiNavInput_Menu, // tap: toggle menu / hold: focus, move, resize // e.g. Square (PS4), X (Xbox), Y (Switch), Alt (Keyboard)
|
ImGuiNavInput_Menu, // Tap: Toggle menu / Hold: Focus, Move, Resize // e.g. Square (PS4), X (Xbox), Y (Switch), Alt (Keyboard)
|
||||||
ImGuiNavInput_DpadLeft, // move / tweak / resize window (w/ PadMenu) // e.g. D-pad Left/Right/Up/Down (Gamepads), Arrow keys (Keyboard)
|
ImGuiNavInput_DpadLeft, // Move / Tweak / Resize window (w/ PadMenu) // e.g. D-pad Left/Right/Up/Down (Gamepads), Arrow keys (Keyboard)
|
||||||
ImGuiNavInput_DpadRight, //
|
ImGuiNavInput_DpadRight, //
|
||||||
ImGuiNavInput_DpadUp, //
|
ImGuiNavInput_DpadUp, //
|
||||||
ImGuiNavInput_DpadDown, //
|
ImGuiNavInput_DpadDown, //
|
||||||
ImGuiNavInput_LStickLeft, // scroll / move window (w/ PadMenu) // e.g. Left Analog Stick Left/Right/Up/Down
|
ImGuiNavInput_LStickLeft, // Scroll / Move window (w/ PadMenu) // e.g. Left Analog Stick Left/Right/Up/Down
|
||||||
ImGuiNavInput_LStickRight, //
|
ImGuiNavInput_LStickRight, //
|
||||||
ImGuiNavInput_LStickUp, //
|
ImGuiNavInput_LStickUp, //
|
||||||
ImGuiNavInput_LStickDown, //
|
ImGuiNavInput_LStickDown, //
|
||||||
ImGuiNavInput_FocusPrev, // next window (w/ PadMenu) // e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch)
|
ImGuiNavInput_FocusPrev, // Focus Next window (w/ PadMenu) // e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch)
|
||||||
ImGuiNavInput_FocusNext, // prev window (w/ PadMenu) // e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch)
|
ImGuiNavInput_FocusNext, // Focus Prev window (w/ PadMenu) // e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch)
|
||||||
ImGuiNavInput_TweakSlow, // slower tweaks // e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch)
|
ImGuiNavInput_TweakSlow, // Slower tweaks // e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch)
|
||||||
ImGuiNavInput_TweakFast, // faster tweaks // e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch)
|
ImGuiNavInput_TweakFast, // Faster tweaks // e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch)
|
||||||
|
|
||||||
// [Internal] Don't use directly! This is used internally to differentiate keyboard from gamepad inputs for behaviors that require to differentiate them.
|
// [Internal] Don't use directly! This is used internally to differentiate keyboard from gamepad inputs for behaviors that require to differentiate them.
|
||||||
// Keyboard behavior that have no corresponding gamepad mapping (e.g. CTRL+TAB) will be directly reading from io.KeysDown[] instead of io.NavInputs[].
|
// Keyboard behavior that have no corresponding gamepad mapping (e.g. CTRL+TAB) will be directly reading from keyboard keys instead of io.NavInputs[].
|
||||||
ImGuiNavInput_KeyLeft_, // move left // = Arrow keys
|
ImGuiNavInput_KeyLeft_, // Move left // = Arrow keys
|
||||||
ImGuiNavInput_KeyRight_, // move right
|
ImGuiNavInput_KeyRight_, // Move right
|
||||||
ImGuiNavInput_KeyUp_, // move up
|
ImGuiNavInput_KeyUp_, // Move up
|
||||||
ImGuiNavInput_KeyDown_, // move down
|
ImGuiNavInput_KeyDown_, // Move down
|
||||||
ImGuiNavInput_COUNT,
|
ImGuiNavInput_COUNT
|
||||||
ImGuiNavInput_InternalStart_ = ImGuiNavInput_KeyLeft_
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Configuration flags stored in io.ConfigFlags. Set by user/application.
|
// Configuration flags stored in io.ConfigFlags. Set by user/application.
|
||||||
enum ImGuiConfigFlags_
|
enum ImGuiConfigFlags_
|
||||||
{
|
{
|
||||||
ImGuiConfigFlags_None = 0,
|
ImGuiConfigFlags_None = 0,
|
||||||
ImGuiConfigFlags_NavEnableKeyboard = 1 << 0, // Master keyboard navigation enable flag. NewFrame() will automatically fill io.NavInputs[] based on io.KeysDown[].
|
ImGuiConfigFlags_NavEnableKeyboard = 1 << 0, // Master keyboard navigation enable flag. NewFrame() will automatically fill io.NavInputs[] based on io.AddKeyEvent() calls
|
||||||
ImGuiConfigFlags_NavEnableGamepad = 1 << 1, // Master gamepad navigation enable flag. This is mostly to instruct your imgui backend to fill io.NavInputs[]. Backend also needs to set ImGuiBackendFlags_HasGamepad.
|
ImGuiConfigFlags_NavEnableGamepad = 1 << 1, // Master gamepad navigation enable flag. This is mostly to instruct your imgui backend to fill io.NavInputs[]. Backend also needs to set ImGuiBackendFlags_HasGamepad.
|
||||||
ImGuiConfigFlags_NavEnableSetMousePos = 1 << 2, // Instruct navigation to move the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is awkward. Will update io.MousePos and set io.WantSetMousePos=true. If enabled you MUST honor io.WantSetMousePos requests in your backend, otherwise ImGui will react as if the mouse is jumping around back and forth.
|
ImGuiConfigFlags_NavEnableSetMousePos = 1 << 2, // Instruct navigation to move the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is awkward. Will update io.MousePos and set io.WantSetMousePos=true. If enabled you MUST honor io.WantSetMousePos requests in your backend, otherwise ImGui will react as if the mouse is jumping around back and forth.
|
||||||
ImGuiConfigFlags_NavNoCaptureKeyboard = 1 << 3, // Instruct navigation to not set the io.WantCaptureKeyboard flag when io.NavActive is set.
|
ImGuiConfigFlags_NavNoCaptureKeyboard = 1 << 3, // Instruct navigation to not set the io.WantCaptureKeyboard flag when io.NavActive is set.
|
||||||
@ -1599,9 +1674,7 @@ enum ImGuiColorEditFlags_
|
|||||||
ImGuiColorEditFlags_InputMask_ = ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_InputHSV
|
ImGuiColorEditFlags_InputMask_ = ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_InputHSV
|
||||||
|
|
||||||
// Obsolete names (will be removed)
|
// Obsolete names (will be removed)
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
// ImGuiColorEditFlags_RGB = ImGuiColorEditFlags_DisplayRGB, ImGuiColorEditFlags_HSV = ImGuiColorEditFlags_DisplayHSV, ImGuiColorEditFlags_HEX = ImGuiColorEditFlags_DisplayHex // [renamed in 1.69]
|
||||||
, ImGuiColorEditFlags_RGB = ImGuiColorEditFlags_DisplayRGB, ImGuiColorEditFlags_HSV = ImGuiColorEditFlags_DisplayHSV, ImGuiColorEditFlags_HEX = ImGuiColorEditFlags_DisplayHex // [renamed in 1.69]
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flags for DragFloat(), DragInt(), SliderFloat(), SliderInt() etc.
|
// Flags for DragFloat(), DragInt(), SliderFloat(), SliderInt() etc.
|
||||||
@ -1817,6 +1890,16 @@ struct ImGuiStyle
|
|||||||
// Access via ImGui::GetIO(). Read 'Programmer guide' section in .cpp file for general usage.
|
// Access via ImGui::GetIO(). Read 'Programmer guide' section in .cpp file for general usage.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// [Internal] Storage used by IsKeyDown(), IsKeyPressed() etc functions.
|
||||||
|
// If prior to 1.87 you used io.KeysDownDuration[] (which was marked as internal), you should use GetKeyData(key)->DownDuration and not io.KeysData[key]->DownDuration.
|
||||||
|
struct ImGuiKeyData
|
||||||
|
{
|
||||||
|
bool Down; // True for if key is down
|
||||||
|
float DownDuration; // Duration the key has been down (<0.0f: not pressed, 0.0f: just pressed, >0.0f: time held)
|
||||||
|
float DownDurationPrev; // Last frame duration the key has been down
|
||||||
|
float AnalogValue; // 0.0f..1.0f for gamepad values
|
||||||
|
};
|
||||||
|
|
||||||
struct ImGuiIO
|
struct ImGuiIO
|
||||||
{
|
{
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
@ -1833,7 +1916,6 @@ struct ImGuiIO
|
|||||||
float MouseDoubleClickTime; // = 0.30f // Time for a double-click, in seconds.
|
float MouseDoubleClickTime; // = 0.30f // Time for a double-click, in seconds.
|
||||||
float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
|
float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
|
||||||
float MouseDragThreshold; // = 6.0f // Distance threshold before considering we are dragging.
|
float MouseDragThreshold; // = 6.0f // Distance threshold before considering we are dragging.
|
||||||
int KeyMap[ImGuiKey_COUNT]; // <unset> // Map of indices into the KeysDown[512] entries array which represent your "native" keyboard state.
|
|
||||||
float KeyRepeatDelay; // = 0.250f // When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.).
|
float KeyRepeatDelay; // = 0.250f // When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.).
|
||||||
float KeyRepeatRate; // = 0.050f // When holding a key/button, rate at which it repeats, in seconds.
|
float KeyRepeatRate; // = 0.050f // When holding a key/button, rate at which it repeats, in seconds.
|
||||||
void* UserData; // = NULL // Store your own data for retrieval by callbacks.
|
void* UserData; // = NULL // Store your own data for retrieval by callbacks.
|
||||||
@ -1847,6 +1929,7 @@ struct ImGuiIO
|
|||||||
// Miscellaneous options
|
// Miscellaneous options
|
||||||
bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by backend implementations.
|
bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by backend implementations.
|
||||||
bool ConfigMacOSXBehaviors; // = defined(__APPLE__) // OS X style: Text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl.
|
bool ConfigMacOSXBehaviors; // = defined(__APPLE__) // OS X style: Text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl.
|
||||||
|
bool ConfigInputTrickleEventQueue; // = true // Enable input queue trickling: some types of events submitted during the same frame (e.g. button down + up) will be spread over multiple frames, improving interactions with low framerates.
|
||||||
bool ConfigInputTextCursorBlink; // = true // Enable blinking cursor (optional as some users consider it to be distracting).
|
bool ConfigInputTextCursorBlink; // = true // Enable blinking cursor (optional as some users consider it to be distracting).
|
||||||
bool ConfigDragClickToInputText; // = false // [BETA] Enable turning DragXXX widgets into text input with a simple mouse click-release (without moving). Not desirable on devices without a keyboard.
|
bool ConfigDragClickToInputText; // = false // [BETA] Enable turning DragXXX widgets into text input with a simple mouse click-release (without moving). Not desirable on devices without a keyboard.
|
||||||
bool ConfigWindowsResizeFromEdges; // = true // Enable resizing of windows from their edges and from the lower-left corner. This requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback. (This used to be a per-window ImGuiWindowFlags_ResizeFromAnySide flag)
|
bool ConfigWindowsResizeFromEdges; // = true // Enable resizing of windows from their edges and from the lower-left corner. This requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback. (This used to be a per-window ImGuiWindowFlags_ResizeFromAnySide flag)
|
||||||
@ -1873,31 +1956,31 @@ struct ImGuiIO
|
|||||||
|
|
||||||
// Optional: Notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME on Windows)
|
// Optional: Notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME on Windows)
|
||||||
// (default to use native imm32 api on Windows)
|
// (default to use native imm32 api on Windows)
|
||||||
void (*ImeSetInputScreenPosFn)(int x, int y);
|
void (*SetPlatformImeDataFn)(ImGuiViewport* viewport, ImGuiPlatformImeData* data);
|
||||||
void* ImeWindowHandle; // = NULL // (Windows) Set this to your HWND to get automatic IME cursor positioning.
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
void* ImeWindowHandle; // = NULL // [Obsolete] Set ImGuiViewport::PlatformHandleRaw instead. Set this to your HWND to get automatic IME cursor positioning.
|
||||||
|
#else
|
||||||
|
void* _UnusedPadding; // Unused field to keep data structure the same size.
|
||||||
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Input - Fill before calling NewFrame()
|
// Input - Call before calling NewFrame()
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
ImVec2 MousePos; // Mouse position, in pixels. Set to ImVec2(-FLT_MAX, -FLT_MAX) if mouse is unavailable (on another screen, etc.)
|
// Input Functions
|
||||||
bool MouseDown[5]; // Mouse buttons: 0=left, 1=right, 2=middle + extras (ImGuiMouseButton_COUNT == 5). Dear ImGui mostly uses left and right buttons. Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API.
|
IMGUI_API void AddKeyEvent(ImGuiKey key, bool down); // Queue a new key down/up event. Key should be "translated" (as in, generally ImGuiKey_A matches the key end-user would use to emit an 'A' character)
|
||||||
float MouseWheel; // Mouse wheel Vertical: 1 unit scrolls about 5 lines text.
|
IMGUI_API void AddKeyAnalogEvent(ImGuiKey key, bool down, float v); // Queue a new key down/up event for analog values (e.g. ImGuiKey_Gamepad_ values). Dead-zones should be handled by the backend.
|
||||||
float MouseWheelH; // Mouse wheel Horizontal. Most users don't have a mouse with an horizontal wheel, may not be filled by all backends.
|
IMGUI_API void AddMousePosEvent(float x, float y); // Queue a mouse position update. Use -FLT_MAX,-FLT_MAX to signify no mouse (e.g. app not focused and not hovered)
|
||||||
bool KeyCtrl; // Keyboard modifier pressed: Control
|
IMGUI_API void AddMouseButtonEvent(int button, bool down); // Queue a mouse button change
|
||||||
bool KeyShift; // Keyboard modifier pressed: Shift
|
IMGUI_API void AddMouseWheelEvent(float wh_x, float wh_y); // Queue a mouse wheel update
|
||||||
bool KeyAlt; // Keyboard modifier pressed: Alt
|
IMGUI_API void AddFocusEvent(bool focused); // Queue a gain/loss of focus for the application (generally based on OS/platform focus of your window)
|
||||||
bool KeySuper; // Keyboard modifier pressed: Cmd/Super/Windows
|
IMGUI_API void AddInputCharacter(unsigned int c); // Queue a new character input
|
||||||
bool KeysDown[512]; // Keyboard keys that are pressed (ideally left in the "native" order your engine has access to keyboard keys, so you can use your own defines/enums for keys).
|
IMGUI_API void AddInputCharacterUTF16(ImWchar16 c); // Queue a new character input from an UTF-16 character, it can be a surrogate
|
||||||
float NavInputs[ImGuiNavInput_COUNT]; // Gamepad inputs. Cleared back to zero by EndFrame(). Keyboard keys will be auto-mapped and be written here by NewFrame().
|
IMGUI_API void AddInputCharactersUTF8(const char* str); // Queue a new characters input from an UTF-8 string
|
||||||
|
|
||||||
// Functions
|
IMGUI_API void ClearInputCharacters(); // [Internal] Clear the text input buffer manually
|
||||||
IMGUI_API void AddInputCharacter(unsigned int c); // Queue new character input
|
IMGUI_API void ClearInputKeys(); // [Internal] Release all keys
|
||||||
IMGUI_API void AddInputCharacterUTF16(ImWchar16 c); // Queue new character input from an UTF-16 character, it can be a surrogate
|
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 AddInputCharactersUTF8(const char* str); // Queue new characters input from an UTF-8 string
|
|
||||||
IMGUI_API void AddFocusEvent(bool focused); // Notifies Dear ImGui when hosting platform windows lose or gain input focus
|
|
||||||
IMGUI_API void ClearInputCharacters(); // [Internal] Clear the text input buffer manually
|
|
||||||
IMGUI_API void ClearInputKeys(); // [Internal] Release all keys
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Output - Updated by NewFrame() or EndFrame()/Render()
|
// Output - Updated by NewFrame() or EndFrame()/Render()
|
||||||
@ -1905,50 +1988,71 @@ struct ImGuiIO
|
|||||||
// generally easier and more correct to use their state BEFORE calling NewFrame(). See FAQ for details!)
|
// generally easier and more correct to use their state BEFORE calling NewFrame(). See FAQ for details!)
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
bool WantCaptureMouse; // Set when Dear ImGui will use mouse inputs, in this case do not dispatch them to your main game/application (either way, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.).
|
bool WantCaptureMouse; // Set when Dear ImGui will use mouse inputs, in this case do not dispatch them to your main game/application (either way, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.).
|
||||||
bool WantCaptureKeyboard; // Set when Dear ImGui will use keyboard inputs, in this case do not dispatch them to your main game/application (either way, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.).
|
bool WantCaptureKeyboard; // Set when Dear ImGui will use keyboard inputs, in this case do not dispatch them to your main game/application (either way, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.).
|
||||||
bool WantTextInput; // Mobile/console: when set, you may display an on-screen keyboard. This is set by Dear ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
|
bool WantTextInput; // Mobile/console: when set, you may display an on-screen keyboard. This is set by Dear ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
|
||||||
bool WantSetMousePos; // MousePos has been altered, backend should reposition mouse on next frame. Rarely used! Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled.
|
bool WantSetMousePos; // MousePos has been altered, backend should reposition mouse on next frame. Rarely used! Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled.
|
||||||
bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. Important: clear io.WantSaveIniSettings yourself after saving!
|
bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. Important: clear io.WantSaveIniSettings yourself after saving!
|
||||||
bool NavActive; // Keyboard/Gamepad navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
|
bool NavActive; // Keyboard/Gamepad navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
|
||||||
bool NavVisible; // Keyboard/Gamepad navigation is visible and allowed (will handle ImGuiKey_NavXXX events).
|
bool NavVisible; // Keyboard/Gamepad navigation is visible and allowed (will handle ImGuiKey_NavXXX events).
|
||||||
float Framerate; // Rough estimate of application framerate, in frame per second. Solely for convenience. Rolling average estimation based on io.DeltaTime over 120 frames.
|
float Framerate; // Rough estimate of application framerate, in frame per second. Solely for convenience. Rolling average estimation based on io.DeltaTime over 120 frames.
|
||||||
int MetricsRenderVertices; // Vertices output during last call to Render()
|
int MetricsRenderVertices; // Vertices output during last call to Render()
|
||||||
int MetricsRenderIndices; // Indices output during last call to Render() = number of triangles * 3
|
int MetricsRenderIndices; // Indices output during last call to Render() = number of triangles * 3
|
||||||
int MetricsRenderWindows; // Number of visible windows
|
int MetricsRenderWindows; // Number of visible windows
|
||||||
int MetricsActiveWindows; // Number of active windows
|
int MetricsActiveWindows; // Number of active windows
|
||||||
int MetricsActiveAllocations; // Number of active allocations, updated by MemAlloc/MemFree based on current context. May be off if you have multiple imgui contexts.
|
int MetricsActiveAllocations; // Number of active allocations, updated by MemAlloc/MemFree based on current context. May be off if you have multiple imgui contexts.
|
||||||
ImVec2 MouseDelta; // Mouse delta. Note that this is zero if either current or previous position are invalid (-FLT_MAX,-FLT_MAX), so a disappearing/reappearing mouse won't have a huge delta.
|
ImVec2 MouseDelta; // Mouse delta. Note that this is zero if either current or previous position are invalid (-FLT_MAX,-FLT_MAX), so a disappearing/reappearing mouse won't have a huge delta.
|
||||||
|
|
||||||
|
// Legacy: before 1.87, we required backend to fill io.KeyMap[] (imgui->native map) during initialization and io.KeysDown[] (native indices) every frame.
|
||||||
|
// This is still temporarily supported as a legacy feature. However the new preferred scheme is for backend to call io.AddKeyEvent().
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||||
|
int KeyMap[ImGuiKey_COUNT]; // [LEGACY] Input: map of indices into the KeysDown[512] entries array which represent your "native" keyboard state. The first 512 are now unused and should be kept zero. Legacy backend will write into KeyMap[] using ImGuiKey_ indices which are always >512.
|
||||||
|
bool KeysDown[512]; // [LEGACY] Input: Keyboard keys that are pressed (ideally left in the "native" order your engine has access to keyboard keys, so you can use your own defines/enums for keys).
|
||||||
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// [Internal] Dear ImGui will maintain those fields. Forward compatibility not guaranteed!
|
// [Internal] Dear ImGui will maintain those fields. Forward compatibility not guaranteed!
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
bool WantCaptureMouseUnlessPopupClose;// Alternative to WantCaptureMouse: (WantCaptureMouse == true && WantCaptureMouseUnlessPopupClose == false) when a click over void is expected to close a popup.
|
// Main Input State
|
||||||
ImGuiKeyModFlags KeyMods; // Key mods flags (same as io.KeyCtrl/KeyShift/KeyAlt/KeySuper but merged into flags), updated by NewFrame()
|
// (this block used to be written by backend, since 1.87 it is best to NOT write to those directly, call the AddXXX functions above instead)
|
||||||
ImGuiKeyModFlags KeyModsPrev; // Previous key mods
|
// (reading from those variables is fair game, as they are extremely unlikely to be moving anywhere)
|
||||||
ImVec2 MousePosPrev; // Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid)
|
ImVec2 MousePos; // Mouse position, in pixels. Set to ImVec2(-FLT_MAX, -FLT_MAX) if mouse is unavailable (on another screen, etc.)
|
||||||
ImVec2 MouseClickedPos[5]; // Position at time of clicking
|
bool MouseDown[5]; // Mouse buttons: 0=left, 1=right, 2=middle + extras (ImGuiMouseButton_COUNT == 5). Dear ImGui mostly uses left and right buttons. Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API.
|
||||||
double MouseClickedTime[5]; // Time of last click (used to figure out double-click)
|
float MouseWheel; // Mouse wheel Vertical: 1 unit scrolls about 5 lines text.
|
||||||
bool MouseClicked[5]; // Mouse button went from !Down to Down (same as MouseClickedCount[x] != 0)
|
float MouseWheelH; // Mouse wheel Horizontal. Most users don't have a mouse with an horizontal wheel, may not be filled by all backends.
|
||||||
bool MouseDoubleClicked[5]; // Has mouse button been double-clicked? (same as MouseClickedCount[x] == 2)
|
bool KeyCtrl; // Keyboard modifier down: Control
|
||||||
ImU16 MouseClickedCount[5]; // == 0 (not clicked), == 1 (same as MouseClicked[]), == 2 (double-clicked), == 3 (triple-clicked) etc. when going from !Down to Down
|
bool KeyShift; // Keyboard modifier down: Shift
|
||||||
ImU16 MouseClickedLastCount[5]; // Count successive number of clicks. Stays valid after mouse release. Reset after another click is done.
|
bool KeyAlt; // Keyboard modifier down: Alt
|
||||||
bool MouseReleased[5]; // Mouse button went from Down to !Down
|
bool KeySuper; // Keyboard modifier down: Cmd/Super/Windows
|
||||||
bool MouseDownOwned[5]; // Track if button was clicked inside a dear imgui window or over void blocked by a popup. We don't request mouse capture from the application if click started outside ImGui bounds.
|
float NavInputs[ImGuiNavInput_COUNT]; // Gamepad inputs. Cleared back to zero by EndFrame(). Keyboard keys will be auto-mapped and be written here by NewFrame().
|
||||||
bool MouseDownOwnedUnlessPopupClose[5];//Track if button was clicked inside a dear imgui window.
|
|
||||||
float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked)
|
// Other state maintained from data above + IO function calls
|
||||||
float MouseDownDurationPrev[5]; // Previous time the mouse button has been down
|
ImGuiKeyModFlags KeyMods; // Key mods flags (same as io.KeyCtrl/KeyShift/KeyAlt/KeySuper but merged into flags), updated by NewFrame()
|
||||||
ImVec2 MouseDragMaxDistanceAbs[5]; // Maximum distance, absolute, on each axis, of how much mouse has traveled from the clicking point
|
ImGuiKeyModFlags KeyModsPrev; // Key mods flags (from previous frame)
|
||||||
float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the clicking point
|
ImGuiKeyData KeysData[ImGuiKey_KeysData_SIZE]; // Key state for all known keys. Use IsKeyXXX() functions to access this.
|
||||||
float KeysDownDuration[512]; // Duration the keyboard key has been down (0.0f == just pressed)
|
bool WantCaptureMouseUnlessPopupClose; // Alternative to WantCaptureMouse: (WantCaptureMouse == true && WantCaptureMouseUnlessPopupClose == false) when a click over void is expected to close a popup.
|
||||||
float KeysDownDurationPrev[512]; // Previous duration the key has been down
|
ImVec2 MousePosPrev; // Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid)
|
||||||
|
ImVec2 MouseClickedPos[5]; // Position at time of clicking
|
||||||
|
double MouseClickedTime[5]; // Time of last click (used to figure out double-click)
|
||||||
|
bool MouseClicked[5]; // Mouse button went from !Down to Down (same as MouseClickedCount[x] != 0)
|
||||||
|
bool MouseDoubleClicked[5]; // Has mouse button been double-clicked? (same as MouseClickedCount[x] == 2)
|
||||||
|
ImU16 MouseClickedCount[5]; // == 0 (not clicked), == 1 (same as MouseClicked[]), == 2 (double-clicked), == 3 (triple-clicked) etc. when going from !Down to Down
|
||||||
|
ImU16 MouseClickedLastCount[5]; // Count successive number of clicks. Stays valid after mouse release. Reset after another click is done.
|
||||||
|
bool MouseReleased[5]; // Mouse button went from Down to !Down
|
||||||
|
bool MouseDownOwned[5]; // Track if button was clicked inside a dear imgui window or over void blocked by a popup. We don't request mouse capture from the application if click started outside ImGui bounds.
|
||||||
|
bool MouseDownOwnedUnlessPopupClose[5]; //Track if button was clicked inside a dear imgui window.
|
||||||
|
float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked)
|
||||||
|
float MouseDownDurationPrev[5]; // Previous time the mouse button has been down
|
||||||
|
float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the clicking point (used for moving thresholds)
|
||||||
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;
|
||||||
ImWchar16 InputQueueSurrogate; // For AddInputCharacterUTF16
|
ImS8 BackendUsingLegacyKeyArrays; // -1: unknown, 0: using AddKeyEvent(), 1: using legacy io.KeysDown[]
|
||||||
ImVector<ImWchar> InputQueueCharacters; // Queue of _characters_ input (obtained by platform backend). Fill using AddInputCharacter() helper.
|
bool BackendUsingLegacyNavInputArray; // 0: using AddKeyAnalogEvent(), 1: writing to legacy io.NavInputs[] directly
|
||||||
|
ImWchar16 InputQueueSurrogate; // For AddInputCharacterUTF16()
|
||||||
|
ImVector<ImWchar> InputQueueCharacters; // Queue of _characters_ input (obtained by platform backend). Fill using AddInputCharacter() helper.
|
||||||
|
|
||||||
IMGUI_API ImGuiIO();
|
IMGUI_API ImGuiIO();
|
||||||
};
|
};
|
||||||
@ -2283,16 +2387,16 @@ typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* c
|
|||||||
#define ImDrawCallback_ResetRenderState (ImDrawCallback)(-1)
|
#define ImDrawCallback_ResetRenderState (ImDrawCallback)(-1)
|
||||||
|
|
||||||
// Typically, 1 command = 1 GPU draw call (unless command is a callback)
|
// Typically, 1 command = 1 GPU draw call (unless command is a callback)
|
||||||
// - VtxOffset/IdxOffset: When 'io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset' is enabled,
|
// - VtxOffset: When 'io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset' is enabled,
|
||||||
// those fields allow us to render meshes larger than 64K vertices while keeping 16-bit indices.
|
// this fields allow us to render meshes larger than 64K vertices while keeping 16-bit indices.
|
||||||
// Pre-1.71 backends will typically ignore the VtxOffset/IdxOffset fields.
|
// Backends made for <1.71. will typically ignore the VtxOffset fields.
|
||||||
// - The ClipRect/TextureId/VtxOffset fields must be contiguous as we memcmp() them together (this is asserted for).
|
// - The ClipRect/TextureId/VtxOffset fields must be contiguous as we memcmp() them together (this is asserted for).
|
||||||
struct ImDrawCmd
|
struct ImDrawCmd
|
||||||
{
|
{
|
||||||
ImVec4 ClipRect; // 4*4 // Clipping rectangle (x1, y1, x2, y2). Subtract ImDrawData->DisplayPos to get clipping rectangle in "viewport" coordinates
|
ImVec4 ClipRect; // 4*4 // Clipping rectangle (x1, y1, x2, y2). Subtract ImDrawData->DisplayPos to get clipping rectangle in "viewport" coordinates
|
||||||
ImTextureID TextureId; // 4-8 // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
|
ImTextureID TextureId; // 4-8 // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
|
||||||
unsigned int VtxOffset; // 4 // Start offset in vertex buffer. ImGuiBackendFlags_RendererHasVtxOffset: always 0, otherwise may be >0 to support meshes larger than 64K vertices with 16-bit indices.
|
unsigned int VtxOffset; // 4 // Start offset in vertex buffer. ImGuiBackendFlags_RendererHasVtxOffset: always 0, otherwise may be >0 to support meshes larger than 64K vertices with 16-bit indices.
|
||||||
unsigned int IdxOffset; // 4 // Start offset in index buffer. Always equal to sum of ElemCount drawn so far.
|
unsigned int IdxOffset; // 4 // Start offset in index buffer.
|
||||||
unsigned int ElemCount; // 4 // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[].
|
unsigned int ElemCount; // 4 // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[].
|
||||||
ImDrawCallback UserCallback; // 4-8 // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally.
|
ImDrawCallback UserCallback; // 4-8 // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally.
|
||||||
void* UserCallbackData; // 4-8 // The draw callback code can access this.
|
void* UserCallbackData; // 4-8 // The draw callback code can access this.
|
||||||
@ -2498,8 +2602,8 @@ struct ImDrawList
|
|||||||
inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); } // Write vertex with unique index
|
inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); } // Write vertex with unique index
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
inline void AddBezierCurve(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments = 0) { AddBezierCubic(p1, p2, p3, p4, col, thickness, num_segments); }
|
inline void AddBezierCurve(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments = 0) { AddBezierCubic(p1, p2, p3, p4, col, thickness, num_segments); } // OBSOLETED in 1.80 (Jan 2021)
|
||||||
inline void PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments = 0) { PathBezierCubicCurveTo(p2, p3, p4, num_segments); }
|
inline void PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments = 0) { PathBezierCubicCurveTo(p2, p3, p4, num_segments); } // OBSOLETED in 1.80 (Jan 2021)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// [Internal helpers]
|
// [Internal helpers]
|
||||||
@ -2728,10 +2832,9 @@ struct ImFontAtlas
|
|||||||
int PackIdMouseCursors; // Custom texture rectangle ID for white pixel and mouse cursors
|
int PackIdMouseCursors; // Custom texture rectangle ID for white pixel and mouse cursors
|
||||||
int PackIdLines; // Custom texture rectangle ID for baked anti-aliased lines
|
int PackIdLines; // Custom texture rectangle ID for baked anti-aliased lines
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
// [Obsolete]
|
||||||
typedef ImFontAtlasCustomRect CustomRect; // OBSOLETED in 1.72+
|
//typedef ImFontAtlasCustomRect CustomRect; // OBSOLETED in 1.72+
|
||||||
//typedef ImFontGlyphRangesBuilder GlyphRangesBuilder; // OBSOLETED in 1.67+
|
//typedef ImFontGlyphRangesBuilder GlyphRangesBuilder; // OBSOLETED in 1.67+
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Font runtime data and rendering
|
// Font runtime data and rendering
|
||||||
@ -2815,6 +2918,9 @@ struct ImGuiViewport
|
|||||||
ImVec2 WorkPos; // Work Area: Position of the viewport minus task bars, menus bars, status bars (>= Pos)
|
ImVec2 WorkPos; // Work Area: Position of the viewport minus task bars, menus bars, status bars (>= Pos)
|
||||||
ImVec2 WorkSize; // Work Area: Size of the viewport minus task bars, menu bars, status bars (<= Size)
|
ImVec2 WorkSize; // Work Area: Size of the viewport minus task bars, menu bars, status bars (<= Size)
|
||||||
|
|
||||||
|
// Platform/Backend Dependent Data
|
||||||
|
void* PlatformHandleRaw; // void* to hold lower-level, platform-native window handle (under Win32 this is expected to be a HWND, unused for other platforms)
|
||||||
|
|
||||||
ImGuiViewport() { memset(this, 0, sizeof(*this)); }
|
ImGuiViewport() { memset(this, 0, sizeof(*this)); }
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
@ -2822,12 +2928,35 @@ struct ImGuiViewport
|
|||||||
ImVec2 GetWorkCenter() const { return ImVec2(WorkPos.x + WorkSize.x * 0.5f, WorkPos.y + WorkSize.y * 0.5f); }
|
ImVec2 GetWorkCenter() const { return ImVec2(WorkPos.x + WorkSize.x * 0.5f, WorkPos.y + WorkSize.y * 0.5f); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// [SECTION] Platform Dependent Interfaces
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// (Optional) Support for IME (Input Method Editor) via the io.SetPlatformImeDataFn() function.
|
||||||
|
struct ImGuiPlatformImeData
|
||||||
|
{
|
||||||
|
bool WantVisible; // A widget wants the IME to be visible
|
||||||
|
ImVec2 InputPos; // Position of the input cursor
|
||||||
|
float InputLineHeight; // Line height
|
||||||
|
|
||||||
|
ImGuiPlatformImeData() { memset(this, 0, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Obsolete functions and types
|
// [SECTION] Obsolete functions and types
|
||||||
// (Will be removed! Read 'API BREAKING CHANGES' section in imgui.cpp for details)
|
// (Will be removed! Read 'API BREAKING CHANGES' section in imgui.cpp for details)
|
||||||
// Please keep your copy of dear imgui up to date! Occasionally set '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' in imconfig.h to stay ahead.
|
// Please keep your copy of dear imgui up to date! Occasionally set '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' in imconfig.h to stay ahead.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace ImGui
|
||||||
|
{
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||||
|
IMGUI_API int GetKeyIndex(ImGuiKey key); // map ImGuiKey_* values into legacy native key index. == io.KeyMap[key]
|
||||||
|
#else
|
||||||
|
static inline int GetKeyIndex(ImGuiKey key) { IM_ASSERT(key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END && "ImGuiKey and native_index was merged together and native_index is disabled by IMGUI_DISABLE_OBSOLETE_KEYIO. Please switch to ImGuiKey."); return key; }
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
namespace ImGui
|
namespace ImGui
|
||||||
{
|
{
|
||||||
@ -2858,24 +2987,21 @@ namespace ImGui
|
|||||||
static inline bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 4, &v_min, &v_max, format, power); }
|
static inline bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 4, &v_min, &v_max, format, power); }
|
||||||
// OBSOLETED in 1.77 (from June 2020)
|
// OBSOLETED in 1.77 (from June 2020)
|
||||||
static inline bool BeginPopupContextWindow(const char* str_id, ImGuiMouseButton mb, bool over_items) { return BeginPopupContextWindow(str_id, mb | (over_items ? 0 : ImGuiPopupFlags_NoOpenOverItems)); }
|
static inline bool BeginPopupContextWindow(const char* str_id, ImGuiMouseButton mb, bool over_items) { return BeginPopupContextWindow(str_id, mb | (over_items ? 0 : ImGuiPopupFlags_NoOpenOverItems)); }
|
||||||
// OBSOLETED in 1.72 (from April 2019)
|
|
||||||
static inline void TreeAdvanceToLabelPos() { SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()); }
|
|
||||||
// OBSOLETED in 1.71 (from June 2019)
|
|
||||||
static inline void SetNextTreeNodeOpen(bool open, ImGuiCond cond = 0) { SetNextItemOpen(open, cond); }
|
|
||||||
// OBSOLETED in 1.70 (from May 2019)
|
|
||||||
static inline float GetContentRegionAvailWidth() { return GetContentRegionAvail().x; }
|
|
||||||
|
|
||||||
// Some of the older obsolete names along with their replacement (commented out so they are not reported in IDE)
|
// Some of the older obsolete names along with their replacement (commented out so they are not reported in IDE)
|
||||||
//static inline ImDrawList* GetOverlayDrawList() { return GetForegroundDrawList(); } // OBSOLETED in 1.69 (from Mar 2019)
|
//static inline void TreeAdvanceToLabelPos() { SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()); } // OBSOLETED in 1.72 (from July 2019)
|
||||||
//static inline void SetScrollHere(float ratio = 0.5f) { SetScrollHereY(ratio); } // OBSOLETED in 1.66 (from Nov 2018)
|
//static inline void SetNextTreeNodeOpen(bool open, ImGuiCond cond = 0) { SetNextItemOpen(open, cond); } // OBSOLETED in 1.71 (from June 2019)
|
||||||
//static inline bool IsItemDeactivatedAfterChange() { return IsItemDeactivatedAfterEdit(); } // OBSOLETED in 1.63 (from Aug 2018)
|
//static inline float GetContentRegionAvailWidth() { return GetContentRegionAvail().x; } // OBSOLETED in 1.70 (from May 2019)
|
||||||
//static inline bool IsAnyWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_AnyWindow); } // OBSOLETED in 1.60 (from Apr 2018)
|
//static inline ImDrawList* GetOverlayDrawList() { return GetForegroundDrawList(); } // OBSOLETED in 1.69 (from Mar 2019)
|
||||||
//static inline bool IsAnyWindowHovered() { return IsWindowHovered(ImGuiHoveredFlags_AnyWindow); } // OBSOLETED in 1.60 (between Dec 2017 and Apr 2018)
|
//static inline void SetScrollHere(float ratio = 0.5f) { SetScrollHereY(ratio); } // OBSOLETED in 1.66 (from Nov 2018)
|
||||||
//static inline void ShowTestWindow() { return ShowDemoWindow(); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
//static inline bool IsItemDeactivatedAfterChange() { return IsItemDeactivatedAfterEdit(); } // OBSOLETED in 1.63 (from Aug 2018)
|
||||||
//static inline bool IsRootWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootWindow); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
//static inline bool IsAnyWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_AnyWindow); } // OBSOLETED in 1.60 (from Apr 2018)
|
||||||
//static inline bool IsRootWindowOrAnyChildFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
//static inline bool IsAnyWindowHovered() { return IsWindowHovered(ImGuiHoveredFlags_AnyWindow); } // OBSOLETED in 1.60 (between Dec 2017 and Apr 2018)
|
||||||
//static inline void SetNextWindowContentWidth(float w) { SetNextWindowContentSize(ImVec2(w, 0.0f)); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
//static inline void ShowTestWindow() { return ShowDemoWindow(); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
||||||
//static inline float GetItemsLineHeightWithSpacing() { return GetFrameHeightWithSpacing(); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
//static inline bool IsRootWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootWindow); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
||||||
|
//static inline bool IsRootWindowOrAnyChildFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
||||||
|
//static inline void SetNextWindowContentWidth(float w) { SetNextWindowContentSize(ImVec2(w, 0.0f)); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
||||||
|
//static inline float GetItemsLineHeightWithSpacing() { return GetFrameHeightWithSpacing(); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OBSOLETED in 1.82 (from Mars 2021): flags for AddRect(), AddRectFilled(), AddImageRounded(), PathRect()
|
// OBSOLETED in 1.82 (from Mars 2021): flags for AddRect(), AddRectFilled(), AddImageRounded(), PathRect()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.86
|
// dear imgui, v1.87
|
||||||
// (demo code)
|
// (demo code)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@ -92,6 +92,7 @@ Index of this file:
|
|||||||
|
|
||||||
// Visual Studio warnings
|
// Visual Studio warnings
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning (disable: 4127) // condition expression is constant
|
||||||
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
|
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
|
||||||
#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2).
|
#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2).
|
||||||
#endif
|
#endif
|
||||||
@ -228,7 +229,6 @@ void ImGui::ShowUserGuide()
|
|||||||
ImGui::BulletText("CTRL+X/C/V to use clipboard cut/copy/paste.");
|
ImGui::BulletText("CTRL+X/C/V to use clipboard cut/copy/paste.");
|
||||||
ImGui::BulletText("CTRL+Z,CTRL+Y to undo/redo.");
|
ImGui::BulletText("CTRL+Z,CTRL+Y to undo/redo.");
|
||||||
ImGui::BulletText("ESCAPE to revert.");
|
ImGui::BulletText("ESCAPE to revert.");
|
||||||
ImGui::BulletText("You can apply arithmetic operators +,*,/ on numerical values.\nUse +- to subtract.");
|
|
||||||
ImGui::Unindent();
|
ImGui::Unindent();
|
||||||
ImGui::BulletText("With keyboard navigation enabled:");
|
ImGui::BulletText("With keyboard navigation enabled:");
|
||||||
ImGui::Indent();
|
ImGui::Indent();
|
||||||
@ -454,13 +454,15 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Text("<<PRESS SPACE TO DISABLE>>");
|
ImGui::Text("<<PRESS SPACE TO DISABLE>>");
|
||||||
}
|
}
|
||||||
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Space)))
|
if (ImGui::IsKeyPressed(ImGuiKey_Space))
|
||||||
io.ConfigFlags &= ~ImGuiConfigFlags_NoMouse;
|
io.ConfigFlags &= ~ImGuiConfigFlags_NoMouse;
|
||||||
}
|
}
|
||||||
ImGui::CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", &io.ConfigFlags, ImGuiConfigFlags_NoMouseCursorChange);
|
ImGui::CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", &io.ConfigFlags, ImGuiConfigFlags_NoMouseCursorChange);
|
||||||
ImGui::SameLine(); HelpMarker("Instruct backend to not alter mouse cursor shape and visibility.");
|
ImGui::SameLine(); HelpMarker("Instruct backend to not alter mouse cursor shape and visibility.");
|
||||||
|
ImGui::Checkbox("io.ConfigInputTrickleEventQueue", &io.ConfigInputTrickleEventQueue);
|
||||||
|
ImGui::SameLine(); HelpMarker("Enable input queue trickling: some types of events submitted during the same frame (e.g. button down + up) will be spread over multiple frames, improving interactions with low framerates.");
|
||||||
ImGui::Checkbox("io.ConfigInputTextCursorBlink", &io.ConfigInputTextCursorBlink);
|
ImGui::Checkbox("io.ConfigInputTextCursorBlink", &io.ConfigInputTextCursorBlink);
|
||||||
ImGui::SameLine(); HelpMarker("Enable blinking cursor (optional as some users consider it to be distracting)");
|
ImGui::SameLine(); HelpMarker("Enable blinking cursor (optional as some users consider it to be distracting).");
|
||||||
ImGui::Checkbox("io.ConfigDragClickToInputText", &io.ConfigDragClickToInputText);
|
ImGui::Checkbox("io.ConfigDragClickToInputText", &io.ConfigDragClickToInputText);
|
||||||
ImGui::SameLine(); HelpMarker("Enable turning DragXXX widgets into text input with a simple mouse click-release (without moving).");
|
ImGui::SameLine(); HelpMarker("Enable turning DragXXX widgets into text input with a simple mouse click-release (without moving).");
|
||||||
ImGui::Checkbox("io.ConfigWindowsResizeFromEdges", &io.ConfigWindowsResizeFromEdges);
|
ImGui::Checkbox("io.ConfigWindowsResizeFromEdges", &io.ConfigWindowsResizeFromEdges);
|
||||||
@ -481,6 +483,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
"Here we expose them as read-only fields to avoid breaking interactions with your backend.");
|
"Here we expose them as read-only fields to avoid breaking interactions with your backend.");
|
||||||
|
|
||||||
// Make a local copy to avoid modifying actual backend flags.
|
// Make a local copy to avoid modifying actual backend flags.
|
||||||
|
// FIXME: We don't use BeginDisabled() to keep label bright, maybe we need a BeginReadonly() equivalent..
|
||||||
ImGuiBackendFlags backend_flags = io.BackendFlags;
|
ImGuiBackendFlags backend_flags = io.BackendFlags;
|
||||||
ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", &backend_flags, ImGuiBackendFlags_HasGamepad);
|
ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", &backend_flags, ImGuiBackendFlags_HasGamepad);
|
||||||
ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", &backend_flags, ImGuiBackendFlags_HasMouseCursors);
|
ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", &backend_flags, ImGuiBackendFlags_HasMouseCursors);
|
||||||
@ -673,10 +676,6 @@ static void ShowDemoWindowWidgets()
|
|||||||
IMGUI_DEMO_MARKER("Widgets/Basic/InputInt, InputFloat");
|
IMGUI_DEMO_MARKER("Widgets/Basic/InputInt, InputFloat");
|
||||||
static int i0 = 123;
|
static int i0 = 123;
|
||||||
ImGui::InputInt("input int", &i0);
|
ImGui::InputInt("input int", &i0);
|
||||||
ImGui::SameLine(); HelpMarker(
|
|
||||||
"You can apply arithmetic operators +,*,/ on numerical values.\n"
|
|
||||||
" e.g. [ 100 ], input \'*2\', result becomes [ 200 ]\n"
|
|
||||||
"Use +- to subtract.");
|
|
||||||
|
|
||||||
static float f0 = 0.001f;
|
static float f0 = 0.001f;
|
||||||
ImGui::InputFloat("input float", &f0, 0.01f, 1.0f, "%.3f");
|
ImGui::InputFloat("input float", &f0, 0.01f, 1.0f, "%.3f");
|
||||||
@ -5639,6 +5638,8 @@ static void ShowDemoWindowColumns()
|
|||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace ImGui { extern ImGuiKeyData* GetKeyData(ImGuiKey key); }
|
||||||
|
|
||||||
static void ShowDemoWindowMisc()
|
static void ShowDemoWindowMisc()
|
||||||
{
|
{
|
||||||
IMGUI_DEMO_MARKER("Filtering");
|
IMGUI_DEMO_MARKER("Filtering");
|
||||||
@ -5692,18 +5693,75 @@ static void ShowDemoWindowMisc()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Display Keyboard/Mouse state
|
// Display Keyboard/Mouse state
|
||||||
IMGUI_DEMO_MARKER("Inputs, Navigation & Focus/Keyboard & Navigation State");
|
IMGUI_DEMO_MARKER("Inputs, Navigation & Focus/Keyboard, Gamepad & Navigation State");
|
||||||
if (ImGui::TreeNode("Keyboard & Navigation State"))
|
if (ImGui::TreeNode("Keyboard, Gamepad & Navigation State"))
|
||||||
{
|
{
|
||||||
ImGui::Text("Keys down:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyDown(i)) { ImGui::SameLine(); ImGui::Text("%d (0x%X) (%.02f secs)", i, i, io.KeysDownDuration[i]); }
|
// We iterate both legacy native range and named ImGuiKey ranges, which is a little odd but this allow displaying the data for old/new backends.
|
||||||
ImGui::Text("Keys pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyPressed(i)) { ImGui::SameLine(); ImGui::Text("%d (0x%X)", i, i); }
|
// User code should never have to go through such hoops: old code may use native keycodes, new code may use ImGuiKey codes.
|
||||||
ImGui::Text("Keys release:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyReleased(i)) { ImGui::SameLine(); ImGui::Text("%d (0x%X)", i, i); }
|
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||||
|
struct funcs { static bool IsLegacyNativeDupe(ImGuiKey) { return false; } };
|
||||||
|
const ImGuiKey key_first = ImGuiKey_NamedKey_BEGIN;
|
||||||
|
#else
|
||||||
|
struct funcs { static bool IsLegacyNativeDupe(ImGuiKey key) { return key < 512 && ImGui::GetIO().KeyMap[key] != -1; } }; // Hide Native<>ImGuiKey duplicates when both exists in the array
|
||||||
|
const ImGuiKey key_first = 0;
|
||||||
|
#endif
|
||||||
|
ImGui::Text("Keys down:"); for (ImGuiKey key = key_first; key < ImGuiKey_COUNT; key++) { if (funcs::IsLegacyNativeDupe(key)) continue; if (ImGui::IsKeyDown(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d (%.02f secs)", ImGui::GetKeyName(key), key, ImGui::GetKeyData(key)->DownDuration); } }
|
||||||
|
ImGui::Text("Keys pressed:"); for (ImGuiKey key = key_first; key < ImGuiKey_COUNT; key++) { if (funcs::IsLegacyNativeDupe(key)) continue; if (ImGui::IsKeyPressed(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d", ImGui::GetKeyName(key), key); } }
|
||||||
|
ImGui::Text("Keys released:"); for (ImGuiKey key = key_first; key < ImGuiKey_COUNT; key++) { if (funcs::IsLegacyNativeDupe(key)) continue; if (ImGui::IsKeyReleased(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d", ImGui::GetKeyName(key), key); } }
|
||||||
ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : "");
|
ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : "");
|
||||||
ImGui::Text("Chars queue:"); for (int i = 0; i < io.InputQueueCharacters.Size; i++) { ImWchar c = io.InputQueueCharacters[i]; ImGui::SameLine(); ImGui::Text("\'%c\' (0x%04X)", (c > ' ' && c <= 255) ? (char)c : '?', c); } // FIXME: We should convert 'c' to UTF-8 here but the functions are not public.
|
ImGui::Text("Chars queue:"); for (int i = 0; i < io.InputQueueCharacters.Size; i++) { ImWchar c = io.InputQueueCharacters[i]; ImGui::SameLine(); ImGui::Text("\'%c\' (0x%04X)", (c > ' ' && c <= 255) ? (char)c : '?', c); } // FIXME: We should convert 'c' to UTF-8 here but the functions are not public.
|
||||||
|
|
||||||
ImGui::Text("NavInputs down:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputs[i] > 0.0f) { ImGui::SameLine(); ImGui::Text("[%d] %.2f (%.02f secs)", i, io.NavInputs[i], io.NavInputsDownDuration[i]); }
|
ImGui::Text("NavInputs down:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputs[i] > 0.0f) { ImGui::SameLine(); ImGui::Text("[%d] %.2f (%.02f secs)", i, io.NavInputs[i], io.NavInputsDownDuration[i]); }
|
||||||
ImGui::Text("NavInputs pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputsDownDuration[i] == 0.0f) { ImGui::SameLine(); ImGui::Text("[%d]", i); }
|
ImGui::Text("NavInputs pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputsDownDuration[i] == 0.0f) { ImGui::SameLine(); ImGui::Text("[%d]", i); }
|
||||||
|
|
||||||
|
// Draw an arbitrary US keyboard layout to visualize translated keys
|
||||||
|
{
|
||||||
|
const ImVec2 key_size = ImVec2(35.0f, 35.0f);
|
||||||
|
const float key_rounding = 3.0f;
|
||||||
|
const ImVec2 key_face_size = ImVec2(25.0f, 25.0f);
|
||||||
|
const ImVec2 key_face_pos = ImVec2(5.0f, 3.0f);
|
||||||
|
const float key_face_rounding = 2.0f;
|
||||||
|
const ImVec2 key_label_pos = ImVec2(7.0f, 4.0f);
|
||||||
|
const ImVec2 key_step = ImVec2(key_size.x - 1.0f, key_size.y - 1.0f);
|
||||||
|
const float key_row_offset = 9.0f;
|
||||||
|
|
||||||
|
ImVec2 board_min = ImGui::GetCursorScreenPos();
|
||||||
|
ImVec2 board_max = ImVec2(board_min.x + 3 * key_step.x + 2 * key_row_offset + 10.0f, board_min.y + 3 * key_step.y + 10.0f);
|
||||||
|
ImVec2 start_pos = ImVec2(board_min.x + 5.0f - key_step.x, board_min.y);
|
||||||
|
|
||||||
|
struct KeyLayoutData { int Row, Col; const char* Label; ImGuiKey Key; };
|
||||||
|
const KeyLayoutData keys_to_display[] =
|
||||||
|
{
|
||||||
|
{ 0, 0, "", ImGuiKey_Tab }, { 0, 1, "Q", ImGuiKey_Q }, { 0, 2, "W", ImGuiKey_W }, { 0, 3, "E", ImGuiKey_E }, { 0, 4, "R", ImGuiKey_R },
|
||||||
|
{ 1, 0, "", ImGuiKey_CapsLock }, { 1, 1, "A", ImGuiKey_A }, { 1, 2, "S", ImGuiKey_S }, { 1, 3, "D", ImGuiKey_D }, { 1, 4, "F", ImGuiKey_F },
|
||||||
|
{ 2, 0, "", ImGuiKey_LeftShift },{ 2, 1, "Z", ImGuiKey_Z }, { 2, 2, "X", ImGuiKey_X }, { 2, 3, "C", ImGuiKey_C }, { 2, 4, "V", ImGuiKey_V }
|
||||||
|
};
|
||||||
|
|
||||||
|
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||||
|
draw_list->PushClipRect(board_min, board_max, true);
|
||||||
|
for (int n = 0; n < IM_ARRAYSIZE(keys_to_display); n++)
|
||||||
|
{
|
||||||
|
const KeyLayoutData* key_data = &keys_to_display[n];
|
||||||
|
ImVec2 key_min = ImVec2(start_pos.x + key_data->Col * key_step.x + key_data->Row * key_row_offset, start_pos.y + key_data->Row * key_step.y);
|
||||||
|
ImVec2 key_max = ImVec2(key_min.x + key_size.x, key_min.y + key_size.y);
|
||||||
|
draw_list->AddRectFilled(key_min, key_max, IM_COL32(204, 204, 204, 255), key_rounding);
|
||||||
|
draw_list->AddRect(key_min, key_max, IM_COL32(24, 24, 24, 255), key_rounding);
|
||||||
|
ImVec2 face_min = ImVec2(key_min.x + key_face_pos.x, key_min.y + key_face_pos.y);
|
||||||
|
ImVec2 face_max = ImVec2(face_min.x + key_face_size.x, face_min.y + key_face_size.y);
|
||||||
|
draw_list->AddRect(face_min, face_max, IM_COL32(193, 193, 193, 255), key_face_rounding, ImDrawFlags_None, 2.0f);
|
||||||
|
draw_list->AddRectFilled(face_min, face_max, IM_COL32(252, 252, 252, 255), key_face_rounding);
|
||||||
|
ImVec2 label_min = ImVec2(key_min.x + key_label_pos.x, key_min.y + key_label_pos.y);
|
||||||
|
draw_list->AddText(label_min, IM_COL32(64, 64, 64, 255), key_data->Label);
|
||||||
|
if (ImGui::IsKeyDown(key_data->Key))
|
||||||
|
draw_list->AddRectFilled(key_min, key_max, IM_COL32(255, 0, 0, 128), key_rounding);
|
||||||
|
}
|
||||||
|
draw_list->PopClipRect();
|
||||||
|
ImGui::Dummy(ImVec2(board_max.x - board_min.x, board_max.y - board_min.y));
|
||||||
|
}
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::TreeNode("Capture override"))
|
||||||
|
{
|
||||||
ImGui::Button("Hovering me sets the\nkeyboard capture flag");
|
ImGui::Button("Hovering me sets the\nkeyboard capture flag");
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered())
|
||||||
ImGui::CaptureKeyboardFromApp(true);
|
ImGui::CaptureKeyboardFromApp(true);
|
||||||
@ -5868,6 +5926,9 @@ void ImGui::ShowAboutWindow(bool* p_open)
|
|||||||
#ifdef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifdef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
ImGui::Text("define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS");
|
ImGui::Text("define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS");
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||||
|
ImGui::Text("define: IMGUI_DISABLE_OBSOLETE_KEYIO");
|
||||||
|
#endif
|
||||||
#ifdef IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS
|
#ifdef IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS
|
||||||
ImGui::Text("define: IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS");
|
ImGui::Text("define: IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS");
|
||||||
#endif
|
#endif
|
||||||
@ -5981,7 +6042,7 @@ void ImGui::ShowAboutWindow(bool* p_open)
|
|||||||
namespace ImGui { IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas); }
|
namespace ImGui { IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas); }
|
||||||
|
|
||||||
// Demo helper function to select among loaded fonts.
|
// Demo helper function to select among loaded fonts.
|
||||||
// Here we use the regular BeginCombo()/EndCombo() api which is more the more flexible one.
|
// Here we use the regular BeginCombo()/EndCombo() api which is the more flexible one.
|
||||||
void ImGui::ShowFontSelector(const char* label)
|
void ImGui::ShowFontSelector(const char* label)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@ -7509,8 +7570,8 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|||||||
|
|
||||||
// Context menu (under default mouse threshold)
|
// Context menu (under default mouse threshold)
|
||||||
ImVec2 drag_delta = ImGui::GetMouseDragDelta(ImGuiMouseButton_Right);
|
ImVec2 drag_delta = ImGui::GetMouseDragDelta(ImGuiMouseButton_Right);
|
||||||
if (opt_enable_context_menu && ImGui::IsMouseReleased(ImGuiMouseButton_Right) && drag_delta.x == 0.0f && drag_delta.y == 0.0f)
|
if (opt_enable_context_menu && drag_delta.x == 0.0f && drag_delta.y == 0.0f)
|
||||||
ImGui::OpenPopupOnItemClick("context");
|
ImGui::OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
|
||||||
if (ImGui::BeginPopup("context"))
|
if (ImGui::BeginPopup("context"))
|
||||||
{
|
{
|
||||||
if (adding_line)
|
if (adding_line)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.86
|
// dear imgui, v1.87
|
||||||
// (drawing and font code)
|
// (drawing and font code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -402,10 +402,9 @@ void ImDrawListSharedData::SetCircleTessellationMaxError(float max_error)
|
|||||||
void ImDrawList::_ResetForNewFrame()
|
void ImDrawList::_ResetForNewFrame()
|
||||||
{
|
{
|
||||||
// Verify that the ImDrawCmd fields we want to memcmp() are contiguous in memory.
|
// Verify that the ImDrawCmd fields we want to memcmp() are contiguous in memory.
|
||||||
// (those should be IM_STATIC_ASSERT() in theory but with our pre C++11 setup the whole check doesn't compile with GCC)
|
IM_STATIC_ASSERT(IM_OFFSETOF(ImDrawCmd, ClipRect) == 0);
|
||||||
IM_ASSERT(IM_OFFSETOF(ImDrawCmd, ClipRect) == 0);
|
IM_STATIC_ASSERT(IM_OFFSETOF(ImDrawCmd, TextureId) == sizeof(ImVec4));
|
||||||
IM_ASSERT(IM_OFFSETOF(ImDrawCmd, TextureId) == sizeof(ImVec4));
|
IM_STATIC_ASSERT(IM_OFFSETOF(ImDrawCmd, VtxOffset) == sizeof(ImVec4) + sizeof(ImTextureID));
|
||||||
IM_ASSERT(IM_OFFSETOF(ImDrawCmd, VtxOffset) == sizeof(ImVec4) + sizeof(ImTextureID));
|
|
||||||
|
|
||||||
CmdBuffer.resize(0);
|
CmdBuffer.resize(0);
|
||||||
IdxBuffer.resize(0);
|
IdxBuffer.resize(0);
|
||||||
@ -488,9 +487,10 @@ void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compare ClipRect, TextureId and VtxOffset with a single memcmp()
|
// Compare ClipRect, TextureId and VtxOffset with a single memcmp()
|
||||||
#define ImDrawCmd_HeaderSize (IM_OFFSETOF(ImDrawCmd, VtxOffset) + sizeof(unsigned int))
|
#define ImDrawCmd_HeaderSize (IM_OFFSETOF(ImDrawCmd, VtxOffset) + sizeof(unsigned int))
|
||||||
#define ImDrawCmd_HeaderCompare(CMD_LHS, CMD_RHS) (memcmp(CMD_LHS, CMD_RHS, ImDrawCmd_HeaderSize)) // Compare ClipRect, TextureId, VtxOffset
|
#define ImDrawCmd_HeaderCompare(CMD_LHS, CMD_RHS) (memcmp(CMD_LHS, CMD_RHS, ImDrawCmd_HeaderSize)) // Compare ClipRect, TextureId, VtxOffset
|
||||||
#define ImDrawCmd_HeaderCopy(CMD_DST, CMD_SRC) (memcpy(CMD_DST, CMD_SRC, ImDrawCmd_HeaderSize)) // Copy ClipRect, TextureId, VtxOffset
|
#define ImDrawCmd_HeaderCopy(CMD_DST, CMD_SRC) (memcpy(CMD_DST, CMD_SRC, ImDrawCmd_HeaderSize)) // Copy ClipRect, TextureId, VtxOffset
|
||||||
|
#define ImDrawCmd_AreSequentialIdxOffset(CMD_0, CMD_1) (CMD_0->IdxOffset + CMD_0->ElemCount == CMD_1->IdxOffset)
|
||||||
|
|
||||||
// Try to merge two last draw commands
|
// Try to merge two last draw commands
|
||||||
void ImDrawList::_TryMergeDrawCmds()
|
void ImDrawList::_TryMergeDrawCmds()
|
||||||
@ -498,7 +498,7 @@ void ImDrawList::_TryMergeDrawCmds()
|
|||||||
IM_ASSERT_PARANOID(CmdBuffer.Size > 0);
|
IM_ASSERT_PARANOID(CmdBuffer.Size > 0);
|
||||||
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
ImDrawCmd* prev_cmd = curr_cmd - 1;
|
ImDrawCmd* prev_cmd = curr_cmd - 1;
|
||||||
if (ImDrawCmd_HeaderCompare(curr_cmd, prev_cmd) == 0 && curr_cmd->UserCallback == NULL && prev_cmd->UserCallback == NULL)
|
if (ImDrawCmd_HeaderCompare(curr_cmd, prev_cmd) == 0 && ImDrawCmd_AreSequentialIdxOffset(prev_cmd, curr_cmd) && curr_cmd->UserCallback == NULL && prev_cmd->UserCallback == NULL)
|
||||||
{
|
{
|
||||||
prev_cmd->ElemCount += curr_cmd->ElemCount;
|
prev_cmd->ElemCount += curr_cmd->ElemCount;
|
||||||
CmdBuffer.pop_back();
|
CmdBuffer.pop_back();
|
||||||
@ -521,7 +521,7 @@ void ImDrawList::_OnChangedClipRect()
|
|||||||
|
|
||||||
// Try to merge with previous command if it matches, else use current command
|
// Try to merge with previous command if it matches, else use current command
|
||||||
ImDrawCmd* prev_cmd = curr_cmd - 1;
|
ImDrawCmd* prev_cmd = curr_cmd - 1;
|
||||||
if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1 && ImDrawCmd_HeaderCompare(&_CmdHeader, prev_cmd) == 0 && prev_cmd->UserCallback == NULL)
|
if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1 && ImDrawCmd_HeaderCompare(&_CmdHeader, prev_cmd) == 0 && ImDrawCmd_AreSequentialIdxOffset(prev_cmd, curr_cmd) && prev_cmd->UserCallback == NULL)
|
||||||
{
|
{
|
||||||
CmdBuffer.pop_back();
|
CmdBuffer.pop_back();
|
||||||
return;
|
return;
|
||||||
@ -544,7 +544,7 @@ void ImDrawList::_OnChangedTextureID()
|
|||||||
|
|
||||||
// Try to merge with previous command if it matches, else use current command
|
// Try to merge with previous command if it matches, else use current command
|
||||||
ImDrawCmd* prev_cmd = curr_cmd - 1;
|
ImDrawCmd* prev_cmd = curr_cmd - 1;
|
||||||
if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1 && ImDrawCmd_HeaderCompare(&_CmdHeader, prev_cmd) == 0 && prev_cmd->UserCallback == NULL)
|
if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1 && ImDrawCmd_HeaderCompare(&_CmdHeader, prev_cmd) == 0 && ImDrawCmd_AreSequentialIdxOffset(prev_cmd, curr_cmd) && prev_cmd->UserCallback == NULL)
|
||||||
{
|
{
|
||||||
CmdBuffer.pop_back();
|
CmdBuffer.pop_back();
|
||||||
return;
|
return;
|
||||||
@ -1733,13 +1733,13 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list)
|
|||||||
for (int i = 1; i < _Count; i++)
|
for (int i = 1; i < _Count; i++)
|
||||||
{
|
{
|
||||||
ImDrawChannel& ch = _Channels[i];
|
ImDrawChannel& ch = _Channels[i];
|
||||||
|
if (ch._CmdBuffer.Size > 0 && ch._CmdBuffer.back().ElemCount == 0 && ch._CmdBuffer.back().UserCallback == NULL) // Equivalent of PopUnusedDrawCmd()
|
||||||
// Equivalent of PopUnusedDrawCmd() for this channel's cmdbuffer and except we don't need to test for UserCallback.
|
|
||||||
if (ch._CmdBuffer.Size > 0 && ch._CmdBuffer.back().ElemCount == 0)
|
|
||||||
ch._CmdBuffer.pop_back();
|
ch._CmdBuffer.pop_back();
|
||||||
|
|
||||||
if (ch._CmdBuffer.Size > 0 && last_cmd != NULL)
|
if (ch._CmdBuffer.Size > 0 && last_cmd != NULL)
|
||||||
{
|
{
|
||||||
|
// Do not include ImDrawCmd_AreSequentialIdxOffset() in the compare as we rebuild IdxOffset values ourselves.
|
||||||
|
// Manipulating IdxOffset (e.g. by reordering draw commands like done by RenderDimmedBackgroundBehindWindow()) is not supported within a splitter.
|
||||||
ImDrawCmd* next_cmd = &ch._CmdBuffer[0];
|
ImDrawCmd* next_cmd = &ch._CmdBuffer[0];
|
||||||
if (ImDrawCmd_HeaderCompare(last_cmd, next_cmd) == 0 && last_cmd->UserCallback == NULL && next_cmd->UserCallback == NULL)
|
if (ImDrawCmd_HeaderCompare(last_cmd, next_cmd) == 0 && last_cmd->UserCallback == NULL && next_cmd->UserCallback == NULL)
|
||||||
{
|
{
|
||||||
|
161
imgui_internal.h
161
imgui_internal.h
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.86
|
// dear imgui, v1.87
|
||||||
// (internal structures/api)
|
// (internal structures/api)
|
||||||
|
|
||||||
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
||||||
@ -18,6 +18,7 @@ Index of this file:
|
|||||||
// [SECTION] Generic helpers
|
// [SECTION] Generic helpers
|
||||||
// [SECTION] ImDrawList support
|
// [SECTION] ImDrawList support
|
||||||
// [SECTION] Widgets support: flags, enums, data structures
|
// [SECTION] Widgets support: flags, enums, data structures
|
||||||
|
// [SECTION] Inputs support
|
||||||
// [SECTION] Clipper support
|
// [SECTION] Clipper support
|
||||||
// [SECTION] Navigation support
|
// [SECTION] Navigation support
|
||||||
// [SECTION] Columns support
|
// [SECTION] Columns support
|
||||||
@ -199,15 +200,13 @@ namespace ImStb
|
|||||||
// Debug Logging for selected systems. Remove the '((void)0) //' to enable.
|
// Debug Logging for selected systems. Remove the '((void)0) //' to enable.
|
||||||
//#define IMGUI_DEBUG_LOG_POPUP IMGUI_DEBUG_LOG // Enable log
|
//#define IMGUI_DEBUG_LOG_POPUP IMGUI_DEBUG_LOG // Enable log
|
||||||
//#define IMGUI_DEBUG_LOG_NAV IMGUI_DEBUG_LOG // Enable log
|
//#define IMGUI_DEBUG_LOG_NAV IMGUI_DEBUG_LOG // Enable log
|
||||||
|
//#define IMGUI_DEBUG_LOG_IO IMGUI_DEBUG_LOG // Enable log
|
||||||
#define IMGUI_DEBUG_LOG_POPUP(...) ((void)0) // Disable log
|
#define IMGUI_DEBUG_LOG_POPUP(...) ((void)0) // Disable log
|
||||||
#define IMGUI_DEBUG_LOG_NAV(...) ((void)0) // Disable log
|
#define IMGUI_DEBUG_LOG_NAV(...) ((void)0) // Disable log
|
||||||
|
#define IMGUI_DEBUG_LOG_IO(...) ((void)0) // Disable log
|
||||||
|
|
||||||
// Static Asserts
|
// Static Asserts
|
||||||
#if (__cplusplus >= 201100) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201100)
|
|
||||||
#define IM_STATIC_ASSERT(_COND) static_assert(_COND, "")
|
#define IM_STATIC_ASSERT(_COND) static_assert(_COND, "")
|
||||||
#else
|
|
||||||
#define IM_STATIC_ASSERT(_COND) typedef char static_assertion_##__line__[(_COND)?1:-1]
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// "Paranoid" Debug Asserts are meant to only be enabled during specific debugging/work, otherwise would slow down the code too much.
|
// "Paranoid" Debug Asserts are meant to only be enabled during specific debugging/work, otherwise would slow down the code too much.
|
||||||
// We currently don't have many of those so the effect is currently negligible, but onward intent to add more aggressive ones in the code.
|
// We currently don't have many of those so the effect is currently negligible, but onward intent to add more aggressive ones in the code.
|
||||||
@ -441,8 +440,9 @@ static inline float ImLengthSqr(const ImVec2& lhs)
|
|||||||
static inline float ImLengthSqr(const ImVec4& lhs) { return (lhs.x * lhs.x) + (lhs.y * lhs.y) + (lhs.z * lhs.z) + (lhs.w * lhs.w); }
|
static inline float ImLengthSqr(const ImVec4& lhs) { return (lhs.x * lhs.x) + (lhs.y * lhs.y) + (lhs.z * lhs.z) + (lhs.w * lhs.w); }
|
||||||
static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = (lhs.x * lhs.x) + (lhs.y * lhs.y); if (d > 0.0f) return ImRsqrt(d); return fail_value; }
|
static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = (lhs.x * lhs.x) + (lhs.y * lhs.y); if (d > 0.0f) return ImRsqrt(d); return fail_value; }
|
||||||
static inline float ImFloor(float f) { return (float)(int)(f); }
|
static inline float ImFloor(float f) { return (float)(int)(f); }
|
||||||
static inline float ImFloorSigned(float f) { return (float)((f >= 0 || (int)f == f) ? (int)f : (int)f - 1); } // Decent replacement for floorf()
|
static inline float ImFloorSigned(float f) { return (float)((f >= 0 || (float)(int)f == f) ? (int)f : (int)f - 1); } // Decent replacement for floorf()
|
||||||
static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)(v.x), (float)(int)(v.y)); }
|
static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)(v.x), (float)(int)(v.y)); }
|
||||||
|
static inline ImVec2 ImFloorSigned(const ImVec2& v) { return ImVec2(ImFloorSigned(v.x), ImFloorSigned(v.y)); }
|
||||||
static inline int ImModPositive(int a, int b) { return (a + b) % b; }
|
static inline int ImModPositive(int a, int b) { return (a + b) % b; }
|
||||||
static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; }
|
static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; }
|
||||||
static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
|
static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
|
||||||
@ -540,17 +540,18 @@ inline void ImBitArraySetBitRange(ImU32* arr, int n, int n2) // Works on ran
|
|||||||
|
|
||||||
// Helper: ImBitArray class (wrapper over ImBitArray functions)
|
// Helper: ImBitArray class (wrapper over ImBitArray functions)
|
||||||
// Store 1-bit per value.
|
// Store 1-bit per value.
|
||||||
template<int BITCOUNT>
|
template<int BITCOUNT, int OFFSET = 0>
|
||||||
struct IMGUI_API ImBitArray
|
struct ImBitArray
|
||||||
{
|
{
|
||||||
ImU32 Storage[(BITCOUNT + 31) >> 5];
|
ImU32 Storage[(BITCOUNT + 31) >> 5];
|
||||||
ImBitArray() { ClearAllBits(); }
|
ImBitArray() { ClearAllBits(); }
|
||||||
void ClearAllBits() { memset(Storage, 0, sizeof(Storage)); }
|
void ClearAllBits() { memset(Storage, 0, sizeof(Storage)); }
|
||||||
void SetAllBits() { memset(Storage, 255, sizeof(Storage)); }
|
void SetAllBits() { memset(Storage, 255, sizeof(Storage)); }
|
||||||
bool TestBit(int n) const { IM_ASSERT(n < BITCOUNT); return ImBitArrayTestBit(Storage, n); }
|
bool TestBit(int n) const { IM_ASSERT(n + OFFSET < BITCOUNT); return ImBitArrayTestBit(Storage, n + OFFSET); }
|
||||||
void SetBit(int n) { IM_ASSERT(n < BITCOUNT); ImBitArraySetBit(Storage, n); }
|
void SetBit(int n) { IM_ASSERT(n + OFFSET < BITCOUNT); ImBitArraySetBit(Storage, n + OFFSET); }
|
||||||
void ClearBit(int n) { IM_ASSERT(n < BITCOUNT); ImBitArrayClearBit(Storage, n); }
|
void ClearBit(int n) { IM_ASSERT(n + OFFSET < BITCOUNT); ImBitArrayClearBit(Storage, n + OFFSET); }
|
||||||
void SetBitRange(int n, int n2) { ImBitArraySetBitRange(Storage, n, n2); } // Works on range [n..n2)
|
void SetBitRange(int n, int n2) { ImBitArraySetBitRange(Storage, n + OFFSET, n2 + OFFSET); } // Works on range [n..n2)
|
||||||
|
bool operator[](int n) const { IM_ASSERT(n + OFFSET < BITCOUNT); return ImBitArrayTestBit(Storage, n + OFFSET); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helper: ImBitVector
|
// Helper: ImBitVector
|
||||||
@ -621,7 +622,7 @@ struct ImSpanAllocator
|
|||||||
// Honor constructor/destructor. Add/remove invalidate all pointers. Indexes have the same lifetime as the associated object.
|
// Honor constructor/destructor. Add/remove invalidate all pointers. Indexes have the same lifetime as the associated object.
|
||||||
typedef int ImPoolIdx;
|
typedef int ImPoolIdx;
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct IMGUI_API ImPool
|
struct ImPool
|
||||||
{
|
{
|
||||||
ImVector<T> Buf; // Contiguous data
|
ImVector<T> Buf; // Contiguous data
|
||||||
ImGuiStorage Map; // ID->Index
|
ImGuiStorage Map; // ID->Index
|
||||||
@ -658,7 +659,7 @@ struct IMGUI_API ImPool
|
|||||||
// We store the chunk size first, and align the final size on 4 bytes boundaries.
|
// We store the chunk size first, and align the final size on 4 bytes boundaries.
|
||||||
// The tedious/zealous amount of casting is to avoid -Wcast-align warnings.
|
// The tedious/zealous amount of casting is to avoid -Wcast-align warnings.
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct IMGUI_API ImChunkStream
|
struct ImChunkStream
|
||||||
{
|
{
|
||||||
ImVector<char> Buf;
|
ImVector<char> Buf;
|
||||||
|
|
||||||
@ -897,28 +898,6 @@ enum ImGuiPlotType
|
|||||||
ImGuiPlotType_Histogram
|
ImGuiPlotType_Histogram
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ImGuiInputSource
|
|
||||||
{
|
|
||||||
ImGuiInputSource_None = 0,
|
|
||||||
ImGuiInputSource_Mouse,
|
|
||||||
ImGuiInputSource_Keyboard,
|
|
||||||
ImGuiInputSource_Gamepad,
|
|
||||||
ImGuiInputSource_Nav, // Stored in g.ActiveIdSource only
|
|
||||||
ImGuiInputSource_Clipboard, // Currently only used by InputText()
|
|
||||||
ImGuiInputSource_COUNT
|
|
||||||
};
|
|
||||||
|
|
||||||
// FIXME-NAV: Clarify/expose various repeat delay/rate
|
|
||||||
enum ImGuiInputReadMode
|
|
||||||
{
|
|
||||||
ImGuiInputReadMode_Down,
|
|
||||||
ImGuiInputReadMode_Pressed,
|
|
||||||
ImGuiInputReadMode_Released,
|
|
||||||
ImGuiInputReadMode_Repeat,
|
|
||||||
ImGuiInputReadMode_RepeatSlow,
|
|
||||||
ImGuiInputReadMode_RepeatFast
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ImGuiPopupPositionPolicy
|
enum ImGuiPopupPositionPolicy
|
||||||
{
|
{
|
||||||
ImGuiPopupPositionPolicy_Default,
|
ImGuiPopupPositionPolicy_Default,
|
||||||
@ -1171,6 +1150,81 @@ struct ImGuiPtrOrIndex
|
|||||||
ImGuiPtrOrIndex(int index) { Ptr = NULL; Index = index; }
|
ImGuiPtrOrIndex(int index) { Ptr = NULL; Index = index; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// [SECTION] Inputs support
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
typedef ImBitArray<ImGuiKey_NamedKey_COUNT, -ImGuiKey_NamedKey_BEGIN> ImBitArrayForNamedKeys;
|
||||||
|
|
||||||
|
enum ImGuiKeyPrivate_
|
||||||
|
{
|
||||||
|
ImGuiKey_LegacyNativeKey_BEGIN = 0,
|
||||||
|
ImGuiKey_LegacyNativeKey_END = 512,
|
||||||
|
ImGuiKey_Gamepad_BEGIN = ImGuiKey_GamepadStart,
|
||||||
|
ImGuiKey_Gamepad_END = ImGuiKey_GamepadRStickRight + 1
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ImGuiInputEventType
|
||||||
|
{
|
||||||
|
ImGuiInputEventType_None = 0,
|
||||||
|
ImGuiInputEventType_MousePos,
|
||||||
|
ImGuiInputEventType_MouseWheel,
|
||||||
|
ImGuiInputEventType_MouseButton,
|
||||||
|
ImGuiInputEventType_Key,
|
||||||
|
ImGuiInputEventType_Char,
|
||||||
|
ImGuiInputEventType_Focus,
|
||||||
|
ImGuiInputEventType_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ImGuiInputSource
|
||||||
|
{
|
||||||
|
ImGuiInputSource_None = 0,
|
||||||
|
ImGuiInputSource_Mouse,
|
||||||
|
ImGuiInputSource_Keyboard,
|
||||||
|
ImGuiInputSource_Gamepad,
|
||||||
|
ImGuiInputSource_Clipboard, // Currently only used by InputText()
|
||||||
|
ImGuiInputSource_Nav, // Stored in g.ActiveIdSource only
|
||||||
|
ImGuiInputSource_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
// FIXME: Structures in the union below need to be declared as anonymous unions appears to be an extension?
|
||||||
|
// Using ImVec2() would fail on Clang 'union member 'MousePos' has a non-trivial default constructor'
|
||||||
|
struct ImGuiInputEventMousePos { float PosX, PosY; };
|
||||||
|
struct ImGuiInputEventMouseWheel { float WheelX, WheelY; };
|
||||||
|
struct ImGuiInputEventMouseButton { int Button; bool Down; };
|
||||||
|
struct ImGuiInputEventKey { ImGuiKey Key; bool Down; float AnalogValue; };
|
||||||
|
struct ImGuiInputEventText { unsigned int Char; };
|
||||||
|
struct ImGuiInputEventAppFocused { bool Focused; };
|
||||||
|
|
||||||
|
struct ImGuiInputEvent
|
||||||
|
{
|
||||||
|
ImGuiInputEventType Type;
|
||||||
|
ImGuiInputSource Source;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
ImGuiInputEventMousePos MousePos; // if Type == ImGuiInputEventType_MousePos
|
||||||
|
ImGuiInputEventMouseWheel MouseWheel; // if Type == ImGuiInputEventType_MouseWheel
|
||||||
|
ImGuiInputEventMouseButton MouseButton; // if Type == ImGuiInputEventType_MouseButton
|
||||||
|
ImGuiInputEventKey Key; // if Type == ImGuiInputEventType_Key
|
||||||
|
ImGuiInputEventText Text; // if Type == ImGuiInputEventType_Text
|
||||||
|
ImGuiInputEventAppFocused AppFocused; // if Type == ImGuiInputEventType_Focus
|
||||||
|
};
|
||||||
|
bool AddedByTestEngine;
|
||||||
|
|
||||||
|
ImGuiInputEvent() { memset(this, 0, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// FIXME-NAV: Clarify/expose various repeat delay/rate
|
||||||
|
enum ImGuiInputReadMode
|
||||||
|
{
|
||||||
|
ImGuiInputReadMode_Down,
|
||||||
|
ImGuiInputReadMode_Pressed,
|
||||||
|
ImGuiInputReadMode_Released,
|
||||||
|
ImGuiInputReadMode_Repeat,
|
||||||
|
ImGuiInputReadMode_RepeatSlow,
|
||||||
|
ImGuiInputReadMode_RepeatFast
|
||||||
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Clipper support
|
// [SECTION] Clipper support
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1499,6 +1553,8 @@ struct ImGuiContext
|
|||||||
bool Initialized;
|
bool Initialized;
|
||||||
bool FontAtlasOwnedByContext; // IO.Fonts-> is owned by the ImGuiContext and will be destructed along with it.
|
bool FontAtlasOwnedByContext; // IO.Fonts-> is owned by the ImGuiContext and will be destructed along with it.
|
||||||
ImGuiIO IO;
|
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.
|
||||||
ImGuiStyle Style;
|
ImGuiStyle Style;
|
||||||
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
|
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
|
||||||
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
|
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
|
||||||
@ -1553,7 +1609,7 @@ struct ImGuiContext
|
|||||||
bool ActiveIdUsingMouseWheel; // Active widget will want to read mouse wheel. Blocks scrolling the underlying window.
|
bool ActiveIdUsingMouseWheel; // Active widget will want to read mouse wheel. Blocks scrolling the underlying window.
|
||||||
ImU32 ActiveIdUsingNavDirMask; // Active widget will want to read those nav move requests (e.g. can activate a button and move away from it)
|
ImU32 ActiveIdUsingNavDirMask; // Active widget will want to read those nav move requests (e.g. can activate a button and move away from it)
|
||||||
ImU32 ActiveIdUsingNavInputMask; // Active widget will want to read those nav inputs.
|
ImU32 ActiveIdUsingNavInputMask; // Active widget will want to read those nav inputs.
|
||||||
ImU64 ActiveIdUsingKeyInputMask; // Active widget will want to read those key inputs. When we grow the ImGuiKey enum we'll need to either to order the enum to make useful keys come first, either redesign this into e.g. a small array.
|
ImBitArrayForNamedKeys ActiveIdUsingKeyInputMask; // Active widget will want to read those key inputs. When we grow the ImGuiKey enum we'll need to either to order the enum to make useful keys come first, either redesign this into e.g. a small array.
|
||||||
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
||||||
ImGuiWindow* ActiveIdWindow;
|
ImGuiWindow* ActiveIdWindow;
|
||||||
ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
|
ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
|
||||||
@ -1705,8 +1761,8 @@ struct ImGuiContext
|
|||||||
ImVector<ImGuiID> MenusIdSubmittedThisFrame; // A list of menu IDs that were rendered at least once
|
ImVector<ImGuiID> MenusIdSubmittedThisFrame; // A list of menu IDs that were rendered at least once
|
||||||
|
|
||||||
// Platform support
|
// Platform support
|
||||||
ImVec2 PlatformImePos; // Cursor position request & last passed to the OS Input Method Editor
|
ImGuiPlatformImeData PlatformImeData; // Data updated by current frame
|
||||||
ImVec2 PlatformImeLastPos;
|
ImGuiPlatformImeData PlatformImeDataPrev; // Previous frame data (when changing we will call io.SetPlatformImeDataFn
|
||||||
char PlatformLocaleDecimalPoint; // '.' or *localeconv()->decimal_point
|
char PlatformLocaleDecimalPoint; // '.' or *localeconv()->decimal_point
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
@ -1789,7 +1845,7 @@ struct ImGuiContext
|
|||||||
ActiveIdUsingMouseWheel = false;
|
ActiveIdUsingMouseWheel = false;
|
||||||
ActiveIdUsingNavDirMask = 0x00;
|
ActiveIdUsingNavDirMask = 0x00;
|
||||||
ActiveIdUsingNavInputMask = 0x00;
|
ActiveIdUsingNavInputMask = 0x00;
|
||||||
ActiveIdUsingKeyInputMask = 0x00;
|
ActiveIdUsingKeyInputMask.ClearAllBits();
|
||||||
ActiveIdClickOffset = ImVec2(-1, -1);
|
ActiveIdClickOffset = ImVec2(-1, -1);
|
||||||
ActiveIdWindow = NULL;
|
ActiveIdWindow = NULL;
|
||||||
ActiveIdSource = ImGuiInputSource_None;
|
ActiveIdSource = ImGuiInputSource_None;
|
||||||
@ -1870,7 +1926,8 @@ struct ImGuiContext
|
|||||||
TooltipOverrideCount = 0;
|
TooltipOverrideCount = 0;
|
||||||
TooltipSlowDelay = 0.50f;
|
TooltipSlowDelay = 0.50f;
|
||||||
|
|
||||||
PlatformImePos = PlatformImeLastPos = ImVec2(FLT_MAX, FLT_MAX);
|
PlatformImeData.InputPos = ImVec2(0.0f, 0.0f);
|
||||||
|
PlatformImeDataPrev.InputPos = ImVec2(-1.0f, -1.0f); // Different to ensure initial submission
|
||||||
PlatformLocaleDecimalPoint = '.';
|
PlatformLocaleDecimalPoint = '.';
|
||||||
|
|
||||||
SettingsLoaded = false;
|
SettingsLoaded = false;
|
||||||
@ -2284,7 +2341,7 @@ struct IMGUI_API ImGuiTable
|
|||||||
ImRect InnerRect; // InnerRect but without decoration. As with OuterRect, for non-scrolling tables, InnerRect.Max.y is
|
ImRect InnerRect; // InnerRect but without decoration. As with OuterRect, for non-scrolling tables, InnerRect.Max.y is
|
||||||
ImRect WorkRect;
|
ImRect WorkRect;
|
||||||
ImRect InnerClipRect;
|
ImRect InnerClipRect;
|
||||||
ImRect BgClipRect; // We use this to cpu-clip cell background color fill
|
ImRect BgClipRect; // We use this to cpu-clip cell background color fill, evolve during the frame as we cross frozen rows boundaries
|
||||||
ImRect Bg0ClipRectForDrawCmd; // Actual ImDrawCmd clip rect for BG0/1 channel. This tends to be == OuterWindow->ClipRect at BeginTable() because output in BG0/BG1 is cpu-clipped
|
ImRect Bg0ClipRectForDrawCmd; // Actual ImDrawCmd clip rect for BG0/1 channel. This tends to be == OuterWindow->ClipRect at BeginTable() because output in BG0/BG1 is cpu-clipped
|
||||||
ImRect Bg2ClipRectForDrawCmd; // Actual ImDrawCmd clip rect for BG2 channel. This tends to be a correct, tight-fit, because output to BG2 are done by widgets relying on regular ClipRect.
|
ImRect Bg2ClipRectForDrawCmd; // Actual ImDrawCmd clip rect for BG2 channel. This tends to be a correct, tight-fit, because output to BG2 are done by widgets relying on regular ClipRect.
|
||||||
ImRect HostClipRect; // This is used to check if we can eventually merge our columns draw calls into the current draw call of the current window.
|
ImRect HostClipRect; // This is used to check if we can eventually merge our columns draw calls into the current draw call of the current window.
|
||||||
@ -2453,6 +2510,7 @@ namespace ImGui
|
|||||||
IMGUI_API void Shutdown(ImGuiContext* context); // Since 1.60 this is a _private_ function. You can call DestroyContext() to destroy the context created by CreateContext().
|
IMGUI_API void Shutdown(ImGuiContext* context); // Since 1.60 this is a _private_ function. You can call DestroyContext() to destroy the context created by CreateContext().
|
||||||
|
|
||||||
// NewFrame
|
// NewFrame
|
||||||
|
IMGUI_API void UpdateInputEvents(bool trickle_fast_inputs);
|
||||||
IMGUI_API void UpdateHoveredWindowAndCaptureFlags();
|
IMGUI_API void UpdateHoveredWindowAndCaptureFlags();
|
||||||
IMGUI_API void StartMouseMovingWindow(ImGuiWindow* window);
|
IMGUI_API void StartMouseMovingWindow(ImGuiWindow* window);
|
||||||
IMGUI_API void UpdateMouseMovingWindowNewFrame();
|
IMGUI_API void UpdateMouseMovingWindowNewFrame();
|
||||||
@ -2573,6 +2631,7 @@ namespace ImGui
|
|||||||
IMGUI_API void NavMoveRequestCancel();
|
IMGUI_API void NavMoveRequestCancel();
|
||||||
IMGUI_API void NavMoveRequestApplyResult();
|
IMGUI_API void NavMoveRequestApplyResult();
|
||||||
IMGUI_API void NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags);
|
IMGUI_API void NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags);
|
||||||
|
IMGUI_API const char* GetNavInputName(ImGuiNavInput n);
|
||||||
IMGUI_API float GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode);
|
IMGUI_API float GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode);
|
||||||
IMGUI_API ImVec2 GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor = 0.0f, float fast_factor = 0.0f);
|
IMGUI_API ImVec2 GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor = 0.0f, float fast_factor = 0.0f);
|
||||||
IMGUI_API int CalcTypematicRepeatAmount(float t0, float t1, float repeat_delay, float repeat_rate);
|
IMGUI_API int CalcTypematicRepeatAmount(float t0, float t1, float repeat_delay, float repeat_rate);
|
||||||
@ -2589,16 +2648,23 @@ namespace ImGui
|
|||||||
|
|
||||||
// Inputs
|
// Inputs
|
||||||
// FIXME: Eventually we should aim to move e.g. IsActiveIdUsingKey() into IsKeyXXX functions.
|
// FIXME: Eventually we should aim to move e.g. IsActiveIdUsingKey() into IsKeyXXX functions.
|
||||||
|
inline bool IsNamedKey(ImGuiKey key) { return key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END; }
|
||||||
|
inline bool IsLegacyKey(ImGuiKey key) { return key >= ImGuiKey_LegacyNativeKey_BEGIN && key < ImGuiKey_LegacyNativeKey_END; }
|
||||||
|
inline bool IsGamepadKey(ImGuiKey key) { return key >= ImGuiKey_Gamepad_BEGIN && key < ImGuiKey_Gamepad_END; }
|
||||||
|
IMGUI_API ImGuiKeyData* GetKeyData(ImGuiKey key);
|
||||||
IMGUI_API void SetItemUsingMouseWheel();
|
IMGUI_API void SetItemUsingMouseWheel();
|
||||||
IMGUI_API void SetActiveIdUsingNavAndKeys();
|
IMGUI_API void SetActiveIdUsingNavAndKeys();
|
||||||
inline bool IsActiveIdUsingNavDir(ImGuiDir dir) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavDirMask & (1 << dir)) != 0; }
|
inline bool IsActiveIdUsingNavDir(ImGuiDir dir) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavDirMask & (1 << dir)) != 0; }
|
||||||
inline bool IsActiveIdUsingNavInput(ImGuiNavInput input) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavInputMask & (1 << input)) != 0; }
|
inline bool IsActiveIdUsingNavInput(ImGuiNavInput input) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavInputMask & (1 << input)) != 0; }
|
||||||
inline bool IsActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; IM_ASSERT(key < 64); return (g.ActiveIdUsingKeyInputMask & ((ImU64)1 << key)) != 0; }
|
inline bool IsActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; return g.ActiveIdUsingKeyInputMask[key]; }
|
||||||
|
inline void SetActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; g.ActiveIdUsingKeyInputMask.SetBit(key); }
|
||||||
IMGUI_API bool IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold = -1.0f);
|
IMGUI_API bool IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold = -1.0f);
|
||||||
inline bool IsKeyPressedMap(ImGuiKey key, bool repeat = true) { ImGuiContext& g = *GImGui; const int key_index = g.IO.KeyMap[key]; return (key_index >= 0) ? IsKeyPressed(key_index, repeat) : false; }
|
|
||||||
inline bool IsNavInputDown(ImGuiNavInput n) { ImGuiContext& g = *GImGui; return g.IO.NavInputs[n] > 0.0f; }
|
inline bool IsNavInputDown(ImGuiNavInput n) { ImGuiContext& g = *GImGui; return g.IO.NavInputs[n] > 0.0f; }
|
||||||
inline bool IsNavInputTest(ImGuiNavInput n, ImGuiInputReadMode rm) { return (GetNavInputAmount(n, rm) > 0.0f); }
|
inline bool IsNavInputTest(ImGuiNavInput n, ImGuiInputReadMode rm) { return (GetNavInputAmount(n, rm) > 0.0f); }
|
||||||
IMGUI_API ImGuiKeyModFlags GetMergedKeyModFlags();
|
IMGUI_API ImGuiKeyModFlags GetMergedKeyModFlags();
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||||
|
inline bool IsKeyPressedMap(ImGuiKey key, bool repeat = true) { IM_ASSERT(IsNamedKey(key)); return IsKeyPressed(key, repeat); }
|
||||||
|
#endif
|
||||||
|
|
||||||
// Drag and Drop
|
// Drag and Drop
|
||||||
IMGUI_API bool BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id);
|
IMGUI_API bool BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id);
|
||||||
@ -2750,7 +2816,7 @@ namespace ImGui
|
|||||||
IMGUI_API const ImGuiDataTypeInfo* DataTypeGetInfo(ImGuiDataType data_type);
|
IMGUI_API const ImGuiDataTypeInfo* DataTypeGetInfo(ImGuiDataType data_type);
|
||||||
IMGUI_API int DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* p_data, const char* format);
|
IMGUI_API int DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* p_data, const char* format);
|
||||||
IMGUI_API void DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, const void* arg_1, const void* arg_2);
|
IMGUI_API void DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, const void* arg_1, const void* arg_2);
|
||||||
IMGUI_API bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* p_data, const char* format);
|
IMGUI_API bool DataTypeApplyFromText(const char* buf, ImGuiDataType data_type, void* p_data, const char* format);
|
||||||
IMGUI_API int DataTypeCompare(ImGuiDataType data_type, const void* arg_1, const void* arg_2);
|
IMGUI_API int DataTypeCompare(ImGuiDataType data_type, const void* arg_1, const void* arg_2);
|
||||||
IMGUI_API bool DataTypeClamp(ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max);
|
IMGUI_API bool DataTypeClamp(ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max);
|
||||||
|
|
||||||
@ -2815,7 +2881,9 @@ struct ImFontBuilderIO
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Helper for font builder
|
// Helper for font builder
|
||||||
|
#ifdef IMGUI_ENABLE_STB_TRUETYPE
|
||||||
IMGUI_API const ImFontBuilderIO* ImFontAtlasGetBuilderForStbTruetype();
|
IMGUI_API const ImFontBuilderIO* ImFontAtlasGetBuilderForStbTruetype();
|
||||||
|
#endif
|
||||||
IMGUI_API void ImFontAtlasBuildInit(ImFontAtlas* atlas);
|
IMGUI_API void ImFontAtlasBuildInit(ImFontAtlas* atlas);
|
||||||
IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
|
IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
|
||||||
IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque);
|
IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque);
|
||||||
@ -2839,7 +2907,8 @@ extern const char* ImGuiTestEngine_FindItemDebugLabel(ImGuiContext* ctx, ImGuiI
|
|||||||
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS) // Register item label and status flags (optional)
|
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS) // Register item label and status flags (optional)
|
||||||
#define IMGUI_TEST_ENGINE_LOG(_FMT,...) if (g.TestEngineHookItems) ImGuiTestEngineHook_Log(&g, _FMT, __VA_ARGS__) // Custom log entry from user land into test log
|
#define IMGUI_TEST_ENGINE_LOG(_FMT,...) if (g.TestEngineHookItems) ImGuiTestEngineHook_Log(&g, _FMT, __VA_ARGS__) // Custom log entry from user land into test log
|
||||||
#else
|
#else
|
||||||
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) ((void)0)
|
#define IMGUI_TEST_ENGINE_ITEM_ADD(_BB,_ID) ((void)0)
|
||||||
|
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) ((void)g)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.86
|
// dear imgui, v1.87
|
||||||
// (tables and columns code)
|
// (tables and columns code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1569,18 +1569,21 @@ ImGuiTableColumnFlags ImGui::TableGetColumnFlags(int column_n)
|
|||||||
|
|
||||||
// Return the cell rectangle based on currently known height.
|
// Return the cell rectangle based on currently known height.
|
||||||
// - Important: we generally don't know our row height until the end of the row, so Max.y will be incorrect in many situations.
|
// - Important: we generally don't know our row height until the end of the row, so Max.y will be incorrect in many situations.
|
||||||
// The only case where this is correct is if we provided a min_row_height to TableNextRow() and don't go below it.
|
// The only case where this is correct is if we provided a min_row_height to TableNextRow() and don't go below it, or in TableEndRow() when we locked that height.
|
||||||
// - Important: if ImGuiTableFlags_PadOuterX is set but ImGuiTableFlags_PadInnerX is not set, the outer-most left and right
|
// - Important: if ImGuiTableFlags_PadOuterX is set but ImGuiTableFlags_PadInnerX is not set, the outer-most left and right
|
||||||
// columns report a small offset so their CellBgRect can extend up to the outer border.
|
// columns report a small offset so their CellBgRect can extend up to the outer border.
|
||||||
|
// FIXME: But the rendering code in TableEndRow() nullifies that with clamping required for scrolling.
|
||||||
ImRect ImGui::TableGetCellBgRect(const ImGuiTable* table, int column_n)
|
ImRect ImGui::TableGetCellBgRect(const ImGuiTable* table, int column_n)
|
||||||
{
|
{
|
||||||
const ImGuiTableColumn* column = &table->Columns[column_n];
|
const ImGuiTableColumn* column = &table->Columns[column_n];
|
||||||
float x1 = column->MinX;
|
float x1 = column->MinX;
|
||||||
float x2 = column->MaxX;
|
float x2 = column->MaxX;
|
||||||
if (column->PrevEnabledColumn == -1)
|
//if (column->PrevEnabledColumn == -1)
|
||||||
x1 -= table->CellSpacingX1;
|
// x1 -= table->OuterPaddingX;
|
||||||
if (column->NextEnabledColumn == -1)
|
//if (column->NextEnabledColumn == -1)
|
||||||
x2 += table->CellSpacingX2;
|
// x2 += table->OuterPaddingX;
|
||||||
|
x1 = ImMax(x1, table->WorkRect.Min.x);
|
||||||
|
x2 = ImMin(x2, table->WorkRect.Max.x);
|
||||||
return ImRect(x1, table->RowPosY1, x2, table->RowPosY2);
|
return ImRect(x1, table->RowPosY1, x2, table->RowPosY2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1797,10 +1800,12 @@ void ImGui::TableEndRow(ImGuiTable* table)
|
|||||||
ImGuiTableCellData* cell_data_end = &table->RowCellData[table->RowCellDataCurrent];
|
ImGuiTableCellData* cell_data_end = &table->RowCellData[table->RowCellDataCurrent];
|
||||||
for (ImGuiTableCellData* cell_data = &table->RowCellData[0]; cell_data <= cell_data_end; cell_data++)
|
for (ImGuiTableCellData* cell_data = &table->RowCellData[0]; cell_data <= cell_data_end; cell_data++)
|
||||||
{
|
{
|
||||||
|
// As we render the BG here we need to clip things (for layout we would not)
|
||||||
|
// FIXME: This cancels the OuterPadding addition done by TableGetCellBgRect(), need to keep it while rendering correctly while scrolling.
|
||||||
const ImGuiTableColumn* column = &table->Columns[cell_data->Column];
|
const ImGuiTableColumn* column = &table->Columns[cell_data->Column];
|
||||||
ImRect cell_bg_rect = TableGetCellBgRect(table, cell_data->Column);
|
ImRect cell_bg_rect = TableGetCellBgRect(table, cell_data->Column);
|
||||||
cell_bg_rect.ClipWith(table->BgClipRect);
|
cell_bg_rect.ClipWith(table->BgClipRect);
|
||||||
cell_bg_rect.Min.x = ImMax(cell_bg_rect.Min.x, column->ClipRect.Min.x); // So that first column after frozen one gets clipped
|
cell_bg_rect.Min.x = ImMax(cell_bg_rect.Min.x, column->ClipRect.Min.x); // So that first column after frozen one gets clipped when scrolling
|
||||||
cell_bg_rect.Max.x = ImMin(cell_bg_rect.Max.x, column->MaxX);
|
cell_bg_rect.Max.x = ImMin(cell_bg_rect.Max.x, column->MaxX);
|
||||||
window->DrawList->AddRectFilled(cell_bg_rect.Min, cell_bg_rect.Max, cell_data->BgColor);
|
window->DrawList->AddRectFilled(cell_bg_rect.Min, cell_bg_rect.Max, cell_data->BgColor);
|
||||||
}
|
}
|
||||||
@ -2353,7 +2358,7 @@ void ImGui::TableMergeDrawChannels(ImGuiTable* table)
|
|||||||
|
|
||||||
// Don't attempt to merge if there are multiple draw calls within the column
|
// Don't attempt to merge if there are multiple draw calls within the column
|
||||||
ImDrawChannel* src_channel = &splitter->_Channels[channel_no];
|
ImDrawChannel* src_channel = &splitter->_Channels[channel_no];
|
||||||
if (src_channel->_CmdBuffer.Size > 0 && src_channel->_CmdBuffer.back().ElemCount == 0)
|
if (src_channel->_CmdBuffer.Size > 0 && src_channel->_CmdBuffer.back().ElemCount == 0 && src_channel->_CmdBuffer.back().UserCallback != NULL) // Equivalent of PopUnusedDrawCmd()
|
||||||
src_channel->_CmdBuffer.pop_back();
|
src_channel->_CmdBuffer.pop_back();
|
||||||
if (src_channel->_CmdBuffer.Size != 1)
|
if (src_channel->_CmdBuffer.Size != 1)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.86
|
// dear imgui, v1.87
|
||||||
// (widgets code)
|
// (widgets code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -731,6 +731,7 @@ bool ImGui::SmallButton(const char* label)
|
|||||||
// Then you can keep 'str_id' empty or the same for all your buttons (instead of creating a string based on a non-string id)
|
// Then you can keep 'str_id' empty or the same for all your buttons (instead of creating a string based on a non-string id)
|
||||||
bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size_arg, ImGuiButtonFlags flags)
|
bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size_arg, ImGuiButtonFlags flags)
|
||||||
{
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
if (window->SkipItems)
|
if (window->SkipItems)
|
||||||
return false;
|
return false;
|
||||||
@ -748,16 +749,17 @@ bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size_arg, ImGuiBut
|
|||||||
bool hovered, held;
|
bool hovered, held;
|
||||||
bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags);
|
bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags);
|
||||||
|
|
||||||
|
IMGUI_TEST_ENGINE_ITEM_INFO(id, str_id, g.LastItemData.StatusFlags);
|
||||||
return pressed;
|
return pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiButtonFlags flags)
|
bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiButtonFlags flags)
|
||||||
{
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
if (window->SkipItems)
|
if (window->SkipItems)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ImGuiContext& g = *GImGui;
|
|
||||||
const ImGuiID id = window->GetID(str_id);
|
const ImGuiID id = window->GetID(str_id);
|
||||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
|
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
|
||||||
const float default_size = GetFrameHeight();
|
const float default_size = GetFrameHeight();
|
||||||
@ -778,6 +780,7 @@ bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiBu
|
|||||||
RenderFrame(bb.Min, bb.Max, bg_col, true, g.Style.FrameRounding);
|
RenderFrame(bb.Min, bb.Max, bg_col, true, g.Style.FrameRounding);
|
||||||
RenderArrow(window->DrawList, bb.Min + ImVec2(ImMax(0.0f, (size.x - g.FontSize) * 0.5f), ImMax(0.0f, (size.y - g.FontSize) * 0.5f)), text_col, dir);
|
RenderArrow(window->DrawList, bb.Min + ImVec2(ImMax(0.0f, (size.x - g.FontSize) * 0.5f), ImMax(0.0f, (size.y - g.FontSize) * 0.5f)), text_col, dir);
|
||||||
|
|
||||||
|
IMGUI_TEST_ENGINE_ITEM_INFO(id, str_id, g.LastItemData.StatusFlags);
|
||||||
return pressed;
|
return pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1992,24 +1995,10 @@ void ImGui::DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, const
|
|||||||
|
|
||||||
// User can input math operators (e.g. +100) to edit a numerical values.
|
// User can input math operators (e.g. +100) to edit a numerical values.
|
||||||
// NB: This is _not_ a full expression evaluator. We should probably add one and replace this dumb mess..
|
// NB: This is _not_ a full expression evaluator. We should probably add one and replace this dumb mess..
|
||||||
bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* p_data, const char* format)
|
bool ImGui::DataTypeApplyFromText(const char* buf, ImGuiDataType data_type, void* p_data, const char* format)
|
||||||
{
|
{
|
||||||
while (ImCharIsBlankA(*buf))
|
while (ImCharIsBlankA(*buf))
|
||||||
buf++;
|
buf++;
|
||||||
|
|
||||||
// We don't support '-' op because it would conflict with inputing negative value.
|
|
||||||
// Instead you can use +-100 to subtract from an existing value
|
|
||||||
char op = buf[0];
|
|
||||||
if (op == '+' || op == '*' || op == '/')
|
|
||||||
{
|
|
||||||
buf++;
|
|
||||||
while (ImCharIsBlankA(*buf))
|
|
||||||
buf++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
op = 0;
|
|
||||||
}
|
|
||||||
if (!buf[0])
|
if (!buf[0])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -2021,54 +2010,11 @@ bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
|||||||
if (format == NULL)
|
if (format == NULL)
|
||||||
format = type_info->ScanFmt;
|
format = type_info->ScanFmt;
|
||||||
|
|
||||||
// FIXME-LEGACY: The aim is to remove those operators and write a proper expression evaluator at some point..
|
if (data_type == ImGuiDataType_S32 || data_type == ImGuiDataType_U32 || data_type == ImGuiDataType_S64 || data_type == ImGuiDataType_U64 || data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double)
|
||||||
int arg1i = 0;
|
|
||||||
if (data_type == ImGuiDataType_S32)
|
|
||||||
{
|
{
|
||||||
int* v = (int*)p_data;
|
// For float/double we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in, so force them into %f and %lf
|
||||||
int arg0i = *v;
|
if (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double)
|
||||||
float arg1f = 0.0f;
|
format = type_info->ScanFmt;
|
||||||
if (op && sscanf(initial_value_buf, format, &arg0i) < 1)
|
|
||||||
return false;
|
|
||||||
// Store operand in a float so we can use fractional value for multipliers (*1.1), but constant always parsed as integer so we can fit big integers (e.g. 2000000003) past float precision
|
|
||||||
if (op == '+') { if (sscanf(buf, "%d", &arg1i)) *v = (int)(arg0i + arg1i); } // Add (use "+-" to subtract)
|
|
||||||
else if (op == '*') { if (sscanf(buf, "%f", &arg1f)) *v = (int)(arg0i * arg1f); } // Multiply
|
|
||||||
else if (op == '/') { if (sscanf(buf, "%f", &arg1f) && arg1f != 0.0f) *v = (int)(arg0i / arg1f); } // Divide
|
|
||||||
else { if (sscanf(buf, format, &arg1i) == 1) *v = arg1i; } // Assign constant
|
|
||||||
}
|
|
||||||
else if (data_type == ImGuiDataType_Float)
|
|
||||||
{
|
|
||||||
// For floats we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in
|
|
||||||
format = "%f";
|
|
||||||
float* v = (float*)p_data;
|
|
||||||
float arg0f = *v, arg1f = 0.0f;
|
|
||||||
if (op && sscanf(initial_value_buf, format, &arg0f) < 1)
|
|
||||||
return false;
|
|
||||||
if (sscanf(buf, format, &arg1f) < 1)
|
|
||||||
return false;
|
|
||||||
if (op == '+') { *v = arg0f + arg1f; } // Add (use "+-" to subtract)
|
|
||||||
else if (op == '*') { *v = arg0f * arg1f; } // Multiply
|
|
||||||
else if (op == '/') { if (arg1f != 0.0f) *v = arg0f / arg1f; } // Divide
|
|
||||||
else { *v = arg1f; } // Assign constant
|
|
||||||
}
|
|
||||||
else if (data_type == ImGuiDataType_Double)
|
|
||||||
{
|
|
||||||
format = "%lf"; // scanf differentiate float/double unlike printf which forces everything to double because of ellipsis
|
|
||||||
double* v = (double*)p_data;
|
|
||||||
double arg0f = *v, arg1f = 0.0;
|
|
||||||
if (op && sscanf(initial_value_buf, format, &arg0f) < 1)
|
|
||||||
return false;
|
|
||||||
if (sscanf(buf, format, &arg1f) < 1)
|
|
||||||
return false;
|
|
||||||
if (op == '+') { *v = arg0f + arg1f; } // Add (use "+-" to subtract)
|
|
||||||
else if (op == '*') { *v = arg0f * arg1f; } // Multiply
|
|
||||||
else if (op == '/') { if (arg1f != 0.0f) *v = arg0f / arg1f; } // Divide
|
|
||||||
else { *v = arg1f; } // Assign constant
|
|
||||||
}
|
|
||||||
else if (data_type == ImGuiDataType_U32 || data_type == ImGuiDataType_S64 || data_type == ImGuiDataType_U64)
|
|
||||||
{
|
|
||||||
// All other types assign constant
|
|
||||||
// We don't bother handling support for legacy operators since they are a little too crappy. Instead we will later implement a proper expression evaluator in the future.
|
|
||||||
if (sscanf(buf, format, p_data) < 1)
|
if (sscanf(buf, format, p_data) < 1)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -3387,8 +3333,6 @@ bool ImGui::TempInputText(const ImRect& bb, ImGuiID id, const char* label, char*
|
|||||||
// However this may not be ideal for all uses, as some user code may break on out of bound values.
|
// However this may not be ideal for all uses, as some user code may break on out of bound values.
|
||||||
bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min, const void* p_clamp_max)
|
bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min, const void* p_clamp_max)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
|
||||||
|
|
||||||
char fmt_buf[32];
|
char fmt_buf[32];
|
||||||
char data_buf[32];
|
char data_buf[32];
|
||||||
format = ImParseFormatTrimDecorations(format, fmt_buf, IM_ARRAYSIZE(fmt_buf));
|
format = ImParseFormatTrimDecorations(format, fmt_buf, IM_ARRAYSIZE(fmt_buf));
|
||||||
@ -3406,7 +3350,7 @@ bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImG
|
|||||||
memcpy(&data_backup, p_data, data_type_size);
|
memcpy(&data_backup, p_data, data_type_size);
|
||||||
|
|
||||||
// Apply new value (or operations) then clamp
|
// Apply new value (or operations) then clamp
|
||||||
DataTypeApplyOpFromText(data_buf, g.InputTextState.InitialTextA.Data, data_type, p_data, NULL);
|
DataTypeApplyFromText(data_buf, data_type, p_data, NULL);
|
||||||
if (p_clamp_min || p_clamp_max)
|
if (p_clamp_min || p_clamp_max)
|
||||||
{
|
{
|
||||||
if (p_clamp_min && p_clamp_max && DataTypeCompare(data_type, p_clamp_min, p_clamp_max) > 0)
|
if (p_clamp_min && p_clamp_max && DataTypeCompare(data_type, p_clamp_min, p_clamp_max) > 0)
|
||||||
@ -3453,7 +3397,7 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
|
|||||||
PushID(label);
|
PushID(label);
|
||||||
SetNextItemWidth(ImMax(1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2));
|
SetNextItemWidth(ImMax(1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2));
|
||||||
if (InputText("", buf, IM_ARRAYSIZE(buf), flags)) // PushId(label) + "" gives us the expected ID from outside point of view
|
if (InputText("", buf, IM_ARRAYSIZE(buf), flags)) // PushId(label) + "" gives us the expected ID from outside point of view
|
||||||
value_changed = DataTypeApplyOpFromText(buf, g.InputTextState.InitialTextA.Data, data_type, p_data, format);
|
value_changed = DataTypeApplyFromText(buf, data_type, p_data, format);
|
||||||
|
|
||||||
// Step buttons
|
// Step buttons
|
||||||
const ImVec2 backup_frame_padding = style.FramePadding;
|
const ImVec2 backup_frame_padding = style.FramePadding;
|
||||||
@ -3490,7 +3434,7 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (InputText(label, buf, IM_ARRAYSIZE(buf), flags))
|
if (InputText(label, buf, IM_ARRAYSIZE(buf), flags))
|
||||||
value_changed = DataTypeApplyOpFromText(buf, g.InputTextState.InitialTextA.Data, data_type, p_data, format);
|
value_changed = DataTypeApplyFromText(buf, data_type, p_data, format);
|
||||||
}
|
}
|
||||||
if (value_changed)
|
if (value_changed)
|
||||||
MarkItemEdited(g.LastItemData.ID);
|
MarkItemEdited(g.LastItemData.ID);
|
||||||
@ -4117,11 +4061,17 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
if (is_multiline || (flags & ImGuiInputTextFlags_CallbackHistory))
|
if (is_multiline || (flags & ImGuiInputTextFlags_CallbackHistory))
|
||||||
g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Up) | (1 << ImGuiDir_Down);
|
g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Up) | (1 << ImGuiDir_Down);
|
||||||
g.ActiveIdUsingNavInputMask |= (1 << ImGuiNavInput_Cancel);
|
g.ActiveIdUsingNavInputMask |= (1 << ImGuiNavInput_Cancel);
|
||||||
g.ActiveIdUsingKeyInputMask |= ((ImU64)1 << ImGuiKey_Home) | ((ImU64)1 << ImGuiKey_End);
|
SetActiveIdUsingKey(ImGuiKey_Home);
|
||||||
|
SetActiveIdUsingKey(ImGuiKey_End);
|
||||||
if (is_multiline)
|
if (is_multiline)
|
||||||
g.ActiveIdUsingKeyInputMask |= ((ImU64)1 << ImGuiKey_PageUp) | ((ImU64)1 << ImGuiKey_PageDown);
|
{
|
||||||
if (flags & (ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_AllowTabInput)) // Disable keyboard tabbing out as we will use the \t character.
|
SetActiveIdUsingKey(ImGuiKey_PageUp);
|
||||||
g.ActiveIdUsingKeyInputMask |= ((ImU64)1 << ImGuiKey_Tab);
|
SetActiveIdUsingKey(ImGuiKey_PageDown);
|
||||||
|
}
|
||||||
|
if (flags & (ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_AllowTabInput)) // Disable keyboard tabbing out as we will use the \t character.
|
||||||
|
{
|
||||||
|
SetActiveIdUsingKey(ImGuiKey_Tab);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have an edge case if ActiveId was set through another widget (e.g. widget being swapped), clear id immediately (don't wait until the end of the function)
|
// We have an edge case if ActiveId was set through another widget (e.g. widget being swapped), clear id immediately (don't wait until the end of the function)
|
||||||
@ -4251,7 +4201,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
// It is ill-defined whether the backend needs to send a \t character when pressing the TAB keys.
|
// It is ill-defined whether the backend needs to send a \t character when pressing the TAB keys.
|
||||||
// Win32 and GLFW naturally do it but not SDL.
|
// Win32 and GLFW naturally do it but not SDL.
|
||||||
const bool ignore_char_inputs = (io.KeyCtrl && !io.KeyAlt) || (is_osx && io.KeySuper);
|
const bool ignore_char_inputs = (io.KeyCtrl && !io.KeyAlt) || (is_osx && io.KeySuper);
|
||||||
if ((flags & ImGuiInputTextFlags_AllowTabInput) && IsKeyPressedMap(ImGuiKey_Tab) && !ignore_char_inputs && !io.KeyShift && !is_readonly)
|
if ((flags & ImGuiInputTextFlags_AllowTabInput) && IsKeyPressed(ImGuiKey_Tab) && !ignore_char_inputs && !io.KeyShift && !is_readonly)
|
||||||
if (!io.InputQueueCharacters.contains('\t'))
|
if (!io.InputQueueCharacters.contains('\t'))
|
||||||
{
|
{
|
||||||
unsigned int c = '\t'; // Insert TAB
|
unsigned int c = '\t'; // Insert TAB
|
||||||
@ -4298,27 +4248,27 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
const bool is_shift_key_only = (io.KeyMods == ImGuiKeyModFlags_Shift);
|
const bool is_shift_key_only = (io.KeyMods == ImGuiKeyModFlags_Shift);
|
||||||
const bool is_shortcut_key = g.IO.ConfigMacOSXBehaviors ? (io.KeyMods == ImGuiKeyModFlags_Super) : (io.KeyMods == ImGuiKeyModFlags_Ctrl);
|
const bool is_shortcut_key = g.IO.ConfigMacOSXBehaviors ? (io.KeyMods == ImGuiKeyModFlags_Super) : (io.KeyMods == ImGuiKeyModFlags_Ctrl);
|
||||||
|
|
||||||
const bool is_cut = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_X)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Delete))) && !is_readonly && !is_password && (!is_multiline || state->HasSelection());
|
const bool is_cut = ((is_shortcut_key && IsKeyPressed(ImGuiKey_X)) || (is_shift_key_only && IsKeyPressed(ImGuiKey_Delete))) && !is_readonly && !is_password && (!is_multiline || state->HasSelection());
|
||||||
const bool is_copy = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_C)) || (is_ctrl_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && !is_password && (!is_multiline || state->HasSelection());
|
const bool is_copy = ((is_shortcut_key && IsKeyPressed(ImGuiKey_C)) || (is_ctrl_key_only && IsKeyPressed(ImGuiKey_Insert))) && !is_password && (!is_multiline || state->HasSelection());
|
||||||
const bool is_paste = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_V)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && !is_readonly;
|
const bool is_paste = ((is_shortcut_key && IsKeyPressed(ImGuiKey_V)) || (is_shift_key_only && IsKeyPressed(ImGuiKey_Insert))) && !is_readonly;
|
||||||
const bool is_undo = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_Z)) && !is_readonly && is_undoable);
|
const bool is_undo = ((is_shortcut_key && IsKeyPressed(ImGuiKey_Z)) && !is_readonly && is_undoable);
|
||||||
const bool is_redo = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_Y)) || (is_osx_shift_shortcut && IsKeyPressedMap(ImGuiKey_Z))) && !is_readonly && is_undoable;
|
const bool is_redo = ((is_shortcut_key && IsKeyPressed(ImGuiKey_Y)) || (is_osx_shift_shortcut && IsKeyPressed(ImGuiKey_Z))) && !is_readonly && is_undoable;
|
||||||
|
|
||||||
// We allow validate/cancel with Nav source (gamepad) to makes it easier to undo an accidental NavInput press with no keyboard wired, but otherwise it isn't very useful.
|
// We allow validate/cancel with Nav source (gamepad) to makes it easier to undo an accidental NavInput press with no keyboard wired, but otherwise it isn't very useful.
|
||||||
const bool is_validate_enter = IsKeyPressedMap(ImGuiKey_Enter) || IsKeyPressedMap(ImGuiKey_KeyPadEnter);
|
const bool is_validate_enter = IsKeyPressed(ImGuiKey_Enter) || IsKeyPressed(ImGuiKey_KeypadEnter);
|
||||||
const bool is_validate_nav = (IsNavInputTest(ImGuiNavInput_Activate, ImGuiInputReadMode_Pressed) && !IsKeyPressedMap(ImGuiKey_Space)) || IsNavInputTest(ImGuiNavInput_Input, ImGuiInputReadMode_Pressed);
|
const bool is_validate_nav = (IsNavInputTest(ImGuiNavInput_Activate, ImGuiInputReadMode_Pressed) && !IsKeyPressed(ImGuiKey_Space)) || IsNavInputTest(ImGuiNavInput_Input, ImGuiInputReadMode_Pressed);
|
||||||
const bool is_cancel = IsKeyPressedMap(ImGuiKey_Escape) || IsNavInputTest(ImGuiNavInput_Cancel, ImGuiInputReadMode_Pressed);
|
const bool is_cancel = IsKeyPressed(ImGuiKey_Escape) || IsNavInputTest(ImGuiNavInput_Cancel, ImGuiInputReadMode_Pressed);
|
||||||
|
|
||||||
if (IsKeyPressedMap(ImGuiKey_LeftArrow)) { state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINESTART : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDLEFT : STB_TEXTEDIT_K_LEFT) | k_mask); }
|
if (IsKeyPressed(ImGuiKey_LeftArrow)) { state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINESTART : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDLEFT : STB_TEXTEDIT_K_LEFT) | k_mask); }
|
||||||
else if (IsKeyPressedMap(ImGuiKey_RightArrow)) { state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINEEND : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDRIGHT : STB_TEXTEDIT_K_RIGHT) | k_mask); }
|
else if (IsKeyPressed(ImGuiKey_RightArrow)) { state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINEEND : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDRIGHT : STB_TEXTEDIT_K_RIGHT) | k_mask); }
|
||||||
else if (IsKeyPressedMap(ImGuiKey_UpArrow) && is_multiline) { if (io.KeyCtrl) SetScrollY(draw_window, ImMax(draw_window->Scroll.y - g.FontSize, 0.0f)); else state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTSTART : STB_TEXTEDIT_K_UP) | k_mask); }
|
else if (IsKeyPressed(ImGuiKey_UpArrow) && is_multiline) { if (io.KeyCtrl) SetScrollY(draw_window, ImMax(draw_window->Scroll.y - g.FontSize, 0.0f)); else state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTSTART : STB_TEXTEDIT_K_UP) | k_mask); }
|
||||||
else if (IsKeyPressedMap(ImGuiKey_DownArrow) && is_multiline) { if (io.KeyCtrl) SetScrollY(draw_window, ImMin(draw_window->Scroll.y + g.FontSize, GetScrollMaxY())); else state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTEND : STB_TEXTEDIT_K_DOWN) | k_mask); }
|
else if (IsKeyPressed(ImGuiKey_DownArrow) && is_multiline) { if (io.KeyCtrl) SetScrollY(draw_window, ImMin(draw_window->Scroll.y + g.FontSize, GetScrollMaxY())); else state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTEND : STB_TEXTEDIT_K_DOWN) | k_mask); }
|
||||||
else if (IsKeyPressedMap(ImGuiKey_PageUp) && is_multiline) { state->OnKeyPressed(STB_TEXTEDIT_K_PGUP | k_mask); scroll_y -= row_count_per_page * g.FontSize; }
|
else if (IsKeyPressed(ImGuiKey_PageUp) && is_multiline) { state->OnKeyPressed(STB_TEXTEDIT_K_PGUP | k_mask); scroll_y -= row_count_per_page * g.FontSize; }
|
||||||
else if (IsKeyPressedMap(ImGuiKey_PageDown) && is_multiline) { state->OnKeyPressed(STB_TEXTEDIT_K_PGDOWN | k_mask); scroll_y += row_count_per_page * g.FontSize; }
|
else if (IsKeyPressed(ImGuiKey_PageDown) && is_multiline) { state->OnKeyPressed(STB_TEXTEDIT_K_PGDOWN | k_mask); scroll_y += row_count_per_page * g.FontSize; }
|
||||||
else if (IsKeyPressedMap(ImGuiKey_Home)) { state->OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTSTART | k_mask : STB_TEXTEDIT_K_LINESTART | k_mask); }
|
else if (IsKeyPressed(ImGuiKey_Home)) { state->OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTSTART | k_mask : STB_TEXTEDIT_K_LINESTART | k_mask); }
|
||||||
else if (IsKeyPressedMap(ImGuiKey_End)) { state->OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTEND | k_mask : STB_TEXTEDIT_K_LINEEND | k_mask); }
|
else if (IsKeyPressed(ImGuiKey_End)) { state->OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTEND | k_mask : STB_TEXTEDIT_K_LINEEND | k_mask); }
|
||||||
else if (IsKeyPressedMap(ImGuiKey_Delete) && !is_readonly && !is_cut) { state->OnKeyPressed(STB_TEXTEDIT_K_DELETE | k_mask); }
|
else if (IsKeyPressed(ImGuiKey_Delete) && !is_readonly && !is_cut) { state->OnKeyPressed(STB_TEXTEDIT_K_DELETE | k_mask); }
|
||||||
else if (IsKeyPressedMap(ImGuiKey_Backspace) && !is_readonly)
|
else if (IsKeyPressed(ImGuiKey_Backspace) && !is_readonly)
|
||||||
{
|
{
|
||||||
if (!state->HasSelection())
|
if (!state->HasSelection())
|
||||||
{
|
{
|
||||||
@ -4357,7 +4307,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
state->OnKeyPressed(is_undo ? STB_TEXTEDIT_K_UNDO : STB_TEXTEDIT_K_REDO);
|
state->OnKeyPressed(is_undo ? STB_TEXTEDIT_K_UNDO : STB_TEXTEDIT_K_REDO);
|
||||||
state->ClearSelection();
|
state->ClearSelection();
|
||||||
}
|
}
|
||||||
else if (is_shortcut_key && IsKeyPressedMap(ImGuiKey_A))
|
else if (is_shortcut_key && IsKeyPressed(ImGuiKey_A))
|
||||||
{
|
{
|
||||||
state->SelectAll();
|
state->SelectAll();
|
||||||
state->CursorFollow = true;
|
state->CursorFollow = true;
|
||||||
@ -4463,18 +4413,18 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
|
|
||||||
// The reason we specify the usage semantic (Completion/History) is that Completion needs to disable keyboard TABBING at the moment.
|
// The reason we specify the usage semantic (Completion/History) is that Completion needs to disable keyboard TABBING at the moment.
|
||||||
ImGuiInputTextFlags event_flag = 0;
|
ImGuiInputTextFlags event_flag = 0;
|
||||||
ImGuiKey event_key = ImGuiKey_COUNT;
|
ImGuiKey event_key = ImGuiKey_None;
|
||||||
if ((flags & ImGuiInputTextFlags_CallbackCompletion) != 0 && IsKeyPressedMap(ImGuiKey_Tab))
|
if ((flags & ImGuiInputTextFlags_CallbackCompletion) != 0 && IsKeyPressed(ImGuiKey_Tab))
|
||||||
{
|
{
|
||||||
event_flag = ImGuiInputTextFlags_CallbackCompletion;
|
event_flag = ImGuiInputTextFlags_CallbackCompletion;
|
||||||
event_key = ImGuiKey_Tab;
|
event_key = ImGuiKey_Tab;
|
||||||
}
|
}
|
||||||
else if ((flags & ImGuiInputTextFlags_CallbackHistory) != 0 && IsKeyPressedMap(ImGuiKey_UpArrow))
|
else if ((flags & ImGuiInputTextFlags_CallbackHistory) != 0 && IsKeyPressed(ImGuiKey_UpArrow))
|
||||||
{
|
{
|
||||||
event_flag = ImGuiInputTextFlags_CallbackHistory;
|
event_flag = ImGuiInputTextFlags_CallbackHistory;
|
||||||
event_key = ImGuiKey_UpArrow;
|
event_key = ImGuiKey_UpArrow;
|
||||||
}
|
}
|
||||||
else if ((flags & ImGuiInputTextFlags_CallbackHistory) != 0 && IsKeyPressedMap(ImGuiKey_DownArrow))
|
else if ((flags & ImGuiInputTextFlags_CallbackHistory) != 0 && IsKeyPressed(ImGuiKey_DownArrow))
|
||||||
{
|
{
|
||||||
event_flag = ImGuiInputTextFlags_CallbackHistory;
|
event_flag = ImGuiInputTextFlags_CallbackHistory;
|
||||||
event_key = ImGuiKey_DownArrow;
|
event_key = ImGuiKey_DownArrow;
|
||||||
@ -4760,7 +4710,11 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
|
|
||||||
// Notify OS of text input position for advanced IME (-1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.)
|
// Notify OS of text input position for advanced IME (-1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.)
|
||||||
if (!is_readonly)
|
if (!is_readonly)
|
||||||
g.PlatformImePos = ImVec2(cursor_screen_pos.x - 1.0f, cursor_screen_pos.y - g.FontSize);
|
{
|
||||||
|
g.PlatformImeData.WantVisible = true;
|
||||||
|
g.PlatformImeData.InputPos = ImVec2(cursor_screen_pos.x - 1.0f, cursor_screen_pos.y - g.FontSize);
|
||||||
|
g.PlatformImeData.InputLineHeight = g.FontSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -4973,7 +4927,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
value_changed |= DragInt(ids[n], &i[n], 1.0f, 0, hdr ? 0 : 255, fmt_table_int[fmt_idx][n]);
|
value_changed |= DragInt(ids[n], &i[n], 1.0f, 0, hdr ? 0 : 255, fmt_table_int[fmt_idx][n]);
|
||||||
}
|
}
|
||||||
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
||||||
OpenPopupOnItemClick("context");
|
OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((flags & ImGuiColorEditFlags_DisplayHex) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
|
else if ((flags & ImGuiColorEditFlags_DisplayHex) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
|
||||||
@ -5001,7 +4955,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
IM_UNUSED(r); // Fixes C6031: Return value ignored: 'sscanf'.
|
IM_UNUSED(r); // Fixes C6031: Return value ignored: 'sscanf'.
|
||||||
}
|
}
|
||||||
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
||||||
OpenPopupOnItemClick("context");
|
OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiWindow* picker_active_window = NULL;
|
ImGuiWindow* picker_active_window = NULL;
|
||||||
@ -5018,11 +4972,11 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
// Store current color and open a picker
|
// Store current color and open a picker
|
||||||
g.ColorPickerRef = col_v4;
|
g.ColorPickerRef = col_v4;
|
||||||
OpenPopup("picker");
|
OpenPopup("picker");
|
||||||
SetNextWindowPos(g.LastItemData.Rect.GetBL() + ImVec2(-1, style.ItemSpacing.y));
|
SetNextWindowPos(g.LastItemData.Rect.GetBL() + ImVec2(0.0f, style.ItemSpacing.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
||||||
OpenPopupOnItemClick("context");
|
OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
|
||||||
|
|
||||||
if (BeginPopup("picker"))
|
if (BeginPopup("picker"))
|
||||||
{
|
{
|
||||||
@ -5236,7 +5190,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
||||||
OpenPopupOnItemClick("context");
|
OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
|
||||||
}
|
}
|
||||||
else if (flags & ImGuiColorEditFlags_PickerHueBar)
|
else if (flags & ImGuiColorEditFlags_PickerHueBar)
|
||||||
{
|
{
|
||||||
@ -5253,7 +5207,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
value_changed = value_changed_sv = true;
|
value_changed = value_changed_sv = true;
|
||||||
}
|
}
|
||||||
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
||||||
OpenPopupOnItemClick("context");
|
OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
|
||||||
|
|
||||||
// Hue bar logic
|
// Hue bar logic
|
||||||
SetCursorScreenPos(ImVec2(bar0_pos_x, picker_pos.y));
|
SetCursorScreenPos(ImVec2(bar0_pos_x, picker_pos.y));
|
||||||
@ -6934,6 +6888,7 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
BeginDisabled();
|
BeginDisabled();
|
||||||
const ImGuiMenuColumns* offsets = &window->DC.MenuColumns;
|
const ImGuiMenuColumns* offsets = &window->DC.MenuColumns;
|
||||||
bool pressed;
|
bool pressed;
|
||||||
|
const ImGuiSelectableFlags selectable_flags = ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups;
|
||||||
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
||||||
{
|
{
|
||||||
// Menu inside an horizontal menu bar
|
// Menu inside an horizontal menu bar
|
||||||
@ -6944,7 +6899,7 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y));
|
PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y));
|
||||||
float w = label_size.x;
|
float w = label_size.x;
|
||||||
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
||||||
pressed = Selectable("", menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups, ImVec2(w, 0.0f));
|
pressed = Selectable("", menu_is_open, selectable_flags, ImVec2(w, 0.0f));
|
||||||
RenderText(text_pos, label);
|
RenderText(text_pos, label);
|
||||||
PopStyleVar();
|
PopStyleVar();
|
||||||
window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar().
|
window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar().
|
||||||
@ -6960,7 +6915,7 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, 0.0f, checkmark_w); // Feedback to next frame
|
float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, 0.0f, checkmark_w); // Feedback to next frame
|
||||||
float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
|
float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
|
||||||
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
||||||
pressed = Selectable("", menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, 0.0f));
|
pressed = Selectable("", menu_is_open, selectable_flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, 0.0f));
|
||||||
RenderText(text_pos, label);
|
RenderText(text_pos, label);
|
||||||
if (icon_w > 0.0f)
|
if (icon_w > 0.0f)
|
||||||
RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon);
|
RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon);
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.)
|
// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.)
|
||||||
// This is also an example of how you may wrap your own similar types.
|
// This is also an example of how you may wrap your own similar types.
|
||||||
|
|
||||||
// Compatibility:
|
|
||||||
// - std::string support is only guaranteed to work from C++11.
|
|
||||||
// If you try to use it pre-C++11, please share your findings (w/ info about compiler/architecture)
|
|
||||||
|
|
||||||
// Changelog:
|
// Changelog:
|
||||||
// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string
|
// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string
|
||||||
|
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.)
|
// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.)
|
||||||
// This is also an example of how you may wrap your own similar types.
|
// This is also an example of how you may wrap your own similar types.
|
||||||
|
|
||||||
// Compatibility:
|
|
||||||
// - std::string support is only guaranteed to work from C++11.
|
|
||||||
// If you try to use it pre-C++11, please share your findings (w/ info about compiler/architecture)
|
|
||||||
|
|
||||||
// Changelog:
|
// Changelog:
|
||||||
// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string
|
// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string
|
||||||
|
|
||||||
|
@ -26,12 +26,12 @@ See https://gist.github.com/ocornut/b3a9ecf13502fd818799a452969649ad
|
|||||||
|
|
||||||
### Comparaison
|
### Comparaison
|
||||||
|
|
||||||
Small, thin anti-aliased fonts are typically benefiting a lots from Freetype's hinting:
|
Small, thin anti-aliased fonts typically benefit a lot from FreeType's hinting:
|
||||||

|

|
||||||
|
|
||||||
### Colorful glyphs/emojis
|
### Colorful glyphs/emojis
|
||||||
|
|
||||||
You can use the `ImGuiFreeTypeBuilderFlags_LoadColor` flag to load certain colorful glyphs. See
|
You can use the `ImGuiFreeTypeBuilderFlags_LoadColor` flag to load certain colorful glyphs. See the
|
||||||
["Using Colorful Glyphs/Emojis"](https://github.com/ocornut/imgui/edit/master/docs/FONTS.md#using-colorful-glyphsemojis) section of FONTS.md.
|
["Using Colorful Glyphs/Emojis"](https://github.com/ocornut/imgui/edit/master/docs/FONTS.md#using-colorful-glyphsemojis) section of FONTS.md.
|
||||||
|
|
||||||

|

|
||||||
|
Reference in New Issue
Block a user