diff --git a/scwx-qt/source/scwx/qt/map/overlay_layer.cpp b/scwx-qt/source/scwx/qt/map/overlay_layer.cpp index 66ad3317..f2bb882a 100644 --- a/scwx-qt/source/scwx/qt/map/overlay_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/overlay_layer.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #include @@ -17,6 +16,7 @@ #include #include #include +#include #include #pragma warning(pop) @@ -34,26 +34,16 @@ class OverlayLayerImpl { public: explicit OverlayLayerImpl(std::shared_ptr context) : - textShader_(context), - font_(util::Font::Create(":/res/fonts/din1451alt.ttf")), - texture_ {GL_INVALID_INDEX}, activeBoxOuter_ {std::make_shared(context)}, activeBoxInner_ {std::make_shared(context)}, - timeBox_ {std::make_shared(context)}, sweepTimeString_ {}, sweepTimeNeedsUpdate_ {true} { - // TODO: Manage font at the global level, texture at the view level } ~OverlayLayerImpl() = default; - gl::TextShader textShader_; - std::shared_ptr font_; - GLuint texture_; - std::shared_ptr activeBoxOuter_; std::shared_ptr activeBoxInner_; - std::shared_ptr timeBox_; std::string sweepTimeString_; bool sweepTimeNeedsUpdate_; @@ -62,7 +52,6 @@ public: OverlayLayer::OverlayLayer(std::shared_ptr context) : DrawLayer(context), p(std::make_unique(context)) { - AddDrawItem(p->timeBox_); AddDrawItem(p->activeBoxOuter_); AddDrawItem(p->activeBoxInner_); @@ -70,7 +59,6 @@ OverlayLayer::OverlayLayer(std::shared_ptr context) : p->activeBoxOuter_->SetBorder(1.0f, {0, 0, 0, 255}); p->activeBoxInner_->SetBorder(1.0f, {255, 255, 255, 255}); p->activeBoxInner_->SetPosition(1.0f, 1.0f); - p->timeBox_->SetFill({0, 0, 0, 192}); } OverlayLayer::~OverlayLayer() = default; @@ -81,15 +69,7 @@ void OverlayLayer::Initialize() DrawLayer::Initialize(); - gl::OpenGLFunctions& gl = context()->gl(); - auto radarProductView = context()->radar_product_view(); - - p->textShader_.Initialize(); - - if (p->texture_ == GL_INVALID_INDEX) - { - p->texture_ = p->font_->GenerateTexture(gl); - } + auto radarProductView = context()->radar_product_view(); if (radarProductView != nullptr) { @@ -103,8 +83,6 @@ void OverlayLayer::Initialize() void OverlayLayer::Render( const QMapLibreGL::CustomLayerRenderParameters& params) { - constexpr float fontSize = 16.0f; - gl::OpenGLFunctions& gl = context()->gl(); auto radarProductView = context()->radar_product_view(); auto& settings = context()->settings(); @@ -130,31 +108,20 @@ void OverlayLayer::Render( p->activeBoxInner_->SetSize(params.width - 2.0f, params.height - 2.0f); } - if (p->sweepTimeString_.length() > 0) - { - const float textLength = - p->font_->TextLength(p->sweepTimeString_, fontSize); - - p->timeBox_->SetPosition(static_cast(params.width) - textLength - - 14.0f, - static_cast(params.height) - 22.0f); - p->timeBox_->SetSize(textLength + 14.0f, 22.0f); - } - DrawLayer::Render(params); if (p->sweepTimeString_.length() > 0) { // Render time - p->textShader_.RenderText(p->sweepTimeString_, - params.width - 7.0f, - static_cast(params.height) - 16.0f, - fontSize, - projection, - boost::gil::rgba8_pixel_t(255, 255, 255, 204), - p->font_, - p->texture_, - gl::TextAlign::Right); + ImGui::SetNextWindowPos(ImVec2 {static_cast(params.width), 0.0f}, + ImGuiCond_Always, + ImVec2 {1.0f, 0.0f}); + ImGui::Begin("Sweep Time", + nullptr, + ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | + ImGuiWindowFlags_AlwaysAutoResize); + ImGui::Text(p->sweepTimeString_.c_str()); + ImGui::End(); } SCWX_GL_CHECK_ERROR(); @@ -166,12 +133,7 @@ void OverlayLayer::Deinitialize() DrawLayer::Deinitialize(); - gl::OpenGLFunctions& gl = context()->gl(); - auto radarProductView = context()->radar_product_view(); - - gl.glDeleteTextures(1, &p->texture_); - - p->texture_ = GL_INVALID_INDEX; + auto radarProductView = context()->radar_product_view(); if (radarProductView != nullptr) { diff --git a/scwx-qt/source/scwx/qt/model/imgui_context_model.cpp b/scwx-qt/source/scwx/qt/model/imgui_context_model.cpp index 80473e34..f045a9b1 100644 --- a/scwx-qt/source/scwx/qt/model/imgui_context_model.cpp +++ b/scwx-qt/source/scwx/qt/model/imgui_context_model.cpp @@ -97,8 +97,11 @@ ImGuiContext* ImGuiContextModel::CreateContext(const std::string& name) io.IniFilename = nullptr; // Style - auto& style = ImGui::GetStyle(); - style.WindowMinSize = {10.0f, 10.0f}; + auto& style = ImGui::GetStyle(); + style.WindowMinSize = {10.0f, 10.0f}; + style.WindowPadding = {6.0f, 4.0f}; + style.Colors[ImGuiCol_Text] = {1.00f, 1.00f, 1.00f, 0.80f}; + style.Colors[ImGuiCol_WindowBg] = {0.06f, 0.06f, 0.06f, 0.75f}; // Register context const int nextPosition = static_cast(p->contexts_.size());