mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:40:05 +00:00
Add hover text wrap to settings
This commit is contained in:
parent
fc6cdc729b
commit
f9e69d15e4
10 changed files with 218 additions and 10 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include <scwx/qt/util/imgui.hpp>
|
||||
#include <scwx/qt/manager/resource_manager.hpp>
|
||||
#include <scwx/qt/manager/settings_manager.hpp>
|
||||
#include <scwx/qt/settings/text_settings.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
|
||||
#include <mutex>
|
||||
|
|
@ -86,16 +87,25 @@ 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();
|
||||
std::size_t textWidth = static_cast<std::size_t>(
|
||||
settings::TextSettings::Instance().hover_text_wrap().GetValue());
|
||||
|
||||
// Wrap text if enabled
|
||||
std::string wrappedText {};
|
||||
if (textWidth > 0)
|
||||
{
|
||||
wrappedText = TextFlow::Column(hoverText).width(textWidth).toString();
|
||||
}
|
||||
|
||||
// Display text is either wrapped or unwrapped text (do this to avoid copy
|
||||
// when not wrapping)
|
||||
const std::string& displayText = (textWidth > 0) ? wrappedText : hoverText;
|
||||
|
||||
::ImGui::BeginTooltip();
|
||||
::ImGui::PushFont(p->monospaceFont_);
|
||||
::ImGui::TextUnformatted(wrappedText.c_str());
|
||||
::ImGui::TextUnformatted(displayText.c_str());
|
||||
::ImGui::PopFont();
|
||||
::ImGui::EndTooltip();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue