mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-29 23:10:06 +00:00 
			
		
		
		
	Address ImGui clang-tidy comments, store font size as float
This commit is contained in:
		
							parent
							
								
									c82b9753c6
								
							
						
					
					
						commit
						ffe1e7efaf
					
				
					 5 changed files with 20 additions and 16 deletions
				
			
		|  | @ -62,10 +62,10 @@ public: | |||
|    std::vector<std::shared_ptr<const gr::Placefile::TextDrawItem>> newList_ {}; | ||||
| 
 | ||||
|    std::vector<std::pair<std::shared_ptr<types::ImGuiFont>, | ||||
|                          units::font_size::pixels<int>>> | ||||
|                          units::font_size::pixels<float>>> | ||||
|       fonts_ {}; | ||||
|    std::vector<std::pair<std::shared_ptr<types::ImGuiFont>, | ||||
|                          units::font_size::pixels<int>>> | ||||
|                          units::font_size::pixels<float>>> | ||||
|       newFonts_ {}; | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -84,11 +84,11 @@ public: | |||
|    boost::unordered_flat_map<std::string, std::vector<char>> rawFontData_ {}; | ||||
|    std::mutex rawFontDataMutex_ {}; | ||||
| 
 | ||||
|    std::pair<std::shared_ptr<types::ImGuiFont>, units::font_size::pixels<int>> | ||||
|    std::pair<std::shared_ptr<types::ImGuiFont>, units::font_size::pixels<float>> | ||||
|       defaultFont_ {}; | ||||
|    boost::unordered_flat_map<types::FontCategory, | ||||
|                              std::pair<std::shared_ptr<types::ImGuiFont>, | ||||
|                                        units::font_size::pixels<int>>> | ||||
|                                        units::font_size::pixels<float>>> | ||||
|       fontCategoryImguiFontMap_ {}; | ||||
|    boost::unordered_flat_map<types::FontCategory, QFont> | ||||
|               fontCategoryQFontMap_ {}; | ||||
|  | @ -160,13 +160,18 @@ void FontManager::InitializeFonts() | |||
|    } | ||||
| } | ||||
| 
 | ||||
| units::font_size::pixels<int> | ||||
| units::font_size::pixels<float> | ||||
| FontManager::ImFontSize(units::font_size::pixels<double> size) | ||||
| { | ||||
|    static constexpr units::font_size::pixels<int> kMinFontSize_ {8}; | ||||
|    static constexpr units::font_size::pixels<int> kMaxFontSize_ {96}; | ||||
| 
 | ||||
|    // Only allow whole pixels, and clamp to 6-72 pt
 | ||||
|    units::font_size::pixels<double> pixels {size}; | ||||
|    units::font_size::pixels<int>    imFontSize { | ||||
|       std::clamp(static_cast<int>(pixels.value()), 8, 96)}; | ||||
|    const units::font_size::pixels<double> pixels {size}; | ||||
|    const units::font_size::pixels<int>    imFontSize { | ||||
|       std::clamp(static_cast<int>(pixels.value()), | ||||
|                  kMinFontSize_.value(), | ||||
|                  kMaxFontSize_.value())}; | ||||
| 
 | ||||
|    return imFontSize; | ||||
| } | ||||
|  | @ -223,7 +228,7 @@ int FontManager::GetFontId(types::Font font) const | |||
|    return -1; | ||||
| } | ||||
| 
 | ||||
| std::pair<std::shared_ptr<types::ImGuiFont>, units::font_size::pixels<int>> | ||||
| std::pair<std::shared_ptr<types::ImGuiFont>, units::font_size::pixels<float>> | ||||
| FontManager::GetImGuiFont(types::FontCategory fontCategory) | ||||
| { | ||||
|    std::unique_lock lock {p->fontCategoryMutex_}; | ||||
|  |  | |||
|  | @ -28,7 +28,7 @@ public: | |||
|    std::shared_mutex& imgui_font_atlas_mutex(); | ||||
| 
 | ||||
|    int GetFontId(types::Font font) const; | ||||
|    std::pair<std::shared_ptr<types::ImGuiFont>, units::font_size::pixels<int>> | ||||
|    std::pair<std::shared_ptr<types::ImGuiFont>, units::font_size::pixels<float>> | ||||
|          GetImGuiFont(types::FontCategory fontCategory); | ||||
|    QFont GetQFont(types::FontCategory fontCategory); | ||||
|    std::shared_ptr<types::ImGuiFont> | ||||
|  | @ -39,7 +39,7 @@ public: | |||
|    void LoadApplicationFont(types::Font font, const std::string& filename); | ||||
|    void InitializeFonts(); | ||||
| 
 | ||||
|    static units::font_size::pixels<int> | ||||
|    static units::font_size::pixels<float> | ||||
|    ImFontSize(units::font_size::pixels<double> size); | ||||
| 
 | ||||
|    static FontManager& Instance(); | ||||
|  |  | |||
|  | @ -26,7 +26,7 @@ public: | |||
|    using FontMap = | ||||
|       boost::unordered_flat_map<std::size_t, | ||||
|                                 std::pair<std::shared_ptr<types::ImGuiFont>, | ||||
|                                           units::font_size::pixels<int>>>; | ||||
|                                           units::font_size::pixels<float>>>; | ||||
| 
 | ||||
|    bool        placefile_enabled(const std::string& name); | ||||
|    bool        placefile_thresholded(const std::string& name); | ||||
|  |  | |||
|  | @ -23,9 +23,8 @@ static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | |||
| class ImGuiFont::Impl | ||||
| { | ||||
| public: | ||||
|    explicit Impl(const std::string&       fontName, | ||||
|                  const std::vector<char>& fontData) : | ||||
|        fontName_ {fontName} | ||||
|    explicit Impl(std::string fontName, const std::vector<char>& fontData) : | ||||
|        fontName_ {std::move(fontName)} | ||||
|    { | ||||
|       CreateImGuiFont(fontData); | ||||
|    } | ||||
|  | @ -34,7 +33,7 @@ public: | |||
| 
 | ||||
|    void CreateImGuiFont(const std::vector<char>& fontData); | ||||
| 
 | ||||
|    const std::string fontName_; | ||||
|    std::string fontName_; | ||||
| 
 | ||||
|    ImFont* imFont_ {nullptr}; | ||||
| }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat