From 1d90f099bd3b7795c14835cfd2208b6e55a1be41 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 26 Apr 2015 13:17:56 +0200 Subject: [PATCH] Tidying up We still have an issue with ImVec4 vs ImRect --- imgui.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index c2f42ebc..86ad7466 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2831,6 +2831,14 @@ int ImGui::GetFrameCount() return GImGui->FrameCount; } +static ImVec4 GetVisibleRect() +{ + ImGuiState& g = *GImGui; + if (g.IO.DisplayVisibleMin.x != g.IO.DisplayVisibleMax.x && g.IO.DisplayVisibleMin.y != g.IO.DisplayVisibleMax.y) + return ImVec4(g.IO.DisplayVisibleMin.x, g.IO.DisplayVisibleMin.y, g.IO.DisplayVisibleMax.x, g.IO.DisplayVisibleMax.y); + return ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y); +} + void ImGui::BeginTooltip() { ImGuiState& g = *GImGui; @@ -3145,10 +3153,8 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_ // Setup outer clipping rectangle if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_ComboBox)) PushClipRect(parent_window->ClipRectStack.back()); - else if (g.IO.DisplayVisibleMin.x != g.IO.DisplayVisibleMax.x && g.IO.DisplayVisibleMin.y != g.IO.DisplayVisibleMax.y) - PushClipRect(ImVec4(g.IO.DisplayVisibleMin.x, g.IO.DisplayVisibleMin.y, g.IO.DisplayVisibleMax.x, g.IO.DisplayVisibleMax.y)); else - PushClipRect(ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y)); + PushClipRect(GetVisibleRect()); // Setup and draw window if (first_begin_of_the_frame) @@ -7890,10 +7896,7 @@ void ImDrawList::PushClipRectFullScreen() // This would be more correct but we're not supposed to access ImGuiState from here? //ImGuiState& g = *GImGui; - //if (g.IO.DisplayVisibleMin.x != g.IO.DisplayVisibleMax.x && g.IO.DisplayVisibleMin.y != g.IO.DisplayVisibleMax.y) - // PushClipRect(ImVec4(g.IO.DisplayVisibleMin.x, g.IO.DisplayVisibleMin.y, g.IO.DisplayVisibleMax.x, g.IO.DisplayVisibleMax.y)); - //else - // PushClipRect(ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y)); + //PushClipRect(GetVisibleRect()); } void ImDrawList::PopClipRect()