Updated ImGui.

This commit is contained in:
Branimir Karadžić 2016-11-12 17:14:45 -08:00
parent ab06553742
commit b0f9dcbed8
3 changed files with 24 additions and 8 deletions

View File

@ -725,14 +725,19 @@ static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y);
// Context // Context
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Default context, default font atlas. // Default font atlas storage .
// New contexts always point by default to this font atlas. It can be changed by reassigning the GetIO().Fonts variable. // New contexts always point by default to this font atlas. It can be changed by reassigning the GetIO().Fonts variable.
static ImGuiContext GImDefaultContext;
static ImFontAtlas GImDefaultFontAtlas; static ImFontAtlas GImDefaultFontAtlas;
// Current context pointer. Implicitely used by all ImGui functions. Always assumed to be != NULL. Change to a different context by calling ImGui::SetCurrentContext() // Default context storage + current context pointer.
// 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 (A) having two instances of the ImGui code under different namespaces or (B) change this variable to be TLS. Further development aim to make this context pointer explicit to all calls. Also read https://github.com/ocornut/imgui/issues/586 // Implicitely used by all ImGui functions. Always assumed to be != NULL. Change to a different context by calling ImGui::SetCurrentContext()
// 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:
// - 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
static ImGuiContext GImDefaultContext;
ImGuiContext* GImGui = &GImDefaultContext; ImGuiContext* GImGui = &GImDefaultContext;
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// User facing structures // User facing structures
@ -2049,7 +2054,11 @@ ImGuiContext* ImGui::GetCurrentContext()
void ImGui::SetCurrentContext(ImGuiContext* ctx) void ImGui::SetCurrentContext(ImGuiContext* ctx)
{ {
#ifdef IMGUI_SET_CURRENT_CONTEXT_FUNC
IMGUI_SET_CURRENT_CONTEXT_FUNC(ctx); // For custom thread-based hackery you may want to have control over this.
#else
GImGui = ctx; GImGui = ctx;
#endif
} }
ImGuiContext* ImGui::CreateContext(void* (*malloc_fn)(size_t), void (*free_fn)(void*)) ImGuiContext* ImGui::CreateContext(void* (*malloc_fn)(size_t), void (*free_fn)(void*))
@ -2068,7 +2077,7 @@ void ImGui::DestroyContext(ImGuiContext* ctx)
ctx->~ImGuiContext(); ctx->~ImGuiContext();
free_fn(ctx); free_fn(ctx);
if (GImGui == ctx) if (GImGui == ctx)
GImGui = NULL; SetCurrentContext(NULL);
} }
ImGuiIO& ImGui::GetIO() ImGuiIO& ImGui::GetIO()

View File

@ -38,7 +38,9 @@
#pragma GCC diagnostic ignored "-Wformat-security" // warning : format string is not a string literal (potentially insecure) #pragma GCC diagnostic ignored "-Wformat-security" // warning : format string is not a string literal (potentially insecure)
#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function #pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value #pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value
//#pragma GCC diagnostic ignored "-Wmisleading-indentation" // warning: this 'if' clause does not guard this statement #if (__GNUC__ >= 6)
#pragma GCC diagnostic ignored "-Wmisleading-indentation" // warning: this 'if' clause does not guard this statement // GCC 6.0+ only. See #883 on github.
#endif
#endif #endif
// Play it nice with Windows users. Notepad in 2015 still doesn't display text data with Unix-style \n. // Play it nice with Windows users. Notepad in 2015 still doesn't display text data with Unix-style \n.

View File

@ -67,7 +67,9 @@ namespace ImGuiStb
// Context // Context
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern IMGUI_API ImGuiContext* GImGui; // current implicit ImGui context pointer #ifndef GImGui
extern IMGUI_API ImGuiContext* GImGui; // Current implicit ImGui context pointer
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Helpers // Helpers
@ -488,9 +490,11 @@ struct ImGuiContext
SetNextWindowSizeCond = 0; SetNextWindowSizeCond = 0;
SetNextWindowContentSizeCond = 0; SetNextWindowContentSizeCond = 0;
SetNextWindowCollapsedCond = 0; SetNextWindowCollapsedCond = 0;
SetNextWindowFocus = false; SetNextWindowSizeConstraintRect = ImRect();
SetNextWindowSizeConstraintCallback = NULL; SetNextWindowSizeConstraintCallback = NULL;
SetNextWindowSizeConstraintCallbackUserData = NULL; SetNextWindowSizeConstraintCallbackUserData = NULL;
SetNextWindowSizeConstraint = false;
SetNextWindowFocus = false;
SetNextTreeNodeOpenVal = false; SetNextTreeNodeOpenVal = false;
SetNextTreeNodeOpenCond = 0; SetNextTreeNodeOpenCond = 0;
@ -597,6 +601,7 @@ struct IMGUI_API ImGuiDrawContext
memset(StackSizesBackup, 0, sizeof(StackSizesBackup)); memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
IndentX = 0.0f; IndentX = 0.0f;
GroupOffsetX = 0.0f;
ColumnsOffsetX = 0.0f; ColumnsOffsetX = 0.0f;
ColumnsCurrent = 0; ColumnsCurrent = 0;
ColumnsCount = 1; ColumnsCount = 1;