From 7a2da7cd02c0d8cfd5833842eebc621990bfacda Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 18 Mar 2015 22:35:14 +0000 Subject: [PATCH] Added style.DisplaySafeAreaPadding which was previously hard-coded (for use if you can't see the edges of your display, e.g. TV screens) --- imgui.cpp | 7 +++---- imgui.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 8e7b0aa8..2f7a6298 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -514,6 +514,7 @@ ImGuiStyle::ImGuiStyle() ColumnsMinSpacing = 6.0f; // Minimum horizontal spacing between two columns ScrollbarWidth = 16.0f; // Width of the vertical scrollbar GrabMinSize = 10.0f; // Minimum width/height of a slider or scrollbar grab + DisplaySafeAreaPadding = ImVec2(22,22); // Window positions are clamped to be visible within the display area. If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding Colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); Colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); @@ -2942,12 +2943,10 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size, float bg // Clamp into view if (!(window->Flags & ImGuiWindowFlags_ChildWindow) && !(window->Flags & ImGuiWindowFlags_Tooltip)) { - // FIXME: Parameterize padding. - const ImVec2 pad = ImVec2(window->FontSize()*2.0f, window->FontSize()*2.0f); // FIXME: Parametrize of clarify this behavior. if (window->AutoFitFrames == 0 && g.IO.DisplaySize.x > 0.0f && g.IO.DisplaySize.y > 0.0f) // Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing. { - ImVec2 clip_min = pad; - ImVec2 clip_max = g.IO.DisplaySize - pad; + ImVec2 clip_min = style.DisplaySafeAreaPadding; + ImVec2 clip_max = g.IO.DisplaySize - style.DisplaySafeAreaPadding; window->PosFloat = ImMax(window->PosFloat + window->Size, clip_min) - window->Size; window->PosFloat = ImMin(window->PosFloat, clip_max); } diff --git a/imgui.h b/imgui.h index d345bc6f..8f28d5fd 100644 --- a/imgui.h +++ b/imgui.h @@ -559,6 +559,7 @@ struct ImGuiStyle float ColumnsMinSpacing; // Minimum horizontal spacing between two columns float ScrollbarWidth; // Width of the vertical scrollbar float GrabMinSize; // Minimum width/height of a slider or scrollbar grab + ImVec2 DisplaySafeAreaPadding; // Window positions are clamped to be visible within the display area. If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. ImVec4 Colors[ImGuiCol_COUNT]; IMGUI_API ImGuiStyle();