|
|
|
@ -2133,17 +2133,8 @@ void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end
|
|
|
|
|
|
|
|
|
|
// Default clip_rect uses (pos_min,pos_max)
|
|
|
|
|
// Handle clipping on CPU immediately (vs typically let the GPU clip the triangles that are overlapping the clipping rectangle edges)
|
|
|
|
|
void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect)
|
|
|
|
|
void ImGui::RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_display_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect)
|
|
|
|
|
{
|
|
|
|
|
// Hide anything after a '##' string
|
|
|
|
|
const char* text_display_end = FindRenderedTextEnd(text, text_end);
|
|
|
|
|
const int text_len = (int)(text_display_end - text);
|
|
|
|
|
if (text_len == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
|
|
|
|
|
|
|
|
// Perform CPU side clipping for single clipped element to avoid using scissor state
|
|
|
|
|
ImVec2 pos = pos_min;
|
|
|
|
|
const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, text_display_end, false, 0.0f);
|
|
|
|
@ -2162,14 +2153,27 @@ void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, cons
|
|
|
|
|
if (need_clipping)
|
|
|
|
|
{
|
|
|
|
|
ImVec4 fine_clip_rect(clip_min->x, clip_min->y, clip_max->x, clip_max->y);
|
|
|
|
|
window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, &fine_clip_rect);
|
|
|
|
|
draw_list->AddText(NULL, 0.0f, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, &fine_clip_rect);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, NULL);
|
|
|
|
|
draw_list->AddText(NULL, 0.0f, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect)
|
|
|
|
|
{
|
|
|
|
|
// Hide anything after a '##' string
|
|
|
|
|
const char* text_display_end = FindRenderedTextEnd(text, text_end);
|
|
|
|
|
const int text_len = (int)(text_display_end - text);
|
|
|
|
|
if (text_len == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
|
|
|
RenderTextClippedEx(window->DrawList, pos_min, pos_max, text, text_display_end, text_size_if_known, align, clip_rect);
|
|
|
|
|
if (g.LogEnabled)
|
|
|
|
|
LogRenderedText(&pos, text, text_display_end);
|
|
|
|
|
LogRenderedText(&pos_min, text, text_display_end);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Render a rectangle shaped with optional rounding and borders
|
|
|
|
|