mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-29 18:50:05 +00:00
Update ImGui to v1.92.2b
This commit is contained in:
parent
26e7220959
commit
dc96e3e3ad
11 changed files with 35 additions and 108 deletions
2
external/imgui
vendored
2
external/imgui
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit 993fa347495860ed44b83574254ef2a317d0c14f
|
||||
Subproject commit 45acd5e0e82f4c954432533ae9985ff0e1aad6d5
|
||||
|
|
@ -159,7 +159,7 @@ void PlacefileText::Impl::RenderTextDrawItem(
|
|||
std::size_t fontNumber = std::clamp<std::size_t>(di->fontNumber_, 0, 8);
|
||||
|
||||
// Set the font for the drop shadow and text
|
||||
ImGui::PushFont(fonts_[fontNumber]->font());
|
||||
ImGui::PushFont(fonts_[fontNumber]->font(), 0.0f);
|
||||
|
||||
if (settings::TextSettings::Instance()
|
||||
.placefile_text_drop_shadow_enabled()
|
||||
|
|
|
|||
|
|
@ -18,11 +18,7 @@
|
|||
#include <fmt/ranges.h>
|
||||
#include <fontconfig/fontconfig.h>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace manager
|
||||
namespace scwx::qt::manager
|
||||
{
|
||||
|
||||
static const std::string logPrefix_ = "scwx::qt::manager::font_manager";
|
||||
|
|
@ -81,8 +77,6 @@ public:
|
|||
|
||||
std::shared_mutex imguiFontAtlasMutex_ {};
|
||||
|
||||
std::uint64_t imguiFontsBuildCount_ {};
|
||||
|
||||
boost::unordered_flat_map<FontRecordPair,
|
||||
std::shared_ptr<types::ImGuiFont>,
|
||||
FontRecordHash<FontRecordPair>>
|
||||
|
|
@ -207,11 +201,6 @@ std::shared_mutex& FontManager::imgui_font_atlas_mutex()
|
|||
return p->imguiFontAtlasMutex_;
|
||||
}
|
||||
|
||||
std::uint64_t FontManager::imgui_fonts_build_count() const
|
||||
{
|
||||
return p->imguiFontsBuildCount_;
|
||||
}
|
||||
|
||||
int FontManager::GetFontId(types::Font font) const
|
||||
{
|
||||
auto it = p->fontIds_.find(font);
|
||||
|
|
@ -327,9 +316,6 @@ FontManager::LoadImGuiFont(const std::string& family,
|
|||
// Store the ImGui font
|
||||
p->imguiFonts_.insert_or_assign(imguiFontKey, imguiFont);
|
||||
|
||||
// Increment ImGui font build count
|
||||
++p->imguiFontsBuildCount_;
|
||||
|
||||
// Return the ImGui font
|
||||
return imguiFont;
|
||||
}
|
||||
|
|
@ -585,6 +571,4 @@ bool operator==(const FontRecord& lhs, const FontRecord& rhs)
|
|||
lhs.filename_ == rhs.filename_;
|
||||
}
|
||||
|
||||
} // namespace manager
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
} // namespace scwx::qt::manager
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ public:
|
|||
~FontManager();
|
||||
|
||||
std::shared_mutex& imgui_font_atlas_mutex();
|
||||
std::uint64_t imgui_fonts_build_count() const;
|
||||
|
||||
int GetFontId(types::Font font) const;
|
||||
std::shared_ptr<types::ImGuiFont>
|
||||
|
|
|
|||
|
|
@ -98,10 +98,11 @@ void DrawLayer::ImGuiFrameStart(const std::shared_ptr<MapContext>& mapContext)
|
|||
ImGui::SetCurrentContext(p->imGuiContext_);
|
||||
|
||||
// Start ImGui Frame
|
||||
model::ImGuiContextModel::Instance().NewFrame();
|
||||
ImGui_ImplQt_NewFrame(mapContext->widget());
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
ImGui::PushFont(defaultFont->font());
|
||||
ImGui::PushFont(defaultFont->font(), 0.0f);
|
||||
}
|
||||
|
||||
void DrawLayer::ImGuiFrameEnd()
|
||||
|
|
|
|||
|
|
@ -172,7 +172,6 @@ public:
|
|||
void HandleHotkeyReleased(types::Hotkey hotkey);
|
||||
void HandleHotkeyUpdates();
|
||||
void HandlePinchGesture(QPinchGesture* gesture);
|
||||
void ImGuiCheckFonts();
|
||||
void InitializeCustomStyles();
|
||||
void InitializeNewRadarProductView(const std::string& colorPalette);
|
||||
void RadarProductManagerConnect();
|
||||
|
|
@ -222,8 +221,7 @@ public:
|
|||
|
||||
ImGuiContext* imGuiContext_;
|
||||
std::string imGuiContextName_;
|
||||
bool imGuiRendererInitialized_;
|
||||
std::uint64_t imGuiFontsBuildCount_ {};
|
||||
bool imGuiRendererInitialized_ {false};
|
||||
|
||||
std::shared_ptr<model::LayerModel> layerModel_ {
|
||||
model::LayerModel::Instance()};
|
||||
|
|
@ -1575,8 +1573,6 @@ void MapWidget::initializeGL()
|
|||
ImGui::SetCurrentContext(p->imGuiContext_);
|
||||
ImGui_ImplQt_RegisterWidget(this);
|
||||
ImGui_ImplOpenGL3_Init();
|
||||
p->imGuiFontsBuildCount_ =
|
||||
manager::FontManager::Instance().imgui_fonts_build_count();
|
||||
p->imGuiRendererInitialized_ = true;
|
||||
|
||||
p->map_.reset(
|
||||
|
|
@ -1628,10 +1624,6 @@ void MapWidget::paintGL()
|
|||
std::shared_lock imguiFontAtlasLock {
|
||||
manager::FontManager::Instance().imgui_font_atlas_mutex()};
|
||||
|
||||
// Check ImGui fonts
|
||||
ImGui::SetCurrentContext(p->imGuiContext_);
|
||||
p->ImGuiCheckFonts();
|
||||
|
||||
// Update pixel ratio
|
||||
p->context_->set_pixel_ratio(pixelRatio());
|
||||
|
||||
|
|
@ -1646,12 +1638,13 @@ void MapWidget::paintGL()
|
|||
ImGui::SetCurrentContext(p->imGuiContext_);
|
||||
|
||||
// Start ImGui Frame
|
||||
model::ImGuiContextModel::Instance().NewFrame();
|
||||
ImGui_ImplQt_NewFrame(this);
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
// Set default font
|
||||
ImGui::PushFont(defaultFont->font());
|
||||
ImGui::PushFont(defaultFont->font(), 0.0f);
|
||||
|
||||
// Perform mouse picking
|
||||
if (p->hasMouse_)
|
||||
|
|
@ -1682,30 +1675,6 @@ void MapWidget::paintGL()
|
|||
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()
|
||||
{
|
||||
const QMapLibre::CustomLayerRenderParameters params = {
|
||||
|
|
|
|||
|
|
@ -539,7 +539,7 @@ void OverlayLayer::Render(const std::shared_ptr<MapContext>& mapContext,
|
|||
ImVec2 {1.0f, 1.0f});
|
||||
ImGui::SetNextWindowBgAlpha(0.5f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2 {3.0f, 2.0f});
|
||||
ImGui::PushFont(attributionFont->font());
|
||||
ImGui::PushFont(attributionFont->font(), 0.0f);
|
||||
ImGui::Begin("Attribution",
|
||||
nullptr,
|
||||
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
|
||||
|
|
|
|||
|
|
@ -4,11 +4,12 @@
|
|||
|
||||
#include <imgui.h>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace model
|
||||
// Expose required functions from internal API
|
||||
void ImFontAtlasUpdateNewFrame(ImFontAtlas* atlas,
|
||||
int frame_count,
|
||||
bool renderer_has_textures);
|
||||
|
||||
namespace scwx::qt::model
|
||||
{
|
||||
|
||||
static const std::string logPrefix_ = "scwx::qt::model::imgui_context_model";
|
||||
|
|
@ -23,6 +24,8 @@ public:
|
|||
|
||||
std::vector<ImGuiContextInfo> contexts_ {};
|
||||
ImFontAtlas fontAtlas_ {};
|
||||
|
||||
int frameCount_ {0};
|
||||
};
|
||||
|
||||
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
|
||||
{
|
||||
return p->contexts_;
|
||||
|
|
@ -153,6 +164,4 @@ ImGuiContextModel& ImGuiContextModel::Instance()
|
|||
|
||||
bool ImGuiContextInfo::operator==(const ImGuiContextInfo& o) const = default;
|
||||
|
||||
} // namespace model
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
} // namespace scwx::qt::model
|
||||
|
|
|
|||
|
|
@ -8,11 +8,7 @@
|
|||
struct ImFontAtlas;
|
||||
struct ImGuiContext;
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace model
|
||||
namespace scwx::qt::model
|
||||
{
|
||||
|
||||
class ImGuiContextModelImpl;
|
||||
|
|
@ -46,6 +42,8 @@ public:
|
|||
ImGuiContext* CreateContext(const std::string& name);
|
||||
void DestroyContext(const std::string& name);
|
||||
|
||||
void NewFrame();
|
||||
|
||||
std::vector<ImGuiContextInfo> contexts() const;
|
||||
ImFontAtlas* font_atlas();
|
||||
|
||||
|
|
@ -59,6 +57,4 @@ private:
|
|||
std::unique_ptr<ImGuiContextModelImpl> p;
|
||||
};
|
||||
|
||||
} // namespace model
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
} // namespace scwx::qt::model
|
||||
|
|
|
|||
|
|
@ -9,11 +9,7 @@
|
|||
#include <backends/imgui_impl_qt.hpp>
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace ui
|
||||
namespace scwx::qt::ui
|
||||
{
|
||||
|
||||
static const std::string logPrefix_ = "scwx::qt::ui::imgui_debug_widget";
|
||||
|
|
@ -51,8 +47,6 @@ public:
|
|||
model::ImGuiContextModel::Instance().DestroyContext(contextName_);
|
||||
}
|
||||
|
||||
void ImGuiCheckFonts();
|
||||
|
||||
ImGuiDebugWidget* self_;
|
||||
ImGuiContext* context_;
|
||||
std::string contextName_;
|
||||
|
|
@ -61,7 +55,6 @@ public:
|
|||
|
||||
std::set<ImGuiContext*> renderedSet_ {};
|
||||
bool imGuiRendererInitialized_ {false};
|
||||
std::uint64_t imGuiFontsBuildCount_ {};
|
||||
};
|
||||
|
||||
ImGuiDebugWidget::ImGuiDebugWidget(QWidget* parent) :
|
||||
|
|
@ -106,8 +99,6 @@ void ImGuiDebugWidget::initializeGL()
|
|||
// Initialize ImGui OpenGL3 backend
|
||||
ImGui::SetCurrentContext(p->context_);
|
||||
ImGui_ImplOpenGL3_Init();
|
||||
p->imGuiFontsBuildCount_ =
|
||||
manager::FontManager::Instance().imgui_fonts_build_count();
|
||||
p->imGuiRendererInitialized_ = true;
|
||||
}
|
||||
|
||||
|
|
@ -122,9 +113,9 @@ void ImGuiDebugWidget::paintGL()
|
|||
std::shared_lock imguiFontAtlasLock {
|
||||
manager::FontManager::Instance().imgui_font_atlas_mutex()};
|
||||
|
||||
model::ImGuiContextModel::Instance().NewFrame();
|
||||
ImGui_ImplQt_NewFrame(this);
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
p->ImGuiCheckFonts();
|
||||
ImGui::NewFrame();
|
||||
|
||||
if (!p->renderedSet_.contains(p->currentContext_))
|
||||
|
|
@ -149,26 +140,4 @@ void ImGuiDebugWidget::paintGL()
|
|||
imguiFontAtlasLock.unlock();
|
||||
}
|
||||
|
||||
void ImGuiDebugWidgetImpl::ImGuiCheckFonts()
|
||||
{
|
||||
// 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
|
||||
} // namespace scwx::qt::ui
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ void ImGui::DrawTooltip(const std::string& hoverText)
|
|||
|
||||
if (::ImGui::BeginTooltip())
|
||||
{
|
||||
::ImGui::PushFont(tooltipFont->font());
|
||||
::ImGui::PushFont(tooltipFont->font(), 0.0f);
|
||||
::ImGui::TextUnformatted(hoverText.c_str());
|
||||
::ImGui::PopFont();
|
||||
::ImGui::EndTooltip();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue