mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 09:10:06 +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);
|
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]->font(), 0.0f);
|
||||||
|
|
||||||
if (settings::TextSettings::Instance()
|
if (settings::TextSettings::Instance()
|
||||||
.placefile_text_drop_shadow_enabled()
|
.placefile_text_drop_shadow_enabled()
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
|
|
@ -81,8 +77,6 @@ public:
|
||||||
|
|
||||||
std::shared_mutex imguiFontAtlasMutex_ {};
|
std::shared_mutex imguiFontAtlasMutex_ {};
|
||||||
|
|
||||||
std::uint64_t imguiFontsBuildCount_ {};
|
|
||||||
|
|
||||||
boost::unordered_flat_map<FontRecordPair,
|
boost::unordered_flat_map<FontRecordPair,
|
||||||
std::shared_ptr<types::ImGuiFont>,
|
std::shared_ptr<types::ImGuiFont>,
|
||||||
FontRecordHash<FontRecordPair>>
|
FontRecordHash<FontRecordPair>>
|
||||||
|
|
@ -207,11 +201,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);
|
||||||
|
|
@ -327,9 +316,6 @@ FontManager::LoadImGuiFont(const std::string& family,
|
||||||
// Store the ImGui font
|
// Store the ImGui font
|
||||||
p->imguiFonts_.insert_or_assign(imguiFontKey, imguiFont);
|
p->imguiFonts_.insert_or_assign(imguiFontKey, imguiFont);
|
||||||
|
|
||||||
// Increment ImGui font build count
|
|
||||||
++p->imguiFontsBuildCount_;
|
|
||||||
|
|
||||||
// Return the ImGui font
|
// Return the ImGui font
|
||||||
return imguiFont;
|
return imguiFont;
|
||||||
}
|
}
|
||||||
|
|
@ -585,6 +571,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,7 +26,6 @@ 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::shared_ptr<types::ImGuiFont>
|
||||||
|
|
|
||||||
|
|
@ -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->font(), 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
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->font(), 0.0f);
|
||||||
|
|
||||||
// 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,7 @@ 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->font(), 0.0f);
|
||||||
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
|
|
||||||
|
|
|
||||||
|
|
@ -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->font(), 0.0f);
|
||||||
::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