// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag.
// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag.
// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag.
// New contexts always point by default to this font atlas. It can be changed by reassigning the GetIO().Fonts variable.
staticImFontAtlasGImDefaultFontAtlas;
// Default context storage + current context pointer.
// Implicitely used by all ImGui functions. Always assumed to be != NULL. Change to a different context by calling ImGui::SetCurrentContext()
// If you are hot-reloading this code in a DLL you will lose the static/global variables. Create your own context+font atlas instead of relying on those default (see FAQ entry "How can I preserve my ImGui context across reloading a DLL?").
// ImGui is currently not thread-safe because of this variable. If you want thread-safety to allow N threads to access N different contexts, you might work around it by:
// Current context pointer. Implicitely used by all ImGui functions. Always assumed to be != NULL.
// CreateContext() will automatically set this pointer if it is NULL. Change to a different context by calling ImGui::SetCurrentContext().
// If you use DLL hotreloading you might need to call SetCurrentContext() after reloading code from this file.
// 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. You may #define GImGui in imconfig.h for that purpose. Future development aim to make this context pointer explicit to all calls. Also read https://github.com/ocornut/imgui/issues/586
// - Having multiple instances of the ImGui code compiled inside different namespace (easiest/safest, if you have a finite number of contexts)
// - or: Changing this variable to be TLS. You may #define GImGui in imconfig.h for further custom hackery. Future development aim to make this context pointer explicit to all calls. Also read https://github.com/ocornut/imgui/issues/586
#ifndef GImGui
staticImGuiContextGImDefaultContext;
ImGuiContext*GImGui=&GImDefaultContext;
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.
// This function is merely here to free heap allocations.
voidImGui::Shutdown()
voidImGui::Shutdown(ImGuiContext*context)
{
ImGuiContext&g=*GImGui;
ImGuiContext&g=*context;
// The fonts atlas can be used prior to calling NewFrame(), so we clear it even if g.Initialized is FALSE (which would happen if we never called NewFrame)
if(g.IO.Fonts)// Testing for NULL to allow user to NULLify in case of running Shutdown() on multiple contexts. Bit hacky.
g.IO.Fonts->Clear();
if(g.IO.Fonts&&g.FontAtlasOwnedByContext)
IM_DELETE(g.IO.Fonts);
// Cleanup of other data are conditional on actually having initialize ImGui.
// In a namespace so that user can add extra functions in a separate file (e.g. Value() helpers for your vector or common types)
namespaceImGui
{
// Context creation and access, if you want to use multiple context, share context between modules (e.g. DLL).
// 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_APIvoidDestroyContext(ImGuiContext*ctx=NULL);// NULL = Destroy current context
IMGUI_APIImGuiContext*GetCurrentContext();
IMGUI_APIvoidSetCurrentContext(ImGuiContext*ctx);
// Main
IMGUI_APIImGuiIO&GetIO();
IMGUI_APIImGuiStyle&GetStyle();
@ -143,7 +151,6 @@ namespace ImGui
IMGUI_APIvoidNewFrame();// start a new ImGui frame, you can submit any command from this point until Render()/EndFrame().
IMGUI_APIvoidRender();// ends the ImGui frame, finalize the draw data, then call your io.RenderDrawListsFn() function if set.
IMGUI_APIvoidEndFrame();// ends the ImGui frame. automatically called by Render(), so most likely don't need to ever call that yourself directly. If you don't need to render you may call EndFrame() but you'll have wasted CPU already. If you don't need to render, better to not create any imgui windows instead!
IMGUI_APIvoidShutdown();
// Demo, Debug, Informations
IMGUI_APIvoidShowDemoWindow(bool*p_open=NULL);// create demo/test window (previously called ShowTestWindow). demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application!
@ -152,6 +159,7 @@ namespace ImGui
IMGUI_APIboolShowStyleSelector(constchar*label);
IMGUI_APIvoidShowFontSelector(constchar*label);
IMGUI_APIvoidShowUserGuide();// add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls).
IMGUI_APIconstchar*GetVersion();
// Window
IMGUI_APIboolBegin(constchar*name,bool*p_open=NULL,ImGuiWindowFlagsflags=0);// push window to the stack and start appending to it. see .cpp for details. return false when window is collapsed (so you can early out in your code) but you always need to call End() regardless. 'bool* p_open' creates a widget on the upper-right to close the window (which sets your bool to false).
@ -515,20 +523,13 @@ namespace ImGui
IMGUI_APIvoidCaptureKeyboardFromApp(boolcapture=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_APIvoidCaptureMouseFromApp(boolcapture=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_APIvoid*MemAlloc(size_tsz);
// Helpers functions to access memory allocators and clipboard functions.
// Internal context access - if you want to use multiple context, share context between modules (e.g. DLL). There is a default context created and active by default.
// 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.
// Optional: override memory allocations. MemFreeFn() may be called with a NULL pointer.
// (default to posix malloc/free)
void*(*MemAllocFn)(size_tsz);
void(*MemFreeFn)(void*ptr);
// Optional: notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME in Windows)
// (default to use native imm32 api on Windows)
void(*ImeSetInputScreenPosFn)(intx,inty);
@ -1029,7 +1025,6 @@ struct ImGuiIO
boolNavActive;// Directional navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
boolNavVisible;// Directional navigation is visible and allowed (will handle ImGuiKey_NavXXX events).
floatFramerate;// Application framerate estimation, in frame per second. Solely for convenience. Rolling average estimation based on IO.DeltaTime over 120 frames
intMetricsAllocs;// Number of active memory allocations
intMetricsRenderVertices;// Vertices output during last call to Render()
intMetricsRenderIndices;// Indices output during last call to Render() = number of triangles * 3
intMetricsActiveWindows;// Number of visible root windows (exclude child windows)
IMGUI_APIvoidShutdown(ImGuiContext*context);// Since 1.54 this is a _private_ function. You can call DestroyContext() to destroy the context created by CreateContext().