mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 02:40:05 +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::shared_ptr<const gr::Placefile::TextDrawItem>> newList_ {}; | ||||||
| 
 | 
 | ||||||
|    std::vector<std::pair<std::shared_ptr<types::ImGuiFont>, |    std::vector<std::pair<std::shared_ptr<types::ImGuiFont>, | ||||||
|                          units::font_size::pixels<int>>> |                          units::font_size::pixels<float>>> | ||||||
|       fonts_ {}; |       fonts_ {}; | ||||||
|    std::vector<std::pair<std::shared_ptr<types::ImGuiFont>, |    std::vector<std::pair<std::shared_ptr<types::ImGuiFont>, | ||||||
|                          units::font_size::pixels<int>>> |                          units::font_size::pixels<float>>> | ||||||
|       newFonts_ {}; |       newFonts_ {}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -84,11 +84,11 @@ public: | ||||||
|    boost::unordered_flat_map<std::string, std::vector<char>> rawFontData_ {}; |    boost::unordered_flat_map<std::string, std::vector<char>> rawFontData_ {}; | ||||||
|    std::mutex rawFontDataMutex_ {}; |    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_ {}; |       defaultFont_ {}; | ||||||
|    boost::unordered_flat_map<types::FontCategory, |    boost::unordered_flat_map<types::FontCategory, | ||||||
|                              std::pair<std::shared_ptr<types::ImGuiFont>, |                              std::pair<std::shared_ptr<types::ImGuiFont>, | ||||||
|                                        units::font_size::pixels<int>>> |                                        units::font_size::pixels<float>>> | ||||||
|       fontCategoryImguiFontMap_ {}; |       fontCategoryImguiFontMap_ {}; | ||||||
|    boost::unordered_flat_map<types::FontCategory, QFont> |    boost::unordered_flat_map<types::FontCategory, QFont> | ||||||
|               fontCategoryQFontMap_ {}; |               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) | 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
 |    // Only allow whole pixels, and clamp to 6-72 pt
 | ||||||
|    units::font_size::pixels<double> pixels {size}; |    const units::font_size::pixels<double> pixels {size}; | ||||||
|    units::font_size::pixels<int>    imFontSize { |    const units::font_size::pixels<int>    imFontSize { | ||||||
|       std::clamp(static_cast<int>(pixels.value()), 8, 96)}; |       std::clamp(static_cast<int>(pixels.value()), | ||||||
|  |                  kMinFontSize_.value(), | ||||||
|  |                  kMaxFontSize_.value())}; | ||||||
| 
 | 
 | ||||||
|    return imFontSize; |    return imFontSize; | ||||||
| } | } | ||||||
|  | @ -223,7 +228,7 @@ int FontManager::GetFontId(types::Font font) const | ||||||
|    return -1; |    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) | FontManager::GetImGuiFont(types::FontCategory fontCategory) | ||||||
| { | { | ||||||
|    std::unique_lock lock {p->fontCategoryMutex_}; |    std::unique_lock lock {p->fontCategoryMutex_}; | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ public: | ||||||
|    std::shared_mutex& imgui_font_atlas_mutex(); |    std::shared_mutex& imgui_font_atlas_mutex(); | ||||||
| 
 | 
 | ||||||
|    int GetFontId(types::Font font) const; |    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); |          GetImGuiFont(types::FontCategory fontCategory); | ||||||
|    QFont GetQFont(types::FontCategory fontCategory); |    QFont GetQFont(types::FontCategory fontCategory); | ||||||
|    std::shared_ptr<types::ImGuiFont> |    std::shared_ptr<types::ImGuiFont> | ||||||
|  | @ -39,7 +39,7 @@ public: | ||||||
|    void LoadApplicationFont(types::Font font, const std::string& filename); |    void LoadApplicationFont(types::Font font, const std::string& filename); | ||||||
|    void InitializeFonts(); |    void InitializeFonts(); | ||||||
| 
 | 
 | ||||||
|    static units::font_size::pixels<int> |    static units::font_size::pixels<float> | ||||||
|    ImFontSize(units::font_size::pixels<double> size); |    ImFontSize(units::font_size::pixels<double> size); | ||||||
| 
 | 
 | ||||||
|    static FontManager& Instance(); |    static FontManager& Instance(); | ||||||
|  |  | ||||||
|  | @ -26,7 +26,7 @@ public: | ||||||
|    using FontMap = |    using FontMap = | ||||||
|       boost::unordered_flat_map<std::size_t, |       boost::unordered_flat_map<std::size_t, | ||||||
|                                 std::pair<std::shared_ptr<types::ImGuiFont>, |                                 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_enabled(const std::string& name); | ||||||
|    bool        placefile_thresholded(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 | class ImGuiFont::Impl | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit Impl(const std::string&       fontName, |    explicit Impl(std::string fontName, const std::vector<char>& fontData) : | ||||||
|                  const std::vector<char>& fontData) : |        fontName_ {std::move(fontName)} | ||||||
|        fontName_ {fontName} |  | ||||||
|    { |    { | ||||||
|       CreateImGuiFont(fontData); |       CreateImGuiFont(fontData); | ||||||
|    } |    } | ||||||
|  | @ -34,7 +33,7 @@ public: | ||||||
| 
 | 
 | ||||||
|    void CreateImGuiFont(const std::vector<char>& fontData); |    void CreateImGuiFont(const std::vector<char>& fontData); | ||||||
| 
 | 
 | ||||||
|    const std::string fontName_; |    std::string fontName_; | ||||||
| 
 | 
 | ||||||
|    ImFont* imFont_ {nullptr}; |    ImFont* imFont_ {nullptr}; | ||||||
| }; | }; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat