From bebb07f12da512694a14f12195695357251bc568 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 17 Jan 2019 16:48:11 +0100 Subject: [PATCH 1/4] ImFontAtlas: Added 0x2000-0x206F general punctuation range to default ChineseFull/ChineseSimplifiedCommon ranges. (#2093) --- docs/CHANGELOG.txt | 3 ++- imgui_draw.cpp | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 01380d36a..05d266223 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -37,7 +37,8 @@ Other Changes: - Added .editorconfig file for text editors to standardize using spaces. (#2038) [@kudaba] - ImDrawList: Fixed AddCircle(), AddCircleFilled() angle step being off, which was visible when drawing a "circle" with a small number of segments (e.g. an hexagon). (#2287) [@baktery] -- Fonts: imgui_freetype: Added support for imgui allocators + custom FreeType only SetAllocatorFunctions. (#2285) [@Vuhdo] +- ImFontAtlas: Added 0x2000-0x206F general punctuation range to default ChineseFull/ChineseSimplifiedCommon ranges. (#2093) +- ImFontAtlas: FreeType: Added support for imgui allocators + custom FreeType only SetAllocatorFunctions. (#2285) [@Vuhdo] - Examples: Win32: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created in a different thread or parent. (#1951, #2087, #2156, #2232) [many people] - Examples: Win32: Added support for XInput games (if ImGuiConfigFlags_NavEnableGamepad is enabled). diff --git a/imgui_draw.cpp b/imgui_draw.cpp index f20f15ab7..a3c48fc8a 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -2167,7 +2167,8 @@ const ImWchar* ImFontAtlas::GetGlyphRangesChineseFull() static const ImWchar ranges[] = { 0x0020, 0x00FF, // Basic Latin + Latin Supplement - 0x3000, 0x30FF, // Punctuations, Hiragana, Katakana + 0x2000, 0x206F, // General Punctuation + 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana 0x31F0, 0x31FF, // Katakana Phonetic Extensions 0xFF00, 0xFFEF, // Half-width characters 0x4e00, 0x9FAF, // CJK Ideograms @@ -2243,9 +2244,10 @@ const ImWchar* ImFontAtlas::GetGlyphRangesChineseSimplifiedCommon() static ImWchar base_ranges[] = // not zero-terminated { 0x0020, 0x00FF, // Basic Latin + Latin Supplement - 0x3000, 0x30FF, // Punctuations, Hiragana, Katakana + 0x2000, 0x206F, // General Punctuation + 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana 0x31F0, 0x31FF, // Katakana Phonetic Extensions - 0xFF00, 0xFFEF, // Half-width characters + 0xFF00, 0xFFEF // Half-width characters }; static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00) * 2 + 1] = { 0 }; if (!full_ranges[0]) @@ -2301,9 +2303,9 @@ const ImWchar* ImFontAtlas::GetGlyphRangesJapanese() static ImWchar base_ranges[] = // not zero-terminated { 0x0020, 0x00FF, // Basic Latin + Latin Supplement - 0x3000, 0x30FF, // Punctuations, Hiragana, Katakana + 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana 0x31F0, 0x31FF, // Katakana Phonetic Extensions - 0xFF00, 0xFFEF, // Half-width characters + 0xFF00, 0xFFEF // Half-width characters }; static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00)*2 + 1] = { 0 }; if (!full_ranges[0]) From b8020032f92d43a18b118b562a99e91edd15841d Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 17 Jan 2019 16:55:23 +0100 Subject: [PATCH 2/4] Examples: Win32: Added support for mouse buttons 4 and 5 via WM_XBUTTON* messages. (#2264) --- docs/CHANGELOG.txt | 1 + examples/imgui_impl_win32.cpp | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 05d266223..6b3f87756 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -42,6 +42,7 @@ Other Changes: - Examples: Win32: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created in a different thread or parent. (#1951, #2087, #2156, #2232) [many people] - Examples: Win32: Added support for XInput games (if ImGuiConfigFlags_NavEnableGamepad is enabled). +- Examples: Win32: Added support for mouse buttons 4 and 5 via WM_XBUTTON* messages. (#2264) - Examples: DirectX9: Explicitly disable fog (D3DRS_FOGENABLE) before drawing in case user state has it set. (#2288, #2230) diff --git a/examples/imgui_impl_win32.cpp b/examples/imgui_impl_win32.cpp index 0e6c675eb..616ee06ad 100644 --- a/examples/imgui_impl_win32.cpp +++ b/examples/imgui_impl_win32.cpp @@ -18,7 +18,8 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) -// 2019-01-17: Inputs: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created in a different thread or parent. +// 2019-01-17: Misc: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created in a different thread or parent. +// 2019-01-17: Inputs: Added support for mouse buttons 4 and 5 via WM_XBUTTON* messages. // 2019-01-15: Inputs: Added support for XInput gamepads (if ImGuiConfigFlags_NavEnableGamepad is set by user application). // 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window. // 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor. @@ -259,11 +260,13 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK: case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK: + case WM_XBUTTONDOWN: case WM_XBUTTONDBLCLK: { int button = 0; - if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) button = 0; - if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) button = 1; - if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) button = 2; + if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) { button = 0; } + if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) { button = 1; } + 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 (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL) ::SetCapture(hwnd); io.MouseDown[button] = true; @@ -272,11 +275,13 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA case WM_LBUTTONUP: case WM_RBUTTONUP: case WM_MBUTTONUP: + case WM_XBUTTONUP: { int button = 0; - if (msg == WM_LBUTTONUP) button = 0; - if (msg == WM_RBUTTONUP) button = 1; - if (msg == WM_MBUTTONUP) button = 2; + if (msg == WM_LBUTTONUP) { button = 0; } + if (msg == WM_RBUTTONUP) { button = 1; } + if (msg == WM_MBUTTONUP) { button = 2; } + if (msg == WM_XBUTTONUP) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; } io.MouseDown[button] = false; if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd) ::ReleaseCapture(); From 295ada036489f1ca226be46f57f6de387979e36e Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 17 Jan 2019 18:04:35 +0100 Subject: [PATCH 3/4] Examples: Win32: Using wc.lpszClassName instead of duplicating the literal. + tweak README format. --- examples/README.txt | 24 +++++++++++------------ examples/example_win32_directx10/main.cpp | 6 +++--- examples/example_win32_directx11/main.cpp | 6 +++--- examples/example_win32_directx12/main.cpp | 6 +++--- examples/example_win32_directx9/main.cpp | 8 ++++---- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/examples/README.txt b/examples/README.txt index 1ee914925..3039f8213 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -161,61 +161,61 @@ example_win32_directx11/ example_win32_directx12/ DirectX12 example, Windows only. - This is quite long and tedious, because: DirectX12. = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx12.cpp + This is quite long and tedious, because: DirectX12. example_apple_metal/ OSX & iOS + Metal. + = main.m + imgui_impl_osx.mm + imgui_impl_metal.mm It is based on the "cross-platform" game template provided with Xcode as of Xcode 9. (NB: you may still want to use GLFW or SDL which will also support Windows, Linux along with OSX.) - = game template + imgui_impl_osx.mm + imgui_impl_metal.mm example_apple_opengl2/ OSX + OpenGL2. - (NB: you may still want to use GLFW or SDL which will also support Windows, Linux along with OSX.) = main.mm + imgui_impl_osx.mm + imgui_impl_opengl2.cpp + (NB: you may still want to use GLFW or SDL which will also support Windows, Linux along with OSX.) example_glfw_opengl2/ + GLFW + OpenGL2 example (legacy, fixed pipeline). + = main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp **DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** **Prefer using OPENGL3 code (with gl3w/glew/glad, you can replace the OpenGL function loader)** - GLFW + OpenGL2 example (legacy, fixed pipeline). This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter. If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to make things more complicated, will require your code to reset many OpenGL attributes to their initial state, and might confuse your GPU driver. One star, not recommended. - = main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp example_glfw_opengl3/ - GLFW (Win32, Mac, Linux) + OpenGL3+/ES2/ES3 example (programmable pipeline, binding modern functions with GL3W). + GLFW (Win32, Mac, Linux) + OpenGL3+/ES2/ES3 example (programmable pipeline). + = main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp This uses more modern OpenGL calls and custom shaders. Prefer using that if you are using modern OpenGL in your application (anything with shaders). - = main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp example_glfw_vulkan/ GLFW (Win32, Mac, Linux) + Vulkan example. - This is quite long and tedious, because: Vulkan. = main.cpp + imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp + This is quite long and tedious, because: Vulkan. example_sdl_opengl2/ + SDL2 (Win32, Mac, Linux etc.) + OpenGL example (legacy, fixed pipeline). + = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl2.cpp **DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** **Prefer using OPENGL3 code (with gl3w/glew/glad, you can replace the OpenGL function loader)** - SDL2 (Win32, Mac, Linux etc.) + OpenGL example (legacy, fixed pipeline). This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter. If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to make things more complicated, will require your code to reset many OpenGL attributes to their initial state, and might confuse your GPU driver. One star, not recommended. - = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl2.cpp example_sdl_opengl3/ SDL2 (Win32, Mac, Linux, etc.) + OpenGL3+/ES2/ES3 example. + = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp This uses more modern OpenGL calls and custom shaders. Prefer using that if you are using modern OpenGL in your application (anything with shaders). - = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp example_sdl_vulkan/ SDL2 (Win32, Mac, Linux, etc.) + Vulkan example. - This is quite long and tedious, because: Vulkan. = main.cpp + imgui_impl_sdl.cpp + imgui_impl_vulkan.cpp + This is quite long and tedious, because: Vulkan. example_allegro5/ Allegro 5 example. diff --git a/examples/example_win32_directx10/main.cpp b/examples/example_win32_directx10/main.cpp index d62293352..1bd358c19 100644 --- a/examples/example_win32_directx10/main.cpp +++ b/examples/example_win32_directx10/main.cpp @@ -96,13 +96,13 @@ int main(int, char**) // Create application window WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL }; RegisterClassEx(&wc); - HWND hwnd = CreateWindow(_T("ImGui Example"), _T("Dear ImGui DirectX10 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); + HWND hwnd = CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX10 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); // Initialize Direct3D if (CreateDeviceD3D(hwnd) < 0) { CleanupDeviceD3D(); - UnregisterClass(_T("ImGui Example"), wc.hInstance); + UnregisterClass(wc.lpszClassName, wc.hInstance); return 1; } @@ -218,7 +218,7 @@ int main(int, char**) CleanupDeviceD3D(); DestroyWindow(hwnd); - UnregisterClass(_T("ImGui Example"), wc.hInstance); + UnregisterClass(wc.lpszClassName, wc.hInstance); return 0; } diff --git a/examples/example_win32_directx11/main.cpp b/examples/example_win32_directx11/main.cpp index eb06ac59c..ee5a4eaf6 100644 --- a/examples/example_win32_directx11/main.cpp +++ b/examples/example_win32_directx11/main.cpp @@ -99,13 +99,13 @@ int main(int, char**) // Create application window WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL }; RegisterClassEx(&wc); - HWND hwnd = CreateWindow(_T("ImGui Example"), _T("Dear ImGui DirectX11 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); + HWND hwnd = CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX11 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); // Initialize Direct3D if (CreateDeviceD3D(hwnd) < 0) { CleanupDeviceD3D(); - UnregisterClass(_T("ImGui Example"), wc.hInstance); + UnregisterClass(wc.lpszClassName, wc.hInstance); return 1; } @@ -222,7 +222,7 @@ int main(int, char**) CleanupDeviceD3D(); DestroyWindow(hwnd); - UnregisterClass(_T("ImGui Example"), wc.hInstance); + UnregisterClass(wc.lpszClassName, wc.hInstance); return 0; } diff --git a/examples/example_win32_directx12/main.cpp b/examples/example_win32_directx12/main.cpp index 285fd8211..cb5895dea 100644 --- a/examples/example_win32_directx12/main.cpp +++ b/examples/example_win32_directx12/main.cpp @@ -272,13 +272,13 @@ int main(int, char**) // Create application window WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL }; RegisterClassEx(&wc); - HWND hwnd = CreateWindow(_T("ImGui Example"), _T("Dear ImGui DirectX12 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); + HWND hwnd = CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX12 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); // Initialize Direct3D if (CreateDeviceD3D(hwnd) < 0) { CleanupDeviceD3D(); - UnregisterClass(_T("ImGui Example"), wc.hInstance); + UnregisterClass(wc.lpszClassName, wc.hInstance); return 1; } @@ -424,7 +424,7 @@ int main(int, char**) CleanupDeviceD3D(); DestroyWindow(hwnd); - UnregisterClass(_T("ImGui Example"), wc.hInstance); + UnregisterClass(wc.lpszClassName, wc.hInstance); return 0; } diff --git a/examples/example_win32_directx9/main.cpp b/examples/example_win32_directx9/main.cpp index a7d5173c0..0f4c3a25a 100644 --- a/examples/example_win32_directx9/main.cpp +++ b/examples/example_win32_directx9/main.cpp @@ -49,13 +49,13 @@ int main(int, char**) // Create application window WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL }; RegisterClassEx(&wc); - HWND hwnd = CreateWindow(_T("ImGui Example"), _T("Dear ImGui DirectX9 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); + HWND hwnd = CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX9 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); // Initialize Direct3D LPDIRECT3D9 pD3D; if ((pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL) { - UnregisterClass(_T("ImGui Example"), wc.hInstance); + UnregisterClass(wc.lpszClassName, wc.hInstance); return 0; } ZeroMemory(&g_d3dpp, sizeof(g_d3dpp)); @@ -71,7 +71,7 @@ int main(int, char**) if (pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &g_d3dpp, &g_pd3dDevice) < 0) { pD3D->Release(); - UnregisterClass(_T("ImGui Example"), wc.hInstance); + UnregisterClass(wc.lpszClassName, wc.hInstance); return 0; } @@ -200,7 +200,7 @@ int main(int, char**) if (g_pd3dDevice) g_pd3dDevice->Release(); if (pD3D) pD3D->Release(); DestroyWindow(hwnd); - UnregisterClass(_T("ImGui Example"), wc.hInstance); + UnregisterClass(wc.lpszClassName, wc.hInstance); return 0; } From 92d29531fa5294e0684969f9dc33126379e6f02d Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 18 Jan 2019 11:34:25 +0100 Subject: [PATCH 4/4] Qt links --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index b1e10d53f..3fe624450 100644 --- a/docs/README.md +++ b/docs/README.md @@ -149,7 +149,7 @@ Frameworks: - LÖVE+Lua: [love-imgui](https://github.com/slages/love-imgui) - Magnum: [ImGuiIntegration](https://doc.magnum.graphics/magnum/namespaceMagnum_1_1ImGuiIntegration.html) ([example](https://doc.magnum.graphics/magnum/examples-imgui.html)) - NanoRT: [syoyo/imgui](https://github.com/syoyo/imgui/tree/nanort) -- Qt3d: [imgui-qt3d](https://github.com/alpqr/imgui-qt3d), QOpenGLWindow [qtimgui](https://github.com/ocornut/imgui/issues/1910) +- Qt: [imgui-qt3d](https://github.com/alpqr/imgui-qt3d) / [QOpenGLWindow (qtimgui)](https://github.com/ocornut/imgui/issues/1910) / [QtDirect3D](https://github.com/giladreich/QtDirect3D) / [qt6](https://github.com/alpqr/qvk6/tree/imgui/examples/rhi/imguidemo) - SFML: [imgui-sfml](https://github.com/EliasD/imgui-sfml) - Software renderer: [imgui_software_renderer](https://github.com/emilk/imgui_software_renderer) - Unreal Engine 4: [segross/UnrealImGui](https://github.com/segross/UnrealImGui) or [sronsse/UnrealEngine_ImGui](https://github.com/sronsse/UnrealEngine_ImGui)