[FancyZones] Improve code quality (part 2: WorkArea init) (#23030)

* init WorkArea with a rectangle
* keep the highlighted zones state in a separate class
This commit is contained in:
Seraphima Zykova
2023-01-23 20:13:05 +03:00
committed by GitHub
parent cc5633db30
commit 6f0b16de49
10 changed files with 201 additions and 162 deletions

View File

@@ -0,0 +1,55 @@
#include "pch.h"
#include "HighlightedZones.h"
#include <FancyZonesLib/Layout.h>
HighlightedZones::HighlightedZones()
{
}
const ZoneIndexSet& HighlightedZones::Zones() const noexcept
{
return m_highlightZone;
}
bool HighlightedZones::Empty() const noexcept
{
return m_highlightZone.empty();
}
bool HighlightedZones::Update(const Layout* layout, POINT const& point, bool selectManyZones) noexcept
{
if (!layout)
{
return false;
}
auto highlightZone = layout->ZonesFromPoint(point);
if (selectManyZones)
{
if (m_initialHighlightZone.empty())
{
// first time
m_initialHighlightZone = highlightZone;
}
else
{
highlightZone = layout->GetCombinedZoneRange(m_initialHighlightZone, highlightZone);
}
}
else
{
m_initialHighlightZone = {};
}
const bool updated = (highlightZone != m_highlightZone);
m_highlightZone = std::move(highlightZone);
return updated;
}
void HighlightedZones::Reset() noexcept
{
m_highlightZone = {};
m_initialHighlightZone = {};
}