Begin: WIP consistent Begin/End behavior, more fixes.

This commit is contained in:
ocornut 2020-10-19 14:06:14 +02:00
parent f4edca3e65
commit 1848480798
3 changed files with 22 additions and 22 deletions

View File

@ -4115,7 +4115,9 @@ void ImGui::NewFrame()
// - The fallback window exceptionally doesn't call End() automatically if Begin() returns false (this is intended). // - The fallback window exceptionally doesn't call End() automatically if Begin() returns false (this is intended).
g.WithinFrameScopeWithImplicitWindow = true; g.WithinFrameScopeWithImplicitWindow = true;
SetNextWindowSize(ImVec2(400, 400), ImGuiCond_FirstUseEver); SetNextWindowSize(ImVec2(400, 400), ImGuiCond_FirstUseEver);
Begin("Debug##Default"); bool ret = Begin("Debug##Default");
IM_UNUSED(ret);
IM_ASSERT(ret);
IM_ASSERT(g.CurrentWindow->IsFallbackWindow == true); IM_ASSERT(g.CurrentWindow->IsFallbackWindow == true);
// [DEBUG] When io.ConfigDebugBeginReturnValue is set, we make Begin() return false at different level of the window stack to validate Begin()/End() behavior in user code. // [DEBUG] When io.ConfigDebugBeginReturnValue is set, we make Begin() return false at different level of the window stack to validate Begin()/End() behavior in user code.
@ -5215,7 +5217,6 @@ void ImGui::EndChild()
// Helper to create a child window / scrolling region that looks like a normal widget frame. // Helper to create a child window / scrolling region that looks like a normal widget frame.
bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags) bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags)
{ {
// FIXME-NEWBEGIN
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style; const ImGuiStyle& style = g.Style;
PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]); PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]);
@ -6760,22 +6761,22 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
} }
// FIXME-OPT // FIXME-OPT
if (window->SkipItems || g.DebugBeginReturnValueCullDepth == g.CurrentWindowStack.Size) bool debug_skip = (g.DebugBeginReturnValueCullDepth == g.CurrentWindowStack.Size) && (window->Flags & ImGuiWindowFlags_DockNodeHost) == 0;
if (window->SkipItems || debug_skip)
{ {
// The implicit fallback is NOT automatically ended as an exception to the rule, // The implicit fallback is NOT automatically ended as an exception to the rule,
// allowing it to always be able to receive commands without crashing. // allowing it to always be able to receive commands without crashing.
if (!window->IsFallbackWindow) if (window->IsFallbackWindow)
{ return true;
if (window->Flags & ImGuiWindowFlags_Popup)
EndPopup(); if (window->Flags & ImGuiWindowFlags_Popup)
else if (window->Flags & ImGuiWindowFlags_ChildWindow) EndPopup();
EndChild(); else if (window->Flags & ImGuiWindowFlags_ChildWindow)
else EndChild();
End(); else
} End();
return false; return false;
} }
return true; return true;
} }

View File

@ -5422,15 +5422,13 @@ void ImGui::ShowAboutWindow(bool* p_open)
static bool show_config_info = false; static bool show_config_info = false;
ImGui::Checkbox("Config/Build Information", &show_config_info); ImGui::Checkbox("Config/Build Information", &show_config_info);
if (show_config_info)
ImGuiIO& io = ImGui::GetIO();
ImGuiStyle& style = ImGui::GetStyle();
const bool copy_to_clipboard = show_config_info && ImGui::Button("Copy to clipboard");
const ImVec2 child_size = ImVec2(0, ImGui::GetTextLineHeightWithSpacing() * 18);
if (show_config_info && ImGui::BeginChildFrame(ImGui::GetID("cfg_infos"), child_size, ImGuiWindowFlags_NoMove))
{ {
ImGuiIO& io = ImGui::GetIO();
ImGuiStyle& style = ImGui::GetStyle();
bool copy_to_clipboard = ImGui::Button("Copy to clipboard");
ImVec2 child_size = ImVec2(0, ImGui::GetTextLineHeightWithSpacing() * 18);
ImGui::BeginChildFrame(ImGui::GetID("cfg_infos"), child_size, ImGuiWindowFlags_NoMove);
if (copy_to_clipboard) if (copy_to_clipboard)
{ {
ImGui::LogToClipboard(); ImGui::LogToClipboard();
@ -5558,6 +5556,7 @@ void ImGui::ShowAboutWindow(bool* p_open)
ImGui::LogText("\n```\n"); ImGui::LogText("\n```\n");
ImGui::LogFinish(); ImGui::LogFinish();
} }
ImGui::EndChildFrame();
} }
ImGui::End(); ImGui::End();
} }

View File

@ -6131,7 +6131,7 @@ bool ImGui::ListBoxHeader(const char* label, const ImVec2& size_arg)
if (label_size.x > 0) if (label_size.x > 0)
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
// FIXME-NEWBEGIN // FIXME-NEWBEGIN: Use to be return true so we'll trigger more issues.
return BeginChildFrame(id, frame_bb.GetSize()); return BeginChildFrame(id, frame_bb.GetSize());
} }