clang format/tidy fixes for rework_layer_text

This commit is contained in:
AdenKoperczak 2025-03-03 10:52:39 -05:00
parent ab682567c6
commit ec296d98eb
3 changed files with 25 additions and 24 deletions

View file

@ -71,7 +71,7 @@ public:
const std::vector<char>& GetRawFontData(const std::string& filename); const std::vector<char>& GetRawFontData(const std::string& filename);
static bool CheckFontFormat(const FcChar8* format); static bool CheckFontFormat(const FcChar8* format);
static FontRecord MatchFontFile(const std::string& family, static FontRecord MatchFontFile(const std::string& family,
const std::vector<std::string>& styles); const std::vector<std::string>& styles);
@ -461,7 +461,7 @@ void FontManager::Impl::FinalizeFontconfig()
bool FontManager::Impl::CheckFontFormat(const FcChar8* format) bool FontManager::Impl::CheckFontFormat(const FcChar8* format)
{ {
const std::string stdFormat = reinterpret_cast<const char *>(format); const std::string stdFormat = reinterpret_cast<const char*>(format);
return stdFormat == kFcTrueType_ || stdFormat == kFcOpenType_; return stdFormat == kFcTrueType_ || stdFormat == kFcOpenType_;
} }

View file

@ -1,3 +1,4 @@
#include <ranges>
#include <scwx/qt/manager/font_manager.hpp> #include <scwx/qt/manager/font_manager.hpp>
#include <scwx/qt/map/draw_layer.hpp> #include <scwx/qt/map/draw_layer.hpp>
#include <scwx/qt/model/imgui_context_model.hpp> #include <scwx/qt/model/imgui_context_model.hpp>
@ -6,14 +7,11 @@
#include <backends/imgui_impl_opengl3.h> #include <backends/imgui_impl_opengl3.h>
#include <backends/imgui_impl_qt.hpp> #include <backends/imgui_impl_qt.hpp>
#include <utility>
#include <fmt/format.h> #include <fmt/format.h>
#include <imgui.h> #include <imgui.h>
namespace scwx namespace scwx::qt::map
{
namespace qt
{
namespace map
{ {
static const std::string logPrefix_ = "scwx::qt::map::draw_layer"; static const std::string logPrefix_ = "scwx::qt::map::draw_layer";
@ -23,12 +21,12 @@ class DrawLayerImpl
{ {
public: public:
explicit DrawLayerImpl(std::shared_ptr<MapContext> context) : explicit DrawLayerImpl(std::shared_ptr<MapContext> context) :
context_ {context}, context_ {std::move(context)}, drawList_ {}
drawList_ {},
textureAtlas_ {GL_INVALID_INDEX}
{ {
static size_t currentMapId_ {0u}; static size_t currentMapId_ {0u};
imGuiContextName_ = fmt::format("Layer {}", ++currentMapId_); imGuiContextName_ = fmt::format("Layer {}", ++currentMapId_);
// This must be initialized after the last line
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
imGuiContext_ = imGuiContext_ =
model::ImGuiContextModel::Instance().CreateContext(imGuiContextName_); model::ImGuiContextModel::Instance().CreateContext(imGuiContextName_);
@ -51,15 +49,20 @@ public:
model::ImGuiContextModel::Instance().DestroyContext(imGuiContextName_); model::ImGuiContextModel::Instance().DestroyContext(imGuiContextName_);
} }
DrawLayerImpl(const DrawLayerImpl&) = delete;
DrawLayerImpl& operator=(const DrawLayerImpl&) = delete;
DrawLayerImpl(const DrawLayerImpl&&) = delete;
DrawLayerImpl& operator=(const DrawLayerImpl&&) = delete;
std::shared_ptr<MapContext> context_; std::shared_ptr<MapContext> context_;
std::vector<std::shared_ptr<gl::draw::DrawItem>> drawList_; std::vector<std::shared_ptr<gl::draw::DrawItem>> drawList_;
GLuint textureAtlas_; GLuint textureAtlas_ {GL_INVALID_INDEX};
std::uint64_t textureAtlasBuildCount_ {}; std::uint64_t textureAtlasBuildCount_ {};
std::string imGuiContextName_; std::string imGuiContextName_;
ImGuiContext* imGuiContext_; ImGuiContext* imGuiContext_;
bool imGuiRendererInitialized_{}; bool imGuiRendererInitialized_ {};
}; };
DrawLayer::DrawLayer(const std::shared_ptr<MapContext>& context) : DrawLayer::DrawLayer(const std::shared_ptr<MapContext>& context) :
@ -171,15 +174,15 @@ bool DrawLayer::RunMousePicking(
bool itemPicked = false; bool itemPicked = false;
// For each draw item in the draw list in reverse // For each draw item in the draw list in reverse
for (auto it = p->drawList_.rbegin(); it != p->drawList_.rend(); ++it) for (auto& it : std::ranges::reverse_view(p->drawList_))
{ {
// Run mouse picking on each draw item // Run mouse picking on each draw item
if ((*it)->RunMousePicking(params, if (it->RunMousePicking(params,
mouseLocalPos, mouseLocalPos,
mouseGlobalPos, mouseGlobalPos,
mouseCoords, mouseCoords,
mouseGeoCoords, mouseGeoCoords,
eventHandler)) eventHandler))
{ {
// If a draw item was picked, don't process additional items // If a draw item was picked, don't process additional items
itemPicked = true; itemPicked = true;
@ -195,6 +198,4 @@ void DrawLayer::AddDrawItem(const std::shared_ptr<gl::draw::DrawItem>& drawItem)
p->drawList_.push_back(drawItem); p->drawList_.push_back(drawItem);
} }
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -50,7 +50,7 @@ public:
common::RadarProductGroup radar_product_group() const; common::RadarProductGroup radar_product_group() const;
std::string radar_product() const; std::string radar_product() const;
int16_t radar_product_code() const; int16_t radar_product_code() const;
QWidget* widget() const; [[nodiscard]] QWidget* widget() const;
void set_map(const std::shared_ptr<QMapLibre::Map>& map); void set_map(const std::shared_ptr<QMapLibre::Map>& map);
void set_map_copyrights(const std::string& copyrights); void set_map_copyrights(const std::string& copyrights);