mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-30 23:50:05 +00:00 
			
		
		
		
	Merge pull request #500 from dpaulat/feature/imgui-v1.92.2b
Update ImGui to v1.92.2b
This commit is contained in:
		
						commit
						e69cf0064a
					
				
					 16 changed files with 124 additions and 191 deletions
				
			
		
							
								
								
									
										2
									
								
								external/imgui
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								external/imgui
									
										
									
									
										vendored
									
									
								
							|  | @ -1 +1 @@ | ||||||
| Subproject commit 993fa347495860ed44b83574254ef2a317d0c14f | Subproject commit 45acd5e0e82f4c954432533ae9985ff0e1aad6d5 | ||||||
|  | @ -1,6 +1,5 @@ | ||||||
| #include <scwx/qt/gl/draw/placefile_text.hpp> | #include <scwx/qt/gl/draw/placefile_text.hpp> | ||||||
| #include <scwx/qt/manager/font_manager.hpp> | #include <scwx/qt/manager/font_manager.hpp> | ||||||
| #include <scwx/qt/manager/placefile_manager.hpp> |  | ||||||
| #include <scwx/qt/settings/text_settings.hpp> | #include <scwx/qt/settings/text_settings.hpp> | ||||||
| #include <scwx/qt/util/maplibre.hpp> | #include <scwx/qt/util/maplibre.hpp> | ||||||
| #include <scwx/qt/util/tooltip.hpp> | #include <scwx/qt/util/tooltip.hpp> | ||||||
|  | @ -62,8 +61,12 @@ public: | ||||||
|    std::vector<std::shared_ptr<const gr::Placefile::TextDrawItem>> textList_ {}; |    std::vector<std::shared_ptr<const gr::Placefile::TextDrawItem>> textList_ {}; | ||||||
|    std::vector<std::shared_ptr<const gr::Placefile::TextDrawItem>> newList_ {}; |    std::vector<std::shared_ptr<const gr::Placefile::TextDrawItem>> newList_ {}; | ||||||
| 
 | 
 | ||||||
|    std::vector<std::shared_ptr<types::ImGuiFont>> fonts_ {}; |    std::vector<std::pair<std::shared_ptr<types::ImGuiFont>, | ||||||
|    std::vector<std::shared_ptr<types::ImGuiFont>> newFonts_ {}; |                          units::font_size::pixels<float>>> | ||||||
|  |       fonts_ {}; | ||||||
|  |    std::vector<std::pair<std::shared_ptr<types::ImGuiFont>, | ||||||
|  |                          units::font_size::pixels<float>>> | ||||||
|  |       newFonts_ {}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| PlacefileText::PlacefileText(const std::string& placefileName) : | PlacefileText::PlacefileText(const std::string& placefileName) : | ||||||
|  | @ -159,7 +162,8 @@ void PlacefileText::Impl::RenderTextDrawItem( | ||||||
|       std::size_t fontNumber = std::clamp<std::size_t>(di->fontNumber_, 0, 8); |       std::size_t fontNumber = std::clamp<std::size_t>(di->fontNumber_, 0, 8); | ||||||
| 
 | 
 | ||||||
|       // Set the font for the drop shadow and text
 |       // Set the font for the drop shadow and text
 | ||||||
|       ImGui::PushFont(fonts_[fontNumber]->font()); |       ImGui::PushFont(fonts_[fontNumber].first->font(), | ||||||
|  |                       fonts_[fontNumber].second.value()); | ||||||
| 
 | 
 | ||||||
|       if (settings::TextSettings::Instance() |       if (settings::TextSettings::Instance() | ||||||
|              .placefile_text_drop_shadow_enabled() |              .placefile_text_drop_shadow_enabled() | ||||||
|  | @ -261,9 +265,7 @@ void PlacefileText::StartText() | ||||||
|    p->newList_.clear(); |    p->newList_.clear(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void PlacefileText::SetFonts( | void PlacefileText::SetFonts(const manager::PlacefileManager::FontMap& fonts) | ||||||
|    const boost::unordered_flat_map<std::size_t, |  | ||||||
|                                    std::shared_ptr<types::ImGuiFont>>& fonts) |  | ||||||
| { | { | ||||||
|    auto defaultFont = manager::FontManager::Instance().GetImGuiFont( |    auto defaultFont = manager::FontManager::Instance().GetImGuiFont( | ||||||
|       types::FontCategory::Default); |       types::FontCategory::Default); | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <scwx/qt/gl/gl_context.hpp> | #include <scwx/qt/gl/gl_context.hpp> | ||||||
| #include <scwx/qt/gl/draw/draw_item.hpp> | #include <scwx/qt/gl/draw/draw_item.hpp> | ||||||
|  | #include <scwx/qt/manager/placefile_manager.hpp> | ||||||
| #include <scwx/qt/types/imgui_font.hpp> | #include <scwx/qt/types/imgui_font.hpp> | ||||||
| #include <scwx/gr/placefile.hpp> | #include <scwx/gr/placefile.hpp> | ||||||
| 
 | 
 | ||||||
|  | @ -54,10 +55,7 @@ public: | ||||||
|     * |     * | ||||||
|     * @param [in] fonts A map of ImGui fonts |     * @param [in] fonts A map of ImGui fonts | ||||||
|     */ |     */ | ||||||
|    void |    void SetFonts(const manager::PlacefileManager::FontMap& fonts); | ||||||
|    SetFonts(const boost::unordered_flat_map<std::size_t, |  | ||||||
|                                             std::shared_ptr<types::ImGuiFont>>& |  | ||||||
|                fonts); |  | ||||||
| 
 | 
 | ||||||
|    /**
 |    /**
 | ||||||
|     * Adds placefile text to the internal draw list. |     * Adds placefile text to the internal draw list. | ||||||
|  |  | ||||||
|  | @ -18,11 +18,7 @@ | ||||||
| #include <fmt/ranges.h> | #include <fmt/ranges.h> | ||||||
| #include <fontconfig/fontconfig.h> | #include <fontconfig/fontconfig.h> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::manager | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace manager |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| static const std::string logPrefix_ = "scwx::qt::manager::font_manager"; | static const std::string logPrefix_ = "scwx::qt::manager::font_manager"; | ||||||
|  | @ -38,15 +34,13 @@ struct FontRecord | ||||||
|    std::string filename_ {}; |    std::string filename_ {}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| typedef std::pair<FontRecord, units::font_size::pixels<int>> FontRecordPair; |  | ||||||
| 
 |  | ||||||
| template<class Key> | template<class Key> | ||||||
| struct FontRecordHash; | struct FontRecordHash; | ||||||
| 
 | 
 | ||||||
| template<> | template<> | ||||||
| struct FontRecordHash<FontRecordPair> | struct FontRecordHash<FontRecord> | ||||||
| { | { | ||||||
|    size_t operator()(const FontRecordPair& x) const; |    size_t operator()(const FontRecord& x) const; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| class FontManager::Impl | class FontManager::Impl | ||||||
|  | @ -81,20 +75,20 @@ public: | ||||||
| 
 | 
 | ||||||
|    std::shared_mutex imguiFontAtlasMutex_ {}; |    std::shared_mutex imguiFontAtlasMutex_ {}; | ||||||
| 
 | 
 | ||||||
|    std::uint64_t imguiFontsBuildCount_ {}; |    boost::unordered_flat_map<FontRecord, | ||||||
| 
 |  | ||||||
|    boost::unordered_flat_map<FontRecordPair, |  | ||||||
|                              std::shared_ptr<types::ImGuiFont>, |                              std::shared_ptr<types::ImGuiFont>, | ||||||
|                              FontRecordHash<FontRecordPair>> |                              FontRecordHash<FontRecord>> | ||||||
|                      imguiFonts_ {}; |                      imguiFonts_ {}; | ||||||
|    std::shared_mutex imguiFontsMutex_ {}; |    std::shared_mutex imguiFontsMutex_ {}; | ||||||
| 
 | 
 | ||||||
|    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::shared_ptr<types::ImGuiFont> defaultFont_ {}; |    std::pair<std::shared_ptr<types::ImGuiFont>, units::font_size::pixels<float>> | ||||||
|  |       defaultFont_ {}; | ||||||
|    boost::unordered_flat_map<types::FontCategory, |    boost::unordered_flat_map<types::FontCategory, | ||||||
|                              std::shared_ptr<types::ImGuiFont>> |                              std::pair<std::shared_ptr<types::ImGuiFont>, | ||||||
|  |                                        units::font_size::pixels<float>>> | ||||||
|       fontCategoryImguiFontMap_ {}; |       fontCategoryImguiFontMap_ {}; | ||||||
|    boost::unordered_flat_map<types::FontCategory, QFont> |    boost::unordered_flat_map<types::FontCategory, QFont> | ||||||
|               fontCategoryQFontMap_ {}; |               fontCategoryQFontMap_ {}; | ||||||
|  | @ -166,6 +160,22 @@ void FontManager::InitializeFonts() | ||||||
|    } |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | 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
 | ||||||
|  |    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; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void FontManager::Impl::UpdateImGuiFont(types::FontCategory fontCategory) | void FontManager::Impl::UpdateImGuiFont(types::FontCategory fontCategory) | ||||||
| { | { | ||||||
|    auto& textSettings = settings::TextSettings::Instance(); |    auto& textSettings = settings::TextSettings::Instance(); | ||||||
|  | @ -176,7 +186,8 @@ void FontManager::Impl::UpdateImGuiFont(types::FontCategory fontCategory) | ||||||
|       textSettings.font_point_size(fontCategory).GetValue()}; |       textSettings.font_point_size(fontCategory).GetValue()}; | ||||||
| 
 | 
 | ||||||
|    fontCategoryImguiFontMap_.insert_or_assign( |    fontCategoryImguiFontMap_.insert_or_assign( | ||||||
|       fontCategory, self_->LoadImGuiFont(family, {styles}, size)); |       fontCategory, | ||||||
|  |       std::make_pair(self_->LoadImGuiFont(family, {styles}), ImFontSize(size))); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void FontManager::Impl::UpdateQFont(types::FontCategory fontCategory) | void FontManager::Impl::UpdateQFont(types::FontCategory fontCategory) | ||||||
|  | @ -207,11 +218,6 @@ std::shared_mutex& FontManager::imgui_font_atlas_mutex() | ||||||
|    return p->imguiFontAtlasMutex_; |    return p->imguiFontAtlasMutex_; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::uint64_t FontManager::imgui_fonts_build_count() const |  | ||||||
| { |  | ||||||
|    return p->imguiFontsBuildCount_; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int FontManager::GetFontId(types::Font font) const | int FontManager::GetFontId(types::Font font) const | ||||||
| { | { | ||||||
|    auto it = p->fontIds_.find(font); |    auto it = p->fontIds_.find(font); | ||||||
|  | @ -222,7 +228,7 @@ int FontManager::GetFontId(types::Font font) const | ||||||
|    return -1; |    return -1; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::shared_ptr<types::ImGuiFont> | 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_}; | ||||||
|  | @ -252,29 +258,21 @@ QFont FontManager::GetQFont(types::FontCategory fontCategory) | ||||||
| std::shared_ptr<types::ImGuiFont> | std::shared_ptr<types::ImGuiFont> | ||||||
| FontManager::LoadImGuiFont(const std::string&              family, | FontManager::LoadImGuiFont(const std::string&              family, | ||||||
|                            const std::vector<std::string>& styles, |                            const std::vector<std::string>& styles, | ||||||
|                            units::font_size::points<double> size, |  | ||||||
|                            bool                            loadIfNotFound) |                            bool                            loadIfNotFound) | ||||||
| { | { | ||||||
|    const std::string styleString = fmt::format("{}", fmt::join(styles, " ")); |    const std::string styleString = fmt::format("{}", fmt::join(styles, " ")); | ||||||
|    const std::string fontString = |    const std::string fontString  = fmt::format("{}:{}", family, styleString); | ||||||
|       fmt::format("{}-{}:{}", family, size.value(), styleString); |  | ||||||
| 
 | 
 | ||||||
|    logger_->debug("LoadFontResource: {}", fontString); |    logger_->debug("LoadFontResource: {}", fontString); | ||||||
| 
 | 
 | ||||||
|    FontRecord fontRecord = Impl::MatchFontFile(family, styles); |    FontRecord fontRecord = Impl::MatchFontFile(family, styles); | ||||||
| 
 | 
 | ||||||
|    // 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)}; |  | ||||||
|    auto imguiFontKey = std::make_pair(fontRecord, imFontSize); |  | ||||||
| 
 |  | ||||||
|    // Search for a loaded ImGui font
 |    // Search for a loaded ImGui font
 | ||||||
|    { |    { | ||||||
|       std::shared_lock imguiFontLock {p->imguiFontsMutex_}; |       std::shared_lock imguiFontLock {p->imguiFontsMutex_}; | ||||||
| 
 | 
 | ||||||
|       // Search for the associated ImGui font
 |       // Search for the associated ImGui font
 | ||||||
|       auto it = p->imguiFonts_.find(imguiFontKey); |       auto it = p->imguiFonts_.find(fontRecord); | ||||||
|       if (it != p->imguiFonts_.end()) |       if (it != p->imguiFonts_.end()) | ||||||
|       { |       { | ||||||
|          return it->second; |          return it->second; | ||||||
|  | @ -299,7 +297,7 @@ FontManager::LoadImGuiFont(const std::string&               family, | ||||||
| 
 | 
 | ||||||
|    // Search for the associated ImGui font again, to prevent loading the same
 |    // Search for the associated ImGui font again, to prevent loading the same
 | ||||||
|    // font twice
 |    // font twice
 | ||||||
|    auto it = p->imguiFonts_.find(imguiFontKey); |    auto it = p->imguiFonts_.find(fontRecord); | ||||||
|    if (it != p->imguiFonts_.end()) |    if (it != p->imguiFonts_.end()) | ||||||
|    { |    { | ||||||
|       return it->second; |       return it->second; | ||||||
|  | @ -310,25 +308,20 @@ FontManager::LoadImGuiFont(const std::string&               family, | ||||||
|    try |    try | ||||||
|    { |    { | ||||||
|       fontName = fmt::format( |       fontName = fmt::format( | ||||||
|          "{}:{}", |          "{}", std::filesystem::path(fontRecord.filename_).filename().string()); | ||||||
|          std::filesystem::path(fontRecord.filename_).filename().string(), |  | ||||||
|          imFontSize.value()); |  | ||||||
|    } |    } | ||||||
|    catch (const std::exception& ex) |    catch (const std::exception& ex) | ||||||
|    { |    { | ||||||
|       logger_->warn(ex.what()); |       logger_->warn(ex.what()); | ||||||
|       fontName = fmt::format("{}:{}", fontRecord.filename_, imFontSize.value()); |       fontName = fmt::format("{}", fontRecord.filename_); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    // Create an ImGui font
 |    // Create an ImGui font
 | ||||||
|    std::shared_ptr<types::ImGuiFont> imguiFont = |    std::shared_ptr<types::ImGuiFont> imguiFont = | ||||||
|       std::make_shared<types::ImGuiFont>(fontName, rawFontData, imFontSize); |       std::make_shared<types::ImGuiFont>(fontName, rawFontData); | ||||||
| 
 | 
 | ||||||
|    // Store the ImGui font
 |    // Store the ImGui font
 | ||||||
|    p->imguiFonts_.insert_or_assign(imguiFontKey, imguiFont); |    p->imguiFonts_.insert_or_assign(fontRecord, imguiFont); | ||||||
| 
 |  | ||||||
|    // Increment ImGui font build count
 |  | ||||||
|    ++p->imguiFontsBuildCount_; |  | ||||||
| 
 | 
 | ||||||
|    // Return the ImGui font
 |    // Return the ImGui font
 | ||||||
|    return imguiFont; |    return imguiFont; | ||||||
|  | @ -568,13 +561,12 @@ FontManager& FontManager::Instance() | ||||||
|    return instance_; |    return instance_; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| size_t FontRecordHash<FontRecordPair>::operator()(const FontRecordPair& x) const | size_t FontRecordHash<FontRecord>::operator()(const FontRecord& x) const | ||||||
| { | { | ||||||
|    size_t seed = 0; |    size_t seed = 0; | ||||||
|    boost::hash_combine(seed, x.first.family_); |    boost::hash_combine(seed, x.family_); | ||||||
|    boost::hash_combine(seed, x.first.style_); |    boost::hash_combine(seed, x.style_); | ||||||
|    boost::hash_combine(seed, x.first.filename_); |    boost::hash_combine(seed, x.filename_); | ||||||
|    boost::hash_combine(seed, x.second.value()); |  | ||||||
|    return seed; |    return seed; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -585,6 +577,4 @@ bool operator==(const FontRecord& lhs, const FontRecord& rhs) | ||||||
|           lhs.filename_ == rhs.filename_; |           lhs.filename_ == rhs.filename_; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace manager
 | } // namespace scwx::qt::manager
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -26,21 +26,22 @@ public: | ||||||
|    ~FontManager(); |    ~FontManager(); | ||||||
| 
 | 
 | ||||||
|    std::shared_mutex& imgui_font_atlas_mutex(); |    std::shared_mutex& imgui_font_atlas_mutex(); | ||||||
|    std::uint64_t      imgui_fonts_build_count() const; |  | ||||||
| 
 | 
 | ||||||
|    int GetFontId(types::Font font) const; |    int GetFontId(types::Font font) const; | ||||||
|    std::shared_ptr<types::ImGuiFont> |    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> | ||||||
|    LoadImGuiFont(const std::string&              family, |    LoadImGuiFont(const std::string&              family, | ||||||
|                  const std::vector<std::string>& styles, |                  const std::vector<std::string>& styles, | ||||||
|                  units::font_size::points<double> size, |  | ||||||
|                  bool                            loadIfNotFound = true); |                  bool                            loadIfNotFound = true); | ||||||
| 
 | 
 | ||||||
|    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<float> | ||||||
|  |    ImFontSize(units::font_size::pixels<double> size); | ||||||
|  | 
 | ||||||
|    static FontManager& Instance(); |    static FontManager& Instance(); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|  |  | ||||||
|  | @ -52,8 +52,7 @@ public: | ||||||
|    void ReadPlacefileSettings(); |    void ReadPlacefileSettings(); | ||||||
|    void WritePlacefileSettings(); |    void WritePlacefileSettings(); | ||||||
| 
 | 
 | ||||||
|    static boost::unordered_flat_map<std::size_t, |    static FontMap | ||||||
|                                     std::shared_ptr<types::ImGuiFont>> |  | ||||||
|    LoadFontResources(const std::shared_ptr<gr::Placefile>& placefile); |    LoadFontResources(const std::shared_ptr<gr::Placefile>& placefile); | ||||||
|    static std::vector<std::shared_ptr<boost::gil::rgba8_image_t>> |    static std::vector<std::shared_ptr<boost::gil::rgba8_image_t>> | ||||||
|    LoadImageResources(const std::shared_ptr<gr::Placefile>& placefile); |    LoadImageResources(const std::shared_ptr<gr::Placefile>& placefile); | ||||||
|  | @ -147,8 +146,7 @@ public: | ||||||
|    std::mutex                     refreshMutex_ {}; |    std::mutex                     refreshMutex_ {}; | ||||||
|    std::mutex                     timerMutex_ {}; |    std::mutex                     timerMutex_ {}; | ||||||
| 
 | 
 | ||||||
|    boost::unordered_flat_map<std::size_t, std::shared_ptr<types::ImGuiFont>> |    FontMap    fonts_ {}; | ||||||
|               fonts_ {}; |  | ||||||
|    std::mutex fontsMutex_ {}; |    std::mutex fontsMutex_ {}; | ||||||
| 
 | 
 | ||||||
|    std::vector<std::shared_ptr<boost::gil::rgba8_image_t>> images_ {}; |    std::vector<std::shared_ptr<boost::gil::rgba8_image_t>> images_ {}; | ||||||
|  | @ -235,7 +233,7 @@ PlacefileManager::placefile(const std::string& name) | ||||||
|    return nullptr; |    return nullptr; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| boost::unordered_flat_map<std::size_t, std::shared_ptr<types::ImGuiFont>> | PlacefileManager::FontMap | ||||||
| PlacefileManager::placefile_fonts(const std::string& name) | PlacefileManager::placefile_fonts(const std::string& name) | ||||||
| { | { | ||||||
|    std::shared_lock lock(p->placefileRecordLock_); |    std::shared_lock lock(p->placefileRecordLock_); | ||||||
|  | @ -775,12 +773,10 @@ std::shared_ptr<PlacefileManager> PlacefileManager::Instance() | ||||||
|    return placefileManager; |    return placefileManager; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| boost::unordered_flat_map<std::size_t, std::shared_ptr<types::ImGuiFont>> | PlacefileManager::FontMap PlacefileManager::Impl::LoadFontResources( | ||||||
| PlacefileManager::Impl::LoadFontResources( |  | ||||||
|    const std::shared_ptr<gr::Placefile>& placefile) |    const std::shared_ptr<gr::Placefile>& placefile) | ||||||
| { | { | ||||||
|    boost::unordered_flat_map<std::size_t, std::shared_ptr<types::ImGuiFont>> |    FontMap imGuiFonts {}; | ||||||
|         imGuiFonts {}; |  | ||||||
|    auto    fonts = placefile->fonts(); |    auto    fonts = placefile->fonts(); | ||||||
| 
 | 
 | ||||||
|    for (auto& font : fonts) |    for (auto& font : fonts) | ||||||
|  | @ -797,9 +793,11 @@ PlacefileManager::Impl::LoadFontResources( | ||||||
|          styles.push_back("italic"); |          styles.push_back("italic"); | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       auto imGuiFont = FontManager::Instance().LoadImGuiFont( |       auto imGuiFont = | ||||||
|          font.second->face_, styles, size); |          FontManager::Instance().LoadImGuiFont(font.second->face_, styles); | ||||||
|       imGuiFonts.emplace(font.first, std::move(imGuiFont)); |       imGuiFonts.emplace( | ||||||
|  |          font.first, | ||||||
|  |          std::make_pair(std::move(imGuiFont), FontManager::ImFontSize(size))); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    return imGuiFonts; |    return imGuiFonts; | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <scwx/gr/placefile.hpp> | #include <scwx/gr/placefile.hpp> | ||||||
| #include <scwx/qt/config/radar_site.hpp> | #include <scwx/qt/config/radar_site.hpp> | ||||||
|  | #include <scwx/qt/types/font_types.hpp> | ||||||
| #include <scwx/qt/types/imgui_font.hpp> | #include <scwx/qt/types/imgui_font.hpp> | ||||||
| 
 | 
 | ||||||
| #include <QObject> | #include <QObject> | ||||||
|  | @ -22,12 +23,16 @@ public: | ||||||
|    explicit PlacefileManager(); |    explicit PlacefileManager(); | ||||||
|    ~PlacefileManager(); |    ~PlacefileManager(); | ||||||
| 
 | 
 | ||||||
|  |    using FontMap = | ||||||
|  |       boost::unordered_flat_map<std::size_t, | ||||||
|  |                                 std::pair<std::shared_ptr<types::ImGuiFont>, | ||||||
|  |                                           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); | ||||||
|    std::string placefile_title(const std::string& name); |    std::string placefile_title(const std::string& name); | ||||||
|    std::shared_ptr<gr::Placefile> placefile(const std::string& name); |    std::shared_ptr<gr::Placefile> placefile(const std::string& name); | ||||||
|    boost::unordered_flat_map<std::size_t, std::shared_ptr<types::ImGuiFont>> |    FontMap                        placefile_fonts(const std::string& name); | ||||||
|    placefile_fonts(const std::string& name); |  | ||||||
| 
 | 
 | ||||||
|    void set_placefile_enabled(const std::string& name, bool enabled); |    void set_placefile_enabled(const std::string& name, bool enabled); | ||||||
|    void set_placefile_thresholded(const std::string& name, bool thresholded); |    void set_placefile_thresholded(const std::string& name, bool thresholded); | ||||||
|  |  | ||||||
|  | @ -98,10 +98,11 @@ void DrawLayer::ImGuiFrameStart(const std::shared_ptr<MapContext>& mapContext) | ||||||
|    ImGui::SetCurrentContext(p->imGuiContext_); |    ImGui::SetCurrentContext(p->imGuiContext_); | ||||||
| 
 | 
 | ||||||
|    // Start ImGui Frame
 |    // Start ImGui Frame
 | ||||||
|  |    model::ImGuiContextModel::Instance().NewFrame(); | ||||||
|    ImGui_ImplQt_NewFrame(mapContext->widget()); |    ImGui_ImplQt_NewFrame(mapContext->widget()); | ||||||
|    ImGui_ImplOpenGL3_NewFrame(); |    ImGui_ImplOpenGL3_NewFrame(); | ||||||
|    ImGui::NewFrame(); |    ImGui::NewFrame(); | ||||||
|    ImGui::PushFont(defaultFont->font()); |    ImGui::PushFont(defaultFont.first->font(), defaultFont.second.value()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void DrawLayer::ImGuiFrameEnd() | void DrawLayer::ImGuiFrameEnd() | ||||||
|  |  | ||||||
|  | @ -172,7 +172,6 @@ public: | ||||||
|    void HandleHotkeyReleased(types::Hotkey hotkey); |    void HandleHotkeyReleased(types::Hotkey hotkey); | ||||||
|    void HandleHotkeyUpdates(); |    void HandleHotkeyUpdates(); | ||||||
|    void HandlePinchGesture(QPinchGesture* gesture); |    void HandlePinchGesture(QPinchGesture* gesture); | ||||||
|    void ImGuiCheckFonts(); |  | ||||||
|    void InitializeCustomStyles(); |    void InitializeCustomStyles(); | ||||||
|    void InitializeNewRadarProductView(const std::string& colorPalette); |    void InitializeNewRadarProductView(const std::string& colorPalette); | ||||||
|    void RadarProductManagerConnect(); |    void RadarProductManagerConnect(); | ||||||
|  | @ -222,8 +221,7 @@ public: | ||||||
| 
 | 
 | ||||||
|    ImGuiContext* imGuiContext_; |    ImGuiContext* imGuiContext_; | ||||||
|    std::string   imGuiContextName_; |    std::string   imGuiContextName_; | ||||||
|    bool          imGuiRendererInitialized_; |    bool          imGuiRendererInitialized_ {false}; | ||||||
|    std::uint64_t imGuiFontsBuildCount_ {}; |  | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<model::LayerModel> layerModel_ { |    std::shared_ptr<model::LayerModel> layerModel_ { | ||||||
|       model::LayerModel::Instance()}; |       model::LayerModel::Instance()}; | ||||||
|  | @ -1575,8 +1573,6 @@ void MapWidget::initializeGL() | ||||||
|    ImGui::SetCurrentContext(p->imGuiContext_); |    ImGui::SetCurrentContext(p->imGuiContext_); | ||||||
|    ImGui_ImplQt_RegisterWidget(this); |    ImGui_ImplQt_RegisterWidget(this); | ||||||
|    ImGui_ImplOpenGL3_Init(); |    ImGui_ImplOpenGL3_Init(); | ||||||
|    p->imGuiFontsBuildCount_ = |  | ||||||
|       manager::FontManager::Instance().imgui_fonts_build_count(); |  | ||||||
|    p->imGuiRendererInitialized_ = true; |    p->imGuiRendererInitialized_ = true; | ||||||
| 
 | 
 | ||||||
|    p->map_.reset( |    p->map_.reset( | ||||||
|  | @ -1628,10 +1624,6 @@ void MapWidget::paintGL() | ||||||
|    std::shared_lock imguiFontAtlasLock { |    std::shared_lock imguiFontAtlasLock { | ||||||
|       manager::FontManager::Instance().imgui_font_atlas_mutex()}; |       manager::FontManager::Instance().imgui_font_atlas_mutex()}; | ||||||
| 
 | 
 | ||||||
|    // Check ImGui fonts
 |  | ||||||
|    ImGui::SetCurrentContext(p->imGuiContext_); |  | ||||||
|    p->ImGuiCheckFonts(); |  | ||||||
| 
 |  | ||||||
|    // Update pixel ratio
 |    // Update pixel ratio
 | ||||||
|    p->context_->set_pixel_ratio(pixelRatio()); |    p->context_->set_pixel_ratio(pixelRatio()); | ||||||
| 
 | 
 | ||||||
|  | @ -1646,12 +1638,13 @@ void MapWidget::paintGL() | ||||||
|    ImGui::SetCurrentContext(p->imGuiContext_); |    ImGui::SetCurrentContext(p->imGuiContext_); | ||||||
| 
 | 
 | ||||||
|    // Start ImGui Frame
 |    // Start ImGui Frame
 | ||||||
|  |    model::ImGuiContextModel::Instance().NewFrame(); | ||||||
|    ImGui_ImplQt_NewFrame(this); |    ImGui_ImplQt_NewFrame(this); | ||||||
|    ImGui_ImplOpenGL3_NewFrame(); |    ImGui_ImplOpenGL3_NewFrame(); | ||||||
|    ImGui::NewFrame(); |    ImGui::NewFrame(); | ||||||
| 
 | 
 | ||||||
|    // Set default font
 |    // Set default font
 | ||||||
|    ImGui::PushFont(defaultFont->font()); |    ImGui::PushFont(defaultFont.first->font(), defaultFont.second.value()); | ||||||
| 
 | 
 | ||||||
|    // Perform mouse picking
 |    // Perform mouse picking
 | ||||||
|    if (p->hasMouse_) |    if (p->hasMouse_) | ||||||
|  | @ -1682,30 +1675,6 @@ void MapWidget::paintGL() | ||||||
|    p->isPainting_ = false; |    p->isPainting_ = false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MapWidgetImpl::ImGuiCheckFonts() |  | ||||||
| { |  | ||||||
|    // Update ImGui Fonts if required
 |  | ||||||
|    std::uint64_t currentImGuiFontsBuildCount = |  | ||||||
|       manager::FontManager::Instance().imgui_fonts_build_count(); |  | ||||||
| 
 |  | ||||||
|    if (imGuiFontsBuildCount_ != currentImGuiFontsBuildCount || |  | ||||||
|        !model::ImGuiContextModel::Instance().font_atlas()->IsBuilt()) |  | ||||||
|    { |  | ||||||
|       ImGui_ImplOpenGL3_DestroyFontsTexture(); |  | ||||||
|       ImGui_ImplOpenGL3_CreateFontsTexture(); |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    static bool haveLogged = false; |  | ||||||
|    if (!model::ImGuiContextModel::Instance().font_atlas()->IsBuilt() && |  | ||||||
|        !haveLogged) |  | ||||||
|    { |  | ||||||
|       logger_->error("ImGui font atlas could not be built."); |  | ||||||
|       haveLogged = true; |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    imGuiFontsBuildCount_ = currentImGuiFontsBuildCount; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void MapWidgetImpl::RunMousePicking() | void MapWidgetImpl::RunMousePicking() | ||||||
| { | { | ||||||
|    const QMapLibre::CustomLayerRenderParameters params = { |    const QMapLibre::CustomLayerRenderParameters params = { | ||||||
|  |  | ||||||
|  | @ -539,7 +539,8 @@ void OverlayLayer::Render(const std::shared_ptr<MapContext>& mapContext, | ||||||
|                               ImVec2 {1.0f, 1.0f}); |                               ImVec2 {1.0f, 1.0f}); | ||||||
|       ImGui::SetNextWindowBgAlpha(0.5f); |       ImGui::SetNextWindowBgAlpha(0.5f); | ||||||
|       ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2 {3.0f, 2.0f}); |       ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2 {3.0f, 2.0f}); | ||||||
|       ImGui::PushFont(attributionFont->font()); |       ImGui::PushFont(attributionFont.first->font(), | ||||||
|  |                       attributionFont.second.value()); | ||||||
|       ImGui::Begin("Attribution", |       ImGui::Begin("Attribution", | ||||||
|                    nullptr, |                    nullptr, | ||||||
|                    ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | |                    ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | | ||||||
|  |  | ||||||
|  | @ -4,11 +4,12 @@ | ||||||
| 
 | 
 | ||||||
| #include <imgui.h> | #include <imgui.h> | ||||||
| 
 | 
 | ||||||
| namespace scwx | // Expose required functions from internal API
 | ||||||
| { | void ImFontAtlasUpdateNewFrame(ImFontAtlas* atlas, | ||||||
| namespace qt |                                int          frame_count, | ||||||
| { |                                bool         renderer_has_textures); | ||||||
| namespace model | 
 | ||||||
|  | namespace scwx::qt::model | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| static const std::string logPrefix_ = "scwx::qt::model::imgui_context_model"; | static const std::string logPrefix_ = "scwx::qt::model::imgui_context_model"; | ||||||
|  | @ -23,6 +24,8 @@ public: | ||||||
| 
 | 
 | ||||||
|    std::vector<ImGuiContextInfo> contexts_ {}; |    std::vector<ImGuiContextInfo> contexts_ {}; | ||||||
|    ImFontAtlas                   fontAtlas_ {}; |    ImFontAtlas                   fontAtlas_ {}; | ||||||
|  | 
 | ||||||
|  |    int frameCount_ {0}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| ImGuiContextModel::ImGuiContextModel() : | ImGuiContextModel::ImGuiContextModel() : | ||||||
|  | @ -135,6 +138,14 @@ void ImGuiContextModel::DestroyContext(const std::string& name) | ||||||
|    } |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void ImGuiContextModel::NewFrame() | ||||||
|  | { | ||||||
|  |    static constexpr bool kRendererHasTextures_ = true; | ||||||
|  | 
 | ||||||
|  |    ImFontAtlasUpdateNewFrame( | ||||||
|  |       &p->fontAtlas_, ++p->frameCount_, kRendererHasTextures_); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| std::vector<ImGuiContextInfo> ImGuiContextModel::contexts() const | std::vector<ImGuiContextInfo> ImGuiContextModel::contexts() const | ||||||
| { | { | ||||||
|    return p->contexts_; |    return p->contexts_; | ||||||
|  | @ -153,6 +164,4 @@ ImGuiContextModel& ImGuiContextModel::Instance() | ||||||
| 
 | 
 | ||||||
| bool ImGuiContextInfo::operator==(const ImGuiContextInfo& o) const = default; | bool ImGuiContextInfo::operator==(const ImGuiContextInfo& o) const = default; | ||||||
| 
 | 
 | ||||||
| } // namespace model
 | } // namespace scwx::qt::model
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -8,11 +8,7 @@ | ||||||
| struct ImFontAtlas; | struct ImFontAtlas; | ||||||
| struct ImGuiContext; | struct ImGuiContext; | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::model | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace model |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| class ImGuiContextModelImpl; | class ImGuiContextModelImpl; | ||||||
|  | @ -46,6 +42,8 @@ public: | ||||||
|    ImGuiContext* CreateContext(const std::string& name); |    ImGuiContext* CreateContext(const std::string& name); | ||||||
|    void          DestroyContext(const std::string& name); |    void          DestroyContext(const std::string& name); | ||||||
| 
 | 
 | ||||||
|  |    void NewFrame(); | ||||||
|  | 
 | ||||||
|    std::vector<ImGuiContextInfo> contexts() const; |    std::vector<ImGuiContextInfo> contexts() const; | ||||||
|    ImFontAtlas*                  font_atlas(); |    ImFontAtlas*                  font_atlas(); | ||||||
| 
 | 
 | ||||||
|  | @ -59,6 +57,4 @@ private: | ||||||
|    std::unique_ptr<ImGuiContextModelImpl> p; |    std::unique_ptr<ImGuiContextModelImpl> p; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace model
 | } // namespace scwx::qt::model
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -23,10 +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)} | ||||||
|                  units::font_size::pixels<int> size) : |  | ||||||
|        fontName_ {fontName}, size_ {size} |  | ||||||
|    { |    { | ||||||
|       CreateImGuiFont(fontData); |       CreateImGuiFont(fontData); | ||||||
|    } |    } | ||||||
|  | @ -35,16 +33,14 @@ public: | ||||||
| 
 | 
 | ||||||
|    void CreateImGuiFont(const std::vector<char>& fontData); |    void CreateImGuiFont(const std::vector<char>& fontData); | ||||||
| 
 | 
 | ||||||
|    const std::string                   fontName_; |    std::string fontName_; | ||||||
|    const units::font_size::pixels<int> size_; |  | ||||||
| 
 | 
 | ||||||
|    ImFont* imFont_ {nullptr}; |    ImFont* imFont_ {nullptr}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| ImGuiFont::ImGuiFont(const std::string&       fontName, | ImGuiFont::ImGuiFont(const std::string&       fontName, | ||||||
|                      const std::vector<char>&      fontData, |                      const std::vector<char>& fontData) : | ||||||
|                      units::font_size::pixels<int> size) : |     p(std::make_unique<Impl>(fontName, fontData)) | ||||||
|     p(std::make_unique<Impl>(fontName, fontData, size)) |  | ||||||
| { | { | ||||||
| } | } | ||||||
| ImGuiFont::~ImGuiFont() = default; | ImGuiFont::~ImGuiFont() = default; | ||||||
|  | @ -53,11 +49,12 @@ void ImGuiFont::Impl::CreateImGuiFont(const std::vector<char>& fontData) | ||||||
| { | { | ||||||
|    logger_->debug("Creating Font: {}", fontName_); |    logger_->debug("Creating Font: {}", fontName_); | ||||||
| 
 | 
 | ||||||
|  |    // Default render size, used in debug widget
 | ||||||
|  |    static constexpr float kSizePixels_ = 16.0f; | ||||||
|  | 
 | ||||||
|    ImFontAtlas* fontAtlas = model::ImGuiContextModel::Instance().font_atlas(); |    ImFontAtlas* fontAtlas = model::ImGuiContextModel::Instance().font_atlas(); | ||||||
|    ImFontConfig fontConfig {}; |    ImFontConfig fontConfig {}; | ||||||
| 
 | 
 | ||||||
|    const float sizePixels = static_cast<float>(size_.value()); |  | ||||||
| 
 |  | ||||||
|    // Do not transfer ownership of font data to ImGui, makes const_cast safe
 |    // Do not transfer ownership of font data to ImGui, makes const_cast safe
 | ||||||
|    fontConfig.FontDataOwnedByAtlas = false; |    fontConfig.FontDataOwnedByAtlas = false; | ||||||
| 
 | 
 | ||||||
|  | @ -69,7 +66,7 @@ void ImGuiFont::Impl::CreateImGuiFont(const std::vector<char>& fontData) | ||||||
|       const_cast<void*>(static_cast<const void*>(fontData.data())), |       const_cast<void*>(static_cast<const void*>(fontData.data())), | ||||||
|       static_cast<int>(std::clamp<std::size_t>( |       static_cast<int>(std::clamp<std::size_t>( | ||||||
|          fontData.size(), 0, std::numeric_limits<int>::max())), |          fontData.size(), 0, std::numeric_limits<int>::max())), | ||||||
|       sizePixels, |       kSizePixels_, | ||||||
|       &fontConfig); |       &fontConfig); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -4,8 +4,6 @@ | ||||||
| #include <string> | #include <string> | ||||||
| #include <vector> | #include <vector> | ||||||
| 
 | 
 | ||||||
| #include <scwx/qt/types/font_types.hpp> |  | ||||||
| 
 |  | ||||||
| struct ImFont; | struct ImFont; | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx | ||||||
|  | @ -19,8 +17,7 @@ class ImGuiFont | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit ImGuiFont(const std::string&       fontName, |    explicit ImGuiFont(const std::string&       fontName, | ||||||
|                       const std::vector<char>&      fontData, |                       const std::vector<char>& fontData); | ||||||
|                       units::font_size::pixels<int> size); |  | ||||||
|    ~ImGuiFont(); |    ~ImGuiFont(); | ||||||
| 
 | 
 | ||||||
|    ImGuiFont(const ImGuiFont&)            = delete; |    ImGuiFont(const ImGuiFont&)            = delete; | ||||||
|  |  | ||||||
|  | @ -9,11 +9,7 @@ | ||||||
| #include <backends/imgui_impl_qt.hpp> | #include <backends/imgui_impl_qt.hpp> | ||||||
| #include <fmt/format.h> | #include <fmt/format.h> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::ui | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace ui |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| static const std::string logPrefix_ = "scwx::qt::ui::imgui_debug_widget"; | static const std::string logPrefix_ = "scwx::qt::ui::imgui_debug_widget"; | ||||||
|  | @ -51,8 +47,6 @@ public: | ||||||
|       model::ImGuiContextModel::Instance().DestroyContext(contextName_); |       model::ImGuiContextModel::Instance().DestroyContext(contextName_); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    void ImGuiCheckFonts(); |  | ||||||
| 
 |  | ||||||
|    ImGuiDebugWidget* self_; |    ImGuiDebugWidget* self_; | ||||||
|    ImGuiContext*     context_; |    ImGuiContext*     context_; | ||||||
|    std::string       contextName_; |    std::string       contextName_; | ||||||
|  | @ -61,7 +55,6 @@ public: | ||||||
| 
 | 
 | ||||||
|    std::set<ImGuiContext*> renderedSet_ {}; |    std::set<ImGuiContext*> renderedSet_ {}; | ||||||
|    bool                    imGuiRendererInitialized_ {false}; |    bool                    imGuiRendererInitialized_ {false}; | ||||||
|    std::uint64_t           imGuiFontsBuildCount_ {}; |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| ImGuiDebugWidget::ImGuiDebugWidget(QWidget* parent) : | ImGuiDebugWidget::ImGuiDebugWidget(QWidget* parent) : | ||||||
|  | @ -106,8 +99,6 @@ void ImGuiDebugWidget::initializeGL() | ||||||
|    // Initialize ImGui OpenGL3 backend
 |    // Initialize ImGui OpenGL3 backend
 | ||||||
|    ImGui::SetCurrentContext(p->context_); |    ImGui::SetCurrentContext(p->context_); | ||||||
|    ImGui_ImplOpenGL3_Init(); |    ImGui_ImplOpenGL3_Init(); | ||||||
|    p->imGuiFontsBuildCount_ = |  | ||||||
|       manager::FontManager::Instance().imgui_fonts_build_count(); |  | ||||||
|    p->imGuiRendererInitialized_ = true; |    p->imGuiRendererInitialized_ = true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -122,9 +113,9 @@ void ImGuiDebugWidget::paintGL() | ||||||
|    std::shared_lock imguiFontAtlasLock { |    std::shared_lock imguiFontAtlasLock { | ||||||
|       manager::FontManager::Instance().imgui_font_atlas_mutex()}; |       manager::FontManager::Instance().imgui_font_atlas_mutex()}; | ||||||
| 
 | 
 | ||||||
|  |    model::ImGuiContextModel::Instance().NewFrame(); | ||||||
|    ImGui_ImplQt_NewFrame(this); |    ImGui_ImplQt_NewFrame(this); | ||||||
|    ImGui_ImplOpenGL3_NewFrame(); |    ImGui_ImplOpenGL3_NewFrame(); | ||||||
|    p->ImGuiCheckFonts(); |  | ||||||
|    ImGui::NewFrame(); |    ImGui::NewFrame(); | ||||||
| 
 | 
 | ||||||
|    if (!p->renderedSet_.contains(p->currentContext_)) |    if (!p->renderedSet_.contains(p->currentContext_)) | ||||||
|  | @ -149,26 +140,4 @@ void ImGuiDebugWidget::paintGL() | ||||||
|    imguiFontAtlasLock.unlock(); |    imguiFontAtlasLock.unlock(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ImGuiDebugWidgetImpl::ImGuiCheckFonts() | } // namespace scwx::qt::ui
 | ||||||
| { |  | ||||||
|    // Update ImGui Fonts if required
 |  | ||||||
|    std::uint64_t currentImGuiFontsBuildCount = |  | ||||||
|       manager::FontManager::Instance().imgui_fonts_build_count(); |  | ||||||
| 
 |  | ||||||
|    if ((context_ == currentContext_ && |  | ||||||
|         imGuiFontsBuildCount_ != currentImGuiFontsBuildCount) || |  | ||||||
|        !model::ImGuiContextModel::Instance().font_atlas()->IsBuilt()) |  | ||||||
|    { |  | ||||||
|       ImGui_ImplOpenGL3_DestroyFontsTexture(); |  | ||||||
|       ImGui_ImplOpenGL3_CreateFontsTexture(); |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    if (context_ == currentContext_) |  | ||||||
|    { |  | ||||||
|       imGuiFontsBuildCount_ = currentImGuiFontsBuildCount; |  | ||||||
|    } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| } // namespace ui
 |  | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ void ImGui::DrawTooltip(const std::string& hoverText) | ||||||
| 
 | 
 | ||||||
|    if (::ImGui::BeginTooltip()) |    if (::ImGui::BeginTooltip()) | ||||||
|    { |    { | ||||||
|       ::ImGui::PushFont(tooltipFont->font()); |       ::ImGui::PushFont(tooltipFont.first->font(), tooltipFont.second.value()); | ||||||
|       ::ImGui::TextUnformatted(hoverText.c_str()); |       ::ImGui::TextUnformatted(hoverText.c_str()); | ||||||
|       ::ImGui::PopFont(); |       ::ImGui::PopFont(); | ||||||
|       ::ImGui::EndTooltip(); |       ::ImGui::EndTooltip(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat