mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-29 23:06:35 +00:00
Cleanup of previous merge. Moved rarely used Get/Set InternalState functions to the bottom of the list to avoid being misleadnig.
This commit is contained in:
parent
bab66cc490
commit
209ab823d6
41
imgui.cpp
41
imgui.cpp
@ -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
|
||||||
|
8
imgui.h
8
imgui.h
@ -146,9 +146,6 @@ public:
|
|||||||
namespace ImGui
|
namespace ImGui
|
||||||
{
|
{
|
||||||
// Main
|
// Main
|
||||||
IMGUI_API void* GetInternalState();
|
|
||||||
IMGUI_API unsigned GetInternalStateSize();
|
|
||||||
IMGUI_API void SetInternalState(void* state, bool construct = false);
|
|
||||||
IMGUI_API ImGuiIO& GetIO();
|
IMGUI_API ImGuiIO& GetIO();
|
||||||
IMGUI_API ImGuiStyle& GetStyle();
|
IMGUI_API ImGuiStyle& GetStyle();
|
||||||
IMGUI_API void NewFrame();
|
IMGUI_API void NewFrame();
|
||||||
@ -337,6 +334,11 @@ namespace ImGui
|
|||||||
IMGUI_API void ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v);
|
IMGUI_API void ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v);
|
||||||
IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
|
IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
|
||||||
|
|
||||||
|
// Internal state access - if you want to share ImGui state between modules (e.g. DLL) or allocate it yourself
|
||||||
|
IMGUI_API void* GetInternalState();
|
||||||
|
IMGUI_API size_t GetInternalStateSize();
|
||||||
|
IMGUI_API void SetInternalState(void* state, bool construct = false);
|
||||||
|
|
||||||
// Obsolete (will be removed)
|
// Obsolete (will be removed)
|
||||||
IMGUI_API void GetDefaultFontData(const void** fnt_data, unsigned int* fnt_size, const void** png_data, unsigned int* png_size);
|
IMGUI_API void GetDefaultFontData(const void** fnt_data, unsigned int* fnt_size, const void** png_data, unsigned int* png_size);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user