|
|
|
@ -9629,8 +9629,9 @@ void ImGui::ScrollToRect(ImGuiWindow* window, const ImRect& item_rect, ImGuiScro |
|
|
|
|
ImVec2 ImGui::ScrollToRectEx(ImGuiWindow* window, const ImRect& item_rect, ImGuiScrollFlags flags) |
|
|
|
|
{ |
|
|
|
|
ImGuiContext& g = *GImGui; |
|
|
|
|
ImRect window_rect(window->InnerRect.Min - ImVec2(1, 1), window->InnerRect.Max + ImVec2(1, 1)); |
|
|
|
|
//GetForegroundDrawList(window)->AddRect(window_rect.Min, window_rect.Max, IM_COL32_WHITE); // [DEBUG]
|
|
|
|
|
ImRect scroll_rect(window->InnerRect.Min - ImVec2(1, 1), window->InnerRect.Max + ImVec2(1, 1)); |
|
|
|
|
//GetForegroundDrawList(window)->AddRect(item_rect.Min, item_rect.Max, IM_COL32(255,0,0,255), 0.0f, 0, 5.0f); // [DEBUG]
|
|
|
|
|
//GetForegroundDrawList(window)->AddRect(scroll_rect.Min, scroll_rect.Max, IM_COL32_WHITE); // [DEBUG]
|
|
|
|
|
|
|
|
|
|
// Check that only one behavior is selected per axis
|
|
|
|
|
IM_ASSERT((flags & ImGuiScrollFlags_MaskX_) == 0 || ImIsPowerOfTwo(flags & ImGuiScrollFlags_MaskX_)); |
|
|
|
@ -9643,16 +9644,16 @@ ImVec2 ImGui::ScrollToRectEx(ImGuiWindow* window, const ImRect& item_rect, ImGui |
|
|
|
|
if ((flags & ImGuiScrollFlags_MaskY_) == 0) |
|
|
|
|
flags |= window->Appearing ? ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeY; |
|
|
|
|
|
|
|
|
|
const bool fully_visible_x = item_rect.Min.x >= window_rect.Min.x && item_rect.Max.x <= window_rect.Max.x; |
|
|
|
|
const bool fully_visible_y = item_rect.Min.y >= window_rect.Min.y && item_rect.Max.y <= window_rect.Max.y; |
|
|
|
|
const bool can_be_fully_visible_x = (item_rect.GetWidth() + g.Style.ItemSpacing.x * 2.0f) <= window_rect.GetWidth() || (window->AutoFitFramesX > 0) || (window->Flags & ImGuiWindowFlags_AlwaysAutoResize) != 0; |
|
|
|
|
const bool can_be_fully_visible_y = (item_rect.GetHeight() + g.Style.ItemSpacing.y * 2.0f) <= window_rect.GetHeight() || (window->AutoFitFramesY > 0) || (window->Flags & ImGuiWindowFlags_AlwaysAutoResize) != 0; |
|
|
|
|
const bool fully_visible_x = item_rect.Min.x >= scroll_rect.Min.x && item_rect.Max.x <= scroll_rect.Max.x; |
|
|
|
|
const bool fully_visible_y = item_rect.Min.y >= scroll_rect.Min.y && item_rect.Max.y <= scroll_rect.Max.y; |
|
|
|
|
const bool can_be_fully_visible_x = (item_rect.GetWidth() + g.Style.ItemSpacing.x * 2.0f) <= scroll_rect.GetWidth() || (window->AutoFitFramesX > 0) || (window->Flags & ImGuiWindowFlags_AlwaysAutoResize) != 0; |
|
|
|
|
const bool can_be_fully_visible_y = (item_rect.GetHeight() + g.Style.ItemSpacing.y * 2.0f) <= scroll_rect.GetHeight() || (window->AutoFitFramesY > 0) || (window->Flags & ImGuiWindowFlags_AlwaysAutoResize) != 0; |
|
|
|
|
|
|
|
|
|
if ((flags & ImGuiScrollFlags_KeepVisibleEdgeX) && !fully_visible_x) |
|
|
|
|
{ |
|
|
|
|
if (item_rect.Min.x < window_rect.Min.x || !can_be_fully_visible_x) |
|
|
|
|
if (item_rect.Min.x < scroll_rect.Min.x || !can_be_fully_visible_x) |
|
|
|
|
SetScrollFromPosX(window, item_rect.Min.x - g.Style.ItemSpacing.x - window->Pos.x, 0.0f); |
|
|
|
|
else if (item_rect.Max.x >= window_rect.Max.x) |
|
|
|
|
else if (item_rect.Max.x >= scroll_rect.Max.x) |
|
|
|
|
SetScrollFromPosX(window, item_rect.Max.x + g.Style.ItemSpacing.x - window->Pos.x, 1.0f); |
|
|
|
|
} |
|
|
|
|
else if (((flags & ImGuiScrollFlags_KeepVisibleCenterX) && !fully_visible_x) || (flags & ImGuiScrollFlags_AlwaysCenterX)) |
|
|
|
@ -9665,9 +9666,9 @@ ImVec2 ImGui::ScrollToRectEx(ImGuiWindow* window, const ImRect& item_rect, ImGui |
|
|
|
|
|
|
|
|
|
if ((flags & ImGuiScrollFlags_KeepVisibleEdgeY) && !fully_visible_y) |
|
|
|
|
{ |
|
|
|
|
if (item_rect.Min.y < window_rect.Min.y || !can_be_fully_visible_y) |
|
|
|
|
if (item_rect.Min.y < scroll_rect.Min.y || !can_be_fully_visible_y) |
|
|
|
|
SetScrollFromPosY(window, item_rect.Min.y - g.Style.ItemSpacing.y - window->Pos.y, 0.0f); |
|
|
|
|
else if (item_rect.Max.y >= window_rect.Max.y) |
|
|
|
|
else if (item_rect.Max.y >= scroll_rect.Max.y) |
|
|
|
|
SetScrollFromPosY(window, item_rect.Max.y + g.Style.ItemSpacing.y - window->Pos.y, 1.0f); |
|
|
|
|
} |
|
|
|
|
else if (((flags & ImGuiScrollFlags_KeepVisibleCenterY) && !fully_visible_y) || (flags & ImGuiScrollFlags_AlwaysCenterY)) |
|
|
|
|