diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index f0c5d6498..2fdc77060 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -54,8 +54,19 @@ HOW TO UPDATE? VERSION 1.66 (In Progress) ----------------------------------------------------------------------- +Other Changes: + +- Fixed calling DestroyContext() always saving .ini data with the current context instead + of the supplied context pointer. (#2066) +- Fixed calling SetNextWindowSize()/SetWindowSize() with non-integer values leading to + accidental alteration of window position. We now round the provided size. (#2067) - Nav, Focus: Fixed ImGuiWindowFlags_NoBringToFrontOnFocus windows not being restoring focus properly after the main menu bar or last focused window is deactivated. +- DragFloat: Fixed a situation where dragging with value rounding enabled or with a power curve + erroneously wrapped the value to one of the min/max edge. (#2024, #708, #320, #2075). +- DragFloat: Disabled using power curve when one edge is FLT_MAX (broken in 1.61). (#2024) +- DragFloat: Disabled setting a default drag speed when one edge is FLT_MAX. (#2024) +- BeginMenu(): Fixed menu popup horizontal offset being off the item in the menu bar when WindowPadding=0.0f. ----------------------------------------------------------------------- diff --git a/examples/README.txt b/examples/README.txt index 36fd8a029..bffd3862d 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -45,7 +45,7 @@ You can find binaries of some of those example applications at: - Dear ImGui has 0 to 1 frame of lag for most behaviors, at 60 FPS your experience should be pleasant. However, consider that OS mouse cursors are typically drawn through a specific hardware accelerated path and will feel smoother than common GPU rendered contents (including Dear ImGui windows). - You may experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, + You may experiment with the io.MouseDrawCursor flag to request Dear ImGui to draw a mouse cursor itself, to visualize the lag between a hardware cursor and a software cursor. However, rendering a mouse cursor at 60 FPS will feel slow. It might be beneficial to the user experience to switch to a software rendered cursor only when an interactive drag is in progress. @@ -186,7 +186,7 @@ example_glfw_opengl2/ **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 ImGui integration, because it is shorter. + 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. @@ -207,7 +207,7 @@ example_sdl_opengl2/ **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 ImGui integration, because it is shorter. + 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. diff --git a/examples/example_allegro5/main.cpp b/examples/example_allegro5/main.cpp index 2c8fc5e02..972861f9d 100644 --- a/examples/example_allegro5/main.cpp +++ b/examples/example_allegro5/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for Allegro 5 -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for Allegro 5 +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. #include #include diff --git a/examples/example_apple_metal/Shared/ViewController.mm b/examples/example_apple_metal/Shared/ViewController.mm index 6a9236c4a..427c0928f 100644 --- a/examples/example_apple_metal/Shared/ViewController.mm +++ b/examples/example_apple_metal/Shared/ViewController.mm @@ -45,9 +45,9 @@ // 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 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, though - // we do make an effort to be good citizens by passing along events when ImGui doesn't want to capture. + // 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, though we + // do make an effort to be good citizens by passing along events when Dear ImGui doesn't want to capture. NSEventMask eventMask = NSEventMaskKeyDown | NSEventMaskKeyUp | NSEventMaskFlagsChanged | NSEventTypeScrollWheel; [NSEvent addLocalMonitorForEventsMatchingMask:eventMask handler:^NSEvent * _Nullable(NSEvent *event) { BOOL wantsCapture = ImGui_ImplOSX_HandleEvent(event, self.view); diff --git a/examples/example_apple_opengl2/main.mm b/examples/example_apple_opengl2/main.mm index e33248729..80831c4e7 100644 --- a/examples/example_apple_opengl2/main.mm +++ b/examples/example_apple_opengl2/main.mm @@ -1,5 +1,5 @@ -// ImGui - standalone example application for OSX + OpenGL2, using legacy fixed pipeline -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for OSX + OpenGL2, using legacy fixed pipeline +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. #include "imgui.h" #include "../imgui_impl_osx.h" diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp index 832fd36c9..37748291e 100644 --- a/examples/example_freeglut_opengl2/main.cpp +++ b/examples/example_freeglut_opengl2/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. // (Using GLUT or FreeGLUT is not recommended unless you really miss the 90's) #include "imgui.h" @@ -57,7 +57,7 @@ void my_display_code() void glut_display_func() { - // Start the ImGui frame + // Start the Dear ImGui frame ImGui_ImplOpenGL2_NewFrame(); ImGui_ImplFreeGLUT_NewFrame(); @@ -95,7 +95,7 @@ int main(int argc, char** argv) // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves. glutDisplayFunc(glut_display_func); - // Setup ImGui binding + // Setup Dear ImGui binding ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io; //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls diff --git a/examples/example_glfw_opengl2/main.cpp b/examples/example_glfw_opengl2/main.cpp index 4b1dfe6db..41f1e397b 100644 --- a/examples/example_glfw_opengl2/main.cpp +++ b/examples/example_glfw_opengl2/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for GLFW + OpenGL2, using legacy fixed pipeline -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for GLFW + OpenGL2, using legacy fixed pipeline +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. // (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) // **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** diff --git a/examples/example_glfw_opengl3/main.cpp b/examples/example_glfw_opengl3/main.cpp index a99174639..ea8d182be 100644 --- a/examples/example_glfw_opengl3/main.cpp +++ b/examples/example_glfw_opengl3/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for GLFW + OpenGL 3, using programmable pipeline -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for GLFW + OpenGL 3, using programmable pipeline +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. // (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) #include "imgui.h" diff --git a/examples/example_glfw_vulkan/CMakeLists.txt b/examples/example_glfw_vulkan/CMakeLists.txt index 60fe5718f..82d7ab47d 100644 --- a/examples/example_glfw_vulkan/CMakeLists.txt +++ b/examples/example_glfw_vulkan/CMakeLists.txt @@ -32,5 +32,5 @@ include_directories(${GLFW_DIR}/deps) file(GLOB sources *.cpp) -add_executable(example_glfw_vulkan ${sources} ${IMGUI_DIR}/examples/imgui_impl_glfw.cpp ${IMGUI_DIR}/examples/imgui_impl_vulkan.cpp ${IMGUI_DIR}/imgui.cpp ${IMGUI_DIR}/imgui_draw.cpp ${IMGUI_DIR}/imgui_demo.cpp) +add_executable(example_glfw_vulkan ${sources} ${IMGUI_DIR}/examples/imgui_impl_glfw.cpp ${IMGUI_DIR}/examples/imgui_impl_vulkan.cpp ${IMGUI_DIR}/imgui.cpp ${IMGUI_DIR}/imgui_draw.cpp ${IMGUI_DIR}/imgui_demo.cpp ${IMGUI_DIR}/imgui_widgets.cpp) target_link_libraries(example_glfw_vulkan ${LIBRARIES}) diff --git a/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj b/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj index 04b550822..b0305e8f2 100644 --- a/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj +++ b/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj @@ -1,4 +1,4 @@ - + @@ -153,6 +153,7 @@ + diff --git a/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters b/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters index 0fa42d7f7..98a445d4d 100644 --- a/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters +++ b/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters @@ -28,6 +28,9 @@ sources + + imgui + diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp index 5552ee3cf..f43e9f226 100644 --- a/examples/example_glfw_vulkan/main.cpp +++ b/examples/example_glfw_vulkan/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for Glfw + Vulkan -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for Glfw + Vulkan +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. #include "imgui.h" #include "imgui_impl_glfw.h" diff --git a/examples/example_marmalade/main.cpp b/examples/example_marmalade/main.cpp index 71a9d9249..d9e2aa5e1 100644 --- a/examples/example_marmalade/main.cpp +++ b/examples/example_marmalade/main.cpp @@ -1,8 +1,8 @@ -// ImGui - standalone example application for Marmalade -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for Marmalade +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. // Copyright (C) 2015 by Giovanni Zito -// This file is part of ImGui +// This file is part of Dear ImGui #include "imgui.h" #include "imgui_impl_marmalade.h" diff --git a/examples/example_null/main.cpp b/examples/example_null/main.cpp index 547ed3c15..90521f9b0 100644 --- a/examples/example_null/main.cpp +++ b/examples/example_null/main.cpp @@ -1,4 +1,4 @@ -// ImGui - null/dummy example application (compile and link imgui with no inputs, no outputs) +// dear imgui: null/dummy example application (compile and link imgui with no inputs, no outputs) #include "imgui.h" #include diff --git a/examples/example_sdl_opengl2/main.cpp b/examples/example_sdl_opengl2/main.cpp index 034618bfd..9ed3d89da 100644 --- a/examples/example_sdl_opengl2/main.cpp +++ b/examples/example_sdl_opengl2/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for SDL2 + OpenGL -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for SDL2 + OpenGL +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. // (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) // **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** diff --git a/examples/example_sdl_opengl3/main.cpp b/examples/example_sdl_opengl3/main.cpp index 648ccd229..83d728813 100644 --- a/examples/example_sdl_opengl3/main.cpp +++ b/examples/example_sdl_opengl3/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for SDL2 + OpenGL -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for SDL2 + OpenGL +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. // (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) // (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.) diff --git a/examples/example_sdl_vulkan/main.cpp b/examples/example_sdl_vulkan/main.cpp index d1a85385a..d3e105e94 100644 --- a/examples/example_sdl_vulkan/main.cpp +++ b/examples/example_sdl_vulkan/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for SDL2 + Vulkan -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for SDL2 + Vulkan +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. #include "imgui.h" #include "imgui_impl_sdl.h" @@ -332,7 +332,7 @@ int main(int, char**) ImGui_ImplVulkanH_WindowData* wd = &g_WindowData; SetupVulkanWindowData(wd, surface, w, h); - // Setup ImGui binding + // Setup Dear ImGui binding ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io; io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls diff --git a/examples/example_win32_directx10/main.cpp b/examples/example_win32_directx10/main.cpp index 4d1bb1b36..3c218f0ee 100644 --- a/examples/example_win32_directx10/main.cpp +++ b/examples/example_win32_directx10/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for DirectX 10 -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for DirectX 10 +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. #include "imgui.h" #include "imgui_impl_win32.h" diff --git a/examples/example_win32_directx11/main.cpp b/examples/example_win32_directx11/main.cpp index 6026ce186..16c03ed57 100644 --- a/examples/example_win32_directx11/main.cpp +++ b/examples/example_win32_directx11/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for DirectX 11 -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui - standalone example application for DirectX 11 +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. #include "imgui.h" #include "imgui_impl_win32.h" diff --git a/examples/example_win32_directx12/main.cpp b/examples/example_win32_directx12/main.cpp index bf4482af0..87cd33291 100644 --- a/examples/example_win32_directx12/main.cpp +++ b/examples/example_win32_directx12/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for DirectX 12 -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for DirectX 12 +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. // FIXME: 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*)) #include "imgui.h" diff --git a/examples/example_win32_directx9/main.cpp b/examples/example_win32_directx9/main.cpp index 6d0bf7f2f..70daec329 100644 --- a/examples/example_win32_directx9/main.cpp +++ b/examples/example_win32_directx9/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for DirectX 9 -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for DirectX 9 +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. #include "imgui.h" #include "imgui_impl_dx9.h" diff --git a/examples/imgui_impl_allegro5.cpp b/examples/imgui_impl_allegro5.cpp index b1e963259..ef99bf158 100644 --- a/examples/imgui_impl_allegro5.cpp +++ b/examples/imgui_impl_allegro5.cpp @@ -1,4 +1,4 @@ -// ImGui Renderer + Platform Binding for: Allegro 5 +// dear imgui: Renderer + Platform Binding for Allegro 5 // (Info: Allegro 5 is a cross-platform general purpose library for handling windows, inputs, graphics, etc.) // Implemented features: @@ -74,7 +74,7 @@ void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data) al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA); // Setup orthographic projection matrix - // Our visible imgui space lies from draw_data->DisplayPps (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). + // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). { float L = draw_data->DisplayPos.x; float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x; @@ -108,7 +108,7 @@ void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data) const int* indices = NULL; if (sizeof(ImDrawIdx) == 2) { - // FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices.. You can '#define ImDrawIdx int' in imconfig.h to request ImGui to output 32-bit indices. + // FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices.. You can '#define ImDrawIdx int' in imconfig.h to request Dear ImGui to output 32-bit indices. // Otherwise, we convert them from 16-bit to 32-bit at runtime here, which works perfectly but is a little wasteful. static ImVector indices_converted; indices_converted.resize(cmd_list->IdxBuffer.Size); diff --git a/examples/imgui_impl_allegro5.h b/examples/imgui_impl_allegro5.h index 053f87fa9..a7792bcc9 100644 --- a/examples/imgui_impl_allegro5.h +++ b/examples/imgui_impl_allegro5.h @@ -1,4 +1,4 @@ -// ImGui Renderer + Platform Binding for: Allegro 5 +// dear imgui: Renderer + Platform Binding for Allegro 5 // (Info: Allegro 5 is a cross-platform general purpose library for handling windows, inputs, graphics, etc.) // Implemented features: diff --git a/examples/imgui_impl_dx10.cpp b/examples/imgui_impl_dx10.cpp index a8a860b2c..3fcbe841a 100644 --- a/examples/imgui_impl_dx10.cpp +++ b/examples/imgui_impl_dx10.cpp @@ -1,4 +1,4 @@ -// ImGui Renderer for: DirectX10 +// dear imgui: Renderer for DirectX10 // This needs to be used along with a Platform Binding (e.g. Win32) // Implemented features: diff --git a/examples/imgui_impl_dx10.h b/examples/imgui_impl_dx10.h index e2560d743..9c4b620af 100644 --- a/examples/imgui_impl_dx10.h +++ b/examples/imgui_impl_dx10.h @@ -1,4 +1,4 @@ -// ImGui Renderer for: DirectX10 +// dear imgui: Renderer for DirectX10 // This needs to be used along with a Platform Binding (e.g. Win32) // Implemented features: diff --git a/examples/imgui_impl_dx11.cpp b/examples/imgui_impl_dx11.cpp index 065b448c4..2132c697d 100644 --- a/examples/imgui_impl_dx11.cpp +++ b/examples/imgui_impl_dx11.cpp @@ -1,4 +1,4 @@ -// ImGui Renderer for: DirectX11 +// dear imgui: Renderer for DirectX11 // This needs to be used along with a Platform Binding (e.g. Win32) // Implemented features: diff --git a/examples/imgui_impl_dx11.h b/examples/imgui_impl_dx11.h index f462e5936..89aa9409d 100644 --- a/examples/imgui_impl_dx11.h +++ b/examples/imgui_impl_dx11.h @@ -1,4 +1,4 @@ -// ImGui Renderer for: DirectX11 +// dear imgui: Renderer for DirectX11 // This needs to be used along with a Platform Binding (e.g. Win32) // Implemented features: diff --git a/examples/imgui_impl_dx12.cpp b/examples/imgui_impl_dx12.cpp index 8c9d1b47a..821b14991 100644 --- a/examples/imgui_impl_dx12.cpp +++ b/examples/imgui_impl_dx12.cpp @@ -1,4 +1,4 @@ -// ImGui Renderer for: DirectX12 +// dear imgui: Renderer for DirectX12 // This needs to be used along with a Platform Binding (e.g. Win32) // Implemented features: diff --git a/examples/imgui_impl_dx12.h b/examples/imgui_impl_dx12.h index 823ac3240..8c462547d 100644 --- a/examples/imgui_impl_dx12.h +++ b/examples/imgui_impl_dx12.h @@ -1,4 +1,4 @@ -// ImGui Renderer for: DirectX12 +// dear imgui: Renderer for DirectX12 // This needs to be used along with a Platform Binding (e.g. Win32) // Implemented features: diff --git a/examples/imgui_impl_dx9.cpp b/examples/imgui_impl_dx9.cpp index e3a1da28b..dd40d6cb6 100644 --- a/examples/imgui_impl_dx9.cpp +++ b/examples/imgui_impl_dx9.cpp @@ -1,4 +1,4 @@ -// ImGui Renderer for: DirectX9 +// dear imgui: Renderer for DirectX9 // This needs to be used along with a Platform Binding (e.g. Win32) // Implemented features: diff --git a/examples/imgui_impl_dx9.h b/examples/imgui_impl_dx9.h index 8c91364d0..03da1bda1 100644 --- a/examples/imgui_impl_dx9.h +++ b/examples/imgui_impl_dx9.h @@ -1,4 +1,4 @@ -// ImGui Renderer for: DirectX9 +// dear imgui: Renderer for DirectX9 // This needs to be used along with a Platform Binding (e.g. Win32) // Implemented features: diff --git a/examples/imgui_impl_freeglut.cpp b/examples/imgui_impl_freeglut.cpp index b265226b4..983bfd68a 100644 --- a/examples/imgui_impl_freeglut.cpp +++ b/examples/imgui_impl_freeglut.cpp @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: FreeGLUT +// dear imgui: Platform Binding for FreeGLUT // This needs to be used along with a Renderer (e.g. OpenGL2) // Issues: @@ -97,7 +97,7 @@ void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y) //printf("char_down_func %d '%c'\n", c, c); ImGuiIO& io = ImGui::GetIO(); if (c >= 32) - io.AddInputCharacter(c); + io.AddInputCharacter((unsigned short)c); // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26. // 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. diff --git a/examples/imgui_impl_freeglut.h b/examples/imgui_impl_freeglut.h index b6b88973d..fc030bb9e 100644 --- a/examples/imgui_impl_freeglut.h +++ b/examples/imgui_impl_freeglut.h @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: FreeGLUT +// dear imgui: Platform Binding for FreeGLUT // This needs to be used along with a Renderer (e.g. OpenGL2) // Issues: diff --git a/examples/imgui_impl_glfw.cpp b/examples/imgui_impl_glfw.cpp index bf178a5ba..f17151af3 100644 --- a/examples/imgui_impl_glfw.cpp +++ b/examples/imgui_impl_glfw.cpp @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: GLFW +// dear imgui: Platform Binding for GLFW // This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..) // (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) diff --git a/examples/imgui_impl_glfw.h b/examples/imgui_impl_glfw.h index 83d0d352f..60cb6eae2 100644 --- a/examples/imgui_impl_glfw.h +++ b/examples/imgui_impl_glfw.h @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: GLFW +// dear imgui: Platform Binding for GLFW // This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..) // (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) diff --git a/examples/imgui_impl_marmalade.cpp b/examples/imgui_impl_marmalade.cpp index 23ced8ff8..d3aa69839 100644 --- a/examples/imgui_impl_marmalade.cpp +++ b/examples/imgui_impl_marmalade.cpp @@ -1,5 +1,5 @@ -// ImGui Renderer + Platform Binding for: Marmalade + IwGx -// Marmalade code: Copyright (C) 2015 by Giovanni Zito (this file is part of ImGui) +// dear imgui: Renderer + Platform Binding for Marmalade + IwGx +// Marmalade code: Copyright (C) 2015 by Giovanni Zito (this file is part of Dear ImGui) // Implemented features: // [X] Renderer: User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. diff --git a/examples/imgui_impl_marmalade.h b/examples/imgui_impl_marmalade.h index 01769b945..96c43337e 100644 --- a/examples/imgui_impl_marmalade.h +++ b/examples/imgui_impl_marmalade.h @@ -1,4 +1,5 @@ -// ImGui Renderer + Platform Binding for: Marmalade + IwGx +// dear imgui: Renderer + Platform Binding for Marmalade + IwGx +// Marmalade code: Copyright (C) 2015 by Giovanni Zito (this file is part of Dear ImGui) // Implemented features: // [X] Renderer: User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. @@ -7,9 +8,6 @@ // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui -// Copyright (C) 2015 by Giovanni Zito -// This file is part of ImGui - IMGUI_IMPL_API bool ImGui_Marmalade_Init(bool install_callbacks); IMGUI_IMPL_API void ImGui_Marmalade_Shutdown(); IMGUI_IMPL_API void ImGui_Marmalade_NewFrame(); diff --git a/examples/imgui_impl_metal.h b/examples/imgui_impl_metal.h index 2ebea1dc9..731ec20bc 100644 --- a/examples/imgui_impl_metal.h +++ b/examples/imgui_impl_metal.h @@ -1,4 +1,4 @@ -// ImGui Renderer for: Metal +// dear imgui: Renderer for Metal // This needs to be used along with a Platform Binding (e.g. OSX) // Implemented features: diff --git a/examples/imgui_impl_metal.mm b/examples/imgui_impl_metal.mm index 89ed3b510..695b8b858 100644 --- a/examples/imgui_impl_metal.mm +++ b/examples/imgui_impl_metal.mm @@ -1,4 +1,4 @@ -// ImGui Renderer for: Metal +// dear imgui: Renderer for Metal // This needs to be used along with a Platform Binding (e.g. OSX) // Implemented features: @@ -410,7 +410,7 @@ void ImGui_ImplMetal_DestroyDeviceObjects() [commandEncoder setDepthStencilState:g_sharedMetalContext.depthStencilState]; // Setup viewport, orthographic projection matrix - // Our visible imgui space lies from draw_data->DisplayPps (top left) to + // Our visible imgui space lies from draw_data->DisplayPos (top left) to // draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is typically (0,0) for single viewport apps. MTLViewport viewport = { diff --git a/examples/imgui_impl_opengl2.cpp b/examples/imgui_impl_opengl2.cpp index 7ca2e56eb..e79e1aaf3 100644 --- a/examples/imgui_impl_opengl2.cpp +++ b/examples/imgui_impl_opengl2.cpp @@ -1,4 +1,4 @@ -// ImGui Renderer for: OpenGL2 (legacy OpenGL, fixed pipeline) +// dear imgui: Renderer for OpenGL2 (legacy OpenGL, fixed pipeline) // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) // Implemented features: diff --git a/examples/imgui_impl_opengl2.h b/examples/imgui_impl_opengl2.h index c3c6b9285..c58b16057 100644 --- a/examples/imgui_impl_opengl2.h +++ b/examples/imgui_impl_opengl2.h @@ -1,4 +1,4 @@ -// ImGui Renderer for: OpenGL2 (legacy OpenGL, fixed pipeline) +// dear imgui: Renderer for OpenGL2 (legacy OpenGL, fixed pipeline) // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) // Implemented features: diff --git a/examples/imgui_impl_opengl3.cpp b/examples/imgui_impl_opengl3.cpp index 83a79b409..7aceea256 100644 --- a/examples/imgui_impl_opengl3.cpp +++ b/examples/imgui_impl_opengl3.cpp @@ -1,4 +1,4 @@ -// ImGui Renderer for: OpenGL3 / OpenGL ES2 / OpenGL ES3 (modern OpenGL with shaders / programmatic pipeline) +// dear imgui: Renderer for OpenGL3 / OpenGL ES2 / OpenGL ES3 (modern OpenGL with shaders / programmatic pipeline) // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) // (Note: We are using GL3W as a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc..) diff --git a/examples/imgui_impl_opengl3.h b/examples/imgui_impl_opengl3.h index 92b351646..96ae9e58c 100644 --- a/examples/imgui_impl_opengl3.h +++ b/examples/imgui_impl_opengl3.h @@ -1,4 +1,4 @@ -// ImGui Renderer for: OpenGL3 / OpenGL ES2 / OpenGL ES3 (modern OpenGL with shaders / programmatic pipeline) +// dear imgui: Renderer for OpenGL3 / OpenGL ES2 / OpenGL ES3 (modern OpenGL with shaders / programmatic pipeline) // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) // (Note: We are using GL3W as a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc..) diff --git a/examples/imgui_impl_osx.h b/examples/imgui_impl_osx.h index ebe73050d..0947025c0 100644 --- a/examples/imgui_impl_osx.h +++ b/examples/imgui_impl_osx.h @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: OSX / Cocoa +// dear imgui: Platform Binding for OSX / Cocoa // This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan, Metal..) // [BETA] Beta bindings, not well tested. If you want a portable application, prefer using the Glfw or SDL platform bindings on Mac. diff --git a/examples/imgui_impl_osx.mm b/examples/imgui_impl_osx.mm index 4b0347a97..d175d2266 100644 --- a/examples/imgui_impl_osx.mm +++ b/examples/imgui_impl_osx.mm @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: OSX / Cocoa +// dear imgui: Platform Binding for OSX / Cocoa // This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan, Metal..) // [BETA] Beta bindings, not well tested. If you want a portable application, prefer using the Glfw or SDL platform bindings on Mac. @@ -189,7 +189,7 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view) { int c = [str characterAtIndex:i]; if (c < 0xF700 && !io.KeyCtrl) - io.AddInputCharacter(c); + io.AddInputCharacter((unsigned short)c); // We must reset in case we're pressing a sequence of special keys while keeping the command pressed int key = mapCharacterToKey(c); diff --git a/examples/imgui_impl_sdl.cpp b/examples/imgui_impl_sdl.cpp index ef174d9a1..f942abcb0 100644 --- a/examples/imgui_impl_sdl.cpp +++ b/examples/imgui_impl_sdl.cpp @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: SDL2 +// dear imgui: Platform Binding for SDL2 // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) // (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.) diff --git a/examples/imgui_impl_sdl.h b/examples/imgui_impl_sdl.h index e4e46d1e0..eccd3e56f 100644 --- a/examples/imgui_impl_sdl.h +++ b/examples/imgui_impl_sdl.h @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: SDL2 +// dear imgui: Platform Binding for SDL2 // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) // (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.) diff --git a/examples/imgui_impl_vulkan.cpp b/examples/imgui_impl_vulkan.cpp index e725557c6..618e67630 100644 --- a/examples/imgui_impl_vulkan.cpp +++ b/examples/imgui_impl_vulkan.cpp @@ -1,4 +1,4 @@ -// ImGui Renderer for: Vulkan +// dear imgui: Renderer for Vulkan // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) // Missing features: diff --git a/examples/imgui_impl_vulkan.h b/examples/imgui_impl_vulkan.h index 54c00da75..ec4725358 100644 --- a/examples/imgui_impl_vulkan.h +++ b/examples/imgui_impl_vulkan.h @@ -1,4 +1,4 @@ -// ImGui Renderer for: Vulkan +// dear imgui: Renderer for Vulkan // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) // Missing features: diff --git a/examples/imgui_impl_win32.cpp b/examples/imgui_impl_win32.cpp index 1575ec0a3..2e0d6cffb 100644 --- a/examples/imgui_impl_win32.cpp +++ b/examples/imgui_impl_win32.cpp @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: Windows (standard windows API for 32 and 64 bits applications) +// dear imgui: Platform Binding for Windows (standard windows API for 32 and 64 bits applications) // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) // Implemented features: diff --git a/examples/imgui_impl_win32.h b/examples/imgui_impl_win32.h index 80f1de581..f25f1ae95 100644 --- a/examples/imgui_impl_win32.h +++ b/examples/imgui_impl_win32.h @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: Windows (standard windows API for 32 and 64 bits applications) +// dear imgui: Platform Binding for Windows (standard windows API for 32 and 64 bits applications) // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) // Implemented features: diff --git a/imgui.cpp b/imgui.cpp index 8ef825207..7652962f6 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3459,7 +3459,12 @@ void ImGui::Shutdown(ImGuiContext* context) // Save settings (unless we haven't attempted to load them: CreateContext/DestroyContext without a call to NewFrame shouldn't save an empty file) if (g.SettingsLoaded && g.IO.IniFilename != NULL) + { + ImGuiContext* backup_context = GImGui; + SetCurrentContext(context); SaveIniSettingsToDisk(g.IO.IniFilename); + SetCurrentContext(backup_context); + } // Destroy platform windows ImGuiContext* backup_context = ImGui::GetCurrentContext(); @@ -4487,7 +4492,7 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl window->DockId = settings->DockId; window->DockOrder = settings->DockOrder; } - window->Size = window->SizeFull = window->SizeFullAtLastBegin = size; + window->Size = window->SizeFull = window->SizeFullAtLastBegin = ImFloor(size); window->DC.CursorMaxPos = window->Pos; // So first call to CalcSizeContents() doesn't return crazy values if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0) @@ -6189,7 +6194,7 @@ static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond con if (size.x > 0.0f) { window->AutoFitFramesX = 0; - window->SizeFull.x = size.x; + window->SizeFull.x = ImFloor(size.x); } else { @@ -6199,7 +6204,7 @@ static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond con if (size.y > 0.0f) { window->AutoFitFramesY = 0; - window->SizeFull.y = size.y; + window->SizeFull.y = ImFloor(size.y); } else { @@ -7757,7 +7762,7 @@ void ImGui::UpdatePlatformWindows() // Show window. On startup ensure platform window don't get focus if (is_new_window) { - if (g.FrameCount < 2) + if (g.FrameCount < 3) // Give a few frames for the application to stabilize (nested contents may lead to viewport being created a few frames late) viewport->Flags |= ImGuiViewportFlags_NoFocusOnAppearing; g.PlatformIO.Platform_ShowWindow(viewport); } @@ -7861,17 +7866,20 @@ void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport) g.PlatformIO.Renderer_DestroyWindow(viewport); if (viewport->CreatedPlatformWindow && g.PlatformIO.Platform_DestroyWindow) g.PlatformIO.Platform_DestroyWindow(viewport); - viewport->CreatedPlatformWindow = false; IM_ASSERT(viewport->RendererUserData == NULL); - IM_ASSERT(viewport->PlatformUserData == NULL && viewport->PlatformHandle == NULL); + IM_ASSERT(viewport->PlatformUserData == NULL); + viewport->PlatformHandle = NULL; + viewport->RendererUserData = viewport->PlatformHandle = NULL; + viewport->CreatedPlatformWindow = false; } void ImGui::DestroyPlatformWindows() { // We call the destroy window on the main viewport (index 0) to give a chance to the back-end to clear any data - // have stored in e.g. PlatformHandle. - // It is expected that the back-end stored a flag to remember that it doesn't own the window created for the - // main viewport, and won't destroy the underlying platform/renderer data. + // have stored in e.g. PlatformUserData, RendererUserData. It can be convenient for the platform back-end code to + // store something in the main viewport, in order for e.g. the mouse handling code to work in a more generic manner. + // It is expected that the back-end can handle calls to Renderer_DestroyWindow/Platform_DestroyWindow without + // crashing if it doesn't have data stored. ImGuiContext& g = *GImGui; for (int i = 0; i < g.Viewports.Size; i++) if (g.Viewports[i]->CreatedPlatformWindow) diff --git a/imgui.h b/imgui.h index 47df5b260..2d0bf3f88 100644 --- a/imgui.h +++ b/imgui.h @@ -2013,7 +2013,7 @@ struct ImFont ImVec2 DisplayOffset; // = (0.f,0.f) // Offset font rendering by xx pixels ImVector Glyphs; // // All glyphs. ImVector IndexAdvanceX; // // Sparse. Glyphs->AdvanceX in a directly indexable way (more cache-friendly, for CalcTextSize functions which are often bottleneck in large UI). - ImVector IndexLookup; // // Sparse. Index glyphs by Unicode code-point. + ImVector IndexLookup; // // Sparse. Index glyphs by Unicode code-point. const ImFontGlyph* FallbackGlyph; // == FindGlyph(FontFallbackChar) float FallbackAdvanceX; // == FallbackGlyph->AdvanceX ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar() @@ -2042,7 +2042,7 @@ struct ImFont // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable. IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8 IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const; - IMGUI_API void RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, unsigned short c) const; + IMGUI_API void RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const; IMGUI_API void RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, bool cpu_fine_clip = false) const; // [Internal] diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 04884436c..9d06f7aaf 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -2575,8 +2575,8 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref) ImGui::Checkbox("Anti-aliased lines", &style.AntiAliasedLines); ImGui::SameLine(); ShowHelpMarker("When disabling anti-aliasing lines, you'll probably want to disable borders in your style as well."); ImGui::Checkbox("Anti-aliased fill", &style.AntiAliasedFill); ImGui::PushItemWidth(100); - ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, FLT_MAX, NULL, 2.0f); - if (style.CurveTessellationTol < 0.0f) style.CurveTessellationTol = 0.10f; + ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, FLT_MAX, "%.2f", 2.0f); + if (style.CurveTessellationTol < 0.10f) style.CurveTessellationTol = 0.10f; ImGui::DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero. ImGui::PopItemWidth(); ImGui::TreePop(); diff --git a/imgui_draw.cpp b/imgui_draw.cpp index ce80881c0..d6a6e4345 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1915,7 +1915,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas) continue; const int codepoint = range.first_unicode_codepoint_in_range + char_idx; - if (cfg.MergeMode && dst_font->FindGlyphNoFallback((unsigned short)codepoint)) + if (cfg.MergeMode && dst_font->FindGlyphNoFallback((ImWchar)codepoint)) continue; float char_advance_x_org = pc.xadvance; @@ -2337,21 +2337,21 @@ void ImFont::BuildLookupTable() { int codepoint = (int)Glyphs[i].Codepoint; IndexAdvanceX[codepoint] = Glyphs[i].AdvanceX; - IndexLookup[codepoint] = (unsigned short)i; + IndexLookup[codepoint] = (ImWchar)i; } // Create a glyph to handle TAB // FIXME: Needs proper TAB handling but it needs to be contextualized (or we could arbitrary say that each string starts at "column 0" ?) - if (FindGlyph((unsigned short)' ')) + if (FindGlyph((ImWchar)' ')) { if (Glyphs.back().Codepoint != '\t') // So we can call this function multiple times Glyphs.resize(Glyphs.Size + 1); ImFontGlyph& tab_glyph = Glyphs.back(); - tab_glyph = *FindGlyph((unsigned short)' '); + tab_glyph = *FindGlyph((ImWchar)' '); tab_glyph.Codepoint = '\t'; tab_glyph.AdvanceX *= 4; IndexAdvanceX[(int)tab_glyph.Codepoint] = (float)tab_glyph.AdvanceX; - IndexLookup[(int)tab_glyph.Codepoint] = (unsigned short)(Glyphs.Size-1); + IndexLookup[(int)tab_glyph.Codepoint] = (ImWchar)(Glyphs.Size-1); } FallbackGlyph = FindGlyphNoFallback(FallbackChar); @@ -2373,7 +2373,7 @@ void ImFont::GrowIndex(int new_size) if (new_size <= IndexLookup.Size) return; IndexAdvanceX.resize(new_size, -1.0f); - IndexLookup.resize(new_size, (unsigned short)-1); + IndexLookup.resize(new_size, (ImWchar)-1); } // x0/y0/x1/y1 are offset from the character upper-left layout position, in pixels. Therefore x0/y0 are often fairly close to zero. @@ -2406,13 +2406,13 @@ void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst) IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function. int index_size = IndexLookup.Size; - if (dst < index_size && IndexLookup.Data[dst] == (unsigned short)-1 && !overwrite_dst) // 'dst' already exists + if (dst < index_size && IndexLookup.Data[dst] == (ImWchar)-1 && !overwrite_dst) // 'dst' already exists return; if (src >= index_size && dst >= index_size) // both 'dst' and 'src' don't exist -> no-op return; GrowIndex(dst + 1); - IndexLookup[dst] = (src < index_size) ? IndexLookup.Data[src] : (unsigned short)-1; + IndexLookup[dst] = (src < index_size) ? IndexLookup.Data[src] : (ImWchar)-1; IndexAdvanceX[dst] = (src < index_size) ? IndexAdvanceX.Data[src] : 1.0f; } @@ -2420,8 +2420,8 @@ const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const { if (c >= IndexLookup.Size) return FallbackGlyph; - const unsigned short i = IndexLookup[c]; - if (i == (unsigned short)-1) + const ImWchar i = IndexLookup[c]; + if (i == (ImWchar)-1) return FallbackGlyph; return &Glyphs.Data[i]; } @@ -2430,8 +2430,8 @@ const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const { if (c >= IndexLookup.Size) return NULL; - const unsigned short i = IndexLookup[c]; - if (i == (unsigned short)-1) + const ImWchar i = IndexLookup[c]; + if (i == (ImWchar)-1) return NULL; return &Glyphs.Data[i]; } @@ -2629,7 +2629,7 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons return text_size; } -void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, unsigned short c) const +void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const { if (c == ' ' || c == '\t' || c == '\n' || c == '\r') // Match behavior of RenderText(), those 4 codepoints are hard-coded. return; @@ -2754,7 +2754,7 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col } float char_width = 0.0f; - if (const ImFontGlyph* glyph = FindGlyph((unsigned short)c)) + if (const ImFontGlyph* glyph = FindGlyph((ImWchar)c)) { char_width = glyph->AdvanceX * scale; diff --git a/imgui_internal.h b/imgui_internal.h index 6df4c4cec..1d90f6e32 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1363,7 +1363,7 @@ namespace ImGui inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; } IMGUI_API ImGuiWindow* FindWindowByID(ImGuiID id); IMGUI_API ImGuiWindow* FindWindowByName(const char* name); - IMGUI_API void FocusWindow(ImGuiWindow* window); // FIXME: Rename to SetWindowFocus() + IMGUI_API void FocusWindow(ImGuiWindow* window); IMGUI_API void FocusPreviousWindowIgnoringOne(ImGuiWindow* ignore_window); IMGUI_API void BringWindowToFocusFront(ImGuiWindow* window); IMGUI_API void BringWindowToDisplayFront(ImGuiWindow* window); diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index c949e4526..88c9e4c1c 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -846,7 +846,7 @@ bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const I // Default to using texture ID as ID. User can still push string/integer prefixes. // We could hash the size/uv to create a unique ID but that would prevent the user from animating UV. - PushID((void*)user_texture_id); + PushID((void*)(intptr_t)user_texture_id); const ImGuiID id = window->GetID("#image"); PopID(); @@ -1715,10 +1715,11 @@ template bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const TYPE v_min, const TYPE v_max, const char* format, float power) { ImGuiContext& g = *GImGui; + const bool is_decimal = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double); + const bool has_min_max = (v_min != v_max); // Default tweak speed - bool has_min_max = (v_min != v_max) && (v_max - v_max < FLT_MAX); - if (v_speed == 0.0f && has_min_max) + if (v_speed == 0.0f && has_min_max && (v_max - v_min < FLT_MAX)) v_speed = (float)((v_max - v_min) * g.DragSpeedDefaultRatio); // Inputs accumulates into g.DragCurrentAccum, which is flushed into the current value as soon as it makes a difference with our precision settings @@ -1727,14 +1728,14 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const { adjust_delta = g.IO.MouseDelta.x; if (g.IO.KeyAlt) - adjust_delta *= 1.0f/100.0f; + adjust_delta *= 1.0f / 100.0f; if (g.IO.KeyShift) adjust_delta *= 10.0f; } else if (g.ActiveIdSource == ImGuiInputSource_Nav) { - int decimal_precision = (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) ? ImParseFormatPrecision(format, 3) : 0; - adjust_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard|ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 1.0f/10.0f, 10.0f).x; + int decimal_precision = is_decimal ? ImParseFormatPrecision(format, 3) : 0; + adjust_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard | ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 1.0f / 10.0f, 10.0f).x; v_speed = ImMax(v_speed, GetMinimumStepAtDecimalPrecision(decimal_precision)); } adjust_delta *= v_speed; @@ -1760,7 +1761,7 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const TYPE v_cur = *v; FLOATTYPE v_old_ref_for_accum_remainder = (FLOATTYPE)0.0f; - const bool is_power = (power != 1.0f && (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) && has_min_max); + const bool is_power = (power != 1.0f && is_decimal && has_min_max && (v_max - v_min < FLT_MAX)); if (is_power) { // Offset + round to user desired precision, with a curve on the v_min..v_max range to get more precision on one side of the range @@ -1793,12 +1794,12 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const if (v_cur == (TYPE)-0) v_cur = (TYPE)0; - // Clamp values (handle overflow/wrap-around) + // Clamp values (+ handle overflow/wrap-around for integer types) if (*v != v_cur && has_min_max) { - if (v_cur < v_min || (v_cur > *v && adjust_delta < 0.0f)) + if (v_cur < v_min || (v_cur > *v && adjust_delta < 0.0f && !is_decimal)) v_cur = v_min; - if (v_cur > v_max || (v_cur < *v && adjust_delta > 0.0f)) + if (v_cur > v_max || (v_cur < *v && adjust_delta > 0.0f && !is_decimal)) v_cur = v_max; } @@ -2849,7 +2850,7 @@ static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* t if (c == '\r') continue; - const float char_width = font->GetCharAdvance((unsigned short)c) * scale; + const float char_width = font->GetCharAdvance((ImWchar)c) * scale; line_width += char_width; } @@ -3702,7 +3703,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2 else { ImVec2 rect_size = InputTextCalcTextSizeW(p, text_selected_end, &p, NULL, true); - if (rect_size.x <= 0.0f) rect_size.x = (float)(int)(g.Font->GetCharAdvance((unsigned short)' ') * 0.50f); // So we can see selected empty lines + if (rect_size.x <= 0.0f) rect_size.x = (float)(int)(g.Font->GetCharAdvance((ImWchar)' ') * 0.50f); // So we can see selected empty lines ImRect rect(rect_pos + ImVec2(0.0f, bg_offy_up - g.FontSize), rect_pos +ImVec2(rect_size.x, bg_offy_dn)); rect.ClipWith(clip_rect); if (rect.Overlaps(clip_rect)) @@ -3930,7 +3931,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag if (label != label_display_end) { TextUnformatted(label, label_display_end); - Separator(); + Spacing(); } ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar; ImGuiColorEditFlags picker_flags = (flags_untouched & picker_flags_to_forward) | ImGuiColorEditFlags__InputsMask | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf; @@ -5556,7 +5557,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled) // Menu inside an horizontal menu bar // Selectable extend their highlight by half ItemSpacing in each direction. // For ChildMenu, the popup position will be overwritten by the call to FindBestWindowPosForPopup() in Begin() - popup_pos = ImVec2(pos.x - window->WindowPadding.x, pos.y - style.FramePadding.y + window->MenuBarHeight()); + popup_pos = ImVec2(pos.x - 1.0f - (float)(int)(style.ItemSpacing.x * 0.5f), pos.y - style.FramePadding.y + window->MenuBarHeight()); window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * 0.5f); PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing * 2.0f); float w = label_size.x; diff --git a/misc/freetype/imgui_freetype.cpp b/misc/freetype/imgui_freetype.cpp index 89aa23f5c..33bdb1404 100644 --- a/misc/freetype/imgui_freetype.cpp +++ b/misc/freetype/imgui_freetype.cpp @@ -337,7 +337,7 @@ bool ImGuiFreeType::BuildFontAtlas(ImFontAtlas* atlas, unsigned int extra_flags) { for (uint32_t codepoint = in_range[0]; codepoint <= in_range[1]; ++codepoint) { - if (cfg.MergeMode && dst_font->FindGlyphNoFallback((unsigned short)codepoint)) + if (cfg.MergeMode && dst_font->FindGlyphNoFallback((ImWchar)codepoint)) continue; FT_Glyph ft_glyph = NULL;