Backends: amends to 1db1066 + merge minor bits from docking incl SetActiveIdUsingNavAndKeys().
No need to clear fields before deletion. DX12: renamed to match docking branch.
diff --git a/backends/imgui_impl_dx12.cpp b/backends/imgui_impl_dx12.cpp
index 76b4a98..c7dcca1 100644
--- a/backends/imgui_impl_dx12.cpp
+++ b/backends/imgui_impl_dx12.cpp
@@ -49,7 +49,7 @@
#endif
// DirectX data
-struct FrameResources
+struct ImGui_ImplDX12_RenderBuffers
{
ID3D12Resource* IndexBuffer;
ID3D12Resource* VertexBuffer;
@@ -59,19 +59,19 @@
struct ImGui_ImplDX12_Data
{
- ID3D12Device* pd3dDevice;
- ID3D12RootSignature* pRootSignature;
- ID3D12PipelineState* pPipelineState;
- DXGI_FORMAT RTVFormat;
- ID3D12Resource* pFontTextureResource;
- D3D12_CPU_DESCRIPTOR_HANDLE hFontSrvCpuDescHandle;
- D3D12_GPU_DESCRIPTOR_HANDLE hFontSrvGpuDescHandle;
+ ID3D12Device* pd3dDevice;
+ ID3D12RootSignature* pRootSignature;
+ ID3D12PipelineState* pPipelineState;
+ DXGI_FORMAT RTVFormat;
+ ID3D12Resource* pFontTextureResource;
+ D3D12_CPU_DESCRIPTOR_HANDLE hFontSrvCpuDescHandle;
+ D3D12_GPU_DESCRIPTOR_HANDLE hFontSrvGpuDescHandle;
- FrameResources* pFrameResources;
- UINT numFramesInFlight;
- UINT frameIndex;
+ ImGui_ImplDX12_RenderBuffers* pFrameResources;
+ UINT numFramesInFlight;
+ UINT frameIndex;
- ImGui_ImplDX12_Data() { memset(this, 0, sizeof(*this)); frameIndex = UINT_MAX; }
+ ImGui_ImplDX12_Data() { memset(this, 0, sizeof(*this)); frameIndex = UINT_MAX; }
};
// Wrapping access to backend data (to facilitate multiple-contexts stored in io.BackendPlatformUserData)
@@ -93,7 +93,7 @@
float mvp[4][4];
};
-static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12GraphicsCommandList* ctx, FrameResources* fr)
+static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12GraphicsCommandList* ctx, ImGui_ImplDX12_RenderBuffers* fr)
{
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
@@ -161,7 +161,7 @@
// If not, we can't just re-allocate the IB or VB, we'll have to do a proper allocator.
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
bd->frameIndex = bd->frameIndex + 1;
- FrameResources* fr = &bd->pFrameResources[bd->frameIndex % bd->numFramesInFlight];
+ ImGui_ImplDX12_RenderBuffers* fr = &bd->pFrameResources[bd->frameIndex % bd->numFramesInFlight];
// Create and grow vertex/index buffers if needed
if (fr->VertexBuffer == NULL || fr->VertexBufferSize < draw_data->TotalVtxCount)
@@ -433,10 +433,8 @@
bool ImGui_ImplDX12_CreateDeviceObjects()
{
- if (ImGui::GetCurrentContext() == NULL)
- return false;
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
- if (!bd->pd3dDevice)
+ if (!bd || !bd->pd3dDevice)
return false;
if (bd->pPipelineState)
ImGui_ImplDX12_InvalidateDeviceObjects();
@@ -668,12 +666,10 @@
void ImGui_ImplDX12_InvalidateDeviceObjects()
{
- if (ImGui::GetCurrentContext() == NULL)
+ ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
+ if (!bd || !bd->pd3dDevice)
return;
ImGuiIO& io = ImGui::GetIO();
- ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
- if (!bd->pd3dDevice)
- return;
SafeRelease(bd->pRootSignature);
SafeRelease(bd->pPipelineState);
@@ -682,7 +678,7 @@
for (UINT i = 0; i < bd->numFramesInFlight; i++)
{
- FrameResources* fr = &bd->pFrameResources[i];
+ ImGui_ImplDX12_RenderBuffers* fr = &bd->pFrameResources[i];
SafeRelease(fr->IndexBuffer);
SafeRelease(fr->VertexBuffer);
}
@@ -704,7 +700,7 @@
bd->RTVFormat = rtv_format;
bd->hFontSrvCpuDescHandle = font_srv_cpu_desc_handle;
bd->hFontSrvGpuDescHandle = font_srv_gpu_desc_handle;
- bd->pFrameResources = new FrameResources[num_frames_in_flight];
+ bd->pFrameResources = new ImGui_ImplDX12_RenderBuffers[num_frames_in_flight];
bd->numFramesInFlight = num_frames_in_flight;
bd->frameIndex = UINT_MAX;
IM_UNUSED(cbv_srv_heap); // Unused in master branch (will be used by multi-viewports)
@@ -712,7 +708,7 @@
// Create buffers with a default size (they will later be grown as needed)
for (int i = 0; i < num_frames_in_flight; i++)
{
- FrameResources* fr = &bd->pFrameResources[i];
+ ImGui_ImplDX12_RenderBuffers* fr = &bd->pFrameResources[i];
fr->IndexBuffer = NULL;
fr->VertexBuffer = NULL;
fr->IndexBufferSize = 10000;
@@ -729,12 +725,6 @@
ImGui_ImplDX12_InvalidateDeviceObjects();
delete[] bd->pFrameResources;
- bd->pFrameResources = NULL;
- bd->pd3dDevice = NULL;
- bd->hFontSrvCpuDescHandle.ptr = 0;
- bd->hFontSrvGpuDescHandle.ptr = 0;
- bd->numFramesInFlight = 0;
- bd->frameIndex = UINT_MAX;
io.BackendRendererName = NULL;
io.BackendRendererUserData = NULL;
ImGui_ImplDX12_DestroyBackendData();
diff --git a/backends/imgui_impl_glfw.cpp b/backends/imgui_impl_glfw.cpp
index 8e87c62..07b61df 100644
--- a/backends/imgui_impl_glfw.cpp
+++ b/backends/imgui_impl_glfw.cpp
@@ -273,14 +273,10 @@
glfwSetScrollCallback(bd->Window, bd->PrevUserCallbackScroll);
glfwSetKeyCallback(bd->Window, bd->PrevUserCallbackKey);
glfwSetCharCallback(bd->Window, bd->PrevUserCallbackChar);
- bd->InstalledCallbacks = false;
}
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
- {
glfwDestroyCursor(bd->MouseCursors[cursor_n]);
- bd->MouseCursors[cursor_n] = NULL;
- }
io.BackendPlatformName = NULL;
io.BackendPlatformUserData = NULL;
diff --git a/backends/imgui_impl_opengl3.cpp b/backends/imgui_impl_opengl3.cpp
index 411a226..ee0fd6f 100644
--- a/backends/imgui_impl_opengl3.cpp
+++ b/backends/imgui_impl_opengl3.cpp
@@ -230,19 +230,18 @@
// Store GLSL version string so we can refer to it later in case we recreate shaders.
// Note: GLSL version is NOT the same as GL version. Leave this to NULL if unsure.
-#if defined(IMGUI_IMPL_OPENGL_ES2)
if (glsl_version == NULL)
+ {
+#if defined(IMGUI_IMPL_OPENGL_ES2)
glsl_version = "#version 100";
#elif defined(IMGUI_IMPL_OPENGL_ES3)
- if (glsl_version == NULL)
glsl_version = "#version 300 es";
#elif defined(__APPLE__)
- if (glsl_version == NULL)
glsl_version = "#version 150";
#else
- if (glsl_version == NULL)
glsl_version = "#version 130";
#endif
+ }
IM_ASSERT((int)strlen(glsl_version) + 2 < IM_ARRAYSIZE(bd->GlslVersionString));
strcpy(bd->GlslVersionString, glsl_version);
strcat(bd->GlslVersionString, "\n");
diff --git a/imgui.cpp b/imgui.cpp
index f7a72d4..44c1b19 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -3526,8 +3526,9 @@
FocusWindow(window);
SetActiveID(window->MoveId, window);
g.NavDisableHighlight = true;
+ g.ActiveIdClickOffset = g.IO.MouseClickedPos[0] - window->RootWindow->Pos;
g.ActiveIdNoClearOnFocusLoss = true;
- g.ActiveIdClickOffset = g.IO.MousePos - window->RootWindow->Pos;
+ SetActiveIdUsingNavAndKeys();
bool can_move_window = true;
if ((window->Flags & ImGuiWindowFlags_NoMove) || (window->RootWindow->Flags & ImGuiWindowFlags_NoMove))
@@ -3563,8 +3564,8 @@
}
else
{
- ClearActiveID();
g.MovingWindow = NULL;
+ ClearActiveID();
}
}
else
@@ -4155,7 +4156,7 @@
g.Viewports.push_back(viewport);
#ifdef IMGUI_HAS_DOCK
-#endif // #ifdef IMGUI_HAS_DOCK
+#endif
g.Initialized = true;
}
@@ -4951,6 +4952,16 @@
g.ActiveIdUsingMouseWheel = true;
}
+void ImGui::SetActiveIdUsingNavAndKeys()
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(g.ActiveId != 0);
+ g.ActiveIdUsingNavDirMask = ~(ImU32)0;
+ g.ActiveIdUsingNavInputMask = ~(ImU32)0;
+ g.ActiveIdUsingKeyInputMask = ~(ImU64)0;
+ NavMoveRequestCancel();
+}
+
ImVec2 ImGui::GetItemRectMin()
{
ImGuiWindow* window = GetCurrentWindowRead();
@@ -9608,7 +9619,7 @@
if (start_windowing_with_gamepad || start_windowing_with_keyboard)
if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1))
{
- g.NavWindowingTarget = g.NavWindowingTargetAnim = window->RootWindow; // FIXME-DOCK: Will need to use RootWindowDockStop
+ g.NavWindowingTarget = g.NavWindowingTargetAnim = window->RootWindow;
g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f;
g.NavWindowingToggleLayer = start_windowing_with_keyboard ? false : true;
g.NavInputSource = start_windowing_with_keyboard ? ImGuiInputSource_Keyboard : ImGuiInputSource_Gamepad;
@@ -9863,10 +9874,8 @@
source_parent_id = window->IDStack.back();
source_drag_active = IsMouseDragging(mouse_button);
- // Disable navigation and key inputs while dragging
- g.ActiveIdUsingNavDirMask = ~(ImU32)0;
- g.ActiveIdUsingNavInputMask = ~(ImU32)0;
- g.ActiveIdUsingKeyInputMask = ~(ImU64)0;
+ // Disable navigation and key inputs while dragging + cancel existing request if any
+ SetActiveIdUsingNavAndKeys();
}
else
{
@@ -10628,8 +10637,9 @@
window->SettingsOffset = g.SettingsWindows.offset_from_ptr(settings);
}
IM_ASSERT(settings->ID == window->ID);
- settings->Pos = ImVec2ih((short)window->Pos.x, (short)window->Pos.y);
- settings->Size = ImVec2ih((short)window->SizeFull.x, (short)window->SizeFull.y);
+ settings->Pos = ImVec2ih(window->Pos);
+ settings->Size = ImVec2ih(window->SizeFull);
+
settings->Collapsed = window->Collapsed;
}
@@ -11233,6 +11243,7 @@
Indent();
Text("ActiveId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d, Source: %s", g.ActiveId, g.ActiveIdPreviousFrame, g.ActiveIdTimer, g.ActiveIdAllowOverlap, input_source_names[g.ActiveIdSource]);
Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL");
+ Text("ActiveIdUsing: Wheel: %d, NavDirMask: %X, NavInputMask: %X, KeyInputMask: %llX", g.ActiveIdUsingMouseWheel, g.ActiveIdUsingNavDirMask, g.ActiveIdUsingNavInputMask, g.ActiveIdUsingKeyInputMask);
Text("HoveredId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredId, g.HoveredIdPreviousFrame, g.HoveredIdTimer, g.HoveredIdAllowOverlap); // Data is "in-flight" so depending on when the Metrics window is called we may see current frame information or not
Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize);
Unindent();
@@ -11585,7 +11596,14 @@
const char* buf_end = buf + IM_ARRAYSIZE(buf);
const bool is_active = (tab_bar->PrevFrameVisible >= GetFrameCount() - 2);
p += ImFormatString(p, buf_end - p, "%s 0x%08X (%d tabs)%s", label, tab_bar->ID, tab_bar->Tabs.Size, is_active ? "" : " *Inactive*");
- IM_UNUSED(p);
+ p += ImFormatString(p, buf_end - p, " { ");
+ for (int tab_n = 0; tab_n < ImMin(tab_bar->Tabs.Size, 3); tab_n++)
+ {
+ ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
+ p += ImFormatString(p, buf_end - p, "%s'%s'",
+ tab_n > 0 ? ", " : "", (tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "???");
+ }
+ p += ImFormatString(p, buf_end - p, (tab_bar->Tabs.Size > 3) ? " ... }" : " } ");
if (!is_active) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); }
bool open = TreeNode(label, "%s", buf);
if (!is_active) { PopStyleColor(); }
@@ -11605,7 +11623,7 @@
if (SmallButton("<")) { TabBarQueueReorder(tab_bar, tab, -1); } SameLine(0, 2);
if (SmallButton(">")) { TabBarQueueReorder(tab_bar, tab, +1); } SameLine();
Text("%02d%c Tab 0x%08X '%s' Offset: %.1f, Width: %.1f/%.1f",
- tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID, (tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "", tab->Offset, tab->Width, tab->ContentWidth);
+ tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID, (tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "???", tab->Offset, tab->Width, tab->ContentWidth);
PopID();
}
TreePop();
diff --git a/imgui.h b/imgui.h
index 925a793..35cd4c9 100644
--- a/imgui.h
+++ b/imgui.h
@@ -2760,7 +2760,7 @@
// [SECTION] Viewports
//-----------------------------------------------------------------------------
-// Flags stored in ImGuiViewport::Flags
+// Flags stored in ImGuiViewport::Flags, giving indications to the platform backends.
enum ImGuiViewportFlags_
{
ImGuiViewportFlags_None = 0,
diff --git a/imgui_demo.cpp b/imgui_demo.cpp
index fe257c7..7718100 100644
--- a/imgui_demo.cpp
+++ b/imgui_demo.cpp
@@ -6974,12 +6974,12 @@
// + a context-menu to choose which corner of the screen to use.
static void ShowExampleAppSimpleOverlay(bool* p_open)
{
- const float PAD = 10.0f;
static int corner = 0;
ImGuiIO& io = ImGui::GetIO();
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;
if (corner != -1)
{
+ const float PAD = 10.0f;
const ImGuiViewport* viewport = ImGui::GetMainViewport();
ImVec2 work_pos = viewport->WorkPos; // Use work area to avoid menu-bar/task-bar, if any!
ImVec2 work_size = viewport->WorkSize;
diff --git a/imgui_draw.cpp b/imgui_draw.cpp
index 6bc0357..bd99ead 100644
--- a/imgui_draw.cpp
+++ b/imgui_draw.cpp
@@ -3730,6 +3730,7 @@
// - RenderMouseCursor()
// - RenderArrowPointingAt()
// - RenderRectFilledRangeH()
+// - RenderRectFilledWithHole()
//-----------------------------------------------------------------------------
// Function in need of a redesign (legacy mess)
// - RenderColorRectWithAlphaCheckerboard()
diff --git a/imgui_internal.h b/imgui_internal.h
index dc480eb..8f10b65 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -1142,7 +1142,7 @@
ImGuiSizeCallback SizeCallback;
void* SizeCallbackUserData;
float BgAlphaVal; // Override background alpha
- ImVec2 MenuBarOffsetMinVal; // *Always on* This is not exposed publicly, so we don't clear it.
+ ImVec2 MenuBarOffsetMinVal; // (Always on) This is not exposed publicly, so we don't clear it and it doesn't have a corresponding flag (could we? for consistency?)
ImGuiNextWindowData() { memset(this, 0, sizeof(*this)); }
inline void ClearFlags() { Flags = ImGuiNextWindowDataFlags_None; }
@@ -2465,6 +2465,7 @@
// Inputs
// FIXME: Eventually we should aim to move e.g. IsActiveIdUsingKey() into IsKeyXXX functions.
IMGUI_API void SetItemUsingMouseWheel();
+ IMGUI_API void SetActiveIdUsingNavAndKeys();
inline bool IsActiveIdUsingNavDir(ImGuiDir dir) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavDirMask & (1 << dir)) != 0; }
inline bool IsActiveIdUsingNavInput(ImGuiNavInput input) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavInputMask & (1 << input)) != 0; }
inline bool IsActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; IM_ASSERT(key < 64); return (g.ActiveIdUsingKeyInputMask & ((ImU64)1 << key)) != 0; }
@@ -2709,8 +2710,8 @@
#define IMGUI_TEST_ENGINE_ITEM_ADD(_BB,_ID) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemAdd(&g, _BB, _ID) // Register item bounding box
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS) // Register item label and status flags (optional)
#define IMGUI_TEST_ENGINE_LOG(_FMT,...) if (g.TestEngineHookItems) ImGuiTestEngineHook_Log(&g, _FMT, __VA_ARGS__) // Custom log entry from user land into test log
-#define IMGUI_TEST_ENGINE_ID_INFO(_ID,_TYPE,_DATA) if (g.TestEngineHookIdInfo == id) ImGuiTestEngineHook_IdInfo(&g, _TYPE, _ID, (const void*)(_DATA));
-#define IMGUI_TEST_ENGINE_ID_INFO2(_ID,_TYPE,_DATA,_DATA2) if (g.TestEngineHookIdInfo == id) ImGuiTestEngineHook_IdInfo(&g, _TYPE, _ID, (const void*)(_DATA), (const void*)(_DATA2));
+#define IMGUI_TEST_ENGINE_ID_INFO(_ID,_TYPE,_DATA) if (g.TestEngineHookIdInfo == _ID) ImGuiTestEngineHook_IdInfo(&g, _TYPE, _ID, (const void*)(_DATA));
+#define IMGUI_TEST_ENGINE_ID_INFO2(_ID,_TYPE,_DATA,_DATA2) if (g.TestEngineHookIdInfo == _ID) ImGuiTestEngineHook_IdInfo(&g, _TYPE, _ID, (const void*)(_DATA), (const void*)(_DATA2));
#else
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) ((void)0)
#endif
diff --git a/imgui_tables.cpp b/imgui_tables.cpp
index 1c7fbcf..0623515 100644
--- a/imgui_tables.cpp
+++ b/imgui_tables.cpp
@@ -288,12 +288,7 @@
flags |= ImGuiTableFlags_NoSavedSettings;
// Inherit _NoSavedSettings from top-level window (child windows always have _NoSavedSettings set)
-#ifdef IMGUI_HAS_DOCK
- ImGuiWindow* window_for_settings = outer_window->RootWindowDockStop;
-#else
- ImGuiWindow* window_for_settings = outer_window->RootWindow;
-#endif
- if (window_for_settings->Flags & ImGuiWindowFlags_NoSavedSettings)
+ if (outer_window->RootWindow->Flags & ImGuiWindowFlags_NoSavedSettings)
flags |= ImGuiTableFlags_NoSavedSettings;
return flags;