Add ImGui Font class and dedicated Font Manager

This commit is contained in:
Dan Paulat 2023-09-24 00:36:27 -05:00
parent d1a478ad12
commit 190bd95781
5 changed files with 205 additions and 2 deletions

View file

@ -0,0 +1,45 @@
#include <scwx/qt/manager/font_manager.hpp>
#include <scwx/util/logger.hpp>
namespace scwx
{
namespace qt
{
namespace manager
{
static const std::string logPrefix_ = "scwx::qt::manager::font_manager";
static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
class FontManager::Impl
{
public:
explicit Impl() {}
~Impl() {}
};
FontManager::FontManager() : p(std::make_unique<Impl>()) {}
FontManager::~FontManager() {};
std::shared_ptr<FontManager> FontManager::Instance()
{
static std::weak_ptr<FontManager> fontManagerReference_ {};
static std::mutex instanceMutex_ {};
std::unique_lock lock(instanceMutex_);
std::shared_ptr<FontManager> fontManager = fontManagerReference_.lock();
if (fontManager == nullptr)
{
fontManager = std::make_shared<FontManager>();
fontManagerReference_ = fontManager;
}
return fontManager;
}
} // namespace manager
} // namespace qt
} // namespace scwx

View file

@ -0,0 +1,31 @@
#pragma once
#include <scwx/qt/types/imgui_font.hpp>
#include <QObject>
namespace scwx
{
namespace qt
{
namespace manager
{
class FontManager : public QObject
{
Q_OBJECT
public:
explicit FontManager();
~FontManager();
static std::shared_ptr<FontManager> Instance();
private:
class Impl;
std::unique_ptr<Impl> p;
};
} // namespace manager
} // namespace qt
} // namespace scwx