Context: Renamed SetMemoryAllocators() to SetAllocatorFunctions(). Tweaked comments. (#1565, #586, #992, #1007, #1558)
This commit is contained in:
parent
e45d7a7060
commit
7e4d28a49d
20
imgui.cpp
20
imgui.cpp
@ -213,7 +213,7 @@
|
||||
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
|
||||
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2018/01/20 (1.XX) - removed allocator parameters from CreateContext(), they are now setup with SetMemoryAllocators() and shared by all contexts.
|
||||
- 2018/01/20 (1.XX) - removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions() and shared by all contexts.
|
||||
- 2018/01/11 (1.54) - obsoleted IsAnyWindowHovered() in favor of IsWindowHovered(ImGuiHoveredFlags_AnyWindow). Kept redirection function (will obsolete).
|
||||
- 2018/01/11 (1.54) - obsoleted IsAnyWindowFocused() in favor of IsWindowFocused(ImGuiFocusedFlags_AnyWindow). Kept redirection function (will obsolete).
|
||||
- 2018/01/03 (1.54) - renamed ImGuiSizeConstraintCallback to ImGuiSizeCallback, ImGuiSizeConstraintCallbackData to ImGuiSizeCallbackData.
|
||||
@ -710,8 +710,8 @@ static ImGuiContext GImDefaultContext;
|
||||
ImGuiContext* GImGui = &GImDefaultContext;
|
||||
#endif
|
||||
|
||||
// Memory Allocator Functions. Use SetMemoryAllocators() to change them.
|
||||
// If you use DLL hotreloading you might need to call SetMemoryAllocators() after reloading code from this file.
|
||||
// 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.
|
||||
#ifndef IMGUI_DISABLE_DEFAULT_ALLOCATORS
|
||||
static void* MallocWrapper(size_t size, void* user_data) { (void)user_data; return malloc(size); }
|
||||
@ -724,7 +724,7 @@ static void FreeWrapper(void* ptr, void* user_data) { (void)user_data;
|
||||
static void* (*GImAllocatorAllocFunc)(size_t size, void* user_data) = MallocWrapper;
|
||||
static void (*GImAllocatorFreeFunc)(void* ptr, void* user_data) = FreeWrapper;
|
||||
static void* GImAllocatorUserData = NULL;
|
||||
static size_t GImAllocatorActiveCount = 0;
|
||||
static size_t GImAllocatorActiveAllocationsCount = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// User facing structures
|
||||
@ -2188,13 +2188,13 @@ float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
|
||||
|
||||
void* ImGui::MemAlloc(size_t sz)
|
||||
{
|
||||
GImAllocatorActiveCount++;
|
||||
GImAllocatorActiveAllocationsCount++;
|
||||
return GImAllocatorAllocFunc(sz, GImAllocatorUserData);
|
||||
}
|
||||
|
||||
void ImGui::MemFree(void* ptr)
|
||||
{
|
||||
if (ptr) GImAllocatorActiveCount--;
|
||||
if (ptr) GImAllocatorActiveAllocationsCount--;
|
||||
return GImAllocatorFreeFunc(ptr, GImAllocatorUserData);
|
||||
}
|
||||
|
||||
@ -2230,10 +2230,10 @@ void ImGui::SetCurrentContext(ImGuiContext* ctx)
|
||||
#endif
|
||||
}
|
||||
|
||||
void ImGui::SetMemoryAllocators(void* (*alloc_fn)(size_t sz, void* user_data), void(*free_fn)(void* ptr, void* user_data), void* user_data)
|
||||
void ImGui::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void(*free_func)(void* ptr, void* user_data), void* user_data)
|
||||
{
|
||||
GImAllocatorAllocFunc = alloc_fn;
|
||||
GImAllocatorFreeFunc = free_fn;
|
||||
GImAllocatorAllocFunc = alloc_func;
|
||||
GImAllocatorFreeFunc = free_func;
|
||||
GImAllocatorUserData = user_data;
|
||||
}
|
||||
|
||||
@ -11684,7 +11684,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
ImGui::Text("Dear ImGui %s", ImGui::GetVersion());
|
||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||
ImGui::Text("%d vertices, %d indices (%d triangles)", ImGui::GetIO().MetricsRenderVertices, ImGui::GetIO().MetricsRenderIndices, ImGui::GetIO().MetricsRenderIndices / 3);
|
||||
ImGui::Text("%d allocations", GImAllocatorActiveCount);
|
||||
ImGui::Text("%d allocations", GImAllocatorActiveAllocationsCount);
|
||||
static bool show_clip_rects = true;
|
||||
ImGui::Checkbox("Show clipping rectangles when hovering an ImDrawCmd", &show_clip_rects);
|
||||
ImGui::Separator();
|
||||
|
6
imgui.h
6
imgui.h
@ -503,8 +503,9 @@ namespace ImGui
|
||||
IMGUI_API void CaptureKeyboardFromApp(bool capture = true); // manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application handle). e.g. force capture keyboard when your widget is being hovered.
|
||||
IMGUI_API void CaptureMouseFromApp(bool capture = true); // manually override io.WantCaptureMouse flag next frame (said flag is entirely left for your application handle).
|
||||
|
||||
// Helpers functions to access functions pointers in ImGui::GetIO()
|
||||
IMGUI_API void* MemAlloc(size_t sz);
|
||||
// Helpers functions to access memory allocators and clipboard functions.
|
||||
IMGUI_API void SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void(*free_func)(void* ptr, void* user_data), void* user_data = NULL);
|
||||
IMGUI_API void* MemAlloc(size_t size);
|
||||
IMGUI_API void MemFree(void* ptr);
|
||||
IMGUI_API const char* GetClipboardText();
|
||||
IMGUI_API void SetClipboardText(const char* text);
|
||||
@ -513,7 +514,6 @@ namespace ImGui
|
||||
// All contexts share a same ImFontAtlas by default. If you want different font atlas, you can new() them and overwrite the GetIO().Fonts variable of an ImGui context.
|
||||
// All those functions are not reliant on the current context.
|
||||
IMGUI_API const char* GetVersion();
|
||||
IMGUI_API void SetMemoryAllocators(void* (*alloc_fn)(size_t sz, void* user_data), void(*free_fn)(void* ptr, void* user_data), void* user_data = NULL);
|
||||
IMGUI_API ImGuiContext* CreateContext();
|
||||
IMGUI_API void DestroyContext(ImGuiContext* ctx);
|
||||
IMGUI_API ImGuiContext* GetCurrentContext();
|
||||
|
Loading…
Reference in New Issue
Block a user