Renamed IM_ARRAYSIZE() -> IM_COUNTOF(). Kept legacy name for now.
build / Build - Windows (push) Has been cancelled
build / Build - Linux (push) Has been cancelled
build / Build - MacOS (push) Has been cancelled
build / Build - iOS (push) Has been cancelled
build / Build - Emscripten (push) Has been cancelled
build / Build - Android (push) Has been cancelled
build / Test - Windows (push) Has been cancelled
build / Test - Linux (push) Has been cancelled
build / Test - MacOS (push) Has been cancelled

This commit is contained in:
ocornut
2025-12-17 14:30:01 +01:00
parent 99bca397d8
commit 4e7c05504a
19 changed files with 235 additions and 231 deletions
+1 -1
View File
@@ -624,7 +624,7 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
// (2) there exists a version of d3d12.dll for Windows 7 (D3D12On7) in one of the following directories. // (2) there exists a version of d3d12.dll for Windows 7 (D3D12On7) in one of the following directories.
// See https://github.com/ocornut/imgui/pull/3696 for details. // See https://github.com/ocornut/imgui/pull/3696 for details.
const char* localD3d12Paths[] = { ".\\d3d12.dll", ".\\d3d12on7\\d3d12.dll", ".\\12on7\\d3d12.dll" }; // A. current directory, B. used by some games, C. used in Microsoft D3D12On7 sample const char* localD3d12Paths[] = { ".\\d3d12.dll", ".\\d3d12on7\\d3d12.dll", ".\\12on7\\d3d12.dll" }; // A. current directory, B. used by some games, C. used in Microsoft D3D12On7 sample
for (int i = 0; i < IM_ARRAYSIZE(localD3d12Paths); i++) for (int i = 0; i < IM_COUNTOF(localD3d12Paths); i++)
if ((d3d12_dll = ::LoadLibraryA(localD3d12Paths[i])) != nullptr) if ((d3d12_dll = ::LoadLibraryA(localD3d12Paths[i])) != nullptr)
break; break;
+1 -1
View File
@@ -454,7 +454,7 @@ static int ImGui_ImplGlfw_TranslateUntranslatedKey(int key, int scancode)
{ {
const char char_names[] = "`-=[]\\,;\'./"; const char char_names[] = "`-=[]\\,;\'./";
const int char_keys[] = { GLFW_KEY_GRAVE_ACCENT, GLFW_KEY_MINUS, GLFW_KEY_EQUAL, GLFW_KEY_LEFT_BRACKET, GLFW_KEY_RIGHT_BRACKET, GLFW_KEY_BACKSLASH, GLFW_KEY_COMMA, GLFW_KEY_SEMICOLON, GLFW_KEY_APOSTROPHE, GLFW_KEY_PERIOD, GLFW_KEY_SLASH, 0 }; const int char_keys[] = { GLFW_KEY_GRAVE_ACCENT, GLFW_KEY_MINUS, GLFW_KEY_EQUAL, GLFW_KEY_LEFT_BRACKET, GLFW_KEY_RIGHT_BRACKET, GLFW_KEY_BACKSLASH, GLFW_KEY_COMMA, GLFW_KEY_SEMICOLON, GLFW_KEY_APOSTROPHE, GLFW_KEY_PERIOD, GLFW_KEY_SLASH, 0 };
IM_ASSERT(IM_ARRAYSIZE(char_names) == IM_ARRAYSIZE(char_keys)); IM_ASSERT(IM_COUNTOF(char_names) == IM_COUNTOF(char_keys));
if (key_name[0] >= '0' && key_name[0] <= '9') { key = GLFW_KEY_0 + (key_name[0] - '0'); } if (key_name[0] >= '0' && key_name[0] <= '9') { key = GLFW_KEY_0 + (key_name[0] - '0'); }
else if (key_name[0] >= 'A' && key_name[0] <= 'Z') { key = GLFW_KEY_A + (key_name[0] - 'A'); } else if (key_name[0] >= 'A' && key_name[0] <= 'Z') { key = GLFW_KEY_A + (key_name[0] - 'A'); }
else if (key_name[0] >= 'a' && key_name[0] <= 'z') { key = GLFW_KEY_A + (key_name[0] - 'a'); } else if (key_name[0] >= 'a' && key_name[0] <= 'z') { key = GLFW_KEY_A + (key_name[0] - 'a'); }
+1 -1
View File
@@ -387,7 +387,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
glsl_version = "#version 130"; glsl_version = "#version 130";
#endif #endif
} }
IM_ASSERT((int)strlen(glsl_version) + 2 < IM_ARRAYSIZE(bd->GlslVersionString)); IM_ASSERT((int)strlen(glsl_version) + 2 < IM_COUNTOF(bd->GlslVersionString));
strcpy(bd->GlslVersionString, glsl_version); strcpy(bd->GlslVersionString, glsl_version);
strcat(bd->GlslVersionString, "\n"); strcat(bd->GlslVersionString, "\n");
+2 -2
View File
@@ -1002,7 +1002,7 @@ static VkPipeline ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAlloc
VkDynamicState dynamic_states[2] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR }; VkDynamicState dynamic_states[2] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
VkPipelineDynamicStateCreateInfo dynamic_state = {}; VkPipelineDynamicStateCreateInfo dynamic_state = {};
dynamic_state.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; dynamic_state.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
dynamic_state.dynamicStateCount = (uint32_t)IM_ARRAYSIZE(dynamic_states); dynamic_state.dynamicStateCount = (uint32_t)IM_COUNTOF(dynamic_states);
dynamic_state.pDynamicStates = dynamic_states; dynamic_state.pDynamicStates = dynamic_states;
VkGraphicsPipelineCreateInfo create_info = {}; VkGraphicsPipelineCreateInfo create_info = {};
@@ -1667,7 +1667,7 @@ void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, V
check_vk_result(err); check_vk_result(err);
VkImage backbuffers[16] = {}; VkImage backbuffers[16] = {};
IM_ASSERT(wd->ImageCount >= min_image_count); IM_ASSERT(wd->ImageCount >= min_image_count);
IM_ASSERT(wd->ImageCount < IM_ARRAYSIZE(backbuffers)); IM_ASSERT(wd->ImageCount < IM_COUNTOF(backbuffers));
err = vkGetSwapchainImagesKHR(device, wd->Swapchain, &wd->ImageCount, backbuffers); err = vkGetSwapchainImagesKHR(device, wd->Swapchain, &wd->ImageCount, backbuffers);
check_vk_result(err); check_vk_result(err);
+1 -1
View File
@@ -197,7 +197,7 @@ static bool ImGui_ImplWin32_InitEx(void* hwnd, bool platform_has_own_dc)
"xinput1_2.dll", // DirectX SDK "xinput1_2.dll", // DirectX SDK
"xinput1_1.dll" // DirectX SDK "xinput1_1.dll" // DirectX SDK
}; };
for (int n = 0; n < IM_ARRAYSIZE(xinput_dll_names); n++) for (int n = 0; n < IM_COUNTOF(xinput_dll_names); n++)
if (HMODULE dll = ::LoadLibraryA(xinput_dll_names[n])) if (HMODULE dll = ::LoadLibraryA(xinput_dll_names[n]))
{ {
bd->XInputDLL = dll; bd->XInputDLL = dll;
+1
View File
@@ -49,6 +49,7 @@ Breaking Changes:
identifiers using "###", and will allow fixing other dangling issues. identifiers using "###", and will allow fixing other dangling issues.
- This will invalidate hashes (stored in .ini data) for Tables and Windows - This will invalidate hashes (stored in .ini data) for Tables and Windows
that are using the "###" operators. (#713, #1698) that are using the "###" operators. (#713, #1698)
- Renamed helper macro IM_ARRAYSIZE() -> IM_COUNTOF(). Kept redirection/legacy name.
- Fonts: Fixed handling of `ImFontConfig::FontDataOwnedByAtlas = false` which - Fonts: Fixed handling of `ImFontConfig::FontDataOwnedByAtlas = false` which
did erroneously make a copy of the font data, essentially defeating the purpose did erroneously make a copy of the font data, essentially defeating the purpose
of this flag and wasting memory (undetected since July 2015 and now spotted of this flag and wasting memory (undetected since July 2015 and now spotted
+2 -2
View File
@@ -202,7 +202,7 @@ if (ImGui::Button(u8"ロード"))
{ {
// do stuff // do stuff
} }
ImGui::InputText("string", buf, IM_ARRAYSIZE(buf)); ImGui::InputText("string", buf, IM_COUNTOF(buf));
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
``` ```
@@ -439,7 +439,7 @@ unsigned char* tex_pixels = nullptr;
int tex_width, tex_height; int tex_width, tex_height;
io.Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_width, &tex_height); io.Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_width, &tex_height);
for (int rect_n = 0; rect_n < IM_ARRAYSIZE(rect_ids); rect_n++) for (int rect_n = 0; rect_n < IM_COUNTOF(rect_ids); rect_n++)
if (const ImTextureRect* rect = io.Fonts->GetCustomRect(rect_ids[rect_n])) if (const ImTextureRect* rect = io.Fonts->GetCustomRect(rect_ids[rect_n]))
{ {
// Fill the custom rectangle with red pixels (in reality you would draw/copy your bitmap data here!) // Fill the custom rectangle with red pixels (in reality you would draw/copy your bitmap data here!)
+1 -1
View File
@@ -52,7 +52,7 @@ After Dear ImGui is set up in your application, you can use it from \_anywhere\_
ImGui::Text("Hello, world %d", 123); ImGui::Text("Hello, world %d", 123);
if (ImGui::Button("Save")) if (ImGui::Button("Save"))
MySaveFunction(); MySaveFunction();
ImGui::InputText("string", buf, IM_ARRAYSIZE(buf)); ImGui::InputText("string", buf, IM_COUNTOF(buf));
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
``` ```
![sample code output (dark, segoeui font, freetype)](https://user-images.githubusercontent.com/8225057/191050833-b7ecf528-bfae-4a9f-ac1b-f3d83437a2f4.png) ![sample code output (dark, segoeui font, freetype)](https://user-images.githubusercontent.com/8225057/191050833-b7ecf528-bfae-4a9f-ac1b-f3d83437a2f4.png)
+3 -3
View File
@@ -201,7 +201,7 @@ static void SetupVulkan(ImVector<const char*> instance_extensions)
pool_info.maxSets = 0; pool_info.maxSets = 0;
for (VkDescriptorPoolSize& pool_size : pool_sizes) for (VkDescriptorPoolSize& pool_size : pool_sizes)
pool_info.maxSets += pool_size.descriptorCount; pool_info.maxSets += pool_size.descriptorCount;
pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes); pool_info.poolSizeCount = (uint32_t)IM_COUNTOF(pool_sizes);
pool_info.pPoolSizes = pool_sizes; pool_info.pPoolSizes = pool_sizes;
err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool); err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool);
check_vk_result(err); check_vk_result(err);
@@ -226,7 +226,7 @@ static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface
// Select Surface Format // Select Surface Format
const VkFormat requestSurfaceImageFormat[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM }; const VkFormat requestSurfaceImageFormat[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM };
const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_ARRAYSIZE(requestSurfaceImageFormat), requestSurfaceColorSpace); wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_COUNTOF(requestSurfaceImageFormat), requestSurfaceColorSpace);
// Select Present Mode // Select Present Mode
#ifdef APP_USE_UNLIMITED_FRAME_RATE #ifdef APP_USE_UNLIMITED_FRAME_RATE
@@ -234,7 +234,7 @@ static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface
#else #else
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR }; VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR };
#endif #endif
wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(g_PhysicalDevice, wd->Surface, &present_modes[0], IM_ARRAYSIZE(present_modes)); wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(g_PhysicalDevice, wd->Surface, &present_modes[0], IM_COUNTOF(present_modes));
//printf("[vulkan] Selected PresentMode = %d\n", wd->PresentMode); //printf("[vulkan] Selected PresentMode = %d\n", wd->PresentMode);
// Create SwapChain, RenderPass, Framebuffer, etc. // Create SwapChain, RenderPass, Framebuffer, etc.
+3 -3
View File
@@ -192,7 +192,7 @@ static void SetupVulkan(ImVector<const char*> instance_extensions)
pool_info.maxSets = 0; pool_info.maxSets = 0;
for (VkDescriptorPoolSize& pool_size : pool_sizes) for (VkDescriptorPoolSize& pool_size : pool_sizes)
pool_info.maxSets += pool_size.descriptorCount; pool_info.maxSets += pool_size.descriptorCount;
pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes); pool_info.poolSizeCount = (uint32_t)IM_COUNTOF(pool_sizes);
pool_info.pPoolSizes = pool_sizes; pool_info.pPoolSizes = pool_sizes;
err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool); err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool);
check_vk_result(err); check_vk_result(err);
@@ -217,7 +217,7 @@ static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface
// Select Surface Format // Select Surface Format
const VkFormat requestSurfaceImageFormat[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM }; const VkFormat requestSurfaceImageFormat[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM };
const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_ARRAYSIZE(requestSurfaceImageFormat), requestSurfaceColorSpace); wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_COUNTOF(requestSurfaceImageFormat), requestSurfaceColorSpace);
// Select Present Mode // Select Present Mode
#ifdef APP_USE_UNLIMITED_FRAME_RATE #ifdef APP_USE_UNLIMITED_FRAME_RATE
@@ -225,7 +225,7 @@ static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface
#else #else
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR }; VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR };
#endif #endif
wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(g_PhysicalDevice, wd->Surface, &present_modes[0], IM_ARRAYSIZE(present_modes)); wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(g_PhysicalDevice, wd->Surface, &present_modes[0], IM_COUNTOF(present_modes));
//printf("[vulkan] Selected PresentMode = %d\n", wd->PresentMode); //printf("[vulkan] Selected PresentMode = %d\n", wd->PresentMode);
// Create SwapChain, RenderPass, Framebuffer, etc. // Create SwapChain, RenderPass, Framebuffer, etc.
+3 -3
View File
@@ -194,7 +194,7 @@ static void SetupVulkan(ImVector<const char*> instance_extensions)
pool_info.maxSets = 0; pool_info.maxSets = 0;
for (VkDescriptorPoolSize& pool_size : pool_sizes) for (VkDescriptorPoolSize& pool_size : pool_sizes)
pool_info.maxSets += pool_size.descriptorCount; pool_info.maxSets += pool_size.descriptorCount;
pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes); pool_info.poolSizeCount = (uint32_t)IM_COUNTOF(pool_sizes);
pool_info.pPoolSizes = pool_sizes; pool_info.pPoolSizes = pool_sizes;
err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool); err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool);
check_vk_result(err); check_vk_result(err);
@@ -219,7 +219,7 @@ static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface
// Select Surface Format // Select Surface Format
const VkFormat requestSurfaceImageFormat[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM }; const VkFormat requestSurfaceImageFormat[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM };
const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_ARRAYSIZE(requestSurfaceImageFormat), requestSurfaceColorSpace); wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_COUNTOF(requestSurfaceImageFormat), requestSurfaceColorSpace);
// Select Present Mode // Select Present Mode
#ifdef APP_USE_UNLIMITED_FRAME_RATE #ifdef APP_USE_UNLIMITED_FRAME_RATE
@@ -227,7 +227,7 @@ static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface
#else #else
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR }; VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR };
#endif #endif
wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(g_PhysicalDevice, wd->Surface, &present_modes[0], IM_ARRAYSIZE(present_modes)); wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(g_PhysicalDevice, wd->Surface, &present_modes[0], IM_COUNTOF(present_modes));
//printf("[vulkan] Selected PresentMode = %d\n", wd->PresentMode); //printf("[vulkan] Selected PresentMode = %d\n", wd->PresentMode);
// Create SwapChain, RenderPass, Framebuffer, etc. // Create SwapChain, RenderPass, Framebuffer, etc.
+3 -3
View File
@@ -190,7 +190,7 @@ static void SetupVulkan(ImVector<const char*> instance_extensions)
pool_info.maxSets = 0; pool_info.maxSets = 0;
for (VkDescriptorPoolSize& pool_size : pool_sizes) for (VkDescriptorPoolSize& pool_size : pool_sizes)
pool_info.maxSets += pool_size.descriptorCount; pool_info.maxSets += pool_size.descriptorCount;
pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes); pool_info.poolSizeCount = (uint32_t)IM_COUNTOF(pool_sizes);
pool_info.pPoolSizes = pool_sizes; pool_info.pPoolSizes = pool_sizes;
err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool); err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool);
check_vk_result(err); check_vk_result(err);
@@ -215,7 +215,7 @@ static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface
// Select Surface Format // Select Surface Format
const VkFormat requestSurfaceImageFormat[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM }; const VkFormat requestSurfaceImageFormat[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM };
const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_ARRAYSIZE(requestSurfaceImageFormat), requestSurfaceColorSpace); wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_COUNTOF(requestSurfaceImageFormat), requestSurfaceColorSpace);
// Select Present Mode // Select Present Mode
#ifdef APP_USE_UNLIMITED_FRAME_RATE #ifdef APP_USE_UNLIMITED_FRAME_RATE
@@ -223,7 +223,7 @@ static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface
#else #else
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR }; VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR };
#endif #endif
wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(g_PhysicalDevice, wd->Surface, &present_modes[0], IM_ARRAYSIZE(present_modes)); wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(g_PhysicalDevice, wd->Surface, &present_modes[0], IM_COUNTOF(present_modes));
//printf("[vulkan] Selected PresentMode = %d\n", wd->PresentMode); //printf("[vulkan] Selected PresentMode = %d\n", wd->PresentMode);
// Create SwapChain, RenderPass, Framebuffer, etc. // Create SwapChain, RenderPass, Framebuffer, etc.
+60 -59
View File
@@ -394,6 +394,7 @@ IMPLEMENTING SUPPORT for ImGuiBackendFlags_RendererHasTextures:
When you are not sure about an old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files. When you are not sure about an old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
You can read releases logs https://github.com/ocornut/imgui/releases for more details. You can read releases logs https://github.com/ocornut/imgui/releases for more details.
- 2025/12/17 (1.92.6) - Renamed helper macro IM_ARRAYSIZE() -> IM_COUNTOF(). Kept redirection/legacy name for now.
- 2025/12/11 (1.92.6) - Hashing: handling of "###" operator to reset to seed within a string identifier doesn't include the "###" characters in the output hash anymore. - 2025/12/11 (1.92.6) - Hashing: handling of "###" operator to reset to seed within a string identifier doesn't include the "###" characters in the output hash anymore.
- Before: GetID("Hello###World") == GetID("###World") != GetID("World"); - Before: GetID("Hello###World") == GetID("###World") != GetID("World");
- Now: GetID("Hello###World") == GetID("###World") == GetID("World"); - Now: GetID("Hello###World") == GetID("###World") == GetID("World");
@@ -1544,7 +1545,7 @@ ImGuiIO::ImGuiIO()
{ {
// Most fields are initialized with zero // Most fields are initialized with zero
memset(this, 0, sizeof(*this)); memset(this, 0, sizeof(*this));
IM_STATIC_ASSERT(IM_ARRAYSIZE(ImGuiIO::MouseDown) == ImGuiMouseButton_COUNT && IM_ARRAYSIZE(ImGuiIO::MouseClicked) == ImGuiMouseButton_COUNT); IM_STATIC_ASSERT(IM_COUNTOF(ImGuiIO::MouseDown) == ImGuiMouseButton_COUNT && IM_COUNTOF(ImGuiIO::MouseClicked) == ImGuiMouseButton_COUNT);
// Settings // Settings
ConfigFlags = ImGuiConfigFlags_None; ConfigFlags = ImGuiConfigFlags_None;
@@ -1616,8 +1617,8 @@ ImGuiIO::ImGuiIO()
MousePos = ImVec2(-FLT_MAX, -FLT_MAX); MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
MousePosPrev = ImVec2(-FLT_MAX, -FLT_MAX); MousePosPrev = ImVec2(-FLT_MAX, -FLT_MAX);
MouseSource = ImGuiMouseSource_Mouse; MouseSource = ImGuiMouseSource_Mouse;
for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++) MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f; for (int i = 0; i < IM_COUNTOF(MouseDownDuration); i++) MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f;
for (int i = 0; i < IM_ARRAYSIZE(KeysData); i++) { KeysData[i].DownDuration = KeysData[i].DownDurationPrev = -1.0f; } for (int i = 0; i < IM_COUNTOF(KeysData); i++) { KeysData[i].DownDuration = KeysData[i].DownDurationPrev = -1.0f; }
AppAcceptingEvents = true; AppAcceptingEvents = true;
} }
@@ -1725,7 +1726,7 @@ void ImGuiIO::ClearInputMouse()
key_data->DownDurationPrev = -1.0f; key_data->DownDurationPrev = -1.0f;
} }
MousePos = ImVec2(-FLT_MAX, -FLT_MAX); MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
for (int n = 0; n < IM_ARRAYSIZE(MouseDown); n++) for (int n = 0; n < IM_COUNTOF(MouseDown); n++)
{ {
MouseDown[n] = false; MouseDown[n] = false;
MouseDownDuration[n] = MouseDownDurationPrev[n] = -1.0f; MouseDownDuration[n] = MouseDownDurationPrev[n] = -1.0f;
@@ -2454,7 +2455,7 @@ ImFileHandle ImFileOpen(const char* filename, const char* mode)
// We don't rely on current ImGuiContext as this is implied to be a helper function which doesn't depend on it (see #7314). // We don't rely on current ImGuiContext as this is implied to be a helper function which doesn't depend on it (see #7314).
wchar_t local_temp_stack[FILENAME_MAX]; wchar_t local_temp_stack[FILENAME_MAX];
ImVector<wchar_t> local_temp_heap; ImVector<wchar_t> local_temp_heap;
if (filename_wsize + mode_wsize > IM_ARRAYSIZE(local_temp_stack)) if (filename_wsize + mode_wsize > IM_COUNTOF(local_temp_stack))
local_temp_heap.resize(filename_wsize + mode_wsize); local_temp_heap.resize(filename_wsize + mode_wsize);
wchar_t* filename_wbuf = local_temp_heap.Data ? local_temp_heap.Data : local_temp_stack; wchar_t* filename_wbuf = local_temp_heap.Data ? local_temp_heap.Data : local_temp_stack;
wchar_t* mode_wbuf = filename_wbuf + filename_wsize; wchar_t* mode_wbuf = filename_wbuf + filename_wsize;
@@ -2969,7 +2970,7 @@ ImGuiTextFilter::ImGuiTextFilter(const char* default_filter) //-V1077
CountGrep = 0; CountGrep = 0;
if (default_filter) if (default_filter)
{ {
ImStrncpy(InputBuf, default_filter, IM_ARRAYSIZE(InputBuf)); ImStrncpy(InputBuf, default_filter, IM_COUNTOF(InputBuf));
Build(); Build();
} }
} }
@@ -2978,7 +2979,7 @@ bool ImGuiTextFilter::Draw(const char* label, float width)
{ {
if (width != 0.0f) if (width != 0.0f)
ImGui::SetNextItemWidth(width); ImGui::SetNextItemWidth(width);
bool value_changed = ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf)); bool value_changed = ImGui::InputText(label, InputBuf, IM_COUNTOF(InputBuf));
if (value_changed) if (value_changed)
Build(); Build();
return value_changed; return value_changed;
@@ -3602,7 +3603,7 @@ static const ImGuiStyleVarInfo GStyleVarsInfo[] =
const ImGuiStyleVarInfo* ImGui::GetStyleVarInfo(ImGuiStyleVar idx) const ImGuiStyleVarInfo* ImGui::GetStyleVarInfo(ImGuiStyleVar idx)
{ {
IM_ASSERT(idx >= 0 && idx < ImGuiStyleVar_COUNT); IM_ASSERT(idx >= 0 && idx < ImGuiStyleVar_COUNT);
IM_STATIC_ASSERT(IM_ARRAYSIZE(GStyleVarsInfo) == ImGuiStyleVar_COUNT); IM_STATIC_ASSERT(IM_COUNTOF(GStyleVarsInfo) == ImGuiStyleVar_COUNT);
return &GStyleVarsInfo[idx]; return &GStyleVarsInfo[idx];
} }
@@ -4343,7 +4344,7 @@ void ImGui::Initialize()
TableSettingsAddSettingsHandler(); TableSettingsAddSettingsHandler();
// Setup default localization table // Setup default localization table
LocalizeRegisterEntries(GLocalizationEntriesEnUS, IM_ARRAYSIZE(GLocalizationEntriesEnUS)); LocalizeRegisterEntries(GLocalizationEntriesEnUS, IM_COUNTOF(GLocalizationEntriesEnUS));
// Setup default ImGuiPlatformIO clipboard/IME handlers. // Setup default ImGuiPlatformIO clipboard/IME handlers.
g.PlatformIO.Platform_GetClipboardTextFn = Platform_GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations g.PlatformIO.Platform_GetClipboardTextFn = Platform_GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations
@@ -4476,7 +4477,7 @@ void ImGui::Shutdown()
// (A) Will be visible in debugger, (B) Will be included in all IMGUI_DEBUG_LOG() calls, (C) Should be <= 15 characters long. // (A) Will be visible in debugger, (B) Will be included in all IMGUI_DEBUG_LOG() calls, (C) Should be <= 15 characters long.
void ImGui::SetContextName(ImGuiContext* ctx, const char* name) void ImGui::SetContextName(ImGuiContext* ctx, const char* name)
{ {
ImStrncpy(ctx->ContextName, name, IM_ARRAYSIZE(ctx->ContextName)); ImStrncpy(ctx->ContextName, name, IM_COUNTOF(ctx->ContextName));
} }
// No specific ordering/dependency support, will see as needed // No specific ordering/dependency support, will see as needed
@@ -5047,7 +5048,7 @@ void ImGui::DebugAllocHook(ImGuiDebugAllocInfo* info, int frame_count, void* ptr
IM_UNUSED(ptr); IM_UNUSED(ptr);
if (entry->FrameCount != frame_count) if (entry->FrameCount != frame_count)
{ {
info->LastEntriesIdx = (info->LastEntriesIdx + 1) % IM_ARRAYSIZE(info->LastEntriesBuf); info->LastEntriesIdx = (info->LastEntriesIdx + 1) % IM_COUNTOF(info->LastEntriesBuf);
entry = &info->LastEntriesBuf[info->LastEntriesIdx]; entry = &info->LastEntriesBuf[info->LastEntriesIdx];
entry->FrameCount = frame_count; entry->FrameCount = frame_count;
entry->AllocCount = entry->FreeCount = 0; entry->AllocCount = entry->FreeCount = 0;
@@ -5132,7 +5133,7 @@ static ImDrawList* GetViewportBgFgDrawList(ImGuiViewportP* viewport, size_t draw
{ {
// Create the draw list on demand, because they are not frequently used for all viewports // Create the draw list on demand, because they are not frequently used for all viewports
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(drawlist_no < IM_ARRAYSIZE(viewport->BgFgDrawLists)); IM_ASSERT(drawlist_no < IM_COUNTOF(viewport->BgFgDrawLists));
ImDrawList* draw_list = viewport->BgFgDrawLists[drawlist_no]; ImDrawList* draw_list = viewport->BgFgDrawLists[drawlist_no];
if (draw_list == NULL) if (draw_list == NULL)
{ {
@@ -5355,7 +5356,7 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags(const ImVec2& mouse_pos)
const bool has_open_modal = (modal_window != NULL); const bool has_open_modal = (modal_window != NULL);
int mouse_earliest_down = -1; int mouse_earliest_down = -1;
bool mouse_any_down = false; bool mouse_any_down = false;
for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) for (int i = 0; i < IM_COUNTOF(io.MouseDown); i++)
{ {
if (io.MouseClicked[i]) if (io.MouseClicked[i])
{ {
@@ -5458,8 +5459,8 @@ void ImGui::NewFrame()
// Calculate frame-rate for the user, as a purely luxurious feature // Calculate frame-rate for the user, as a purely luxurious feature
g.FramerateSecPerFrameAccum += g.IO.DeltaTime - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx]; g.FramerateSecPerFrameAccum += g.IO.DeltaTime - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx];
g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx] = g.IO.DeltaTime; g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx] = g.IO.DeltaTime;
g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame); g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_COUNTOF(g.FramerateSecPerFrame);
g.FramerateSecPerFrameCount = ImMin(g.FramerateSecPerFrameCount + 1, IM_ARRAYSIZE(g.FramerateSecPerFrame)); g.FramerateSecPerFrameCount = ImMin(g.FramerateSecPerFrameCount + 1, IM_COUNTOF(g.FramerateSecPerFrame));
g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)g.FramerateSecPerFrameCount)) : FLT_MAX; g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)g.FramerateSecPerFrameCount)) : FLT_MAX;
// Process input queue (trickle as many events as possible), turn events into writes to IO structure // Process input queue (trickle as many events as possible), turn events into writes to IO structure
@@ -5768,10 +5769,10 @@ static void FlattenDrawDataIntoSingleLayer(ImDrawDataBuilder* builder)
{ {
int n = builder->Layers[0]->Size; int n = builder->Layers[0]->Size;
int full_size = n; int full_size = n;
for (int i = 1; i < IM_ARRAYSIZE(builder->Layers); i++) for (int i = 1; i < IM_COUNTOF(builder->Layers); i++)
full_size += builder->Layers[i]->Size; full_size += builder->Layers[i]->Size;
builder->Layers[0]->resize(full_size); builder->Layers[0]->resize(full_size);
for (int layer_n = 1; layer_n < IM_ARRAYSIZE(builder->Layers); layer_n++) for (int layer_n = 1; layer_n < IM_COUNTOF(builder->Layers); layer_n++)
{ {
ImVector<ImDrawList*>* layer = builder->Layers[layer_n]; ImVector<ImDrawList*>* layer = builder->Layers[layer_n];
if (layer->empty()) if (layer->empty())
@@ -6047,7 +6048,7 @@ void ImGui::Render()
if (IsWindowActiveAndVisible(window) && (window->Flags & ImGuiWindowFlags_ChildWindow) == 0 && window != windows_to_render_top_most[0] && window != windows_to_render_top_most[1]) if (IsWindowActiveAndVisible(window) && (window->Flags & ImGuiWindowFlags_ChildWindow) == 0 && window != windows_to_render_top_most[0] && window != windows_to_render_top_most[1])
AddRootWindowToDrawData(window); AddRootWindowToDrawData(window);
} }
for (int n = 0; n < IM_ARRAYSIZE(windows_to_render_top_most); n++) for (int n = 0; n < IM_COUNTOF(windows_to_render_top_most); n++)
if (windows_to_render_top_most[n] && IsWindowActiveAndVisible(windows_to_render_top_most[n])) // NavWindowingTarget is always temporarily displayed as the top-most window if (windows_to_render_top_most[n] && IsWindowActiveAndVisible(windows_to_render_top_most[n])) // NavWindowingTarget is always temporarily displayed as the top-most window
AddRootWindowToDrawData(windows_to_render_top_most[n]); AddRootWindowToDrawData(windows_to_render_top_most[n]);
@@ -9376,7 +9377,7 @@ static const char* const GKeyNames[] =
"MouseLeft", "MouseRight", "MouseMiddle", "MouseX1", "MouseX2", "MouseWheelX", "MouseWheelY", "MouseLeft", "MouseRight", "MouseMiddle", "MouseX1", "MouseX2", "MouseWheelX", "MouseWheelY",
"ModCtrl", "ModShift", "ModAlt", "ModSuper", // ReservedForModXXX are showing the ModXXX names. "ModCtrl", "ModShift", "ModAlt", "ModSuper", // ReservedForModXXX are showing the ModXXX names.
}; };
IM_STATIC_ASSERT(ImGuiKey_NamedKey_COUNT == IM_ARRAYSIZE(GKeyNames)); IM_STATIC_ASSERT(ImGuiKey_NamedKey_COUNT == IM_COUNTOF(GKeyNames));
const char* ImGui::GetKeyName(ImGuiKey key) const char* ImGui::GetKeyName(ImGuiKey key)
{ {
@@ -9400,7 +9401,7 @@ const char* ImGui::GetKeyChordName(ImGuiKeyChord key_chord)
const ImGuiKey key = (ImGuiKey)(key_chord & ~ImGuiMod_Mask_); const ImGuiKey key = (ImGuiKey)(key_chord & ~ImGuiMod_Mask_);
if (IsLRModKey(key)) if (IsLRModKey(key))
key_chord &= ~GetModForLRModKey(key); // Return "Ctrl+LeftShift" instead of "Ctrl+Shift+LeftShift" key_chord &= ~GetModForLRModKey(key); // Return "Ctrl+LeftShift" instead of "Ctrl+Shift+LeftShift"
ImFormatString(g.TempKeychordName, IM_ARRAYSIZE(g.TempKeychordName), "%s%s%s%s%s", ImFormatString(g.TempKeychordName, IM_COUNTOF(g.TempKeychordName), "%s%s%s%s%s",
(key_chord & ImGuiMod_Ctrl) ? "Ctrl+" : "", (key_chord & ImGuiMod_Ctrl) ? "Ctrl+" : "",
(key_chord & ImGuiMod_Shift) ? "Shift+" : "", (key_chord & ImGuiMod_Shift) ? "Shift+" : "",
(key_chord & ImGuiMod_Alt) ? "Alt+" : "", (key_chord & ImGuiMod_Alt) ? "Alt+" : "",
@@ -9808,14 +9809,14 @@ bool ImGui::IsKeyReleased(ImGuiKey key, ImGuiID owner_id)
bool ImGui::IsMouseDown(ImGuiMouseButton button) bool ImGui::IsMouseDown(ImGuiMouseButton button)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); IM_ASSERT(button >= 0 && button < IM_COUNTOF(g.IO.MouseDown));
return g.IO.MouseDown[button] && TestKeyOwner(MouseButtonToKey(button), ImGuiKeyOwner_Any); // should be same as IsKeyDown(MouseButtonToKey(button), ImGuiKeyOwner_Any), but this allows legacy code hijacking the io.Mousedown[] array. return g.IO.MouseDown[button] && TestKeyOwner(MouseButtonToKey(button), ImGuiKeyOwner_Any); // should be same as IsKeyDown(MouseButtonToKey(button), ImGuiKeyOwner_Any), but this allows legacy code hijacking the io.Mousedown[] array.
} }
bool ImGui::IsMouseDown(ImGuiMouseButton button, ImGuiID owner_id) bool ImGui::IsMouseDown(ImGuiMouseButton button, ImGuiID owner_id)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); IM_ASSERT(button >= 0 && button < IM_COUNTOF(g.IO.MouseDown));
return g.IO.MouseDown[button] && TestKeyOwner(MouseButtonToKey(button), owner_id); // Should be same as IsKeyDown(MouseButtonToKey(button), owner_id), but this allows legacy code hijacking the io.Mousedown[] array. return g.IO.MouseDown[button] && TestKeyOwner(MouseButtonToKey(button), owner_id); // Should be same as IsKeyDown(MouseButtonToKey(button), owner_id), but this allows legacy code hijacking the io.Mousedown[] array.
} }
@@ -9827,7 +9828,7 @@ bool ImGui::IsMouseClicked(ImGuiMouseButton button, bool repeat)
bool ImGui::IsMouseClicked(ImGuiMouseButton button, ImGuiInputFlags flags, ImGuiID owner_id) bool ImGui::IsMouseClicked(ImGuiMouseButton button, ImGuiInputFlags flags, ImGuiID owner_id)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); IM_ASSERT(button >= 0 && button < IM_COUNTOF(g.IO.MouseDown));
if (!g.IO.MouseDown[button]) // In theory this should already be encoded as (DownDuration < 0.0f), but testing this facilitates eating mechanism (until we finish work on key ownership) if (!g.IO.MouseDown[button]) // In theory this should already be encoded as (DownDuration < 0.0f), but testing this facilitates eating mechanism (until we finish work on key ownership)
return false; return false;
const float t = g.IO.MouseDownDuration[button]; const float t = g.IO.MouseDownDuration[button];
@@ -9849,14 +9850,14 @@ bool ImGui::IsMouseClicked(ImGuiMouseButton button, ImGuiInputFlags flags, ImGui
bool ImGui::IsMouseReleased(ImGuiMouseButton button) bool ImGui::IsMouseReleased(ImGuiMouseButton button)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); IM_ASSERT(button >= 0 && button < IM_COUNTOF(g.IO.MouseDown));
return g.IO.MouseReleased[button] && TestKeyOwner(MouseButtonToKey(button), ImGuiKeyOwner_Any); // Should be same as IsKeyReleased(MouseButtonToKey(button), ImGuiKeyOwner_Any) return g.IO.MouseReleased[button] && TestKeyOwner(MouseButtonToKey(button), ImGuiKeyOwner_Any); // Should be same as IsKeyReleased(MouseButtonToKey(button), ImGuiKeyOwner_Any)
} }
bool ImGui::IsMouseReleased(ImGuiMouseButton button, ImGuiID owner_id) bool ImGui::IsMouseReleased(ImGuiMouseButton button, ImGuiID owner_id)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); IM_ASSERT(button >= 0 && button < IM_COUNTOF(g.IO.MouseDown));
return g.IO.MouseReleased[button] && TestKeyOwner(MouseButtonToKey(button), owner_id); // Should be same as IsKeyReleased(MouseButtonToKey(button), owner_id) return g.IO.MouseReleased[button] && TestKeyOwner(MouseButtonToKey(button), owner_id); // Should be same as IsKeyReleased(MouseButtonToKey(button), owner_id)
} }
@@ -9866,7 +9867,7 @@ bool ImGui::IsMouseReleased(ImGuiMouseButton button, ImGuiID owner_id)
bool ImGui::IsMouseReleasedWithDelay(ImGuiMouseButton button, float delay) bool ImGui::IsMouseReleasedWithDelay(ImGuiMouseButton button, float delay)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); IM_ASSERT(button >= 0 && button < IM_COUNTOF(g.IO.MouseDown));
const float time_since_release = (float)(g.Time - g.IO.MouseReleasedTime[button]); const float time_since_release = (float)(g.Time - g.IO.MouseReleasedTime[button]);
return !IsMouseDown(button) && (time_since_release - g.IO.DeltaTime < delay) && (time_since_release >= delay); return !IsMouseDown(button) && (time_since_release - g.IO.DeltaTime < delay) && (time_since_release >= delay);
} }
@@ -9874,21 +9875,21 @@ bool ImGui::IsMouseReleasedWithDelay(ImGuiMouseButton button, float delay)
bool ImGui::IsMouseDoubleClicked(ImGuiMouseButton button) bool ImGui::IsMouseDoubleClicked(ImGuiMouseButton button)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); IM_ASSERT(button >= 0 && button < IM_COUNTOF(g.IO.MouseDown));
return g.IO.MouseClickedCount[button] == 2 && TestKeyOwner(MouseButtonToKey(button), ImGuiKeyOwner_Any); return g.IO.MouseClickedCount[button] == 2 && TestKeyOwner(MouseButtonToKey(button), ImGuiKeyOwner_Any);
} }
bool ImGui::IsMouseDoubleClicked(ImGuiMouseButton button, ImGuiID owner_id) bool ImGui::IsMouseDoubleClicked(ImGuiMouseButton button, ImGuiID owner_id)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); IM_ASSERT(button >= 0 && button < IM_COUNTOF(g.IO.MouseDown));
return g.IO.MouseClickedCount[button] == 2 && TestKeyOwner(MouseButtonToKey(button), owner_id); return g.IO.MouseClickedCount[button] == 2 && TestKeyOwner(MouseButtonToKey(button), owner_id);
} }
int ImGui::GetMouseClickedCount(ImGuiMouseButton button) int ImGui::GetMouseClickedCount(ImGuiMouseButton button)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); IM_ASSERT(button >= 0 && button < IM_COUNTOF(g.IO.MouseDown));
return g.IO.MouseClickedCount[button]; return g.IO.MouseClickedCount[button];
} }
@@ -9915,7 +9916,7 @@ bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool c
bool ImGui::IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold) bool ImGui::IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); IM_ASSERT(button >= 0 && button < IM_COUNTOF(g.IO.MouseDown));
if (lock_threshold < 0.0f) if (lock_threshold < 0.0f)
lock_threshold = g.IO.MouseDragThreshold; lock_threshold = g.IO.MouseDragThreshold;
return g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold; return g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold;
@@ -9924,7 +9925,7 @@ bool ImGui::IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_thresho
bool ImGui::IsMouseDragging(ImGuiMouseButton button, float lock_threshold) bool ImGui::IsMouseDragging(ImGuiMouseButton button, float lock_threshold)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); IM_ASSERT(button >= 0 && button < IM_COUNTOF(g.IO.MouseDown));
if (!g.IO.MouseDown[button]) if (!g.IO.MouseDown[button])
return false; return false;
return IsMouseDragPastThreshold(button, lock_threshold); return IsMouseDragPastThreshold(button, lock_threshold);
@@ -9971,7 +9972,7 @@ bool ImGui::IsMousePosValid(const ImVec2* mouse_pos)
bool ImGui::IsAnyMouseDown() bool ImGui::IsAnyMouseDown()
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
for (int n = 0; n < IM_ARRAYSIZE(g.IO.MouseDown); n++) for (int n = 0; n < IM_COUNTOF(g.IO.MouseDown); n++)
if (g.IO.MouseDown[n]) if (g.IO.MouseDown[n])
return true; return true;
return false; return false;
@@ -9983,7 +9984,7 @@ bool ImGui::IsAnyMouseDown()
ImVec2 ImGui::GetMouseDragDelta(ImGuiMouseButton button, float lock_threshold) ImVec2 ImGui::GetMouseDragDelta(ImGuiMouseButton button, float lock_threshold)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); IM_ASSERT(button >= 0 && button < IM_COUNTOF(g.IO.MouseDown));
if (lock_threshold < 0.0f) if (lock_threshold < 0.0f)
lock_threshold = g.IO.MouseDragThreshold; lock_threshold = g.IO.MouseDragThreshold;
if (g.IO.MouseDown[button] || g.IO.MouseReleased[button]) if (g.IO.MouseDown[button] || g.IO.MouseReleased[button])
@@ -9996,7 +9997,7 @@ ImVec2 ImGui::GetMouseDragDelta(ImGuiMouseButton button, float lock_threshold)
void ImGui::ResetMouseDragDelta(ImGuiMouseButton button) void ImGui::ResetMouseDragDelta(ImGuiMouseButton button)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); IM_ASSERT(button >= 0 && button < IM_COUNTOF(g.IO.MouseDown));
// NB: We don't need to reset g.IO.MouseDragMaxDistanceSqr // NB: We don't need to reset g.IO.MouseDragMaxDistanceSqr
g.IO.MouseClickedPos[button] = g.IO.MousePos; g.IO.MouseClickedPos[button] = g.IO.MousePos;
} }
@@ -10139,7 +10140,7 @@ static void ImGui::UpdateMouseInputs()
if (io.MouseDelta.x != 0.0f || io.MouseDelta.y != 0.0f) if (io.MouseDelta.x != 0.0f || io.MouseDelta.y != 0.0f)
g.NavHighlightItemUnderNav = false; g.NavHighlightItemUnderNav = false;
for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) for (int i = 0; i < IM_COUNTOF(io.MouseDown); i++)
{ {
io.MouseClicked[i] = io.MouseDown[i] && io.MouseDownDuration[i] < 0.0f; io.MouseClicked[i] = io.MouseDown[i] && io.MouseDownDuration[i] < 0.0f;
io.MouseClickedCount[i] = 0; // Will be filled below io.MouseClickedCount[i] = 0; // Will be filled below
@@ -10346,7 +10347,7 @@ void ImGui::SetNextFrameWantCaptureMouse(bool want_capture_mouse)
static const char* GetInputSourceName(ImGuiInputSource source) static const char* GetInputSourceName(ImGuiInputSource source)
{ {
const char* input_source_names[] = { "None", "Mouse", "Keyboard", "Gamepad" }; const char* input_source_names[] = { "None", "Mouse", "Keyboard", "Gamepad" };
IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT); IM_ASSERT(IM_COUNTOF(input_source_names) == ImGuiInputSource_COUNT);
if (source < 0 || source >= ImGuiInputSource_COUNT) if (source < 0 || source >= ImGuiInputSource_COUNT)
return "Unknown"; return "Unknown";
return input_source_names[source]; return input_source_names[source];
@@ -10354,7 +10355,7 @@ static const char* GetInputSourceName(ImGuiInputSource source)
static const char* GetMouseSourceName(ImGuiMouseSource source) static const char* GetMouseSourceName(ImGuiMouseSource source)
{ {
const char* mouse_source_names[] = { "Mouse", "TouchScreen", "Pen" }; const char* mouse_source_names[] = { "Mouse", "TouchScreen", "Pen" };
IM_ASSERT(IM_ARRAYSIZE(mouse_source_names) == ImGuiMouseSource_COUNT); IM_ASSERT(IM_COUNTOF(mouse_source_names) == ImGuiMouseSource_COUNT);
if (source < 0 || source >= ImGuiMouseSource_COUNT) if (source < 0 || source >= ImGuiMouseSource_COUNT)
return "Unknown"; return "Unknown";
return mouse_source_names[source]; return mouse_source_names[source];
@@ -11988,7 +11989,7 @@ bool ImGui::BeginTooltipEx(ImGuiTooltipFlags tooltip_flags, ImGuiWindowFlags ext
const char* window_name_template = is_dragdrop_tooltip ? "##Tooltip_DragDrop_%02d" : "##Tooltip_%02d"; const char* window_name_template = is_dragdrop_tooltip ? "##Tooltip_DragDrop_%02d" : "##Tooltip_%02d";
char window_name[32]; char window_name[32];
ImFormatString(window_name, IM_ARRAYSIZE(window_name), window_name_template, g.TooltipOverrideCount); ImFormatString(window_name, IM_COUNTOF(window_name), window_name_template, g.TooltipOverrideCount);
ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize; ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize;
Begin(window_name, NULL, flags | extra_window_flags); Begin(window_name, NULL, flags | extra_window_flags);
// 2023-03-09: Added bool return value to the API, but currently always returning true. // 2023-03-09: Added bool return value to the API, but currently always returning true.
@@ -12344,7 +12345,7 @@ bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_window_flags)
char name[20]; char name[20];
IM_ASSERT((extra_window_flags & ImGuiWindowFlags_ChildMenu) == 0); // Use BeginPopupMenuEx() IM_ASSERT((extra_window_flags & ImGuiWindowFlags_ChildMenu) == 0); // Use BeginPopupMenuEx()
ImFormatString(name, IM_ARRAYSIZE(name), "##Popup_%08x", id); // No recycling, so we can close/open during the same frame ImFormatString(name, IM_COUNTOF(name), "##Popup_%08x", id); // No recycling, so we can close/open during the same frame
bool is_open = Begin(name, NULL, extra_window_flags | ImGuiWindowFlags_Popup); bool is_open = Begin(name, NULL, extra_window_flags | ImGuiWindowFlags_Popup);
if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display) if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display)
@@ -12364,7 +12365,7 @@ bool ImGui::BeginPopupMenuEx(ImGuiID id, const char* label, ImGuiWindowFlags ext
char name[128]; char name[128];
IM_ASSERT(extra_window_flags & ImGuiWindowFlags_ChildMenu); IM_ASSERT(extra_window_flags & ImGuiWindowFlags_ChildMenu);
ImFormatString(name, IM_ARRAYSIZE(name), "%s###Menu_%02d", label, g.BeginMenuDepth); // Recycle windows based on depth ImFormatString(name, IM_COUNTOF(name), "%s###Menu_%02d", label, g.BeginMenuDepth); // Recycle windows based on depth
bool is_open = Begin(name, NULL, extra_window_flags | ImGuiWindowFlags_Popup); bool is_open = Begin(name, NULL, extra_window_flags | ImGuiWindowFlags_Popup);
if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display) if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display)
EndPopup(); EndPopup();
@@ -13112,7 +13113,7 @@ static bool ImGui::NavScoreItem(ImGuiNavItemData* result, const ImRect& nav_bb)
{ {
if (quadrant == move_dir) if (quadrant == move_dir)
{ {
ImFormatString(buf, IM_ARRAYSIZE(buf), "%.0f/%.0f", dist_box, dist_center); ImFormatString(buf, IM_COUNTOF(buf), "%.0f/%.0f", dist_box, dist_center);
ImDrawList* draw_list = GetForegroundDrawList(window); ImDrawList* draw_list = GetForegroundDrawList(window);
draw_list->AddRectFilled(cand.Min, cand.Max, IM_COL32(255, 0, 0, 80)); draw_list->AddRectFilled(cand.Min, cand.Max, IM_COL32(255, 0, 0, 80));
draw_list->AddRectFilled(cand.Min, cand.Min + CalcTextSize(buf), IM_COL32(255, 0, 0, 200)); draw_list->AddRectFilled(cand.Min, cand.Min + CalcTextSize(buf), IM_COL32(255, 0, 0, 200));
@@ -13123,7 +13124,7 @@ static bool ImGui::NavScoreItem(ImGuiNavItemData* result, const ImRect& nav_bb)
const bool debug_tty = (g.IO.KeyCtrl && IsKeyPressed(ImGuiKey_Space)); const bool debug_tty = (g.IO.KeyCtrl && IsKeyPressed(ImGuiKey_Space));
if (debug_hovering || debug_tty) if (debug_hovering || debug_tty)
{ {
ImFormatString(buf, IM_ARRAYSIZE(buf), ImFormatString(buf, IM_COUNTOF(buf),
"d-box (%7.3f,%7.3f) -> %7.3f\nd-center (%7.3f,%7.3f) -> %7.3f\nd-axial (%7.3f,%7.3f) -> %7.3f\nnav %c, quadrant %c", "d-box (%7.3f,%7.3f) -> %7.3f\nd-center (%7.3f,%7.3f) -> %7.3f\nd-axial (%7.3f,%7.3f) -> %7.3f\nnav %c, quadrant %c",
dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial, "-WENS"[move_dir+1], "-WENS"[quadrant+1]); dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial, "-WENS"[move_dir+1], "-WENS"[quadrant+1]);
if (debug_hovering) if (debug_hovering)
@@ -14792,7 +14793,7 @@ bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_s
cond = ImGuiCond_Always; cond = ImGuiCond_Always;
IM_ASSERT(type != NULL); IM_ASSERT(type != NULL);
IM_ASSERT(ImStrlen(type) < IM_ARRAYSIZE(payload.DataType) && "Payload type can be at most 32 characters long"); IM_ASSERT(ImStrlen(type) < IM_COUNTOF(payload.DataType) && "Payload type can be at most 32 characters long");
IM_ASSERT((data != NULL && data_size > 0) || (data == NULL && data_size == 0)); IM_ASSERT((data != NULL && data_size > 0) || (data == NULL && data_size == 0));
IM_ASSERT(cond == ImGuiCond_Always || cond == ImGuiCond_Once); IM_ASSERT(cond == ImGuiCond_Always || cond == ImGuiCond_Once);
IM_ASSERT(payload.SourceId != 0); // Not called between BeginDragDropSource() and EndDragDropSource() IM_ASSERT(payload.SourceId != 0); // Not called between BeginDragDropSource() and EndDragDropSource()
@@ -14800,7 +14801,7 @@ bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_s
if (cond == ImGuiCond_Always || payload.DataFrameCount == -1) if (cond == ImGuiCond_Always || payload.DataFrameCount == -1)
{ {
// Copy payload // Copy payload
ImStrncpy(payload.DataType, type, IM_ARRAYSIZE(payload.DataType)); ImStrncpy(payload.DataType, type, IM_COUNTOF(payload.DataType));
g.DragDropPayloadBufHeap.resize(0); g.DragDropPayloadBufHeap.resize(0);
if (data_size > sizeof(g.DragDropPayloadBufLocal)) if (data_size > sizeof(g.DragDropPayloadBufLocal))
{ {
@@ -16071,7 +16072,7 @@ void ImGui::DebugRenderKeyboardPreview(ImDrawList* draw_list)
if (!IsItemVisible()) if (!IsItemVisible())
return; return;
draw_list->PushClipRect(board_min, board_max, true); draw_list->PushClipRect(board_min, board_max, true);
for (int n = 0; n < IM_ARRAYSIZE(keys_to_display); n++) for (int n = 0; n < IM_COUNTOF(keys_to_display); n++)
{ {
const KeyLayoutData* key_data = &keys_to_display[n]; const KeyLayoutData* key_data = &keys_to_display[n];
ImVec2 key_min = ImVec2(start_pos.x + key_data->Col * key_step.x + key_data->Row * key_row_offset, start_pos.y + key_data->Row * key_step.y); ImVec2 key_min = ImVec2(start_pos.x + key_data->Col * key_step.x + key_data->Row * key_row_offset, start_pos.y + key_data->Row * key_step.y);
@@ -16360,7 +16361,7 @@ void ImGui::DebugNodeTexture(ImTextureData* tex, int int_id, const ImFontAtlasRe
char texref_desc[30]; char texref_desc[30];
Text("Status = %s (%d), Format = %s (%d), UseColors = %d", ImTextureDataGetStatusName(tex->Status), tex->Status, ImTextureDataGetFormatName(tex->Format), tex->Format, tex->UseColors); Text("Status = %s (%d), Format = %s (%d), UseColors = %d", ImTextureDataGetStatusName(tex->Status), tex->Status, ImTextureDataGetFormatName(tex->Format), tex->Format, tex->UseColors);
Text("TexRef = %s, BackendUserData = %p", FormatTextureRefForDebugDisplay(texref_desc, IM_ARRAYSIZE(texref_desc), tex->GetTexRef()), tex->BackendUserData); Text("TexRef = %s, BackendUserData = %p", FormatTextureRefForDebugDisplay(texref_desc, IM_COUNTOF(texref_desc), tex->GetTexRef()), tex->BackendUserData);
TreePop(); TreePop();
} }
PopID(); PopID();
@@ -16515,7 +16516,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
for (int column_n = 0; column_n < table->ColumnsCount; column_n++) for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
{ {
ImRect r = Funcs::GetTableRect(table, rect_n, column_n); ImRect r = Funcs::GetTableRect(table, rect_n, column_n);
ImFormatString(buf, IM_ARRAYSIZE(buf), "(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) Col %d %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), column_n, trt_rects_names[rect_n]); ImFormatString(buf, IM_COUNTOF(buf), "(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) Col %d %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), column_n, trt_rects_names[rect_n]);
Selectable(buf); Selectable(buf);
if (IsItemHovered()) if (IsItemHovered())
GetForegroundDrawList(table->OuterWindow)->AddRect(r.Min - ImVec2(1, 1), r.Max + ImVec2(1, 1), IM_COL32(255, 255, 0, 255), 0.0f, 0, 2.0f); GetForegroundDrawList(table->OuterWindow)->AddRect(r.Min - ImVec2(1, 1), r.Max + ImVec2(1, 1), IM_COL32(255, 255, 0, 255), 0.0f, 0, 2.0f);
@@ -16524,7 +16525,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
else else
{ {
ImRect r = Funcs::GetTableRect(table, rect_n, -1); ImRect r = Funcs::GetTableRect(table, rect_n, -1);
ImFormatString(buf, IM_ARRAYSIZE(buf), "(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), trt_rects_names[rect_n]); ImFormatString(buf, IM_COUNTOF(buf), "(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), trt_rects_names[rect_n]);
Selectable(buf); Selectable(buf);
if (IsItemHovered()) if (IsItemHovered())
GetForegroundDrawList(table->OuterWindow)->AddRect(r.Min - ImVec2(1, 1), r.Max + ImVec2(1, 1), IM_COL32(255, 255, 0, 255), 0.0f, 0, 2.0f); GetForegroundDrawList(table->OuterWindow)->AddRect(r.Min - ImVec2(1, 1), r.Max + ImVec2(1, 1), IM_COL32(255, 255, 0, 255), 0.0f, 0, 2.0f);
@@ -16548,7 +16549,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
{ {
static char buf[64] = ""; static char buf[64] = "";
SetNextItemWidth(-FLT_MIN); SetNextItemWidth(-FLT_MIN);
InputText("##DebugTextEncodingBuf", buf, IM_ARRAYSIZE(buf)); InputText("##DebugTextEncodingBuf", buf, IM_COUNTOF(buf));
if (buf[0] != 0) if (buf[0] != 0)
DebugTextEncoding(buf); DebugTextEncoding(buf);
} }
@@ -16742,7 +16743,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
Text("%d current allocations", info->TotalAllocCount - info->TotalFreeCount); Text("%d current allocations", info->TotalAllocCount - info->TotalFreeCount);
if (SmallButton("GC now")) { g.GcCompactAll = true; } if (SmallButton("GC now")) { g.GcCompactAll = true; }
Text("Recent frames with allocations:"); Text("Recent frames with allocations:");
int buf_size = IM_ARRAYSIZE(info->LastEntriesBuf); int buf_size = IM_COUNTOF(info->LastEntriesBuf);
for (int n = buf_size - 1; n >= 0; n--) for (int n = buf_size - 1; n >= 0; n--)
{ {
ImGuiDebugAllocEntry* entry = &info->LastEntriesBuf[(info->LastEntriesIdx - n + buf_size) % buf_size]; ImGuiDebugAllocEntry* entry = &info->LastEntriesBuf[(info->LastEntriesIdx - n + buf_size) % buf_size];
@@ -16779,7 +16780,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
else else
Text("Mouse pos: <INVALID>"); Text("Mouse pos: <INVALID>");
Text("Mouse delta: (%g, %g)", io.MouseDelta.x, io.MouseDelta.y); Text("Mouse delta: (%g, %g)", io.MouseDelta.x, io.MouseDelta.y);
int count = IM_ARRAYSIZE(io.MouseDown); int count = IM_COUNTOF(io.MouseDown);
Text("Mouse down:"); for (int i = 0; i < count; i++) if (IsMouseDown(i)) { SameLine(); Text("b%d (%.02f secs)", i, io.MouseDownDuration[i]); } Text("Mouse down:"); for (int i = 0; i < count; i++) if (IsMouseDown(i)) { SameLine(); Text("b%d (%.02f secs)", i, io.MouseDownDuration[i]); }
Text("Mouse clicked:"); for (int i = 0; i < count; i++) if (IsMouseClicked(i)) { SameLine(); Text("b%d (%d)", i, io.MouseClickedCount[i]); } Text("Mouse clicked:"); for (int i = 0; i < count; i++) if (IsMouseClicked(i)) { SameLine(); Text("b%d (%d)", i, io.MouseClickedCount[i]); }
Text("Mouse released:"); for (int i = 0; i < count; i++) if (IsMouseReleased(i)) { SameLine(); Text("b%d", i); } Text("Mouse released:"); for (int i = 0; i < count; i++) if (IsMouseReleased(i)) { SameLine(); Text("b%d", i); }
@@ -16910,7 +16911,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
if (cfg->ShowWindowsBeginOrder && !(window->Flags & ImGuiWindowFlags_ChildWindow)) if (cfg->ShowWindowsBeginOrder && !(window->Flags & ImGuiWindowFlags_ChildWindow))
{ {
char buf[32]; char buf[32];
ImFormatString(buf, IM_ARRAYSIZE(buf), "%d", window->BeginOrderWithinContext); ImFormatString(buf, IM_COUNTOF(buf), "%d", window->BeginOrderWithinContext);
float font_size = GetFontSize(); float font_size = GetFontSize();
draw_list->AddRectFilled(window->Pos, window->Pos + ImVec2(font_size, font_size), IM_COL32(200, 100, 100, 255)); draw_list->AddRectFilled(window->Pos, window->Pos + ImVec2(font_size, font_size), IM_COL32(200, 100, 100, 255));
draw_list->AddText(window->Pos, IM_COL32(255, 255, 255, 255), buf); draw_list->AddText(window->Pos, IM_COL32(255, 255, 255, 255), buf);
@@ -17061,9 +17062,9 @@ void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, con
} }
char texid_desc[30]; char texid_desc[30];
FormatTextureRefForDebugDisplay(texid_desc, IM_ARRAYSIZE(texid_desc), pcmd->TexRef); FormatTextureRefForDebugDisplay(texid_desc, IM_COUNTOF(texid_desc), pcmd->TexRef);
char buf[300]; char buf[300];
ImFormatString(buf, IM_ARRAYSIZE(buf), "DrawCmd:%5d tris, Tex %s, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)", ImFormatString(buf, IM_COUNTOF(buf), "DrawCmd:%5d tris, Tex %s, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)",
pcmd->ElemCount / 3, texid_desc, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w); pcmd->ElemCount / 3, texid_desc, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
bool pcmd_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf); bool pcmd_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf);
if (IsItemHovered() && (cfg->ShowDrawCmdMesh || cfg->ShowDrawCmdBoundingBoxes) && fg_draw_list) if (IsItemHovered() && (cfg->ShowDrawCmdMesh || cfg->ShowDrawCmdBoundingBoxes) && fg_draw_list)
@@ -17085,7 +17086,7 @@ void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, con
} }
// Display vertex information summary. Hover to get all triangles drawn in wire-frame // Display vertex information summary. Hover to get all triangles drawn in wire-frame
ImFormatString(buf, IM_ARRAYSIZE(buf), "Mesh: ElemCount: %d, VtxOffset: +%d, IdxOffset: +%d, Area: ~%0.f px", pcmd->ElemCount, pcmd->VtxOffset, pcmd->IdxOffset, total_area); ImFormatString(buf, IM_COUNTOF(buf), "Mesh: ElemCount: %d, VtxOffset: +%d, IdxOffset: +%d, Area: ~%0.f px", pcmd->ElemCount, pcmd->VtxOffset, pcmd->IdxOffset, total_area);
Selectable(buf); Selectable(buf);
if (IsItemHovered() && fg_draw_list) if (IsItemHovered() && fg_draw_list)
DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, true, false); DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, true, false);
@@ -17096,7 +17097,7 @@ void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, con
while (clipper.Step()) while (clipper.Step())
for (int prim = clipper.DisplayStart, idx_i = pcmd->IdxOffset + clipper.DisplayStart * 3; prim < clipper.DisplayEnd; prim++) for (int prim = clipper.DisplayStart, idx_i = pcmd->IdxOffset + clipper.DisplayStart * 3; prim < clipper.DisplayEnd; prim++)
{ {
char* buf_p = buf, * buf_end = buf + IM_ARRAYSIZE(buf); char* buf_p = buf, * buf_end = buf + IM_COUNTOF(buf);
ImVec2 triangle[3]; ImVec2 triangle[3];
for (int n = 0; n < 3; n++, idx_i++) for (int n = 0; n < 3; n++, idx_i++)
{ {
@@ -17401,7 +17402,7 @@ void ImGui::DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label)
// Standalone tab bars (not associated to docking/windows functionality) currently hold no discernible strings. // Standalone tab bars (not associated to docking/windows functionality) currently hold no discernible strings.
char buf[256]; char buf[256];
char* p = buf; char* p = buf;
const char* buf_end = buf + IM_ARRAYSIZE(buf); const char* buf_end = buf + IM_COUNTOF(buf);
const bool is_active = (tab_bar->PrevFrameVisible >= GetFrameCount() - 2); const bool is_active = (tab_bar->PrevFrameVisible >= GetFrameCount() - 2);
p += ImFormatString(p, buf_end - p, "%s 0x%08X (%d tabs)%s {", label, tab_bar->ID, tab_bar->Tabs.Size, is_active ? "" : " *Inactive*"); p += ImFormatString(p, buf_end - p, "%s 0x%08X (%d tabs)%s {", label, tab_bar->ID, tab_bar->Tabs.Size, is_active ? "" : " *Inactive*");
for (int tab_n = 0; tab_n < ImMin(tab_bar->Tabs.Size, 3); tab_n++) for (int tab_n = 0; tab_n < ImMin(tab_bar->Tabs.Size, 3); tab_n++)
@@ -17559,7 +17560,7 @@ void ImGui::DebugNodeWindowsListByBeginStackParent(ImGuiWindow** windows, int wi
if (window->ParentWindowInBeginStack != parent_in_begin_stack) if (window->ParentWindowInBeginStack != parent_in_begin_stack)
continue; continue;
char buf[20]; char buf[20];
ImFormatString(buf, IM_ARRAYSIZE(buf), "[%04d] Window", window->BeginOrderWithinContext); ImFormatString(buf, IM_COUNTOF(buf), "[%04d] Window", window->BeginOrderWithinContext);
//BulletText("[%04d] Window '%s'", window->BeginOrderWithinContext, window->Name); //BulletText("[%04d] Window '%s'", window->BeginOrderWithinContext, window->Name);
DebugNodeWindow(window, buf); DebugNodeWindow(window, buf);
TreePush(buf); TreePush(buf);
@@ -17993,7 +17994,7 @@ static const char* DebugItemPathQuery_GetResultAsPath(ImGuiDebugItemPathQuery* q
for (int stack_n = 0; stack_n < query->Results.Size; stack_n++) for (int stack_n = 0; stack_n < query->Results.Size; stack_n++)
{ {
char level_desc[256]; char level_desc[256];
DebugItemPathQuery_FormatLevelInfo(query, stack_n, false, level_desc, IM_ARRAYSIZE(level_desc)); DebugItemPathQuery_FormatLevelInfo(query, stack_n, false, level_desc, IM_COUNTOF(level_desc));
buf->append(stack_n == 0 ? "//" : "/"); buf->append(stack_n == 0 ? "//" : "/");
for (const char* p = level_desc; *p != 0; ) for (const char* p = level_desc; *p != 0; )
{ {
+4 -2
View File
@@ -30,7 +30,7 @@
// Library Version // Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
#define IMGUI_VERSION "1.92.6 WIP" #define IMGUI_VERSION "1.92.6 WIP"
#define IMGUI_VERSION_NUM 19255 #define IMGUI_VERSION_NUM 19256
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000 #define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198 #define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198
@@ -95,7 +95,7 @@ Index of this file:
#include <assert.h> #include <assert.h>
#define IM_ASSERT(_EXPR) assert(_EXPR) // You can override the default assert handler by editing imconfig.h #define IM_ASSERT(_EXPR) assert(_EXPR) // You can override the default assert handler by editing imconfig.h
#endif #endif
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR) / sizeof(*(_ARR)))) // Size of a static C-style array. Don't use on pointers! #define IM_COUNTOF(_ARR) ((int)(sizeof(_ARR) / sizeof(*(_ARR)))) // Size of a static C-style array. Don't use on pointers!
#define IM_UNUSED(_VAR) ((void)(_VAR)) // Used to silence "unused variable warnings". Often useful as asserts may be stripped out from final builds. #define IM_UNUSED(_VAR) ((void)(_VAR)) // Used to silence "unused variable warnings". Often useful as asserts may be stripped out from final builds.
#define IM_STRINGIFY_HELPER(_EXPR) #_EXPR #define IM_STRINGIFY_HELPER(_EXPR) #_EXPR
#define IM_STRINGIFY(_EXPR) IM_STRINGIFY_HELPER(_EXPR) // Preprocessor idiom to stringify e.g. an integer or a macro. #define IM_STRINGIFY(_EXPR) IM_STRINGIFY_HELPER(_EXPR) // Preprocessor idiom to stringify e.g. an integer or a macro.
@@ -4151,6 +4151,8 @@ typedef ImFontAtlasRect ImFontAtlasCustomRect;
#endif // #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS #endif // #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
#define IM_ARRAYSIZE IM_COUNTOF // RENAMED IN 1.92.6: IM_ARRAYSIZE -> IM_COUNTOF
// RENAMED IMGUI_DISABLE_METRICS_WINDOW > IMGUI_DISABLE_DEBUG_TOOLS in 1.88 (from June 2022) // RENAMED IMGUI_DISABLE_METRICS_WINDOW > IMGUI_DISABLE_DEBUG_TOOLS in 1.88 (from June 2022)
#ifdef IMGUI_DISABLE_METRICS_WINDOW #ifdef IMGUI_DISABLE_METRICS_WINDOW
#error IMGUI_DISABLE_METRICS_WINDOW was renamed to IMGUI_DISABLE_DEBUG_TOOLS, please use new name. #error IMGUI_DISABLE_METRICS_WINDOW was renamed to IMGUI_DISABLE_DEBUG_TOOLS, please use new name.
+106 -106
View File
File diff suppressed because it is too large Load Diff
+11 -11
View File
@@ -391,9 +391,9 @@ ImDrawListSharedData::ImDrawListSharedData()
{ {
memset(this, 0, sizeof(*this)); memset(this, 0, sizeof(*this));
InitialFringeScale = 1.0f; InitialFringeScale = 1.0f;
for (int i = 0; i < IM_ARRAYSIZE(ArcFastVtx); i++) for (int i = 0; i < IM_COUNTOF(ArcFastVtx); i++)
{ {
const float a = ((float)i * 2 * IM_PI) / (float)IM_ARRAYSIZE(ArcFastVtx); const float a = ((float)i * 2 * IM_PI) / (float)IM_COUNTOF(ArcFastVtx);
ArcFastVtx[i] = ImVec2(ImCos(a), ImSin(a)); ArcFastVtx[i] = ImVec2(ImCos(a), ImSin(a));
} }
ArcFastRadiusCutoff = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC_R(IM_DRAWLIST_ARCFAST_SAMPLE_MAX, CircleSegmentMaxError); ArcFastRadiusCutoff = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC_R(IM_DRAWLIST_ARCFAST_SAMPLE_MAX, CircleSegmentMaxError);
@@ -411,7 +411,7 @@ void ImDrawListSharedData::SetCircleTessellationMaxError(float max_error)
IM_ASSERT(max_error > 0.0f); IM_ASSERT(max_error > 0.0f);
CircleSegmentMaxError = max_error; CircleSegmentMaxError = max_error;
for (int i = 0; i < IM_ARRAYSIZE(CircleSegmentCounts); i++) for (int i = 0; i < IM_COUNTOF(CircleSegmentCounts); i++)
{ {
const float radius = (float)i; const float radius = (float)i;
CircleSegmentCounts[i] = (ImU8)((i > 0) ? IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, CircleSegmentMaxError) : IM_DRAWLIST_ARCFAST_SAMPLE_MAX); CircleSegmentCounts[i] = (ImU8)((i > 0) ? IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, CircleSegmentMaxError) : IM_DRAWLIST_ARCFAST_SAMPLE_MAX);
@@ -646,7 +646,7 @@ int ImDrawList::_CalcCircleAutoSegmentCount(float radius) const
{ {
// Automatic segment count // Automatic segment count
const int radius_idx = (int)(radius + 0.999999f); // ceil to never reduce accuracy const int radius_idx = (int)(radius + 0.999999f); // ceil to never reduce accuracy
if (radius_idx >= 0 && radius_idx < IM_ARRAYSIZE(_Data->CircleSegmentCounts)) if (radius_idx >= 0 && radius_idx < IM_COUNTOF(_Data->CircleSegmentCounts))
return _Data->CircleSegmentCounts[radius_idx]; // Use cached value return _Data->CircleSegmentCounts[radius_idx]; // Use cached value
else else
return IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, _Data->CircleSegmentMaxError); return IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, _Data->CircleSegmentMaxError);
@@ -3122,7 +3122,7 @@ ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template)
if (font_cfg.SizePixels <= 0.0f) if (font_cfg.SizePixels <= 0.0f)
font_cfg.SizePixels = 13.0f * 1.0f; font_cfg.SizePixels = 13.0f * 1.0f;
if (font_cfg.Name[0] == '\0') if (font_cfg.Name[0] == '\0')
ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "ProggyClean.ttf"); ImFormatString(font_cfg.Name, IM_COUNTOF(font_cfg.Name), "ProggyClean.ttf");
font_cfg.EllipsisChar = (ImWchar)0x0085; font_cfg.EllipsisChar = (ImWchar)0x0085;
font_cfg.GlyphOffset.y += 1.0f * IM_TRUNC(font_cfg.SizePixels / 13.0f); // Add +1 offset per 13 units font_cfg.GlyphOffset.y += 1.0f * IM_TRUNC(font_cfg.SizePixels / 13.0f); // Add +1 offset per 13 units
@@ -3156,7 +3156,7 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels,
// Store a short copy of filename into into the font name for convenience // Store a short copy of filename into into the font name for convenience
const char* p; const char* p;
for (p = filename + ImStrlen(filename); p > filename && p[-1] != '/' && p[-1] != '\\'; p--) {} for (p = filename + ImStrlen(filename); p > filename && p[-1] != '/' && p[-1] != '\\'; p--) {}
ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "%s", p); ImFormatString(font_cfg.Name, IM_COUNTOF(font_cfg.Name), "%s", p);
} }
return AddFontFromMemoryTTF(data, (int)data_size, size_pixels, &font_cfg, glyph_ranges); return AddFontFromMemoryTTF(data, (int)data_size, size_pixels, &font_cfg, glyph_ranges);
} }
@@ -4005,7 +4005,7 @@ static void ImFontAtlasDebugWriteTexToDisk(ImTextureData* tex, const char* descr
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
char buf[128]; char buf[128];
ImFormatString(buf, IM_ARRAYSIZE(buf), "[%05d] Texture #%03d - %s.png", g.FrameCount, tex->UniqueID, description); ImFormatString(buf, IM_COUNTOF(buf), "[%05d] Texture #%03d - %s.png", g.FrameCount, tex->UniqueID, description);
stbi_write_png(buf, tex->Width, tex->Height, tex->BytesPerPixel, tex->Pixels, tex->GetPitch()); // tex->BytesPerPixel is technically not component, but ok for the formats we support. stbi_write_png(buf, tex->Width, tex->Height, tex->BytesPerPixel, tex->Pixels, tex->GetPitch()); // tex->BytesPerPixel is technically not component, but ok for the formats we support.
} }
#endif #endif
@@ -4885,11 +4885,11 @@ const ImWchar* ImFontAtlas::GetGlyphRangesChineseSimplifiedCommon()
0xFF00, 0xFFEF, // Half-width characters 0xFF00, 0xFFEF, // Half-width characters
0xFFFD, 0xFFFD // Invalid 0xFFFD, 0xFFFD // Invalid
}; };
static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00) * 2 + 1] = { 0 }; static ImWchar full_ranges[IM_COUNTOF(base_ranges) + IM_COUNTOF(accumulative_offsets_from_0x4E00) * 2 + 1] = { 0 };
if (!full_ranges[0]) if (!full_ranges[0])
{ {
memcpy(full_ranges, base_ranges, sizeof(base_ranges)); memcpy(full_ranges, base_ranges, sizeof(base_ranges));
UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_ARRAYSIZE(accumulative_offsets_from_0x4E00), full_ranges + IM_ARRAYSIZE(base_ranges)); UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_COUNTOF(accumulative_offsets_from_0x4E00), full_ranges + IM_COUNTOF(base_ranges));
} }
return &full_ranges[0]; return &full_ranges[0];
} }
@@ -4975,11 +4975,11 @@ const ImWchar* ImFontAtlas::GetGlyphRangesJapanese()
0xFF00, 0xFFEF, // Half-width characters 0xFF00, 0xFFEF, // Half-width characters
0xFFFD, 0xFFFD // Invalid 0xFFFD, 0xFFFD // Invalid
}; };
static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00)*2 + 1] = { 0 }; static ImWchar full_ranges[IM_COUNTOF(base_ranges) + IM_COUNTOF(accumulative_offsets_from_0x4E00)*2 + 1] = { 0 };
if (!full_ranges[0]) if (!full_ranges[0])
{ {
memcpy(full_ranges, base_ranges, sizeof(base_ranges)); memcpy(full_ranges, base_ranges, sizeof(base_ranges));
UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_ARRAYSIZE(accumulative_offsets_from_0x4E00), full_ranges + IM_ARRAYSIZE(base_ranges)); UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_COUNTOF(accumulative_offsets_from_0x4E00), full_ranges + IM_COUNTOF(base_ranges));
} }
return &full_ranges[0]; return &full_ranges[0];
} }
+1 -1
View File
@@ -1581,7 +1581,7 @@ struct ImGuiKeyRoutingTable
ImVector<ImGuiKeyRoutingData> EntriesNext; // Double-buffer to avoid reallocation (could use a shared buffer) ImVector<ImGuiKeyRoutingData> EntriesNext; // Double-buffer to avoid reallocation (could use a shared buffer)
ImGuiKeyRoutingTable() { Clear(); } ImGuiKeyRoutingTable() { Clear(); }
void Clear() { for (int n = 0; n < IM_ARRAYSIZE(Index); n++) Index[n] = -1; Entries.clear(); EntriesNext.clear(); } void Clear() { for (int n = 0; n < IM_COUNTOF(Index); n++) Index[n] = -1; Entries.clear(); EntriesNext.clear(); }
}; };
// This extends ImGuiKeyData but only for named keys (legacy keys don't support the new features) // This extends ImGuiKeyData but only for named keys (legacy keys don't support the new features)
+5 -5
View File
@@ -2624,7 +2624,7 @@ void ImGui::TableMergeDrawChannels(ImGuiTable* table)
const int size_for_masks_bitarrays_one = (int)ImBitArrayGetStorageSizeInBytes(max_draw_channels); const int size_for_masks_bitarrays_one = (int)ImBitArrayGetStorageSizeInBytes(max_draw_channels);
g.TempBuffer.reserve(size_for_masks_bitarrays_one * 5); g.TempBuffer.reserve(size_for_masks_bitarrays_one * 5);
memset(g.TempBuffer.Data, 0, size_for_masks_bitarrays_one * 5); memset(g.TempBuffer.Data, 0, size_for_masks_bitarrays_one * 5);
for (int n = 0; n < IM_ARRAYSIZE(merge_groups); n++) for (int n = 0; n < IM_COUNTOF(merge_groups); n++)
merge_groups[n].ChannelsMask = (ImBitArrayPtr)(void*)(g.TempBuffer.Data + (size_for_masks_bitarrays_one * n)); merge_groups[n].ChannelsMask = (ImBitArrayPtr)(void*)(g.TempBuffer.Data + (size_for_masks_bitarrays_one * n));
ImBitArrayPtr remaining_mask = (ImBitArrayPtr)(void*)(g.TempBuffer.Data + (size_for_masks_bitarrays_one * 4)); ImBitArrayPtr remaining_mask = (ImBitArrayPtr)(void*)(g.TempBuffer.Data + (size_for_masks_bitarrays_one * 4));
@@ -2681,7 +2681,7 @@ void ImGui::TableMergeDrawChannels(ImGuiTable* table)
// [DEBUG] Display merge groups // [DEBUG] Display merge groups
#if 0 #if 0
if (g.IO.KeyShift) if (g.IO.KeyShift)
for (int merge_group_n = 0; merge_group_n < IM_ARRAYSIZE(merge_groups); merge_group_n++) for (int merge_group_n = 0; merge_group_n < IM_COUNTOF(merge_groups); merge_group_n++)
{ {
MergeGroup* merge_group = &merge_groups[merge_group_n]; MergeGroup* merge_group = &merge_groups[merge_group_n];
if (merge_group->ChannelsCount == 0) if (merge_group->ChannelsCount == 0)
@@ -2709,7 +2709,7 @@ void ImGui::TableMergeDrawChannels(ImGuiTable* table)
int remaining_count = splitter->_Count - (has_freeze_v ? LEADING_DRAW_CHANNELS + 1 : LEADING_DRAW_CHANNELS); int remaining_count = splitter->_Count - (has_freeze_v ? LEADING_DRAW_CHANNELS + 1 : LEADING_DRAW_CHANNELS);
//ImRect host_rect = (table->InnerWindow == table->OuterWindow) ? table->InnerClipRect : table->HostClipRect; //ImRect host_rect = (table->InnerWindow == table->OuterWindow) ? table->InnerClipRect : table->HostClipRect;
ImRect host_rect = table->HostClipRect; ImRect host_rect = table->HostClipRect;
for (int merge_group_n = 0; merge_group_n < IM_ARRAYSIZE(merge_groups); merge_group_n++) for (int merge_group_n = 0; merge_group_n < IM_COUNTOF(merge_groups); merge_group_n++)
{ {
if (int merge_channels_count = merge_groups[merge_group_n].ChannelsCount) if (int merge_channels_count = merge_groups[merge_group_n].ChannelsCount)
{ {
@@ -3202,7 +3202,7 @@ void ImGui::TableHeader(const char* label)
sort_arrow = true; sort_arrow = true;
if (column->SortOrder > 0) if (column->SortOrder > 0)
{ {
ImFormatString(sort_order_suf, IM_ARRAYSIZE(sort_order_suf), "%d", column->SortOrder + 1); ImFormatString(sort_order_suf, IM_COUNTOF(sort_order_suf), "%d", column->SortOrder + 1);
w_sort_text = g.Style.ItemInnerSpacing.x + CalcTextSize(sort_order_suf).x; w_sort_text = g.Style.ItemInnerSpacing.x + CalcTextSize(sort_order_suf).x;
} }
} }
@@ -4094,7 +4094,7 @@ void ImGui::DebugNodeTable(ImGuiTable* table)
ImGuiTableColumn* column = &table->Columns[n]; ImGuiTableColumn* column = &table->Columns[n];
const char* name = TableGetColumnName(table, n); const char* name = TableGetColumnName(table, n);
char buf[512]; char buf[512];
ImFormatString(buf, IM_ARRAYSIZE(buf), ImFormatString(buf, IM_COUNTOF(buf),
"Column %d order %d '%s': offset %+.2f to %+.2f%s\n" "Column %d order %d '%s': offset %+.2f to %+.2f%s\n"
"Enabled: %d, VisibleX/Y: %d/%d, RequestOutput: %d, SkipItems: %d, DrawChannels: %d,%d\n" "Enabled: %d, VisibleX/Y: %d/%d, RequestOutput: %d, SkipItems: %d, DrawChannels: %d,%d\n"
"WidthGiven: %.1f, Request/Auto: %.1f/%.1f, StretchWeight: %.3f (%.1f%%)\n" "WidthGiven: %.1f, Request/Auto: %.1f/%.1f, StretchWeight: %.3f (%.1f%%)\n"
+26 -26
View File
@@ -1452,7 +1452,7 @@ void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* over
{ {
if (!overlay) if (!overlay)
{ {
ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%.0f%%", fraction * 100 + 0.01f); ImFormatString(overlay_buf, IM_COUNTOF(overlay_buf), "%.0f%%", fraction * 100 + 0.01f);
overlay = overlay_buf; overlay = overlay_buf;
} }
@@ -2019,7 +2019,7 @@ bool ImGui::BeginComboPopup(ImGuiID popup_id, const ImRect& bb, ImGuiComboFlags
// This is essentially a specialized version of BeginPopupEx() // This is essentially a specialized version of BeginPopupEx()
char name[16]; char name[16];
ImFormatString(name, IM_ARRAYSIZE(name), "##Combo_%02d", g.BeginComboDepth); // Recycle windows based on depth ImFormatString(name, IM_COUNTOF(name), "##Combo_%02d", g.BeginComboDepth); // Recycle windows based on depth
// Set position given a custom constraint (peak into expected window size so we can position it) // Set position given a custom constraint (peak into expected window size so we can position it)
// FIXME: This might be easier to express with an hypothetical SetNextWindowPosConstraints() function? // FIXME: This might be easier to express with an hypothetical SetNextWindowPosConstraints() function?
@@ -2265,7 +2265,7 @@ static const ImGuiDataTypeInfo GDataTypeInfo[] =
{ sizeof(bool), "bool", "%d", "%d" }, // ImGuiDataType_Bool { sizeof(bool), "bool", "%d", "%d" }, // ImGuiDataType_Bool
{ 0, "char*","%s", "%s" }, // ImGuiDataType_String { 0, "char*","%s", "%s" }, // ImGuiDataType_String
}; };
IM_STATIC_ASSERT(IM_ARRAYSIZE(GDataTypeInfo) == ImGuiDataType_COUNT); IM_STATIC_ASSERT(IM_COUNTOF(GDataTypeInfo) == ImGuiDataType_COUNT);
const ImGuiDataTypeInfo* ImGui::DataTypeGetInfo(ImGuiDataType data_type) const ImGuiDataTypeInfo* ImGui::DataTypeGetInfo(ImGuiDataType data_type)
{ {
@@ -2374,7 +2374,7 @@ bool ImGui::DataTypeApplyFromText(const char* buf, ImGuiDataType data_type, void
if (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) if (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double)
format = type_info->ScanFmt; format = type_info->ScanFmt;
else else
format = ImParseFormatSanitizeForScanning(format, format_sanitized, IM_ARRAYSIZE(format_sanitized)); format = ImParseFormatSanitizeForScanning(format, format_sanitized, IM_COUNTOF(format_sanitized));
// Small types need a 32-bit buffer to receive the result from scanf() // Small types need a 32-bit buffer to receive the result from scanf()
int v32 = 0; int v32 = 0;
@@ -2465,7 +2465,7 @@ static float GetMinimumStepAtDecimalPrecision(int decimal_precision)
static const float min_steps[10] = { 1.0f, 0.1f, 0.01f, 0.001f, 0.0001f, 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, 0.000000001f }; static const float min_steps[10] = { 1.0f, 0.1f, 0.01f, 0.001f, 0.0001f, 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, 0.000000001f };
if (decimal_precision < 0) if (decimal_precision < 0)
return FLT_MIN; return FLT_MIN;
return (decimal_precision < IM_ARRAYSIZE(min_steps)) ? min_steps[decimal_precision] : ImPow(10.0f, (float)-decimal_precision); return (decimal_precision < IM_COUNTOF(min_steps)) ? min_steps[decimal_precision] : ImPow(10.0f, (float)-decimal_precision);
} }
template<typename TYPE> template<typename TYPE>
@@ -2479,12 +2479,12 @@ TYPE ImGui::RoundScalarWithFormatT(const char* format, ImGuiDataType data_type,
// Sanitize format // Sanitize format
char fmt_sanitized[32]; char fmt_sanitized[32];
ImParseFormatSanitizeForPrinting(fmt_start, fmt_sanitized, IM_ARRAYSIZE(fmt_sanitized)); ImParseFormatSanitizeForPrinting(fmt_start, fmt_sanitized, IM_COUNTOF(fmt_sanitized));
fmt_start = fmt_sanitized; fmt_start = fmt_sanitized;
// Format value with our rounding, and read back // Format value with our rounding, and read back
char v_str[64]; char v_str[64];
ImFormatString(v_str, IM_ARRAYSIZE(v_str), fmt_start, v); ImFormatString(v_str, IM_COUNTOF(v_str), fmt_start, v);
const char* p = v_str; const char* p = v_str;
while (*p == ' ') while (*p == ' ')
p++; p++;
@@ -2774,7 +2774,7 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
// Display value using user-provided display format so user can add prefix/suffix/decorations to the value. // Display value using user-provided display format so user can add prefix/suffix/decorations to the value.
char value_buf[64]; char value_buf[64];
const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_ARRAYSIZE(value_buf), data_type, p_data, format); const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_COUNTOF(value_buf), data_type, p_data, format);
if (g.LogEnabled) if (g.LogEnabled)
LogSetNextTextDecoration("{", "}"); LogSetNextTextDecoration("{", "}");
RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f, 0.5f)); RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f, 0.5f));
@@ -3371,7 +3371,7 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
// Display value using user-provided display format so user can add prefix/suffix/decorations to the value. // Display value using user-provided display format so user can add prefix/suffix/decorations to the value.
char value_buf[64]; char value_buf[64];
const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_ARRAYSIZE(value_buf), data_type, p_data, format); const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_COUNTOF(value_buf), data_type, p_data, format);
if (g.LogEnabled) if (g.LogEnabled)
LogSetNextTextDecoration("{", "}"); LogSetNextTextDecoration("{", "}");
RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f, 0.5f)); RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f, 0.5f));
@@ -3524,7 +3524,7 @@ bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType d
// Display value using user-provided display format so user can add prefix/suffix/decorations to the value. // Display value using user-provided display format so user can add prefix/suffix/decorations to the value.
// For the vertical slider we allow centered text to overlap the frame padding // For the vertical slider we allow centered text to overlap the frame padding
char value_buf[64]; char value_buf[64];
const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_ARRAYSIZE(value_buf), data_type, p_data, format); const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_COUNTOF(value_buf), data_type, p_data, format);
RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y + style.FramePadding.y), frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f, 0.0f)); RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y + style.FramePadding.y), frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f, 0.0f));
if (label_size.x > 0.0f) if (label_size.x > 0.0f)
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
@@ -3724,16 +3724,16 @@ bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImG
const ImGuiDataTypeInfo* type_info = DataTypeGetInfo(data_type); const ImGuiDataTypeInfo* type_info = DataTypeGetInfo(data_type);
char fmt_buf[32]; char fmt_buf[32];
char data_buf[32]; char data_buf[32];
format = ImParseFormatTrimDecorations(format, fmt_buf, IM_ARRAYSIZE(fmt_buf)); format = ImParseFormatTrimDecorations(format, fmt_buf, IM_COUNTOF(fmt_buf));
if (format[0] == 0) if (format[0] == 0)
format = type_info->PrintFmt; format = type_info->PrintFmt;
DataTypeFormatString(data_buf, IM_ARRAYSIZE(data_buf), data_type, p_data, format); DataTypeFormatString(data_buf, IM_COUNTOF(data_buf), data_type, p_data, format);
ImStrTrimBlanks(data_buf); ImStrTrimBlanks(data_buf);
ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | (ImGuiInputTextFlags)ImGuiInputTextFlags_LocalizeDecimalPoint; ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | (ImGuiInputTextFlags)ImGuiInputTextFlags_LocalizeDecimalPoint;
g.LastItemData.ItemFlags |= ImGuiItemFlags_NoMarkEdited; // Because TempInputText() uses ImGuiInputTextFlags_MergedItem it doesn't submit a new item, so we poke LastItemData. g.LastItemData.ItemFlags |= ImGuiItemFlags_NoMarkEdited; // Because TempInputText() uses ImGuiInputTextFlags_MergedItem it doesn't submit a new item, so we poke LastItemData.
bool value_changed = false; bool value_changed = false;
if (TempInputText(bb, id, label, data_buf, IM_ARRAYSIZE(data_buf), flags)) if (TempInputText(bb, id, label, data_buf, IM_COUNTOF(data_buf), flags))
{ {
// Backup old value // Backup old value
size_t data_type_size = type_info->Size; size_t data_type_size = type_info->Size;
@@ -3786,7 +3786,7 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
if ((flags & ImGuiInputTextFlags_DisplayEmptyRefVal) && DataTypeCompare(data_type, p_data, p_data_default) == 0) if ((flags & ImGuiInputTextFlags_DisplayEmptyRefVal) && DataTypeCompare(data_type, p_data, p_data_default) == 0)
buf[0] = 0; buf[0] = 0;
else else
DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format); DataTypeFormatString(buf, IM_COUNTOF(buf), data_type, p_data, format);
// Disable the MarkItemEdited() call in InputText but keep ImGuiItemStatusFlags_Edited. // Disable the MarkItemEdited() call in InputText but keep ImGuiItemStatusFlags_Edited.
// We call MarkItemEdited() ourselves by comparing the actual data rather than the string. // We call MarkItemEdited() ourselves by comparing the actual data rather than the string.
@@ -3796,7 +3796,7 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
bool value_changed = false; bool value_changed = false;
if (p_step == NULL) if (p_step == NULL)
{ {
if (InputText(label, buf, IM_ARRAYSIZE(buf), flags)) if (InputText(label, buf, IM_COUNTOF(buf), flags))
value_changed = DataTypeApplyFromText(buf, data_type, p_data, format, (flags & ImGuiInputTextFlags_ParseEmptyRefVal) ? p_data_default : NULL); value_changed = DataTypeApplyFromText(buf, data_type, p_data, format, (flags & ImGuiInputTextFlags_ParseEmptyRefVal) ? p_data_default : NULL);
} }
else else
@@ -3806,7 +3806,7 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
BeginGroup(); // The only purpose of the group here is to allow the caller to query item data e.g. IsItemActive() BeginGroup(); // The only purpose of the group here is to allow the caller to query item data e.g. IsItemActive()
PushID(label); PushID(label);
SetNextItemWidth(ImMax(1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2)); SetNextItemWidth(ImMax(1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2));
if (InputText("", buf, IM_ARRAYSIZE(buf), flags)) // PushId(label) + "" gives us the expected ID from outside point of view if (InputText("", buf, IM_COUNTOF(buf), flags)) // PushId(label) + "" gives us the expected ID from outside point of view
value_changed = DataTypeApplyFromText(buf, data_type, p_data, format, (flags & ImGuiInputTextFlags_ParseEmptyRefVal) ? p_data_default : NULL); value_changed = DataTypeApplyFromText(buf, data_type, p_data, format, (flags & ImGuiInputTextFlags_ParseEmptyRefVal) ? p_data_default : NULL);
IMGUI_TEST_ENGINE_ITEM_INFO(g.LastItemData.ID, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Inputable); IMGUI_TEST_ENGINE_ITEM_INFO(g.LastItemData.ID, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Inputable);
@@ -5851,11 +5851,11 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
// RGB Hexadecimal Input // RGB Hexadecimal Input
char buf[64]; char buf[64];
if (alpha) if (alpha)
ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X%02X", ImClamp(i[0], 0, 255), ImClamp(i[1], 0, 255), ImClamp(i[2], 0, 255), ImClamp(i[3], 0, 255)); ImFormatString(buf, IM_COUNTOF(buf), "#%02X%02X%02X%02X", ImClamp(i[0], 0, 255), ImClamp(i[1], 0, 255), ImClamp(i[2], 0, 255), ImClamp(i[3], 0, 255));
else else
ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", ImClamp(i[0], 0, 255), ImClamp(i[1], 0, 255), ImClamp(i[2], 0, 255)); ImFormatString(buf, IM_COUNTOF(buf), "#%02X%02X%02X", ImClamp(i[0], 0, 255), ImClamp(i[1], 0, 255), ImClamp(i[2], 0, 255));
SetNextItemWidth(w_inputs); SetNextItemWidth(w_inputs);
if (InputText("##Text", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsUppercase)) if (InputText("##Text", buf, IM_COUNTOF(buf), ImGuiInputTextFlags_CharsUppercase))
{ {
value_changed = true; value_changed = true;
char* p = buf; char* p = buf;
@@ -6549,18 +6549,18 @@ void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags)
{ {
int cr = IM_F32_TO_INT8_SAT(col[0]), cg = IM_F32_TO_INT8_SAT(col[1]), cb = IM_F32_TO_INT8_SAT(col[2]), ca = (flags & ImGuiColorEditFlags_NoAlpha) ? 255 : IM_F32_TO_INT8_SAT(col[3]); int cr = IM_F32_TO_INT8_SAT(col[0]), cg = IM_F32_TO_INT8_SAT(col[1]), cb = IM_F32_TO_INT8_SAT(col[2]), ca = (flags & ImGuiColorEditFlags_NoAlpha) ? 255 : IM_F32_TO_INT8_SAT(col[3]);
char buf[64]; char buf[64];
ImFormatString(buf, IM_ARRAYSIZE(buf), "(%.3ff, %.3ff, %.3ff, %.3ff)", col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]); ImFormatString(buf, IM_COUNTOF(buf), "(%.3ff, %.3ff, %.3ff, %.3ff)", col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]);
if (Selectable(buf)) if (Selectable(buf))
SetClipboardText(buf); SetClipboardText(buf);
ImFormatString(buf, IM_ARRAYSIZE(buf), "(%d,%d,%d,%d)", cr, cg, cb, ca); ImFormatString(buf, IM_COUNTOF(buf), "(%d,%d,%d,%d)", cr, cg, cb, ca);
if (Selectable(buf)) if (Selectable(buf))
SetClipboardText(buf); SetClipboardText(buf);
ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", cr, cg, cb); ImFormatString(buf, IM_COUNTOF(buf), "#%02X%02X%02X", cr, cg, cb);
if (Selectable(buf)) if (Selectable(buf))
SetClipboardText(buf); SetClipboardText(buf);
if (!(flags & ImGuiColorEditFlags_NoAlpha)) if (!(flags & ImGuiColorEditFlags_NoAlpha))
{ {
ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X%02X", cr, cg, cb, ca); ImFormatString(buf, IM_COUNTOF(buf), "#%02X%02X%02X%02X", cr, cg, cb, ca);
if (Selectable(buf)) if (Selectable(buf))
SetClipboardText(buf); SetClipboardText(buf);
} }
@@ -7513,7 +7513,7 @@ ImGuiTypingSelectRequest* ImGui::GetTypingSelectRequest(ImGuiTypingSelectFlags f
} }
// Append to buffer // Append to buffer
const int buffer_max_len = IM_ARRAYSIZE(data->SearchBuffer) - 1; const int buffer_max_len = IM_COUNTOF(data->SearchBuffer) - 1;
int buffer_len = (int)ImStrlen(data->SearchBuffer); int buffer_len = (int)ImStrlen(data->SearchBuffer);
bool select_request = false; bool select_request = false;
for (ImWchar w : g.IO.InputQueueCharacters) for (ImWchar w : g.IO.InputQueueCharacters)
@@ -8913,7 +8913,7 @@ void ImGui::Value(const char* prefix, float v, const char* float_format)
if (float_format) if (float_format)
{ {
char fmt[64]; char fmt[64];
ImFormatString(fmt, IM_ARRAYSIZE(fmt), "%%s: %s", float_format); ImFormatString(fmt, IM_COUNTOF(fmt), "%%s: %s", float_format);
Text(fmt, prefix, v); Text(fmt, prefix, v);
} }
else else
@@ -8952,7 +8952,7 @@ void ImGuiMenuColumns::CalcNextTotalWidth(bool update_offsets)
{ {
ImU16 offset = 0; ImU16 offset = 0;
bool want_spacing = false; bool want_spacing = false;
for (int i = 0; i < IM_ARRAYSIZE(Widths); i++) for (int i = 0; i < IM_COUNTOF(Widths); i++)
{ {
ImU16 width = Widths[i]; ImU16 width = Widths[i];
if (want_spacing && width > 0) if (want_spacing && width > 0)