mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-06 04:58:47 +02:00
Merge branch 'master' into docking
# Conflicts: # backends/imgui_impl_dx9.cpp # backends/imgui_impl_win32.cpp # docs/CHANGELOG.txt # imgui.cpp
This commit is contained in:
86
imgui.cpp
86
imgui.cpp
@ -15,6 +15,7 @@
|
||||
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
||||
// - Wiki https://github.com/ocornut/imgui/wiki
|
||||
// - Issues & support https://github.com/ocornut/imgui/issues
|
||||
// - Discussions https://github.com/ocornut/imgui/discussions
|
||||
|
||||
// Developed by Omar Cornut and every direct or indirect contributors to the GitHub.
|
||||
// See LICENSE.txt for copyright and licensing details (standard MIT License).
|
||||
@ -385,6 +386,7 @@ CODE
|
||||
- 2021/XX/XX (1.XX) - Moved IME support functions from io.ImeSetInputScreenPosFn, io.ImeWindowHandle to the PlatformIO api.
|
||||
|
||||
|
||||
- 2021/02/22 (1.82) - win32+mingw: Re-enabled IME functions by default even under MinGW. In July 2016, issue #738 had me incorrectly disable those default functions for MinGW. MinGW users should: either link with -limm32, either set their imconfig file with '#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS'.
|
||||
- 2021/02/17 (1.82) - renamed rarely used style.CircleSegmentMaxError (old default = 1.60f) to style.CircleTessellationMaxError (new default = 0.30f) as the meaning of the value changed.
|
||||
- 2021/02/03 (1.81) - renamed ListBoxHeader(const char* label, ImVec2 size) to BeginListBox(). Kept inline redirection function (will obsolete).
|
||||
- removed ListBoxHeader(const char* label, int items_count, int height_in_items = -1) in favor of specifying size. Kept inline redirection function (will obsolete).
|
||||
@ -935,27 +937,33 @@ static void UpdateViewportPlatformMonitor(ImGuiViewportP* viewport);
|
||||
// [SECTION] CONTEXT AND MEMORY ALLOCATORS
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// 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.
|
||||
// - Same apply for hot-reloading mechanisms that are reliant on reloading DLL (note that many hot-reloading mechanism works without DLL).
|
||||
// - 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.
|
||||
// - Confused? In a debugger: add GImGui to your watch window and notice how its value changes depending on your current location (which DLL boundary you are in).
|
||||
|
||||
// Current context pointer. Implicitly used by all Dear ImGui functions. Always assumed to be != NULL.
|
||||
// ImGui::CreateContext() will automatically set this pointer if it is NULL. Change to a different context by calling ImGui::SetCurrentContext().
|
||||
// 1) Important: globals are not shared across DLL boundaries! If you use DLLs or any form of hot-reloading: you will need to call
|
||||
// SetCurrentContext() (with the pointer you got from CreateContext) from each unique static/DLL boundary, and after each hot-reloading.
|
||||
// In your debugger, add GImGui to your watch window and notice how its value changes depending on which location you are currently stepping into.
|
||||
// 2) Important: Dear ImGui functions are not thread-safe because of this pointer.
|
||||
// If you want thread-safety to allow N threads to access N different contexts, you can:
|
||||
// - Change this variable to use thread local storage so each thread can refer to a different context, in imconfig.h:
|
||||
// struct ImGuiContext;
|
||||
// extern thread_local ImGuiContext* MyImGuiTLS;
|
||||
// #define GImGui MyImGuiTLS
|
||||
// And then define MyImGuiTLS in one of your cpp file. Note that thread_local is a C++11 keyword, earlier C++ uses compiler-specific keyword.
|
||||
// - Future development aim to make this context pointer explicit to all calls. Also read https://github.com/ocornut/imgui/issues/586
|
||||
// - If you need a finite number of contexts, you may compile and use multiple instances of the ImGui code from different namespace.
|
||||
// - ImGui::CreateContext() will automatically set this pointer if it is NULL.
|
||||
// Change to a different context by calling ImGui::SetCurrentContext().
|
||||
// - Important: Dear ImGui functions are not thread-safe because of this pointer.
|
||||
// If you want thread-safety to allow N threads to access N different contexts:
|
||||
// - Change this variable to use thread local storage so each thread can refer to a different context, in your imconfig.h:
|
||||
// struct ImGuiContext;
|
||||
// extern thread_local ImGuiContext* MyImGuiTLS;
|
||||
// #define GImGui MyImGuiTLS
|
||||
// And then define MyImGuiTLS in one of your cpp file. Note that thread_local is a C++11 keyword, earlier C++ uses compiler-specific keyword.
|
||||
// - Future development aim to make this context pointer explicit to all calls. Also read https://github.com/ocornut/imgui/issues/586
|
||||
// - If you need a finite number of contexts, you may compile and use multiple instances of the ImGui code from different namespace.
|
||||
// - DLL users: read comments above.
|
||||
#ifndef GImGui
|
||||
ImGuiContext* GImGui = NULL;
|
||||
#endif
|
||||
|
||||
// Memory Allocator functions. Use SetAllocatorFunctions() to change them.
|
||||
// If you use DLL hotreloading you might need to call SetAllocatorFunctions() after reloading code from this file.
|
||||
// Otherwise, you probably don't want to modify them mid-program, and if you use global/static e.g. ImVector<> instances you may need to keep them accessible during program destruction.
|
||||
// - You probably don't want to modify those mid-program, and if you use global/static e.g. ImVector<> instances you may need to keep them accessible during program destruction.
|
||||
// - DLL users: read comments above.
|
||||
#ifndef IMGUI_DISABLE_DEFAULT_ALLOCATORS
|
||||
static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); return malloc(size); }
|
||||
static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); free(ptr); }
|
||||
@ -963,10 +971,9 @@ static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_d
|
||||
static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(size); IM_ASSERT(0); return NULL; }
|
||||
static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(ptr); IM_ASSERT(0); }
|
||||
#endif
|
||||
|
||||
static void* (*GImAllocatorAllocFunc)(size_t size, void* user_data) = MallocWrapper;
|
||||
static void (*GImAllocatorFreeFunc)(void* ptr, void* user_data) = FreeWrapper;
|
||||
static void* GImAllocatorUserData = NULL;
|
||||
static ImGuiMemAllocFunc* GImAllocatorAllocFunc = MallocWrapper;
|
||||
static ImGuiMemFreeFunc* GImAllocatorFreeFunc = FreeWrapper;
|
||||
static void* GImAllocatorUserData = NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] USER FACING STRUCTURES (ImGuiStyle, ImGuiIO)
|
||||
@ -3381,13 +3388,21 @@ void ImGui::SetCurrentContext(ImGuiContext* ctx)
|
||||
#endif
|
||||
}
|
||||
|
||||
void ImGui::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data)
|
||||
void ImGui::SetAllocatorFunctions(ImGuiMemAllocFunc* alloc_func, ImGuiMemFreeFunc* free_func, void* user_data)
|
||||
{
|
||||
GImAllocatorAllocFunc = alloc_func;
|
||||
GImAllocatorFreeFunc = free_func;
|
||||
GImAllocatorUserData = user_data;
|
||||
}
|
||||
|
||||
// This is provided to facilitate copying allocators from one static/DLL boundary to another (e.g. retrieve default allocator of your executable address space)
|
||||
void ImGui::GetAllocatorFunctions(ImGuiMemAllocFunc** p_alloc_func, ImGuiMemFreeFunc** p_free_func, void** p_user_data)
|
||||
{
|
||||
*p_alloc_func = GImAllocatorAllocFunc;
|
||||
*p_free_func = GImAllocatorFreeFunc;
|
||||
*p_user_data = GImAllocatorUserData;
|
||||
}
|
||||
|
||||
ImGuiContext* ImGui::CreateContext(ImFontAtlas* shared_font_atlas)
|
||||
{
|
||||
ImGuiContext* ctx = IM_NEW(ImGuiContext)(shared_font_atlas);
|
||||
@ -6940,11 +6955,12 @@ void ImGui::FocusWindow(ImGuiWindow* window)
|
||||
g.NavWindow = window;
|
||||
if (window && g.NavDisableMouseHover)
|
||||
g.NavMousePosDirty = true;
|
||||
g.NavInitRequest = false;
|
||||
g.NavId = window ? window->NavLastIds[0] : 0; // Restore NavId
|
||||
g.NavFocusScopeId = 0;
|
||||
g.NavIdIsAlive = false;
|
||||
g.NavLayer = ImGuiNavLayer_Main;
|
||||
g.NavInitRequest = g.NavMoveRequest = false;
|
||||
NavUpdateAnyRequestFlag();
|
||||
//IMGUI_DEBUG_LOG("FocusWindow(\"%s\")\n", window ? window->Name : NULL);
|
||||
}
|
||||
|
||||
@ -10618,14 +10634,8 @@ void ImGui::EndDragDropTarget()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Pass text data straight to log (without being displayed)
|
||||
void ImGui::LogText(const char* fmt, ...)
|
||||
static inline void LogTextV(ImGuiContext& g, const char* fmt, va_list args)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (!g.LogEnabled)
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
if (g.LogFile)
|
||||
{
|
||||
g.LogBuffer.Buf.resize(0);
|
||||
@ -10636,9 +10646,29 @@ void ImGui::LogText(const char* fmt, ...)
|
||||
{
|
||||
g.LogBuffer.appendfv(fmt, args);
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui::LogText(const char* fmt, ...)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (!g.LogEnabled)
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
LogTextV(g, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void ImGui::LogTextV(const char* fmt, va_list args)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (!g.LogEnabled)
|
||||
return;
|
||||
|
||||
LogTextV(g, fmt, args);
|
||||
}
|
||||
|
||||
// Internal version that takes a position to decide on newline placement and pad items according to their depth.
|
||||
// We split text into individual lines to add current tree level padding
|
||||
// FIXME: This code is a little complicated perhaps, considering simplifying the whole system.
|
||||
|
Reference in New Issue
Block a user