@ -1036,8 +1036,8 @@ struct ImGuiState
}
}
} ;
} ;
static ImGuiState GImDefaultState ;
static ImGuiState GImDefaultState ; // Internal state storage
static ImGuiState * GImGui = & GImDefaultState ;
static ImGuiState * GImGui = & GImDefaultState ; // We access everything through this pointer. NB: this pointer is always assumed to be != NULL
struct ImGuiWindow
struct ImGuiWindow
{
{
@ -1104,20 +1104,23 @@ public:
static ImGuiWindow * GetCurrentWindow ( )
static ImGuiWindow * GetCurrentWindow ( )
{
{
IM_ASSERT ( GImGui - > CurrentWindow ! = NULL ) ; // ImGui::NewFrame() hasn't been called yet?
ImGuiState & g = * GImGui ;
GImGui - > CurrentWindow - > Accessed = true ;
IM_ASSERT ( g . CurrentWindow ! = NULL ) ; // ImGui::NewFrame() hasn't been called yet?
return GImGui - > CurrentWindow ;
g . CurrentWindow - > Accessed = true ;
return g . CurrentWindow ;
}
}
static void SetActiveId ( ImGuiID id )
static void SetActiveId ( ImGuiID id )
{
{
GImGui - > ActiveId = id ;
ImGuiState & g = * GImGui ;
g . ActiveId = id ;
}
}
static void RegisterAliveId ( const ImGuiID & id )
static void RegisterAliveId ( const ImGuiID & id )
{
{
if ( GImGui - > ActiveId = = id )
ImGuiState & g = * GImGui ;
GImGui - > ActiveIdIsAlive = true ;
if ( g . ActiveId = = id )
g . ActiveIdIsAlive = true ;
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
@ -1611,25 +1614,26 @@ static void MarkSettingsDirty()
g . SettingsDirtyTimer = g . IO . IniSavingRate ;
g . SettingsDirtyTimer = g . IO . IniSavingRate ;
}
}
// Internal state access - if you want to share ImGui state between modules (e.g. DLL) or allocate it yourself
// Note that we still point to some static data and members (such as GFontAtlas), so the state instance you end up using will point to the static data within its module
void * ImGui : : GetInternalState ( )
void * ImGui : : GetInternalState ( )
{
{
return GImGui ;
return GImGui ;
}
}
unsigned ImGui : : GetInternalStateSize ( )
size_t ImGui : : GetInternalStateSize ( )
{
{
return sizeof ( ImGuiState ) ;
return sizeof ( ImGuiState ) ;
}
}
void ImGui : : SetInternalState ( void * state , bool construct )
void ImGui : : SetInternalState ( void * state , bool construct )
{
{
if ( construct )
if ( construct )
new ( state ) ImGuiState ;
new ( state ) ImGuiState ( ) ;
GImGui = ( ImGuiState * ) state ;
GImGui = ( ImGuiState * ) state ;
}
}
ImGuiIO & ImGui : : GetIO ( )
ImGuiIO & ImGui : : GetIO ( )
{
{
return GImGui - > IO ;
return GImGui - > IO ;
@ -7579,15 +7583,16 @@ static const char* GetClipboardTextFn_DefaultImpl()
// Local ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers
// Local ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers
static void SetClipboardTextFn_DefaultImpl ( const char * text )
static void SetClipboardTextFn_DefaultImpl ( const char * text )
{
{
if ( GImGui - > PrivateClipboard )
ImGuiState & g = * GImGui ;
if ( g . PrivateClipboard )
{
{
ImGui : : MemFree ( GImGui - > PrivateClipboard ) ;
ImGui : : MemFree ( g . PrivateClipboard ) ;
GImGui - > PrivateClipboard = NULL ;
g . PrivateClipboard = NULL ;
}
}
const char * text_end = text + strlen ( text ) ;
const char * text_end = text + strlen ( text ) ;
GImGui - > PrivateClipboard = ( char * ) ImGui : : MemAlloc ( ( size_t ) ( text_end - text ) + 1 ) ;
g . PrivateClipboard = ( char * ) ImGui : : MemAlloc ( ( size_t ) ( text_end - text ) + 1 ) ;
memcpy ( GImGui - > PrivateClipboard , text , ( size_t ) ( text_end - text ) ) ;
memcpy ( g . PrivateClipboard , text , ( size_t ) ( text_end - text ) ) ;
GImGui - > PrivateClipboard [ ( size_t ) ( text_end - text ) ] = 0 ;
g . PrivateClipboard [ ( size_t ) ( text_end - text ) ] = 0 ;
}
}
# endif
# endif