|
|
|
@ -2243,6 +2243,47 @@ void ImGuiTextBuffer::appendfv(const char* fmt, va_list args)
|
|
|
|
|
// the API mid-way through development and support two ways to using the clipper, needs some rework (see TODO)
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// Helper to calculate coarse clipping of large list of evenly sized items.
|
|
|
|
|
// NB: Prefer using the ImGuiListClipper higher-level helper if you can! Read comments and instructions there on how those use this sort of pattern.
|
|
|
|
|
// NB: 'items_count' is only used to clamp the result, if you don't know your count you can use INT_MAX
|
|
|
|
|
void ImGui::CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end)
|
|
|
|
|
{
|
|
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
|
|
|
if (g.LogEnabled)
|
|
|
|
|
{
|
|
|
|
|
// If logging is active, do not perform any clipping
|
|
|
|
|
*out_items_display_start = 0;
|
|
|
|
|
*out_items_display_end = items_count;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (window->SkipItems)
|
|
|
|
|
{
|
|
|
|
|
*out_items_display_start = *out_items_display_end = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We create the union of the ClipRect and the NavScoringRect which at worst should be 1 page away from ClipRect
|
|
|
|
|
ImRect unclipped_rect = window->ClipRect;
|
|
|
|
|
if (g.NavMoveRequest)
|
|
|
|
|
unclipped_rect.Add(g.NavScoringRectScreen);
|
|
|
|
|
|
|
|
|
|
const ImVec2 pos = window->DC.CursorPos;
|
|
|
|
|
int start = (int)((unclipped_rect.Min.y - pos.y) / items_height);
|
|
|
|
|
int end = (int)((unclipped_rect.Max.y - pos.y) / items_height);
|
|
|
|
|
|
|
|
|
|
// When performing a navigation request, ensure we have one item extra in the direction we are moving to
|
|
|
|
|
if (g.NavMoveRequest && g.NavMoveClipDir == ImGuiDir_Up)
|
|
|
|
|
start--;
|
|
|
|
|
if (g.NavMoveRequest && g.NavMoveClipDir == ImGuiDir_Down)
|
|
|
|
|
end++;
|
|
|
|
|
|
|
|
|
|
start = ImClamp(start, 0, items_count);
|
|
|
|
|
end = ImClamp(end + 1, start, items_count);
|
|
|
|
|
*out_items_display_start = start;
|
|
|
|
|
*out_items_display_end = end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height)
|
|
|
|
|
{
|
|
|
|
|
// Set cursor position and a few other things so that SetScrollHereY() and Columns() can work when seeking cursor.
|
|
|
|
@ -4130,47 +4171,6 @@ ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_tex
|
|
|
|
|
return text_size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Helper to calculate coarse clipping of large list of evenly sized items.
|
|
|
|
|
// NB: Prefer using the ImGuiListClipper higher-level helper if you can! Read comments and instructions there on how those use this sort of pattern.
|
|
|
|
|
// NB: 'items_count' is only used to clamp the result, if you don't know your count you can use INT_MAX
|
|
|
|
|
void ImGui::CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end)
|
|
|
|
|
{
|
|
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
|
|
|
if (g.LogEnabled)
|
|
|
|
|
{
|
|
|
|
|
// If logging is active, do not perform any clipping
|
|
|
|
|
*out_items_display_start = 0;
|
|
|
|
|
*out_items_display_end = items_count;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (window->SkipItems)
|
|
|
|
|
{
|
|
|
|
|
*out_items_display_start = *out_items_display_end = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We create the union of the ClipRect and the NavScoringRect which at worst should be 1 page away from ClipRect
|
|
|
|
|
ImRect unclipped_rect = window->ClipRect;
|
|
|
|
|
if (g.NavMoveRequest)
|
|
|
|
|
unclipped_rect.Add(g.NavScoringRectScreen);
|
|
|
|
|
|
|
|
|
|
const ImVec2 pos = window->DC.CursorPos;
|
|
|
|
|
int start = (int)((unclipped_rect.Min.y - pos.y) / items_height);
|
|
|
|
|
int end = (int)((unclipped_rect.Max.y - pos.y) / items_height);
|
|
|
|
|
|
|
|
|
|
// When performing a navigation request, ensure we have one item extra in the direction we are moving to
|
|
|
|
|
if (g.NavMoveRequest && g.NavMoveClipDir == ImGuiDir_Up)
|
|
|
|
|
start--;
|
|
|
|
|
if (g.NavMoveRequest && g.NavMoveClipDir == ImGuiDir_Down)
|
|
|
|
|
end++;
|
|
|
|
|
|
|
|
|
|
start = ImClamp(start, 0, items_count);
|
|
|
|
|
end = ImClamp(end + 1, start, items_count);
|
|
|
|
|
*out_items_display_start = start;
|
|
|
|
|
*out_items_display_end = end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Find window given position, search front-to-back
|
|
|
|
|
// FIXME: Note that we have an inconsequential lag here: OuterRectClipped is updated in Begin(), so windows moved programatically
|
|
|
|
|
// with SetWindowPos() and not SetNextWindowPos() will have that rectangle lagging by a frame at the time FindHoveredWindow() is
|
|
|
|
|