mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-27 01:56:35 +00:00
Nav, Docking: Fix crash on dimming docked window and DockSpaceOverViewport() with PassthruCentralNode.
(amend1dc3af3
,23ef6c1
,657073a
)
This commit is contained in:
parent
fc198fe1db
commit
0647cf434c
@ -4636,7 +4636,11 @@ static void ImGui::RenderDimmedBackgroundBehindWindow(ImGuiWindow* window, ImU32
|
|||||||
|
|
||||||
// Draw behind window by moving the draw command at the FRONT of the draw list
|
// Draw behind window by moving the draw command at the FRONT of the draw list
|
||||||
{
|
{
|
||||||
|
// We've already called AddWindowToDrawData() which called DrawList->ChannelsMerge() on DockNodeHost windows,
|
||||||
|
// and draw list have been trimmed already, hence the explicit recreation of a draw command if missing.
|
||||||
ImDrawList* draw_list = window->RootWindowDockTree->DrawList;
|
ImDrawList* draw_list = window->RootWindowDockTree->DrawList;
|
||||||
|
if (draw_list->CmdBuffer.Size == 0)
|
||||||
|
draw_list->AddDrawCmd();
|
||||||
draw_list->PushClipRect(viewport_rect.Min - ImVec2(1, 1), viewport_rect.Max + ImVec2(1, 1), false); // Ensure ImDrawCmd are not merged
|
draw_list->PushClipRect(viewport_rect.Min - ImVec2(1, 1), viewport_rect.Max + ImVec2(1, 1), false); // Ensure ImDrawCmd are not merged
|
||||||
draw_list->AddRectFilled(viewport_rect.Min, viewport_rect.Max, col);
|
draw_list->AddRectFilled(viewport_rect.Min, viewport_rect.Max, col);
|
||||||
ImDrawCmd cmd = draw_list->CmdBuffer.back();
|
ImDrawCmd cmd = draw_list->CmdBuffer.back();
|
||||||
@ -4651,7 +4655,6 @@ static void ImGui::RenderDimmedBackgroundBehindWindow(ImGuiWindow* window, ImU32
|
|||||||
{
|
{
|
||||||
ImDrawList* draw_list = FindFrontMostVisibleChildWindow(window->RootWindowDockTree)->DrawList;
|
ImDrawList* draw_list = FindFrontMostVisibleChildWindow(window->RootWindowDockTree)->DrawList;
|
||||||
draw_list->PushClipRect(viewport_rect.Min, viewport_rect.Max, false);
|
draw_list->PushClipRect(viewport_rect.Min, viewport_rect.Max, false);
|
||||||
//if (window->RootWindowDockTree != window->RootWindow)
|
|
||||||
RenderRectFilledWithHole(draw_list, window->RootWindowDockTree->Rect(), window->RootWindow->Rect(), col, 0.0f);// window->RootWindowDockTree->WindowRounding);
|
RenderRectFilledWithHole(draw_list, window->RootWindowDockTree->Rect(), window->RootWindow->Rect(), col, 0.0f);// window->RootWindowDockTree->WindowRounding);
|
||||||
draw_list->PopClipRect();
|
draw_list->PopClipRect();
|
||||||
}
|
}
|
||||||
@ -4690,6 +4693,8 @@ static void ImGui::RenderDimmedBackgrounds()
|
|||||||
bb.Expand(distance);
|
bb.Expand(distance);
|
||||||
if (bb.GetWidth() >= viewport->Size.x && bb.GetHeight() >= viewport->Size.y)
|
if (bb.GetWidth() >= viewport->Size.x && bb.GetHeight() >= viewport->Size.y)
|
||||||
bb.Expand(-distance - 1.0f); // If a window fits the entire viewport, adjust its highlight inward
|
bb.Expand(-distance - 1.0f); // If a window fits the entire viewport, adjust its highlight inward
|
||||||
|
if (window->DrawList->CmdBuffer.Size == 0)
|
||||||
|
window->DrawList->AddDrawCmd();
|
||||||
window->DrawList->PushClipRect(viewport->Pos, viewport->Pos + viewport->Size);
|
window->DrawList->PushClipRect(viewport->Pos, viewport->Pos + viewport->Size);
|
||||||
window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha), window->WindowRounding, 0, 3.0f);
|
window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha), window->WindowRounding, 0, 3.0f);
|
||||||
window->DrawList->PopClipRect();
|
window->DrawList->PopClipRect();
|
||||||
|
@ -481,6 +481,7 @@ void ImDrawList::_PopUnusedDrawCmd()
|
|||||||
|
|
||||||
void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data)
|
void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data)
|
||||||
{
|
{
|
||||||
|
IM_ASSERT_PARANOID(CmdBuffer.Size > 0);
|
||||||
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
IM_ASSERT(curr_cmd->UserCallback == NULL);
|
IM_ASSERT(curr_cmd->UserCallback == NULL);
|
||||||
if (curr_cmd->ElemCount != 0)
|
if (curr_cmd->ElemCount != 0)
|
||||||
@ -502,6 +503,7 @@ void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data)
|
|||||||
// Try to merge two last draw commands
|
// Try to merge two last draw commands
|
||||||
void ImDrawList::_TryMergeDrawCmds()
|
void ImDrawList::_TryMergeDrawCmds()
|
||||||
{
|
{
|
||||||
|
IM_ASSERT_PARANOID(CmdBuffer.Size > 0);
|
||||||
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
ImDrawCmd* prev_cmd = curr_cmd - 1;
|
ImDrawCmd* prev_cmd = curr_cmd - 1;
|
||||||
if (ImDrawCmd_HeaderCompare(curr_cmd, prev_cmd) == 0 && curr_cmd->UserCallback == NULL && prev_cmd->UserCallback == NULL)
|
if (ImDrawCmd_HeaderCompare(curr_cmd, prev_cmd) == 0 && curr_cmd->UserCallback == NULL && prev_cmd->UserCallback == NULL)
|
||||||
@ -516,6 +518,7 @@ void ImDrawList::_TryMergeDrawCmds()
|
|||||||
void ImDrawList::_OnChangedClipRect()
|
void ImDrawList::_OnChangedClipRect()
|
||||||
{
|
{
|
||||||
// If current command is used with different settings we need to add a new command
|
// If current command is used with different settings we need to add a new command
|
||||||
|
IM_ASSERT_PARANOID(CmdBuffer.Size > 0);
|
||||||
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
if (curr_cmd->ElemCount != 0 && memcmp(&curr_cmd->ClipRect, &_CmdHeader.ClipRect, sizeof(ImVec4)) != 0)
|
if (curr_cmd->ElemCount != 0 && memcmp(&curr_cmd->ClipRect, &_CmdHeader.ClipRect, sizeof(ImVec4)) != 0)
|
||||||
{
|
{
|
||||||
@ -538,6 +541,7 @@ void ImDrawList::_OnChangedClipRect()
|
|||||||
void ImDrawList::_OnChangedTextureID()
|
void ImDrawList::_OnChangedTextureID()
|
||||||
{
|
{
|
||||||
// If current command is used with different settings we need to add a new command
|
// If current command is used with different settings we need to add a new command
|
||||||
|
IM_ASSERT_PARANOID(CmdBuffer.Size > 0);
|
||||||
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
if (curr_cmd->ElemCount != 0 && curr_cmd->TextureId != _CmdHeader.TextureId)
|
if (curr_cmd->ElemCount != 0 && curr_cmd->TextureId != _CmdHeader.TextureId)
|
||||||
{
|
{
|
||||||
@ -561,6 +565,7 @@ void ImDrawList::_OnChangedVtxOffset()
|
|||||||
{
|
{
|
||||||
// We don't need to compare curr_cmd->VtxOffset != _CmdHeader.VtxOffset because we know it'll be different at the time we call this.
|
// We don't need to compare curr_cmd->VtxOffset != _CmdHeader.VtxOffset because we know it'll be different at the time we call this.
|
||||||
_VtxCurrentIdx = 0;
|
_VtxCurrentIdx = 0;
|
||||||
|
IM_ASSERT_PARANOID(CmdBuffer.Size > 0);
|
||||||
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
//IM_ASSERT(curr_cmd->VtxOffset != _CmdHeader.VtxOffset); // See #3349
|
//IM_ASSERT(curr_cmd->VtxOffset != _CmdHeader.VtxOffset); // See #3349
|
||||||
if (curr_cmd->ElemCount != 0)
|
if (curr_cmd->ElemCount != 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user