MultiLine text display

This commit is contained in:
Bruno Herbelin
2021-12-31 13:16:16 +01:00
parent 8838c19c39
commit 17018c137f
2 changed files with 13 additions and 0 deletions

View File

@@ -1721,3 +1721,15 @@ bool ImGuiToolkit::InputTextMultiline(const char* label, std::string* str, const
}
void ImGuiToolkit::ShowTextMultiline(const char* label, const std::string &str, float width)
{
size_t numlines = std::count(str.begin(), str.end(), '\n') + 1;
ImGuiContext& g = *GImGui;
ImVec2 size(width, numlines * (g.FontSize + g.Style.ItemSpacing.y) + g.Style.FramePadding.y * 2.0f);
ImGui::PushStyleColor(ImGuiCol_FrameBg, g.Style.Colors[ImGuiCol_FrameBgHovered]);
ImGui::InputTextMultiline(label, (char*)str.c_str(), str.capacity() + 1, size, ImGuiInputTextFlags_ReadOnly);
ImGui::PopStyleColor();
}