diff --git a/.github/issue_template.md b/.github/issue_template.md
index 4fe6119c..fdd09439 100644
--- a/.github/issue_template.md
+++ b/.github/issue_template.md
@@ -1,12 +1,12 @@
(Click "Preview" above ^ to turn URL into clickable links)
-1. PLEASE CAREFULLY READ: [FAQ](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md)
+1. FOR FIRST-TIME USERS ISSUES COMPILING/LINKING/RUNNING or LOADING FONTS, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions).
-2. PLEASE CAREFULLY READ: [Issue Submitting Guidelines](https://github.com/ocornut/imgui/issues/2261)
+2. PLEASE CAREFULLY READ: [FAQ](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md)
-3. FOR FIRST-TIME USERS ISSUES COMPILING/LINKING/RUNNING/LOADING FONTS, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions).
+3. PLEASE CAREFULLY READ: [Issue Submitting Guidelines](https://github.com/ocornut/imgui/issues/2261)
-4. PLEASE MAKE SURE that you have: read the FAQ; explored the contents of `ShowDemoWindow()` including the Examples menu; searched among Issues; used your IDE to search for keywords in all sources and text files; and read the link provided in (1) (2).
+4. PLEASE MAKE SURE that you have: read the FAQ; explored the contents of `ShowDemoWindow()` including the Examples menu; searched among Issues; used your IDE to search for keywords in all sources and text files; and read the links above.
5. Be mindful that messages are being sent to the e-mail box of "Watching" users. Try to proof-read your messages before sending them. Edits are not seen by those users.
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index 533027c9..187d7105 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -1,6 +1,6 @@
(Click "Preview" to turn any http URL into a clickable link)
-PLEASE CAREFULLY READ:
-https://github.com/ocornut/imgui/issues/2261
+1. PLEASE CAREFULLY READ: [Issue Submitting Guidelines](https://github.com/ocornut/imgui/issues/2261)
+
+2. Clear this template before submitting your PR.
-(Clear this template before submitting your PR)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 09b09e71..a667bd58 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -37,20 +37,30 @@ jobs:
- name: Fix Projects
shell: powershell
run: |
- # WARNING: This will need updating if toolset/sdk change in project files!
+ # CI workers do not supporter older Visual Studio versions. Fix projects to target newer available version.
gci -recurse -filter "*.vcxproj" | ForEach-Object {
- # Fix SDK and toolset for most samples.
- (Get-Content $_.FullName) -Replace "v110","v142" | Set-Content -Path $_.FullName
- (Get-Content $_.FullName) -Replace "8.1","10.0.18362.0" | Set-Content -Path $_.FullName
- # Fix SDK and toolset for samples that require newer SDK/toolset. At the moment it is only dx12.
- (Get-Content $_.FullName) -Replace "v140","v142" | Set-Content -Path $_.FullName
- (Get-Content $_.FullName) -Replace "10.0.14393.0","10.0.18362.0" | Set-Content -Path $_.FullName
+ (Get-Content $_.FullName) -Replace "v\d{3}","v142" | Set-Content -Path $_.FullName
+ (Get-Content $_.FullName) -Replace "[\d\.]+","10.0.18362.0" | Set-Content -Path $_.FullName
}
# Not using matrix here because it would inflate job count too much. Check out and setup is done for every job and that makes build times way too long.
- name: Build example_null (extra warnings, mingw 64-bit)
run: mingw32-make -C examples/example_null WITH_EXTRA_WARNINGS=1
+ - name: Build example_null (mingw 64-bit, as DLL)
+ shell: bash
+ run: |
+ echo '#ifdef _EXPORT' > example_single_file.cpp
+ echo '# define IMGUI_API __declspec(dllexport)' >> example_single_file.cpp
+ echo '#else' >> example_single_file.cpp
+ echo '# define IMGUI_API __declspec(dllimport)' >> example_single_file.cpp
+ echo '#endif' >> example_single_file.cpp
+ echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
+ echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
+ g++ -I. -Wall -Wformat -D_EXPORT -shared -o libimgui.dll -Wl,--out-implib,libimgui.a example_single_file.cpp -limm32
+ g++ -I. -Wall -Wformat -o example_null.exe examples/example_null/main.cpp -L. -limgui
+ rm -f example_null.exe libimgui.* example_single_file.*
+
- name: Build example_null (extra warnings, msvc 64-bit)
shell: cmd
run: |
@@ -226,6 +236,18 @@ jobs:
make -C examples/example_null clean
CXXFLAGS="$CXXFLAGS -m64 -Werror" CXX=clang++ make -C examples/example_null WITH_EXTRA_WARNINGS=1
+ - name: Build example_null (extra warnings, empty IM_ASSERT)
+ run: |
+ cat > example_single_file.cpp <<'EOF'
+
+ #define IM_ASSERT(x)
+ #define IMGUI_IMPLEMENTATION
+ #include "misc/single_file/imgui_single_file.h"
+ #include "examples/example_null/main.cpp"
+
+ EOF
+ g++ -I. -Wall -Wformat -Wextra -Werror -Wno-zero-as-null-pointer-constant -Wno-double-promotion -Wno-variadic-macros -Wno-empty-body -o example_single_file example_single_file.cpp
+
- name: Build example_null (freetype)
run: |
make -C examples/example_null clean
@@ -279,6 +301,18 @@ jobs:
EOF
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)
run: |
cat > example_single_file.cpp <<'EOF'
@@ -471,34 +505,3 @@ jobs:
run: |
cd examples/example_android_opengl3/android
gradle assembleDebug
-
- Discord-CI:
- runs-on: ubuntu-18.04
- if: always()
- needs: [Windows, Linux, MacOS, iOS, Emscripten, Android]
- steps:
- - uses: dearimgui/github_discord_notifier@latest
- with:
- discord-webhook: ${{ secrets.DISCORD_CI_WEBHOOK }}
- github-token: ${{ github.token }}
- action-task: discord-jobs
- discord-filter: "'{{ github.branch }}'.match(/master|docking/g) != null && '{{ run.conclusion }}' != '{{ last_run.conclusion }}'"
- discord-username: GitHub Actions
- discord-job-new-failure-message: ''
- discord-job-fixed-failure-message: ''
- discord-job-new-failure-embed: |
- {
- "title": "`{{ job.name }}` job is failing on `{{ github.branch }}`!",
- "description": "Commit [{{ github.context.payload.head_commit.title }}]({{ github.context.payload.head_commit.url }}) pushed to [{{ github.branch }}]({{ github.branch_url }}) broke [{{ job.name }}]({{ job.url }}) build job.\nFailing steps: {{ failing_steps }}",
- "url": "{{ job.url }}",
- "color": "0xFF0000",
- "timestamp": "{{ run.updated_at }}"
- }
- discord-job-fixed-failure-embed: |
- {
- "title": "`{{ github.branch }}` branch is no longer failing!",
- "description": "Build failures were fixed on [{{ github.branch }}]({{ github.branch_url }}) branch.",
- "color": "0x00FF00",
- "url": "{{ github.context.payload.head_commit.url }}",
- "timestamp": "{{ run.completed_at }}"
- }
diff --git a/LICENSE.txt b/LICENSE.txt
index 780533dc..4023e0ca 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,6 +1,6 @@
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
of this software and associated documentation files (the "Software"), to deal
diff --git a/backends/imgui_impl_allegro5.cpp b/backends/imgui_impl_allegro5.cpp
index 6a7af437..dcc806a6 100644
--- a/backends/imgui_impl_allegro5.cpp
+++ b/backends/imgui_impl_allegro5.cpp
@@ -3,6 +3,7 @@
// Implemented features:
// [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: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// Issues:
@@ -16,6 +17,11 @@
// CHANGELOG
// (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-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-05-19: Renderer: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
@@ -155,7 +161,6 @@ void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data)
}
// Render command lists
- int idx_offset = 0;
ImVec2 clip_off = draw_data->DisplayPos;
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
@@ -171,12 +176,17 @@ void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data)
}
else
{
- // Draw
+ // Project scissor/clipping rectangles into framebuffer space
+ ImVec2 clip_min(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_off.y);
+ ImVec2 clip_max(pcmd->ClipRect.z - clip_off.x, pcmd->ClipRect.w - clip_off.y);
+ if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
+ continue;
+
+ // Apply scissor/clipping rectangle, Draw
ALLEGRO_BITMAP* texture = (ALLEGRO_BITMAP*)pcmd->GetTexID();
- al_set_clipping_rectangle(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_off.y, pcmd->ClipRect.z - pcmd->ClipRect.x, pcmd->ClipRect.w - pcmd->ClipRect.y);
- al_draw_prim(&vertices[0], bd->VertexDecl, texture, idx_offset, idx_offset + pcmd->ElemCount, ALLEGRO_PRIM_TRIANGLE_LIST);
+ al_set_clipping_rectangle(clip_min.x, clip_min.y, clip_max.x - clip_min.x, clip_max.y - clip_min.y);
+ al_draw_prim(&vertices[0], bd->VertexDecl, texture, pcmd->IdxOffset, pcmd->IdxOffset + pcmd->ElemCount, ALLEGRO_PRIM_TRIANGLE_LIST);
}
- idx_offset += pcmd->ElemCount;
}
}
@@ -269,6 +279,119 @@ static void ImGui_ImplAllegro5_SetClipboardText(void*, const char* text)
}
#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)
{
ImGuiIO& io = ImGui::GetIO();
@@ -294,30 +417,6 @@ bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
};
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
io.SetClipboardTextFn = ImGui_ImplAllegro5_SetClipboardText;
io.GetClipboardTextFn = ImGui_ImplAllegro5_GetClipboardText;
@@ -329,8 +428,9 @@ bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
void ImGui_ImplAllegro5_Shutdown()
{
- ImGuiIO& io = ImGui::GetIO();
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
+ IM_ASSERT(bd != NULL && "No platform backend to shutdown, or already shutdown?");
+ ImGuiIO& io = ImGui::GetIO();
ImGui_ImplAllegro5_InvalidateDeviceObjects();
if (bd->VertexDecl)
@@ -343,6 +443,18 @@ void ImGui_ImplAllegro5_Shutdown()
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.
// - 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.
@@ -357,29 +469,28 @@ bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT* ev)
case ALLEGRO_EVENT_MOUSE_AXES:
if (ev->mouse.display == bd->Display)
{
- io.MouseWheel += ev->mouse.dz;
- io.MouseWheelH -= ev->mouse.dw;
- io.MousePos = ImVec2(ev->mouse.x, ev->mouse.y);
+ io.AddMousePosEvent(ev->mouse.x, ev->mouse.y);
+ io.AddMouseWheelEvent(-ev->mouse.dw, ev->mouse.dz);
}
return true;
case ALLEGRO_EVENT_MOUSE_BUTTON_DOWN:
case ALLEGRO_EVENT_MOUSE_BUTTON_UP:
- if (ev->mouse.display == bd->Display && ev->mouse.button <= 5)
- io.MouseDown[ev->mouse.button - 1] = (ev->type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN);
+ if (ev->mouse.display == bd->Display && ev->mouse.button > 0 && ev->mouse.button <= 5)
+ io.AddMouseButtonEvent(ev->mouse.button - 1, ev->type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN);
return true;
case ALLEGRO_EVENT_TOUCH_MOVE:
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;
case ALLEGRO_EVENT_TOUCH_BEGIN:
case ALLEGRO_EVENT_TOUCH_END:
case ALLEGRO_EVENT_TOUCH_CANCEL:
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;
case ALLEGRO_EVENT_MOUSE_LEAVE_DISPLAY:
if (ev->mouse.display == bd->Display)
- io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
+ io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
return true;
case ALLEGRO_EVENT_KEY_CHAR:
if (ev->keyboard.display == bd->Display)
@@ -389,7 +500,12 @@ bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT* ev)
case ALLEGRO_EVENT_KEY_DOWN:
case ALLEGRO_EVENT_KEY_UP:
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;
case ALLEGRO_EVENT_DISPLAY_SWITCH_OUT:
if (ev->display.source == bd->Display)
@@ -459,13 +575,6 @@ void ImGui_ImplAllegro5_NewFrame()
io.DeltaTime = bd->Time > 0.0 ? (float)(current_time - bd->Time) : (float)(1.0f / 60.0f);
bd->Time = current_time;
- // Setup inputs
- 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);
-
+ // Setup mouse cursor shape
ImGui_ImplAllegro5_UpdateMouseCursor();
}
diff --git a/backends/imgui_impl_allegro5.h b/backends/imgui_impl_allegro5.h
index 06c7120b..7e97969e 100644
--- a/backends/imgui_impl_allegro5.h
+++ b/backends/imgui_impl_allegro5.h
@@ -3,13 +3,14 @@
// Implemented features:
// [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: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// Issues:
// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually.
// [ ] 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.
// 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
diff --git a/backends/imgui_impl_android.cpp b/backends/imgui_impl_android.cpp
index aae8e6b8..bb8de811 100644
--- a/backends/imgui_impl_android.cpp
+++ b/backends/imgui_impl_android.cpp
@@ -2,29 +2,31 @@
// This needs to be used along with the OpenGL 3 Renderer (imgui_impl_opengl3)
// 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:
// [ ] Platform: Clipboard support.
// [ ] 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.
// 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: 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.
// 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
// CHANGELOG
// (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.
#include "imgui.h"
#include "imgui_impl_android.h"
#include
-#include