From ecf2f58b9d50c8cc6f29e76076888843e4fa4228 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 21 May 2022 16:56:51 +0200 Subject: Simplified active label detection --- View.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/View.cpp b/View.cpp index fd2e83a..cf6ea9a 100644 --- a/View.cpp +++ b/View.cpp @@ -66,19 +66,14 @@ View::update(const float dt) } std::sort(m_labels.begin(), m_labels.end(), [](auto& a, auto& b){ return a.depth > b.depth; }); m_active = nullptr; - for (auto& label : m_labels) { + std::for_each(m_labels.rbegin(), m_labels.rend(), [this](auto& label) { if (label.hover) { - if (m_active) { - if (label.depth < m_active->depth) - m_active = &label; - } + if (m_active) + label.hover = false; else m_active = &label; - label.hover = false; } - } - if (m_active) - m_active->hover = true; + }); } -- cgit v1.1