diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index f7a5f3092388..000000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,232 +0,0 @@ -cmake_minimum_required(VERSION 3.16) -project(imgui CXX) - -set(CMAKE_DEBUG_POSTFIX d) - -if(APPLE) - set(CMAKE_CXX_STANDARD 11) - enable_language(OBJCXX) -endif() - -add_library(${PROJECT_NAME} "") -add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) -target_include_directories( - ${PROJECT_NAME} - PUBLIC - $ - $ -) - -target_sources( - ${PROJECT_NAME} - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/imgui.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/imgui_demo.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/imgui_draw.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/imgui_tables.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/imgui_widgets.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/misc/cpp/imgui_stdlib.cpp -) - -target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11) - -if(IMGUI_BUILD_ALLEGRO5_BINDING) - find_path(ALLEGRO5_INCLUDE_DIRS allegro5/allegro.h) - target_include_directories(${PROJECT_NAME} PRIVATE ${ALLEGRO5_INCLUDE_DIRS}) - target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_allegro5.cpp) -endif() - -if(IMGUI_BUILD_DX9_BINDING) - target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_dx9.cpp) -endif() - -if(IMGUI_BUILD_DX10_BINDING) - target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_dx10.cpp) -endif() - -if(IMGUI_BUILD_DX11_BINDING) - target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_dx11.cpp) -endif() - -if(IMGUI_BUILD_DX12_BINDING) - target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_dx12.cpp) -endif() - -if(IMGUI_BUILD_GLFW_BINDING) - if(NOT EMSCRIPTEN) - find_package(glfw3 CONFIG REQUIRED) - target_link_libraries(${PROJECT_NAME} PUBLIC glfw) - endif() - target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_glfw.cpp) -endif() - -if(IMGUI_BUILD_GLUT_BINDING) - find_package(GLUT REQUIRED) - target_link_libraries(${PROJECT_NAME} PUBLIC GLUT::GLUT) - target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_glut.cpp) -endif() - -if(IMGUI_BUILD_METAL_BINDING) - target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_metal.mm) - set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_metal.mm PROPERTIES COMPILE_FLAGS -fobjc-weak) -endif() - -if(IMGUI_BUILD_OPENGL2_BINDING) - target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_opengl2.cpp) -endif() - -if(IMGUI_BUILD_OPENGL3_BINDING) - target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp) -endif() - -if(IMGUI_BUILD_OSX_BINDING) - target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_osx.mm) -endif() - -if(IMGUI_BUILD_SDL2_BINDING) - find_package(SDL2 CONFIG REQUIRED) - target_link_libraries(${PROJECT_NAME} PUBLIC SDL2::SDL2) - target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_sdl2.cpp) -endif() - -if(IMGUI_BUILD_SDL2_RENDERER_BINDING) - find_package(SDL2 CONFIG REQUIRED) - target_link_libraries(${PROJECT_NAME} PUBLIC SDL2::SDL2) - target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_sdlrenderer.cpp) -endif() - -if(IMGUI_BUILD_VULKAN_BINDING) - find_package(Vulkan REQUIRED) - target_link_libraries(${PROJECT_NAME} PUBLIC Vulkan::Vulkan) - target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_vulkan.cpp) -endif() - -if(IMGUI_BUILD_WIN32_BINDING) - target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_win32.cpp) -endif() - -if(IMGUI_FREETYPE) - find_package(freetype CONFIG REQUIRED) - target_link_libraries(${PROJECT_NAME} PUBLIC freetype) - target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/misc/freetype/imgui_freetype.cpp) - target_compile_definitions(${PROJECT_NAME} PUBLIC IMGUI_ENABLE_FREETYPE) -endif() - -if(IMGUI_USE_WCHAR32) - target_compile_definitions(${PROJECT_NAME} PUBLIC IMGUI_USE_WCHAR32) -endif() - -list(REMOVE_DUPLICATES BINDINGS_SOURCES) - -install( - TARGETS ${PROJECT_NAME} - EXPORT ${PROJECT_NAME}_target - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin -) - -foreach(BINDING_TARGET ${BINDING_TARGETS}) - install( - TARGETS ${BINDING_TARGET} - EXPORT ${PROJECT_NAME}_target - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin - ) -endforeach() - -if(NOT IMGUI_SKIP_HEADERS) - install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/imgui.h - ${CMAKE_CURRENT_SOURCE_DIR}/imconfig.h - ${CMAKE_CURRENT_SOURCE_DIR}/imgui_internal.h - ${CMAKE_CURRENT_SOURCE_DIR}/imstb_textedit.h - ${CMAKE_CURRENT_SOURCE_DIR}/imstb_rectpack.h - ${CMAKE_CURRENT_SOURCE_DIR}/imstb_truetype.h - ${CMAKE_CURRENT_SOURCE_DIR}/misc/cpp/imgui_stdlib.h - DESTINATION include - ) - - if(IMGUI_BUILD_ALLEGRO5_BINDING) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_allegro5.h DESTINATION include) - endif() - - if(IMGUI_BUILD_DX9_BINDING) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_dx9.h DESTINATION include) - endif() - - if(IMGUI_BUILD_DX10_BINDING) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_dx10.h DESTINATION include) - endif() - - if(IMGUI_BUILD_DX11_BINDING) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_dx11.h DESTINATION include) - endif() - - if(IMGUI_BUILD_DX12_BINDING) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_dx12.h DESTINATION include) - endif() - - if(IMGUI_BUILD_GLFW_BINDING) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_glfw.h DESTINATION include) - endif() - - if(IMGUI_BUILD_GLUT_BINDING) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_glut.h DESTINATION include) - endif() - - if(IMGUI_BUILD_METAL_BINDING) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_metal.h DESTINATION include) - endif() - - if(IMGUI_BUILD_OPENGL2_BINDING) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_opengl2.h DESTINATION include) - endif() - - if(IMGUI_BUILD_OPENGL3_BINDING) - install( - FILES - ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_opengl3.h - ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_opengl3_loader.h - DESTINATION - include - ) - endif() - - if(IMGUI_BUILD_OSX_BINDING) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_osx.h DESTINATION include) - endif() - - if(IMGUI_BUILD_SDL2_BINDING) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_sdl2.h DESTINATION include) - endif() - - if(IMGUI_BUILD_SDL2_RENDERER_BINDING) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_sdlrenderer.h DESTINATION include) - endif() - - if(IMGUI_BUILD_VULKAN_BINDING) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_vulkan.h DESTINATION include) - endif() - - if(IMGUI_BUILD_WIN32_BINDING) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_win32.h DESTINATION include) - endif() - - if(IMGUI_FREETYPE) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/misc/freetype/imgui_freetype.h DESTINATION include) - endif() -endif() - -include(CMakePackageConfigHelpers) -configure_package_config_file(imgui-config.cmake.in imgui-config.cmake INSTALL_DESTINATION share/imgui) - -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/imgui-config.cmake DESTINATION share/imgui) - -install( - EXPORT ${PROJECT_NAME}_target - NAMESPACE ${PROJECT_NAME}:: - FILE ${PROJECT_NAME}-targets.cmake - DESTINATION share/${PROJECT_NAME} -) diff --git a/backends/imgui_impl_sdl2.cpp b/backends/imgui_impl_sdl2.cpp index c4f96418fa20..afed7b4abb6d 100644 --- a/backends/imgui_impl_sdl2.cpp +++ b/backends/imgui_impl_sdl2.cpp @@ -410,7 +410,6 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event) // - In some cases, when detaching a window from main viewport SDL may send SDL_WINDOWEVENT_ENTER one frame too late, // causing SDL_WINDOWEVENT_LEAVE on previous frame to interrupt drag operation by clear mouse position. This is why // we delay process the SDL_WINDOWEVENT_LEAVE events by one frame. See issue #5012 for details. - Uint8 window_event = event->window.event; if (window_event == SDL_WINDOWEVENT_ENTER) { @@ -420,33 +419,20 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event) if (window_event == SDL_WINDOWEVENT_LEAVE) bd->MouseLastLeaveFrame = ImGui::GetFrameCount() + 1; if (window_event == SDL_WINDOWEVENT_FOCUS_GAINED) - { io.AddFocusEvent(true); - } else if (window_event == SDL_WINDOWEVENT_FOCUS_LOST) - { io.AddFocusEvent(false); - } if (window_event == SDL_WINDOWEVENT_CLOSE || window_event == SDL_WINDOWEVENT_MOVED || window_event == SDL_WINDOWEVENT_RESIZED) - { if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle((void*)SDL_GetWindowFromID(event->window.windowID))) { if (window_event == SDL_WINDOWEVENT_CLOSE) - { viewport->PlatformRequestClose = true; - } if (window_event == SDL_WINDOWEVENT_MOVED) - { viewport->PlatformRequestMove = true; - } if (window_event == SDL_WINDOWEVENT_RESIZED) - { viewport->PlatformRequestResize = true; - } return true; } - - } return true; } case SDL_CONTROLLERDEVICEADDED: @@ -632,12 +618,14 @@ static void ImGui_ImplSDL2_UpdateMouseData() // We forward mouse input when hovered or captured (via SDL_MOUSEMOTION) or when focused (below) #if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE +// MicroStrain start #if !defined(_WIN32) && defined(NDEBUG) - // SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside // On linux, this can get the mouse stuck when a breakpoint is hit, so disable for debug builds. // See https://github.com/ocornut/imgui/issues/4197 and https://github.com/ocornut/imgui/issues/3650 +// MicroStrain end + // SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside SDL_CaptureMouse((bd->MouseButtonsDown != 0) ? SDL_TRUE : SDL_FALSE); -#endif +#endif // MicroStrain SDL_Window* focused_window = SDL_GetKeyboardFocus(); const bool is_app_focused = (focused_window && (bd->Window == focused_window || ImGui::FindViewportByPlatformHandle((void*)focused_window))); #else @@ -923,6 +911,7 @@ struct ImGui_ImplSDL2_ViewportData Uint32 WindowID; bool WindowOwned; SDL_GLContext GLContext; + ImGui_ImplSDL2_ViewportData() { Window = nullptr; WindowID = 0; WindowOwned = false; GLContext = nullptr; } ~ImGui_ImplSDL2_ViewportData() { IM_ASSERT(Window == nullptr && GLContext == nullptr); } }; @@ -959,9 +948,7 @@ static void ImGui_ImplSDL2_CreateWindow(ImGuiViewport* viewport) #if SDL_HAS_ALWAYS_ON_TOP sdl_flags |= (viewport->Flags & ImGuiViewportFlags_TopMost) ? SDL_WINDOW_ALWAYS_ON_TOP : 0; #endif - vd->Window = SDL_CreateWindow("No Title Yet", (int)viewport->Pos.x, (int)viewport->Pos.y, (int)viewport->Size.x, (int)viewport->Size.y, sdl_flags); - vd->WindowOwned = true; if (use_opengl) { @@ -973,7 +960,6 @@ static void ImGui_ImplSDL2_CreateWindow(ImGuiViewport* viewport) viewport->PlatformHandle = (void*)vd->Window; viewport->PlatformHandleRaw = nullptr; - SDL_SysWMinfo info; SDL_VERSION(&info.version); if (SDL_GetWindowWMInfo(vd->Window, &info)) diff --git a/backends/imgui_impl_sdl3.cpp b/backends/imgui_impl_sdl3.cpp index e484c6971b84..34672735cb69 100644 --- a/backends/imgui_impl_sdl3.cpp +++ b/backends/imgui_impl_sdl3.cpp @@ -559,11 +559,14 @@ static void ImGui_ImplSDL3_UpdateMouseData() // We forward mouse input when hovered or captured (via SDL_EVENT_MOUSE_MOTION) or when focused (below) #if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE +// MicroStrain start #if !defined(_WIN32) && defined(NDEBUG) - // SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside // On linux, this can get the mouse stuck when a breakpoint is hit, so disable for debug builds. + // See https://github.com/ocornut/imgui/issues/4197 and https://github.com/ocornut/imgui/issues/3650 +// MicroStrain end + // SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside SDL_CaptureMouse((bd->MouseButtonsDown != 0) ? SDL_TRUE : SDL_FALSE); -#endif +#endif // MicroStrain SDL_Window* focused_window = SDL_GetKeyboardFocus(); const bool is_app_focused = (focused_window && (bd->Window == focused_window || ImGui::FindViewportByPlatformHandle((void*)focused_window))); #else diff --git a/imconfig.h b/imconfig.h index 306611113816..d556cbaf1be9 100644 --- a/imconfig.h +++ b/imconfig.h @@ -23,9 +23,7 @@ // Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility. // DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions() // for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details. -#ifdef WIN32_ - #define IMGUI_API __declspec( dllexport ) -#endif +//#define IMGUI_API __declspec( dllexport ) //#define IMGUI_API __declspec( dllimport ) //---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to clean your code of obsolete function/names. @@ -102,13 +100,13 @@ operator MyVec4() const { return MyVec4(x,y,z,w); } */ //---- ...Or use Dear ImGui's own very basic math operators. -#define IMGUI_DEFINE_MATH_OPERATORS +//#define IMGUI_DEFINE_MATH_OPERATORS //---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. // Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). // Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. // Read about ImGuiBackendFlags_RendererHasVtxOffset for details. -#define ImDrawIdx unsigned int +//#define ImDrawIdx unsigned int //---- Override ImDrawCallback signature (will need to modify renderer backends accordingly) //struct ImDrawList; diff --git a/imgui-config.cmake.in b/imgui-config.cmake.in deleted file mode 100644 index 960d32fb292f..000000000000 --- a/imgui-config.cmake.in +++ /dev/null @@ -1,29 +0,0 @@ -cmake_policy(SET CMP0012 NEW) - -@PACKAGE_INIT@ - -include(CMakeFindDependencyMacro) - -if (@IMGUI_BUILD_GLFW_BINDING@) - if (NOT "@EMSCRIPTEN@") - find_dependency(glfw3 CONFIG) - endif() -endif() - -if (@IMGUI_BUILD_GLUT_BINDING@) - find_dependency(GLUT) -endif() - -if (@IMGUI_BUILD_SDL2_BINDING@ OR @IMGUI_BUILD_SDL2_RENDERER_BINDING@) - find_dependency(SDL2 CONFIG) -endif() - -if (@IMGUI_BUILD_VULKAN_BINDING@) - find_dependency(Vulkan) -endif() - -if (@IMGUI_FREETYPE@) - find_dependency(freetype CONFIG) -endif() - -include("${CMAKE_CURRENT_LIST_DIR}/imgui-targets.cmake") diff --git a/imgui.cpp b/imgui.cpp index f87dbd210790..2049011f914e 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3291,11 +3291,11 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx) case ImGuiCol_Button: return "Button"; case ImGuiCol_ButtonHovered: return "ButtonHovered"; case ImGuiCol_ButtonActive: return "ButtonActive"; - case ImGuiCol_ButtonText: return "ButtonText"; // MicroStrain Custom + case ImGuiCol_ButtonText: return "ButtonText"; // MicroStrain case ImGuiCol_Header: return "Header"; case ImGuiCol_HeaderHovered: return "HeaderHovered"; case ImGuiCol_HeaderActive: return "HeaderActive"; - case ImGuiCol_HeaderText: return "HeaderText"; // MicroStrain Custom + case ImGuiCol_HeaderText: return "HeaderText"; // MicroStrain case ImGuiCol_Separator: return "Separator"; case ImGuiCol_SeparatorHovered: return "SeparatorHovered"; case ImGuiCol_SeparatorActive: return "SeparatorActive"; @@ -3307,7 +3307,7 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx) case ImGuiCol_TabActive: return "TabActive"; case ImGuiCol_TabUnfocused: return "TabUnfocused"; case ImGuiCol_TabUnfocusedActive: return "TabUnfocusedActive"; - case ImGuiCol_TabText: return "TabText"; // MicroStrain Custom + case ImGuiCol_TabText: return "TabText"; // MicroStrain case ImGuiCol_DockingPreview: return "DockingPreview"; case ImGuiCol_DockingEmptyBg: return "DockingEmptyBg"; case ImGuiCol_PlotLines: return "PlotLines"; @@ -3315,7 +3315,7 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx) case ImGuiCol_PlotHistogram: return "PlotHistogram"; case ImGuiCol_PlotHistogramHovered: return "PlotHistogramHovered"; case ImGuiCol_TableHeaderBg: return "TableHeaderBg"; - case ImGuiCol_TableHeaderText: return "TableHeaderText"; // MicroStrain Custom + case ImGuiCol_TableHeaderText: return "TableHeaderText"; // MicroStrain case ImGuiCol_TableBorderStrong: return "TableBorderStrong"; case ImGuiCol_TableBorderLight: return "TableBorderLight"; case ImGuiCol_TableRowBg: return "TableRowBg"; @@ -6032,7 +6032,6 @@ static ImVec2 CalcWindowAutoFitSize(ImGuiWindow* window, const ImVec2& size_cont const float decoration_h_without_scrollbars = window->DecoOuterSizeY1 + window->DecoOuterSizeY2 - window->ScrollbarSizes.y; ImVec2 size_pad = window->WindowPadding * 2.0f; ImVec2 size_desired = size_contents + size_pad + ImVec2(decoration_w_without_scrollbars, decoration_h_without_scrollbars); - if (window->Flags & ImGuiWindowFlags_Tooltip) { // Tooltip always resize @@ -7142,7 +7141,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) // Late create viewport if we don't fit within our current host viewport. if (window->ViewportAllowPlatformMonitorExtend >= 0 && !window->ViewportOwned && !(window->Viewport->Flags & ImGuiViewportFlags_IsMinimized)) - if ((window->WindowClass.ViewportFlagsOverrideSet & ImGuiViewportFlags_NoAutoMerge) || !window->Viewport->GetMainRect().Contains(window->Rect())) + if (!window->Viewport->GetMainRect().Contains(window->Rect())) { // This is based on the assumption that the DPI will be known ahead (same as the DPI of the selection done in UpdateSelectWindowViewport) //ImGuiViewport* old_viewport = window->Viewport; diff --git a/imgui.h b/imgui.h index b7eb9fbc89d4..3f670d87d6b7 100644 --- a/imgui.h +++ b/imgui.h @@ -558,13 +558,15 @@ namespace ImGui // Widgets: Combo Box (Dropdown) // - The BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items. - // - The BeginComboInputText()/EndComboInputText() api uses an input text object to allow for filtering dropdown items. + // - The BeginComboInputText()/EndComboInputText() api uses an input text object to allow for filtering dropdown items. // MicroStrain // - The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose. This is analogous to how ListBox are created. IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags = 0); IMGUI_API void EndCombo(); // only call EndCombo() if BeginCombo() returns true! + // MicroStrain start // TODO: Rework to use ImGuiTextFilter instead of InputText IMGUI_API bool BeginComboInputText(const char* label, const char* preview_value, char* buffer, size_t buffer_size, bool* buffer_changed = NULL, ImGuiComboFlags combo_flags = 0, ImGuiInputTextFlags input_flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); IMGUI_API void EndComboInputText(); + // MicroStrain end IMGUI_API bool Combo(const char* label, int* current_item, const char* const items[], int items_count, int popup_max_height_in_items = -1); IMGUI_API bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_max_height_in_items = -1); // Separate items with \0 within a string, end item-list with \0\0. e.g. "One\0Two\0Three\0" IMGUI_API bool Combo(const char* label, int* current_item, const char* (*getter)(void* user_data, int idx), void* user_data, int items_count, int popup_max_height_in_items = -1); @@ -1212,8 +1214,8 @@ enum ImGuiComboFlags_ ImGuiComboFlags_HeightLargest = 1 << 4, // As many fitting items as possible ImGuiComboFlags_NoArrowButton = 1 << 5, // Display on the preview box without the square arrow button ImGuiComboFlags_NoPreview = 1 << 6, // Display only a square arrow button - ImGuiComboFlags_InputText = 1 << 7, // Combo is using an input text instead of a preview box - ImGuiComboFlags_WidthFitPreview = 1 << 8, // Width dynamically calculated from preview contents + ImGuiComboFlags_WidthFitPreview = 1 << 7, // Width dynamically calculated from preview contents + ImGuiComboFlags_InputText = 1 << 8, // Combo is using an input text instead of a preview box // MicroStrain ImGuiComboFlags_HeightMask_ = ImGuiComboFlags_HeightSmall | ImGuiComboFlags_HeightRegular | ImGuiComboFlags_HeightLarge | ImGuiComboFlags_HeightLargest, }; @@ -1597,11 +1599,11 @@ enum ImGuiCol_ ImGuiCol_Button, ImGuiCol_ButtonHovered, ImGuiCol_ButtonActive, - ImGuiCol_ButtonText, // MicroStrain + ImGuiCol_ButtonText, // MicroStrain ImGuiCol_Header, // Header* colors are used for CollapsingHeader, TreeNode, Selectable, MenuItem ImGuiCol_HeaderHovered, ImGuiCol_HeaderActive, - ImGuiCol_HeaderText, // MicroStrain + ImGuiCol_HeaderText, // MicroStrain ImGuiCol_Separator, ImGuiCol_SeparatorHovered, ImGuiCol_SeparatorActive, @@ -1613,7 +1615,7 @@ enum ImGuiCol_ ImGuiCol_TabActive, ImGuiCol_TabUnfocused, ImGuiCol_TabUnfocusedActive, - ImGuiCol_TabText, // MicroStrain + ImGuiCol_TabText, // MicroStrain ImGuiCol_DockingPreview, // Preview overlay color when about to docking something ImGuiCol_DockingEmptyBg, // Background color for empty node (e.g. CentralNode with no window docked into it) ImGuiCol_PlotLines, @@ -1621,7 +1623,7 @@ enum ImGuiCol_ ImGuiCol_PlotHistogram, ImGuiCol_PlotHistogramHovered, ImGuiCol_TableHeaderBg, // Table header background - ImGuiCol_TableHeaderText, // MicroStrain + ImGuiCol_TableHeaderText, // MicroStrain ImGuiCol_TableBorderStrong, // Table outer and header borders (prefer using Alpha=1.0 here) ImGuiCol_TableBorderLight, // Table inner borders (prefer using Alpha=1.0 here) ImGuiCol_TableRowBg, // Table row background (even rows) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index a82eebf17d16..f8f1127bdfcf 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -179,10 +179,10 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst) ImVec4* colors = style->Colors; colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); - colors[ImGuiCol_ButtonText] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); // MicroStrain - colors[ImGuiCol_HeaderText] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); // MicroStrain - colors[ImGuiCol_TabText] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); // MicroStrain - colors[ImGuiCol_TableHeaderText] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); // MicroStrain + colors[ImGuiCol_ButtonText] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); // MicroStrain + colors[ImGuiCol_HeaderText] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); // MicroStrain + colors[ImGuiCol_TabText] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); // MicroStrain + colors[ImGuiCol_TableHeaderText] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); // MicroStrain colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f); colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); @@ -245,10 +245,10 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst) ImVec4* colors = style->Colors; colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); - colors[ImGuiCol_ButtonText] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); // MicroStrain - colors[ImGuiCol_HeaderText] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); // MicroStrain - colors[ImGuiCol_TabText] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); // MicroStrain - colors[ImGuiCol_TableHeaderText] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); // MicroStrain + colors[ImGuiCol_ButtonText] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); // MicroStrain + colors[ImGuiCol_HeaderText] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); // MicroStrain + colors[ImGuiCol_TabText] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); // MicroStrain + colors[ImGuiCol_TableHeaderText] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); // MicroStrain colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f); colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.85f); colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); @@ -312,10 +312,10 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst) ImVec4* colors = style->Colors; colors[ImGuiCol_Text] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); - colors[ImGuiCol_ButtonText] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); // MicroStrain - colors[ImGuiCol_HeaderText] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); // MicroStrain - colors[ImGuiCol_TabText] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); // MicroStrain - colors[ImGuiCol_TableHeaderText] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); // MicroStrain + colors[ImGuiCol_ButtonText] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); // MicroStrain + colors[ImGuiCol_HeaderText] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); // MicroStrain + colors[ImGuiCol_TabText] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); // MicroStrain + colors[ImGuiCol_TableHeaderText] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); // MicroStrain colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f); colors[ImGuiCol_WindowBg] = ImVec4(0.94f, 0.94f, 0.94f, 1.00f); colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); diff --git a/imgui_tables.cpp b/imgui_tables.cpp index a8ed50697e81..e31725852853 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -3140,12 +3140,14 @@ void ImGui::TableHeader(const char* label) float y = label_pos.y; if (column->SortOrder > 0) { - PushStyleColor(ImGuiCol_TableHeaderText, GetColorU32(ImGuiCol_TableHeaderText, 0.70f)); // MicroStrain +// PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_Text, 0.70f)); // MicroStrain (original) + PushStyleColor(ImGuiCol_TableHeaderText, GetColorU32(ImGuiCol_TableHeaderText, 0.70f)); // MicroStrain RenderText(ImVec2(x + g.Style.ItemInnerSpacing.x, y), sort_order_suf); PopStyleColor(); x += w_sort_text; } - RenderArrow(window->DrawList, ImVec2(x, y), GetColorU32(ImGuiCol_TableHeaderText), column->SortDirection == ImGuiSortDirection_Ascending ? ImGuiDir_Up : ImGuiDir_Down, ARROW_SCALE); // MicroStrain +// RenderArrow(window->DrawList, ImVec2(x, y), GetColorU32(ImGuiCol_Text), column->SortDirection == ImGuiSortDirection_Ascending ? ImGuiDir_Up : ImGuiDir_Down, ARROW_SCALE); // MicroStrain (original) + RenderArrow(window->DrawList, ImVec2(x, y), GetColorU32(ImGuiCol_TableHeaderText), column->SortDirection == ImGuiSortDirection_Ascending ? ImGuiDir_Up : ImGuiDir_Down, ARROW_SCALE); // MicroStrain } // Handle clicking on column header to adjust Sort Order diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 59953931106d..73ee5067312c 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -722,10 +722,9 @@ bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags if (g.LogEnabled) LogSetNextTextDecoration("[", "]"); - - PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_ButtonText)); + PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_ButtonText)); // MicroStrain RenderTextClipped(bb.Min + style.FramePadding, bb.Max - style.FramePadding, label, NULL, &label_size, style.ButtonTextAlign, &bb); - PopStyleColor(); + PopStyleColor(); // MicroStrain // Automatically close popups //if (pressed && !(flags & ImGuiButtonFlags_DontClosePopups) && (window->Flags & ImGuiWindowFlags_Popup)) @@ -796,7 +795,8 @@ bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiBu // Render const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); - const ImU32 text_col = GetColorU32(ImGuiCol_ButtonText); // MicroStrain +// const ImU32 text_col = GetColorU32(ImGuiCol_Text); // MicroStrain (original) + const ImU32 text_col = GetColorU32(ImGuiCol_ButtonText); // MicroStrain RenderNavHighlight(bb, id); RenderFrame(bb.Min, bb.Max, bg_col, true, g.Style.FrameRounding); RenderArrow(window->DrawList, bb.Min + ImVec2(ImMax(0.0f, (size.x - g.FontSize) * 0.5f), ImMax(0.0f, (size.y - g.FontSize) * 0.5f)), text_col, dir); @@ -1792,8 +1792,10 @@ bool ImGui::BeginComboPopup(ImGuiID popup_id, const ImRect& bb, ImGuiComboFlags constraint_min.x = w; if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize) == 0 || g.NextWindowData.SizeVal.y <= 0.0f) constraint_max.y = CalcMaxPopupHeightFromItemCount(popup_max_height_in_items); + // MicroStrain start if (flags & ImGuiComboFlags_InputText) constraint_max.y += bb.GetHeight(); + // MicroStrain end SetNextWindowSizeConstraints(constraint_min, constraint_max); } @@ -1817,15 +1819,19 @@ bool ImGui::BeginComboPopup(ImGuiID popup_id, const ImRect& bb, ImGuiComboFlags // We don't use BeginPopupEx() solely because we have a custom name string, which we could make an argument to BeginPopupEx() ImGuiWindowFlags window_flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_Popup | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoMove; - if (flags & ImGuiComboFlags_InputText) + // MicroStrain start + if (flags & ImGuiComboFlags_InputText) { - PushStyleVar(ImGuiStyleVar_PopupBorderSize, 0.0f); // The child window only needs a border - PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); // Remove padding since the child window will replace the full popup + PushStyleVar(ImGuiStyleVar_PopupBorderSize, 0.0f); // The child window only needs a border + PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); // Remove padding since the child window will replace the full popup } else PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(g.Style.FramePadding.x, g.Style.WindowPadding.y)); // Horizontally align ourselves with the framed text + // MicroStrain end +// PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(g.Style.FramePadding.x, g.Style.WindowPadding.y)); // Horizontally align ourselves with the framed text // MicroStrain (original) bool ret = Begin(name, NULL, window_flags); - PopStyleVar(flags & ImGuiComboFlags_InputText ? 2 : 1); +// PopStyleVar(); // MicroStrain (original) + PopStyleVar(flags & ImGuiComboFlags_InputText ? 2 : 1); // MicroStrain if (!ret) { EndPopup(); @@ -1843,6 +1849,7 @@ void ImGui::EndCombo() g.BeginComboDepth--; } +// MicroStrain start bool ImGui::BeginComboInputText(const char* label, const char* preview_value, char* buffer, size_t buffer_size, bool* buffer_changed, ImGuiComboFlags combo_flags, ImGuiInputTextFlags input_flags, ImGuiInputTextCallback callback, void* user_data) { ImGuiContext& g = *GImGui; @@ -2040,6 +2047,7 @@ void ImGui::EndComboInputText() EndChild(); EndCombo(); } +// MicroStrain end // Call directly after the BeginCombo/EndCombo block. The preview is designed to only host non-interactive elements // (Experimental, see GitHub issues: #1658, #4168) @@ -6560,7 +6568,8 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_ToggledSelection; // Render - const ImU32 text_col = GetColorU32(ImGuiCol_HeaderText); // MicroStrain +// const ImU32 text_col = GetColorU32(ImGuiCol_Text); // MicroStrain (original) + const ImU32 text_col = GetColorU32(ImGuiCol_HeaderText); // MicroStrain ImGuiNavHighlightFlags nav_highlight_flags = ImGuiNavHighlightFlags_Compact; if (display_frame) { @@ -6600,7 +6609,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l if (span_all_columns) TablePopBackgroundChannel(); - PushStyleColor(ImGuiCol_Text, text_col); // MicroStrain + PushStyleColor(ImGuiCol_Text, text_col); // MicroStrain // Label if (display_frame) @@ -6608,7 +6617,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l else RenderText(text_pos, label, label_end, false); - PopStyleColor(); // MicroStrain + PopStyleColor(); // MicroStrain if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) TreePushOverrideID(id); @@ -6878,20 +6887,23 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl PopColumnsBackground(); } - // MicroStrain - if(hovered || selected) + // MicroStrain start + if (hovered || selected) ImGui::PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_HeaderText)); - else if(disabled_item || disabled_global) + else if (disabled_item || disabled_global) ImGui::PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_TextDisabled)); + // MicroStrain end RenderTextClipped(text_min, text_max, label, NULL, &label_size, style.SelectableTextAlign, &bb); - // MicroStrain - if(hovered || selected || disabled_item || disabled_global) + // MicroStrain start + if (hovered || selected || disabled_item || disabled_global) ImGui::PopStyleColor(); + // MicroStrain end // Automatically close popups - if (pressed && ((window->Flags & ImGuiWindowFlags_Popup) || (window->IsExplicitChild && window->ParentWindow->Flags & ImGuiWindowFlags_Popup)) && !(flags & ImGuiSelectableFlags_DontClosePopups) && !(g.LastItemData.InFlags & ImGuiItemFlags_SelectableDontClosePopup)) +// if (pressed && (window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiSelectableFlags_DontClosePopups) && !(g.LastItemData.InFlags & ImGuiItemFlags_SelectableDontClosePopup)) // MicroStrain (original) + if (pressed && ((window->Flags & ImGuiWindowFlags_Popup) || (window->IsExplicitChild && window->ParentWindow->Flags & ImGuiWindowFlags_Popup)) && !(flags & ImGuiSelectableFlags_DontClosePopups) && !(g.LastItemData.InFlags & ImGuiItemFlags_SelectableDontClosePopup)) // MicroStrain CloseCurrentPopup(); if (disabled_item && !disabled_global) @@ -8718,10 +8730,12 @@ static ImGuiTabItem* ImGui::TabBarScrollingButtons(ImGuiTabBar* tab_bar) //window->DrawList->AddRect(ImVec2(tab_bar->BarRect.Max.x - scrolling_buttons_width, tab_bar->BarRect.Min.y), ImVec2(tab_bar->BarRect.Max.x, tab_bar->BarRect.Max.y), IM_COL32(255,0,0,255)); int select_dir = 0; - ImVec4 arrow_col = g.Style.Colors[ImGuiCol_TabText]; // MicroStrain +// ImVec4 arrow_col = g.Style.Colors[ImGuiCol_Text]; // MicroStrain (original) + ImVec4 arrow_col = g.Style.Colors[ImGuiCol_TabText]; // MicroStrain arrow_col.w *= 0.5f; - PushStyleColor(ImGuiCol_TabText, arrow_col); // MicroStrain +// PushStyleColor(ImGuiCol_Text, arrow_col); // MicroStrain (original) + PushStyleColor(ImGuiCol_TabText, arrow_col); // MicroStrain PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); const float backup_repeat_delay = g.IO.KeyRepeatDelay; const float backup_repeat_rate = g.IO.KeyRepeatRate; @@ -8778,9 +8792,11 @@ static ImGuiTabItem* ImGui::TabBarTabListPopupButton(ImGuiTabBar* tab_bar) window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x - g.Style.FramePadding.y, tab_bar->BarRect.Min.y); tab_bar->BarRect.Min.x += tab_list_popup_button_width; - ImVec4 arrow_col = g.Style.Colors[ImGuiCol_TabText]; // MicroStrain +// ImVec4 arrow_col = g.Style.Colors[ImGuiCol_Text]; // MicroStrain (original) + ImVec4 arrow_col = g.Style.Colors[ImGuiCol_TabText]; // MicroStrain arrow_col.w *= 0.5f; - PushStyleColor(ImGuiCol_TabText, arrow_col); // MicroStrain +// PushStyleColor(ImGuiCol_Text, arrow_col); // MicroStrain (original) + PushStyleColor(ImGuiCol_TabText, arrow_col); // MicroStrain PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); bool open = BeginCombo("##v", NULL, ImGuiComboFlags_NoPreview | ImGuiComboFlags_HeightLargest); PopStyleColor(2); @@ -9291,7 +9307,8 @@ void ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, else if (unsaved_marker_visible) { const ImRect bullet_bb(button_pos, button_pos + ImVec2(button_sz, button_sz)); - RenderBullet(draw_list, bullet_bb.GetCenter(), GetColorU32(ImGuiCol_TabText)); // MicroStrain +// RenderBullet(draw_list, bullet_bb.GetCenter(), GetColorU32(ImGuiCol_Text)); // MicroStrain (original) + RenderBullet(draw_list, bullet_bb.GetCenter(), GetColorU32(ImGuiCol_TabText)); // MicroStrain } // This is all rather complicated @@ -9304,10 +9321,9 @@ void ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, text_ellipsis_clip_bb.Max.x -= unsaved_marker_visible ? (button_sz * 0.80f) : 0.0f; ellipsis_max_x = text_pixel_clip_bb.Max.x; } - - PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_TabText)); // MicroStrain + PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_TabText)); // MicroStrain RenderTextEllipsis(draw_list, text_ellipsis_clip_bb.Min, text_ellipsis_clip_bb.Max, text_pixel_clip_bb.Max.x, ellipsis_max_x, label, NULL, &label_size); - PopStyleColor(); // MicroStrain + PopStyleColor(); // MicroStrain #if 0 if (!is_contents_visible) diff --git a/misc/cpp/imgui_stdlib.cpp b/misc/cpp/imgui_stdlib.cpp index e806641f0896..72cefa415572 100644 --- a/misc/cpp/imgui_stdlib.cpp +++ b/misc/cpp/imgui_stdlib.cpp @@ -10,12 +10,6 @@ #include "imgui.h" #include "imgui_stdlib.h" - -void ImGui::TextUnformatted(std::string_view text) -{ - ImGui::TextUnformatted(text.data(), text.data() + text.size()); -} - // Clang warnings with -Weverything #if defined(__clang__) #pragma clang diagnostic push @@ -86,6 +80,13 @@ bool ImGui::InputTextWithHint(const char* label, const char* hint, std::string* return InputTextWithHint(label, hint, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data); } +// MicroStrain start +void ImGui::TextUnformatted(std::string_view text) +{ + ImGui::TextUnformatted(text.data(), text.data() + text.size()); +} +// MicroStrain end + #if defined(__clang__) #pragma clang diagnostic pop #endif diff --git a/misc/cpp/imgui_stdlib.h b/misc/cpp/imgui_stdlib.h index 862140d1eb43..de1c22543742 100644 --- a/misc/cpp/imgui_stdlib.h +++ b/misc/cpp/imgui_stdlib.h @@ -13,11 +13,10 @@ namespace ImGui { - IMGUI_API void TextUnformatted(std::string_view text); - // ImGui::InputText() with std::string // Because text input needs dynamic resizing, we need to setup a callback to grow the capacity IMGUI_API bool InputText(const char* label, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr); IMGUI_API bool InputTextMultiline(const char* label, std::string* str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr); IMGUI_API bool InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr); + IMGUI_API void TextUnformatted(std::string_view text); // MicroStrain }