Added io.DisplayVisibleMin / io.DisplayVisibleMax to allow for virtual / scrolling display.

+ remove duplicated "Setup outer clipping rectangle" block in Begin))
This commit is contained in:
ocornut 2015-01-29 14:20:25 +01:00
parent 962ef3924a
commit 27161d2a98
2 changed files with 23 additions and 20 deletions

View File

@ -525,6 +525,7 @@ ImGuiIO::ImGuiIO()
MousePosPrev = ImVec2(-1,-1); MousePosPrev = ImVec2(-1,-1);
MouseDoubleClickTime = 0.30f; MouseDoubleClickTime = 0.30f;
MouseDoubleClickMaxDist = 6.0f; MouseDoubleClickMaxDist = 6.0f;
DisplayVisibleMin = DisplayVisibleMax = ImVec2(0.0f, 0.0f);
UserData = NULL; UserData = NULL;
// User functions // User functions
@ -2474,7 +2475,6 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
if (first_begin_of_the_frame) if (first_begin_of_the_frame)
{ {
window->DrawList->Clear(); window->DrawList->Clear();
window->DrawList->PushTextureID(g.Font->ContainerAtlas->TexID);
window->Visible = true; window->Visible = true;
// New windows appears in front // New windows appears in front
@ -2490,13 +2490,22 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
window->Pos = window->PosFloat = parent_window->DC.CursorPos; window->Pos = window->PosFloat = parent_window->DC.CursorPos;
window->SizeFull = size; window->SizeFull = size;
} }
}
// Outer clipping rectangle // Setup texture
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_ComboBox)) window->DrawList->PushTextureID(g.Font->ContainerAtlas->TexID);
PushClipRect(parent_window->ClipRectStack.back());
else
PushClipRect(ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y));
// 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));
// Setup and draw window
if (first_begin_of_the_frame)
{
// Seed ID stack with our window pointer // Seed ID stack with our window pointer
window->IDStack.resize(0); window->IDStack.resize(0);
ImGui::PushID(window); ImGui::PushID(window);
@ -2531,11 +2540,14 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
// Clamp into view // Clamp into view
if (!(window->Flags & ImGuiWindowFlags_ChildWindow) && !(window->Flags & ImGuiWindowFlags_Tooltip)) 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. const ImVec2 pad = ImVec2(window->FontSize()*2.0f, window->FontSize()*2.0f); // FIXME: Parametrize of clarify this behavior.
if (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. if (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.
{ {
window->PosFloat = ImMax(window->PosFloat + window->Size, pad) - window->Size; ImVec2 clip_min = pad;
window->PosFloat = ImMin(window->PosFloat, ImVec2(g.IO.DisplaySize.x, g.IO.DisplaySize.y) - pad); ImVec2 clip_max = g.IO.DisplaySize - pad;
window->PosFloat = ImMax(window->PosFloat + window->Size, clip_min) - window->Size;
window->PosFloat = ImMin(window->PosFloat, clip_max);
} }
window->SizeFull = ImMax(window->SizeFull, style.WindowMinSize); window->SizeFull = ImMax(window->SizeFull, style.WindowMinSize);
} }
@ -2783,17 +2795,6 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
PopClipRect(); PopClipRect();
} }
} }
else
{
// Short path when we do multiple Begin in the same frame.
window->DrawList->PushTextureID(g.Font->ContainerAtlas->TexID);
// Outer clipping rectangle
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_ComboBox))
PushClipRect(parent_window->ClipRectStack.back());
else
PushClipRect(ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y));
}
// Inner clipping rectangle // Inner clipping rectangle
// We set this up after processing the resize grip so that our clip rectangle doesn't lag by a frame // We set this up after processing the resize grip so that our clip rectangle doesn't lag by a frame
@ -3647,7 +3648,7 @@ bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size)
if (!ItemAdd(bb, &id)) if (!ItemAdd(bb, &id))
return false; return false;
bool hovered, held; bool hovered, held;
bool pressed = ButtonBehaviour(bb, id, &hovered, &held, true); bool pressed = ButtonBehaviour(bb, id, &hovered, &held, true);
return pressed; return pressed;

View File

@ -501,6 +501,8 @@ struct ImGuiIO
ImFontAtlas* Fonts; // <auto> // Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array. ImFontAtlas* Fonts; // <auto> // Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array.
float FontGlobalScale; // = 1.0f // Global scale all fonts float FontGlobalScale; // = 1.0f // Global scale all fonts
bool FontAllowUserScaling; // = false // Allow user scaling text of individual window with CTRL+Wheel. bool FontAllowUserScaling; // = false // Allow user scaling text of individual window with CTRL+Wheel.
ImVec2 DisplayVisibleMin; // <unset> (0.0f,0.0f) // If you use DisplaySize as a virtual space larger than your screen, set DisplayVisibleMin/Max to the visible area.
ImVec2 DisplayVisibleMax; // <unset> (0.0f,0.0f) // If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize
//------------------------------------------------------------------ //------------------------------------------------------------------
// User Functions // User Functions