mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 06:20:06 +00:00 
			
		
		
		
	Refactor tooltip display
This commit is contained in:
		
							parent
							
								
									9ebc859756
								
							
						
					
					
						commit
						0badf01a92
					
				
					 8 changed files with 87 additions and 28 deletions
				
			
		
							
								
								
									
										42
									
								
								scwx-qt/source/scwx/qt/util/tooltip.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								scwx-qt/source/scwx/qt/util/tooltip.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,42 @@ | |||
| #include <scwx/qt/util/tooltip.hpp> | ||||
| #include <scwx/qt/settings/text_settings.hpp> | ||||
| #include <scwx/qt/util/imgui.hpp> | ||||
| 
 | ||||
| #include <TextFlow.hpp> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace qt | ||||
| { | ||||
| namespace util | ||||
| { | ||||
| namespace tooltip | ||||
| { | ||||
| 
 | ||||
| static const std::string logPrefix_ = "scwx::qt::util::tooltip"; | ||||
| 
 | ||||
| void Show(const std::string& text, const QPointF& /* mouseGlobalPos */) | ||||
| { | ||||
|    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(text).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 : text; | ||||
| 
 | ||||
|    util::ImGui::Instance().DrawTooltip(displayText); | ||||
| } | ||||
| 
 | ||||
| void Hide() {} | ||||
| 
 | ||||
| } // namespace tooltip
 | ||||
| } // namespace util
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat