Scrollbar: Fixed an issue where scrollbars wouldn't display on the frame following a frame where all child window contents would be culled.

Demo: Fixed a small bug with scrolling demo.
Metrics: Tweaks.
This commit is contained in:
omar 2019-11-08 19:00:49 +01:00
parent 57dc34f4e8
commit 6e8e2c0fa9
3 changed files with 36 additions and 22 deletions

View File

@ -63,6 +63,8 @@ Other Changes:
multi-line label and no frame padding, such as: multi-line text, small button, tree node item, etc. multi-line label and no frame padding, such as: multi-line text, small button, tree node item, etc.
The second item was correctly offset to match text baseline, and would interact/display correctly, The second item was correctly offset to match text baseline, and would interact/display correctly,
but it wouldn't push the contents area boundary low enough. but it wouldn't push the contents area boundary low enough.
- Scrollbar: Fixed an issue where scrollbars wouldn't display on the frame following a frame where
all child window contents would be culled.
- ColorPicker: Fixed SV triangle gradient to block (broken in 1.73). (#2864, #2711). [@lewa-j] - ColorPicker: Fixed SV triangle gradient to block (broken in 1.73). (#2864, #2711). [@lewa-j]
- TreeNode: Fixed combination of ImGuiTreeNodeFlags_SpanFullWidth and ImGuiTreeNodeFlags_OpenOnArrow - TreeNode: Fixed combination of ImGuiTreeNodeFlags_SpanFullWidth and ImGuiTreeNodeFlags_OpenOnArrow
incorrectly locating the arrow hit position to the left of the frame. (#2451, #2438, #1897) incorrectly locating the arrow hit position to the left of the frame. (#2451, #2438, #1897)

View File

@ -5054,6 +5054,9 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
ImGuiStyle& style = g.Style; ImGuiStyle& style = g.Style;
ImGuiWindowFlags flags = window->Flags; ImGuiWindowFlags flags = window->Flags;
// Ensure that ScrollBar doesn't read last frame's SkipItems
window->SkipItems = false;
// Draw window + handle manual resize // Draw window + handle manual resize
// As we highlight the title bar when want_focus is set, multiple reappearing windows will have have their title bar highlighted on their reappearing frame. // As we highlight the title bar when want_focus is set, multiple reappearing windows will have have their title bar highlighted on their reappearing frame.
const float window_rounding = window->WindowRounding; const float window_rounding = window->WindowRounding;
@ -9754,7 +9757,10 @@ void ImGui::ShowMetricsWindow(bool* p_open)
ImGui::BulletText("%s: NULL", label); ImGui::BulletText("%s: NULL", label);
return; return;
} }
if (!ImGui::TreeNode(window, "%s '%s', %d @ 0x%p", label, window->Name, (window->Active || window->WasActive), window)) bool open = ImGui::TreeNode(window, "%s '%s', %d @ 0x%p", label, window->Name, (window->Active || window->WasActive), window);
if (ImGui::IsItemHovered() && window->WasActive)
ImGui::GetForegroundDrawList()->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255));
if (!open)
return; return;
ImGuiWindowFlags flags = window->Flags; ImGuiWindowFlags flags = window->Flags;
NodeDrawList(window, window->DrawList, "DrawList"); NodeDrawList(window, window->DrawList, "DrawList");
@ -9763,7 +9769,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
(flags & ImGuiWindowFlags_ChildWindow) ? "Child " : "", (flags & ImGuiWindowFlags_Tooltip) ? "Tooltip " : "", (flags & ImGuiWindowFlags_Popup) ? "Popup " : "", (flags & ImGuiWindowFlags_ChildWindow) ? "Child " : "", (flags & ImGuiWindowFlags_Tooltip) ? "Tooltip " : "", (flags & ImGuiWindowFlags_Popup) ? "Popup " : "",
(flags & ImGuiWindowFlags_Modal) ? "Modal " : "", (flags & ImGuiWindowFlags_ChildMenu) ? "ChildMenu " : "", (flags & ImGuiWindowFlags_NoSavedSettings) ? "NoSavedSettings " : "", (flags & ImGuiWindowFlags_Modal) ? "Modal " : "", (flags & ImGuiWindowFlags_ChildMenu) ? "ChildMenu " : "", (flags & ImGuiWindowFlags_NoSavedSettings) ? "NoSavedSettings " : "",
(flags & ImGuiWindowFlags_NoMouseInputs)? "NoMouseInputs":"", (flags & ImGuiWindowFlags_NoNavInputs) ? "NoNavInputs" : "", (flags & ImGuiWindowFlags_AlwaysAutoResize) ? "AlwaysAutoResize" : ""); (flags & ImGuiWindowFlags_NoMouseInputs)? "NoMouseInputs":"", (flags & ImGuiWindowFlags_NoNavInputs) ? "NoNavInputs" : "", (flags & ImGuiWindowFlags_AlwaysAutoResize) ? "AlwaysAutoResize" : "");
ImGui::BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f)", window->Scroll.x, window->ScrollMax.x, window->Scroll.y, window->ScrollMax.y); ImGui::BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f) Scrollbar:%s%s", window->Scroll.x, window->ScrollMax.x, window->Scroll.y, window->ScrollMax.y, window->ScrollbarX ? "X" : "", window->ScrollbarY ? "Y" : "");
ImGui::BulletText("Active: %d/%d, WriteAccessed: %d, BeginOrderWithinContext: %d", window->Active, window->WasActive, window->WriteAccessed, (window->Active || window->WasActive) ? window->BeginOrderWithinContext : -1); ImGui::BulletText("Active: %d/%d, WriteAccessed: %d, BeginOrderWithinContext: %d", window->Active, window->WasActive, window->WriteAccessed, (window->Active || window->WasActive) ? window->BeginOrderWithinContext : -1);
ImGui::BulletText("Appearing: %d, Hidden: %d (CanSkip %d Cannot %d), SkipItems: %d", window->Appearing, window->Hidden, window->HiddenFramesCanSkipItems, window->HiddenFramesCannotSkipItems, window->SkipItems); ImGui::BulletText("Appearing: %d, Hidden: %d (CanSkip %d Cannot %d), SkipItems: %d", window->Appearing, window->Hidden, window->HiddenFramesCanSkipItems, window->HiddenFramesCannotSkipItems, window->SkipItems);
ImGui::BulletText("NavLastIds: 0x%08X,0x%08X, NavLayerActiveMask: %X", window->NavLastIds[0], window->NavLastIds[1], window->DC.NavLayerActiveMask); ImGui::BulletText("NavLastIds: 0x%08X,0x%08X, NavLayerActiveMask: %X", window->NavLastIds[0], window->NavLastIds[1], window->DC.NavLayerActiveMask);
@ -9821,7 +9827,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
}; };
Funcs::NodeWindows(g.Windows, "Windows"); Funcs::NodeWindows(g.Windows, "Windows");
if (ImGui::TreeNode("DrawList", "Active DrawLists (%d)", g.DrawDataBuilder.Layers[0].Size)) if (ImGui::TreeNode("DrawLists", "Active DrawLists (%d)", g.DrawDataBuilder.Layers[0].Size))
{ {
for (int i = 0; i < g.DrawDataBuilder.Layers[0].Size; i++) for (int i = 0; i < g.DrawDataBuilder.Layers[0].Size; i++)
Funcs::NodeDrawList(NULL, g.DrawDataBuilder.Layers[0][i], "DrawList"); Funcs::NodeDrawList(NULL, g.DrawDataBuilder.Layers[0][i], "DrawList");

View File

@ -2215,7 +2215,7 @@ static void ShowDemoWindowLayout()
ImGui::TextUnformatted(names[i]); ImGui::TextUnformatted(names[i]);
ImGuiWindowFlags child_flags = enable_extra_decorations ? ImGuiWindowFlags_MenuBar : 0; ImGuiWindowFlags child_flags = enable_extra_decorations ? ImGuiWindowFlags_MenuBar : 0;
ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(child_w, 200.0f), true, child_flags); bool window_visible = ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(child_w, 200.0f), true, child_flags);
if (ImGui::BeginMenuBar()) if (ImGui::BeginMenuBar())
{ {
ImGui::TextUnformatted("abc"); ImGui::TextUnformatted("abc");
@ -2225,16 +2225,19 @@ static void ShowDemoWindowLayout()
ImGui::SetScrollY(scroll_to_off_px); ImGui::SetScrollY(scroll_to_off_px);
if (scroll_to_pos) if (scroll_to_pos)
ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_pos_px, i * 0.25f); ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_pos_px, i * 0.25f);
for (int item = 0; item < 100; item++) if (window_visible) // Avoid calling SetScrollHereY when running with culled items
{ {
if (enable_track && item == track_item) for (int item = 0; item < 100; item++)
{ {
ImGui::TextColored(ImVec4(1,1,0,1), "Item %d", item); if (enable_track && item == track_item)
ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom {
} ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item);
else ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom
{ }
ImGui::Text("Item %d", item); else
{
ImGui::Text("Item %d", item);
}
} }
} }
float scroll_y = ImGui::GetScrollY(); float scroll_y = ImGui::GetScrollY();
@ -2253,23 +2256,26 @@ static void ShowDemoWindowLayout()
{ {
float child_height = ImGui::GetTextLineHeight() + style.ScrollbarSize + style.WindowPadding.y * 2.0f; float child_height = ImGui::GetTextLineHeight() + style.ScrollbarSize + style.WindowPadding.y * 2.0f;
ImGuiWindowFlags child_flags = ImGuiWindowFlags_HorizontalScrollbar | (enable_extra_decorations ? ImGuiWindowFlags_AlwaysVerticalScrollbar : 0); ImGuiWindowFlags child_flags = ImGuiWindowFlags_HorizontalScrollbar | (enable_extra_decorations ? ImGuiWindowFlags_AlwaysVerticalScrollbar : 0);
ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(-100, child_height), true, child_flags); bool window_visible = ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(-100, child_height), true, child_flags);
if (scroll_to_off) if (scroll_to_off)
ImGui::SetScrollX(scroll_to_off_px); ImGui::SetScrollX(scroll_to_off_px);
if (scroll_to_pos) if (scroll_to_pos)
ImGui::SetScrollFromPosX(ImGui::GetCursorStartPos().x + scroll_to_pos_px, i * 0.25f); ImGui::SetScrollFromPosX(ImGui::GetCursorStartPos().x + scroll_to_pos_px, i * 0.25f);
for (int item = 0; item < 100; item++) if (window_visible) // Avoid calling SetScrollHereY when running with culled items
{ {
if (enable_track && item == track_item) for (int item = 0; item < 100; item++)
{ {
ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item); if (enable_track && item == track_item)
ImGui::SetScrollHereX(i * 0.25f); // 0.0f:left, 0.5f:center, 1.0f:right {
ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item);
ImGui::SetScrollHereX(i * 0.25f); // 0.0f:left, 0.5f:center, 1.0f:right
}
else
{
ImGui::Text("Item %d", item);
}
ImGui::SameLine();
} }
else
{
ImGui::Text("Item %d", item);
}
ImGui::SameLine();
} }
float scroll_x = ImGui::GetScrollX(); float scroll_x = ImGui::GetScrollX();
float scroll_max_x = ImGui::GetScrollMaxX(); float scroll_max_x = ImGui::GetScrollMaxX();