diff --git a/.gitmodules b/.gitmodules index a0fe596c..d73393a6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -34,3 +34,6 @@ [submodule "external/units"] path = external/units url = https://github.com/nholthaus/units.git +[submodule "external/textflowcpp"] + path = external/textflowcpp + url = https://github.com/catchorg/textflowcpp.git diff --git a/ACKNOWLEDGEMENTS.md b/ACKNOWLEDGEMENTS.md index 87476473..1e70a3c7 100644 --- a/ACKNOWLEDGEMENTS.md +++ b/ACKNOWLEDGEMENTS.md @@ -36,6 +36,8 @@ Supercell Wx uses code from the following dependencies: | [spdlog](https://github.com/gabime/spdlog) | [MIT License](https://spdx.org/licenses/MIT.html) | | [SQLite](https://www.sqlite.org/) | Public Domain | | [stb](https://github.com/nothings/stb) | Public Domain | +| [TextFlowCpp](https://github.com/catchorg/textflowcpp) | [Boost Software License 1.0](https://spdx.org/licenses/BSL-1.0.html) | +| [Units](https://github.com/nholthaus/units) | [MIT License](https://spdx.org/licenses/MIT.html) | | [Vulkan SDK](https://www.vulkan.org/) | [Apache License 2.0](https://spdx.org/licenses/Apache-2.0.html) | | [zlib](https://zlib.net/) | [zlib License](https://spdx.org/licenses/Zlib.html) | diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 806b603b..3c0be1cf 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -11,6 +11,7 @@ set_property(DIRECTORY imgui.cmake mapbox-gl-native.cmake stb.cmake + textflowcpp.cmake units.cmake) include(aws-sdk-cpp.cmake) @@ -20,4 +21,5 @@ include(hsluv-c.cmake) include(imgui.cmake) include(mapbox-gl-native.cmake) include(stb.cmake) +include(textflowcpp.cmake) include(units.cmake) diff --git a/external/textflowcpp b/external/textflowcpp new file mode 160000 index 00000000..12010ddc --- /dev/null +++ b/external/textflowcpp @@ -0,0 +1 @@ +Subproject commit 12010ddc8d15538ceea20622d22977e7c5a25da5 diff --git a/external/textflowcpp.cmake b/external/textflowcpp.cmake new file mode 100644 index 00000000..1e36da18 --- /dev/null +++ b/external/textflowcpp.cmake @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.20) +set(PROJECT_NAME scwx-textflowcpp) + +set(TEXTFLOWCPP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/textflowcpp PARENT_SCOPE) diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake index 7719e855..4b7e1d80 100644 --- a/scwx-qt/scwx-qt.cmake +++ b/scwx-qt/scwx-qt.cmake @@ -418,7 +418,8 @@ target_include_directories(scwx-qt PUBLIC ${scwx-qt_SOURCE_DIR}/source ${FTGL_INCLUDE_DIR} ${IMGUI_INCLUDE_DIRS} ${MBGL_INCLUDE_DIR} - ${STB_INCLUDE_DIR}) + ${STB_INCLUDE_DIR} + ${TEXTFLOWCPP_INCLUDE_DIR}) target_include_directories(supercell-wx PUBLIC ${scwx-qt_SOURCE_DIR}/source) diff --git a/scwx-qt/source/scwx/qt/util/imgui.cpp b/scwx-qt/source/scwx/qt/util/imgui.cpp index 9d1622ed..018e5000 100644 --- a/scwx-qt/source/scwx/qt/util/imgui.cpp +++ b/scwx-qt/source/scwx/qt/util/imgui.cpp @@ -5,6 +5,7 @@ #include +#include #include namespace scwx @@ -85,11 +86,16 @@ void ImGui::Impl::UpdateMonospaceFont() void ImGui::DrawTooltip(const std::string& hoverText) { + static constexpr std::size_t kDefaultWidth = 80u; + p->Initialize(); + auto wrappedText = + TextFlow::Column(hoverText).width(kDefaultWidth).toString(); + ::ImGui::BeginTooltip(); ::ImGui::PushFont(p->monospaceFont_); - ::ImGui::TextUnformatted(hoverText.c_str()); + ::ImGui::TextUnformatted(wrappedText.c_str()); ::ImGui::PopFont(); ::ImGui::EndTooltip(); }