mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 03:30:06 +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
									
								
								scwx-qt/res/icons/font-awesome-6/font-solid.svg
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								scwx-qt/res/icons/font-awesome-6/font-solid.svg
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | ||||||
|  | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.4.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M254 52.8C249.3 40.3 237.3 32 224 32s-25.3 8.3-30 20.8L57.8 416H32c-17.7 0-32 14.3-32 32s14.3 32 32 32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32h-1.8l18-48H303.8l18 48H320c-17.7 0-32 14.3-32 32s14.3 32 32 32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32H390.2L254 52.8zM279.8 304H168.2L224 155.1 279.8 304z"/></svg> | ||||||
| After Width: | Height: | Size: 544 B | 
|  | @ -137,6 +137,7 @@ set(HDR_SETTINGS source/scwx/qt/settings/general_settings.hpp | ||||||
|                  source/scwx/qt/settings/settings_interface_base.hpp |                  source/scwx/qt/settings/settings_interface_base.hpp | ||||||
|                  source/scwx/qt/settings/settings_variable.hpp |                  source/scwx/qt/settings/settings_variable.hpp | ||||||
|                  source/scwx/qt/settings/settings_variable_base.hpp |                  source/scwx/qt/settings/settings_variable_base.hpp | ||||||
|  |                  source/scwx/qt/settings/text_settings.hpp | ||||||
|                  source/scwx/qt/settings/ui_settings.hpp) |                  source/scwx/qt/settings/ui_settings.hpp) | ||||||
| set(SRC_SETTINGS source/scwx/qt/settings/general_settings.cpp | set(SRC_SETTINGS source/scwx/qt/settings/general_settings.cpp | ||||||
|                  source/scwx/qt/settings/map_settings.cpp |                  source/scwx/qt/settings/map_settings.cpp | ||||||
|  | @ -147,6 +148,7 @@ set(SRC_SETTINGS source/scwx/qt/settings/general_settings.cpp | ||||||
|                  source/scwx/qt/settings/settings_interface_base.cpp |                  source/scwx/qt/settings/settings_interface_base.cpp | ||||||
|                  source/scwx/qt/settings/settings_variable.cpp |                  source/scwx/qt/settings/settings_variable.cpp | ||||||
|                  source/scwx/qt/settings/settings_variable_base.cpp |                  source/scwx/qt/settings/settings_variable_base.cpp | ||||||
|  |                  source/scwx/qt/settings/text_settings.cpp | ||||||
|                  source/scwx/qt/settings/ui_settings.cpp) |                  source/scwx/qt/settings/ui_settings.cpp) | ||||||
| set(HDR_TYPES source/scwx/qt/types/alert_types.hpp | set(HDR_TYPES source/scwx/qt/types/alert_types.hpp | ||||||
|               source/scwx/qt/types/font_types.hpp |               source/scwx/qt/types/font_types.hpp | ||||||
|  |  | ||||||
|  | @ -25,6 +25,7 @@ | ||||||
|         <file>res/icons/font-awesome-6/book-solid.svg</file> |         <file>res/icons/font-awesome-6/book-solid.svg</file> | ||||||
|         <file>res/icons/font-awesome-6/discord.svg</file> |         <file>res/icons/font-awesome-6/discord.svg</file> | ||||||
|         <file>res/icons/font-awesome-6/earth-americas-solid.svg</file> |         <file>res/icons/font-awesome-6/earth-americas-solid.svg</file> | ||||||
|  |         <file>res/icons/font-awesome-6/font-solid.svg</file> | ||||||
|         <file>res/icons/font-awesome-6/forward-step-solid.svg</file> |         <file>res/icons/font-awesome-6/forward-step-solid.svg</file> | ||||||
|         <file>res/icons/font-awesome-6/gears-solid.svg</file> |         <file>res/icons/font-awesome-6/gears-solid.svg</file> | ||||||
|         <file>res/icons/font-awesome-6/github.svg</file> |         <file>res/icons/font-awesome-6/github.svg</file> | ||||||
|  |  | ||||||
|  | @ -1,5 +1,6 @@ | ||||||
| #include <scwx/qt/manager/settings_manager.hpp> | #include <scwx/qt/manager/settings_manager.hpp> | ||||||
| #include <scwx/qt/map/map_provider.hpp> | #include <scwx/qt/map/map_provider.hpp> | ||||||
|  | #include <scwx/qt/settings/text_settings.hpp> | ||||||
| #include <scwx/qt/settings/ui_settings.hpp> | #include <scwx/qt/settings/ui_settings.hpp> | ||||||
| #include <scwx/qt/util/json.hpp> | #include <scwx/qt/util/json.hpp> | ||||||
| #include <scwx/util/logger.hpp> | #include <scwx/util/logger.hpp> | ||||||
|  | @ -130,6 +131,7 @@ static boost::json::value ConvertSettingsToJson() | ||||||
|    general_settings().WriteJson(settingsJson); |    general_settings().WriteJson(settingsJson); | ||||||
|    map_settings().WriteJson(settingsJson); |    map_settings().WriteJson(settingsJson); | ||||||
|    palette_settings().WriteJson(settingsJson); |    palette_settings().WriteJson(settingsJson); | ||||||
|  |    settings::TextSettings::Instance().WriteJson(settingsJson); | ||||||
|    settings::UiSettings::Instance().WriteJson(settingsJson); |    settings::UiSettings::Instance().WriteJson(settingsJson); | ||||||
| 
 | 
 | ||||||
|    return settingsJson; |    return settingsJson; | ||||||
|  | @ -142,6 +144,7 @@ static void GenerateDefaultSettings() | ||||||
|    general_settings().SetDefaults(); |    general_settings().SetDefaults(); | ||||||
|    map_settings().SetDefaults(); |    map_settings().SetDefaults(); | ||||||
|    palette_settings().SetDefaults(); |    palette_settings().SetDefaults(); | ||||||
|  |    settings::TextSettings::Instance().SetDefaults(); | ||||||
|    settings::UiSettings::Instance().SetDefaults(); |    settings::UiSettings::Instance().SetDefaults(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -154,6 +157,7 @@ static bool LoadSettings(const boost::json::object& settingsJson) | ||||||
|    jsonDirty |= !general_settings().ReadJson(settingsJson); |    jsonDirty |= !general_settings().ReadJson(settingsJson); | ||||||
|    jsonDirty |= !map_settings().ReadJson(settingsJson); |    jsonDirty |= !map_settings().ReadJson(settingsJson); | ||||||
|    jsonDirty |= !palette_settings().ReadJson(settingsJson); |    jsonDirty |= !palette_settings().ReadJson(settingsJson); | ||||||
|  |    jsonDirty |= !settings::TextSettings::Instance().ReadJson(settingsJson); | ||||||
|    jsonDirty |= !settings::UiSettings::Instance().ReadJson(settingsJson); |    jsonDirty |= !settings::UiSettings::Instance().ReadJson(settingsJson); | ||||||
| 
 | 
 | ||||||
|    return jsonDirty; |    return jsonDirty; | ||||||
|  |  | ||||||
							
								
								
									
										56
									
								
								scwx-qt/source/scwx/qt/settings/text_settings.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								scwx-qt/source/scwx/qt/settings/text_settings.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,56 @@ | ||||||
|  | #include <scwx/qt/settings/text_settings.hpp> | ||||||
|  | 
 | ||||||
|  | namespace scwx | ||||||
|  | { | ||||||
|  | namespace qt | ||||||
|  | { | ||||||
|  | namespace settings | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | static const std::string logPrefix_ = "scwx::qt::settings::text_settings"; | ||||||
|  | 
 | ||||||
|  | class TextSettings::Impl | ||||||
|  | { | ||||||
|  | public: | ||||||
|  |    explicit Impl() | ||||||
|  |    { | ||||||
|  |       hoverTextWrap_.SetDefault(80); | ||||||
|  |       hoverTextWrap_.SetMinimum(0); | ||||||
|  |       hoverTextWrap_.SetMaximum(999); | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    ~Impl() {} | ||||||
|  | 
 | ||||||
|  |    SettingsVariable<std::int64_t> hoverTextWrap_ {"hover_text_wrap"}; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | TextSettings::TextSettings() : | ||||||
|  |     SettingsCategory("text"), p(std::make_unique<Impl>()) | ||||||
|  | { | ||||||
|  |    RegisterVariables({&p->hoverTextWrap_}); | ||||||
|  |    SetDefaults(); | ||||||
|  | } | ||||||
|  | TextSettings::~TextSettings() = default; | ||||||
|  | 
 | ||||||
|  | TextSettings::TextSettings(TextSettings&&) noexcept            = default; | ||||||
|  | TextSettings& TextSettings::operator=(TextSettings&&) noexcept = default; | ||||||
|  | 
 | ||||||
|  | SettingsVariable<std::int64_t>& TextSettings::hover_text_wrap() const | ||||||
|  | { | ||||||
|  |    return p->hoverTextWrap_; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | TextSettings& TextSettings::Instance() | ||||||
|  | { | ||||||
|  |    static TextSettings TextSettings_; | ||||||
|  |    return TextSettings_; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | bool operator==(const TextSettings& lhs, const TextSettings& rhs) | ||||||
|  | { | ||||||
|  |    return (lhs.p->hoverTextWrap_ == rhs.p->hoverTextWrap_); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | } // namespace settings
 | ||||||
|  | } // namespace qt
 | ||||||
|  | } // namespace scwx
 | ||||||
							
								
								
									
										42
									
								
								scwx-qt/source/scwx/qt/settings/text_settings.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								scwx-qt/source/scwx/qt/settings/text_settings.hpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,42 @@ | ||||||
|  | #pragma once | ||||||
|  | 
 | ||||||
|  | #include <scwx/qt/settings/settings_category.hpp> | ||||||
|  | #include <scwx/qt/settings/settings_variable.hpp> | ||||||
|  | 
 | ||||||
|  | #include <memory> | ||||||
|  | #include <string> | ||||||
|  | 
 | ||||||
|  | namespace scwx | ||||||
|  | { | ||||||
|  | namespace qt | ||||||
|  | { | ||||||
|  | namespace settings | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | class TextSettings : public SettingsCategory | ||||||
|  | { | ||||||
|  | public: | ||||||
|  |    explicit TextSettings(); | ||||||
|  |    ~TextSettings(); | ||||||
|  | 
 | ||||||
|  |    TextSettings(const TextSettings&)            = delete; | ||||||
|  |    TextSettings& operator=(const TextSettings&) = delete; | ||||||
|  | 
 | ||||||
|  |    TextSettings(TextSettings&&) noexcept; | ||||||
|  |    TextSettings& operator=(TextSettings&&) noexcept; | ||||||
|  | 
 | ||||||
|  |    SettingsVariable<std::int64_t>& hover_text_wrap() const; | ||||||
|  | 
 | ||||||
|  |    static TextSettings& Instance(); | ||||||
|  | 
 | ||||||
|  |    friend bool operator==(const TextSettings& lhs, const TextSettings& rhs); | ||||||
|  | 
 | ||||||
|  | private: | ||||||
|  |    class Impl; | ||||||
|  | 
 | ||||||
|  |    std::unique_ptr<Impl> p; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | } // namespace settings
 | ||||||
|  | } // namespace qt
 | ||||||
|  | } // namespace scwx
 | ||||||
|  | @ -7,6 +7,7 @@ | ||||||
| #include <scwx/qt/manager/settings_manager.hpp> | #include <scwx/qt/manager/settings_manager.hpp> | ||||||
| #include <scwx/qt/map/map_provider.hpp> | #include <scwx/qt/map/map_provider.hpp> | ||||||
| #include <scwx/qt/settings/settings_interface.hpp> | #include <scwx/qt/settings/settings_interface.hpp> | ||||||
|  | #include <scwx/qt/settings/text_settings.hpp> | ||||||
| #include <scwx/qt/types/alert_types.hpp> | #include <scwx/qt/types/alert_types.hpp> | ||||||
| #include <scwx/qt/ui/placefile_settings_widget.hpp> | #include <scwx/qt/ui/placefile_settings_widget.hpp> | ||||||
| #include <scwx/qt/ui/radar_site_dialog.hpp> | #include <scwx/qt/ui/radar_site_dialog.hpp> | ||||||
|  | @ -92,7 +93,8 @@ public: | ||||||
|           &mapTilerApiKey_, |           &mapTilerApiKey_, | ||||||
|           &defaultAlertAction_, |           &defaultAlertAction_, | ||||||
|           &updateNotificationsEnabled_, |           &updateNotificationsEnabled_, | ||||||
|           &debugEnabled_}} |           &debugEnabled_, | ||||||
|  |           &hoverTextWrap_}} | ||||||
|    { |    { | ||||||
|       // Configure default alert phenomena colors
 |       // Configure default alert phenomena colors
 | ||||||
|       auto& paletteSettings = manager::SettingsManager::palette_settings(); |       auto& paletteSettings = manager::SettingsManager::palette_settings(); | ||||||
|  | @ -117,6 +119,7 @@ public: | ||||||
|    void SetupPalettesColorTablesTab(); |    void SetupPalettesColorTablesTab(); | ||||||
|    void SetupPalettesAlertsTab(); |    void SetupPalettesAlertsTab(); | ||||||
|    void SetupPlacefilesTab(); |    void SetupPlacefilesTab(); | ||||||
|  |    void SetupTextTab(); | ||||||
| 
 | 
 | ||||||
|    void ShowColorDialog(QLineEdit* lineEdit, QFrame* frame = nullptr); |    void ShowColorDialog(QLineEdit* lineEdit, QFrame* frame = nullptr); | ||||||
|    void UpdateRadarDialogLocation(const std::string& id); |    void UpdateRadarDialogLocation(const std::string& id); | ||||||
|  | @ -139,7 +142,7 @@ public: | ||||||
|    static void SetBackgroundColor(const std::string& value, QFrame* frame); |    static void SetBackgroundColor(const std::string& value, QFrame* frame); | ||||||
| 
 | 
 | ||||||
|    SettingsDialog*          self_; |    SettingsDialog*          self_; | ||||||
|    PlacefileSettingsWidget* placefileSettingsWidget_; |    PlacefileSettingsWidget* placefileSettingsWidget_ {nullptr}; | ||||||
|    RadarSiteDialog*         radarSiteDialog_; |    RadarSiteDialog*         radarSiteDialog_; | ||||||
| 
 | 
 | ||||||
|    settings::SettingsInterface<std::string>               defaultRadarSite_ {}; |    settings::SettingsInterface<std::string>               defaultRadarSite_ {}; | ||||||
|  | @ -162,6 +165,8 @@ public: | ||||||
|                       settings::SettingsInterface<std::string>> |                       settings::SettingsInterface<std::string>> | ||||||
|       inactiveAlertColors_ {}; |       inactiveAlertColors_ {}; | ||||||
| 
 | 
 | ||||||
|  |    settings::SettingsInterface<std::int64_t> hoverTextWrap_ {}; | ||||||
|  | 
 | ||||||
|    std::vector<settings::SettingsInterfaceBase*> settings_; |    std::vector<settings::SettingsInterfaceBase*> settings_; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | @ -181,6 +186,9 @@ SettingsDialog::SettingsDialog(QWidget* parent) : | ||||||
|    // Palettes > Alerts
 |    // Palettes > Alerts
 | ||||||
|    p->SetupPalettesAlertsTab(); |    p->SetupPalettesAlertsTab(); | ||||||
| 
 | 
 | ||||||
|  |    // Text
 | ||||||
|  |    p->SetupTextTab(); | ||||||
|  | 
 | ||||||
|    // Placefiles
 |    // Placefiles
 | ||||||
|    p->SetupPlacefilesTab(); |    p->SetupPlacefilesTab(); | ||||||
| 
 | 
 | ||||||
|  | @ -630,6 +638,15 @@ void SettingsDialogImpl::SetupPlacefilesTab() | ||||||
|    self_->ui->placefiles->layout()->addWidget(placefileSettingsWidget_); |    self_->ui->placefiles->layout()->addWidget(placefileSettingsWidget_); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void SettingsDialogImpl::SetupTextTab() | ||||||
|  | { | ||||||
|  |    settings::TextSettings& textSettings = settings::TextSettings::Instance(); | ||||||
|  | 
 | ||||||
|  |    hoverTextWrap_.SetSettingsVariable(textSettings.hover_text_wrap()); | ||||||
|  |    hoverTextWrap_.SetEditWidget(self_->ui->hoverTextWrapSpinBox); | ||||||
|  |    hoverTextWrap_.SetResetButton(self_->ui->resetHoverTextWrapButton); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| QImage SettingsDialogImpl::GenerateColorTableImage( | QImage SettingsDialogImpl::GenerateColorTableImage( | ||||||
|    std::shared_ptr<common::ColorTable> colorTable, |    std::shared_ptr<common::ColorTable> colorTable, | ||||||
|    std::uint16_t                       min, |    std::uint16_t                       min, | ||||||
|  |  | ||||||
|  | @ -73,6 +73,15 @@ | ||||||
|            <normaloff>:/res/icons/font-awesome-6/palette-solid.svg</normaloff>:/res/icons/font-awesome-6/palette-solid.svg</iconset> |            <normaloff>:/res/icons/font-awesome-6/palette-solid.svg</normaloff>:/res/icons/font-awesome-6/palette-solid.svg</iconset> | ||||||
|          </property> |          </property> | ||||||
|         </item> |         </item> | ||||||
|  |         <item> | ||||||
|  |          <property name="text"> | ||||||
|  |           <string>Text</string> | ||||||
|  |          </property> | ||||||
|  |          <property name="icon"> | ||||||
|  |           <iconset resource="../../../../scwx-qt.qrc"> | ||||||
|  |            <normaloff>:/res/icons/font-awesome-6/font-solid.svg</normaloff>:/res/icons/font-awesome-6/font-solid.svg</iconset> | ||||||
|  |          </property> | ||||||
|  |         </item> | ||||||
|         <item> |         <item> | ||||||
|          <property name="text"> |          <property name="text"> | ||||||
|           <string>Placefiles</string> |           <string>Placefiles</string> | ||||||
|  | @ -355,8 +364,8 @@ | ||||||
|                   <rect> |                   <rect> | ||||||
|                    <x>0</x> |                    <x>0</x> | ||||||
|                    <y>0</y> |                    <y>0</y> | ||||||
|                    <width>66</width> |                    <width>481</width> | ||||||
|                    <height>18</height> |                    <height>382</height> | ||||||
|                   </rect> |                   </rect> | ||||||
|                  </property> |                  </property> | ||||||
|                  <layout class="QGridLayout" name="gridLayout_3"> |                  <layout class="QGridLayout" name="gridLayout_3"> | ||||||
|  | @ -427,6 +436,72 @@ | ||||||
|           </item> |           </item> | ||||||
|          </layout> |          </layout> | ||||||
|         </widget> |         </widget> | ||||||
|  |         <widget class="QWidget" name="text"> | ||||||
|  |          <layout class="QVBoxLayout" name="verticalLayout_5"> | ||||||
|  |           <item> | ||||||
|  |            <widget class="QFrame" name="frame_3"> | ||||||
|  |             <property name="frameShape"> | ||||||
|  |              <enum>QFrame::StyledPanel</enum> | ||||||
|  |             </property> | ||||||
|  |             <property name="frameShadow"> | ||||||
|  |              <enum>QFrame::Raised</enum> | ||||||
|  |             </property> | ||||||
|  |             <layout class="QGridLayout" name="gridLayout_7"> | ||||||
|  |              <property name="leftMargin"> | ||||||
|  |               <number>0</number> | ||||||
|  |              </property> | ||||||
|  |              <property name="topMargin"> | ||||||
|  |               <number>0</number> | ||||||
|  |              </property> | ||||||
|  |              <property name="rightMargin"> | ||||||
|  |               <number>0</number> | ||||||
|  |              </property> | ||||||
|  |              <property name="bottomMargin"> | ||||||
|  |               <number>0</number> | ||||||
|  |              </property> | ||||||
|  |              <item row="0" column="0"> | ||||||
|  |               <widget class="QLabel" name="label_8"> | ||||||
|  |                <property name="text"> | ||||||
|  |                 <string>Hover text character wrap (0 to disable)</string> | ||||||
|  |                </property> | ||||||
|  |               </widget> | ||||||
|  |              </item> | ||||||
|  |              <item row="0" column="1"> | ||||||
|  |               <widget class="QSpinBox" name="hoverTextWrapSpinBox"> | ||||||
|  |                <property name="maximum"> | ||||||
|  |                 <number>999</number> | ||||||
|  |                </property> | ||||||
|  |               </widget> | ||||||
|  |              </item> | ||||||
|  |              <item row="0" column="2"> | ||||||
|  |               <widget class="QToolButton" name="resetHoverTextWrapButton"> | ||||||
|  |                <property name="text"> | ||||||
|  |                 <string>...</string> | ||||||
|  |                </property> | ||||||
|  |                <property name="icon"> | ||||||
|  |                 <iconset resource="../../../../scwx-qt.qrc"> | ||||||
|  |                  <normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset> | ||||||
|  |                </property> | ||||||
|  |               </widget> | ||||||
|  |              </item> | ||||||
|  |             </layout> | ||||||
|  |            </widget> | ||||||
|  |           </item> | ||||||
|  |           <item> | ||||||
|  |            <spacer name="verticalSpacer_4"> | ||||||
|  |             <property name="orientation"> | ||||||
|  |              <enum>Qt::Vertical</enum> | ||||||
|  |             </property> | ||||||
|  |             <property name="sizeHint" stdset="0"> | ||||||
|  |              <size> | ||||||
|  |               <width>20</width> | ||||||
|  |               <height>40</height> | ||||||
|  |              </size> | ||||||
|  |             </property> | ||||||
|  |            </spacer> | ||||||
|  |           </item> | ||||||
|  |          </layout> | ||||||
|  |         </widget> | ||||||
|         <widget class="QWidget" name="placefiles"> |         <widget class="QWidget" name="placefiles"> | ||||||
|          <layout class="QVBoxLayout" name="verticalLayout_4"> |          <layout class="QVBoxLayout" name="verticalLayout_4"> | ||||||
|           <property name="leftMargin"> |           <property name="leftMargin"> | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| #include <scwx/qt/util/imgui.hpp> | #include <scwx/qt/util/imgui.hpp> | ||||||
| #include <scwx/qt/manager/resource_manager.hpp> | #include <scwx/qt/manager/resource_manager.hpp> | ||||||
| #include <scwx/qt/manager/settings_manager.hpp> | #include <scwx/qt/manager/settings_manager.hpp> | ||||||
|  | #include <scwx/qt/settings/text_settings.hpp> | ||||||
| #include <scwx/util/logger.hpp> | #include <scwx/util/logger.hpp> | ||||||
| 
 | 
 | ||||||
| #include <mutex> | #include <mutex> | ||||||
|  | @ -86,16 +87,25 @@ void ImGui::Impl::UpdateMonospaceFont() | ||||||
| 
 | 
 | ||||||
| void ImGui::DrawTooltip(const std::string& hoverText) | void ImGui::DrawTooltip(const std::string& hoverText) | ||||||
| { | { | ||||||
|    static constexpr std::size_t kDefaultWidth = 80u; |  | ||||||
| 
 |  | ||||||
|    p->Initialize(); |    p->Initialize(); | ||||||
| 
 | 
 | ||||||
|    auto wrappedText = |    std::size_t textWidth = static_cast<std::size_t>( | ||||||
|       TextFlow::Column(hoverText).width(kDefaultWidth).toString(); |       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::BeginTooltip(); | ||||||
|    ::ImGui::PushFont(p->monospaceFont_); |    ::ImGui::PushFont(p->monospaceFont_); | ||||||
|    ::ImGui::TextUnformatted(wrappedText.c_str()); |    ::ImGui::TextUnformatted(displayText.c_str()); | ||||||
|    ::ImGui::PopFont(); |    ::ImGui::PopFont(); | ||||||
|    ::ImGui::EndTooltip(); |    ::ImGui::EndTooltip(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1 +1 @@ | ||||||
| Subproject commit a87219c010a26905fd893e68e17077144394b316 | Subproject commit 6d407be1b6f2e72490ef0d07da1e297994df8fe4 | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat