2023-01-23 20:13:05 +03:00
|
|
|
#include "pch.h"
|
|
|
|
|
#include "HighlightedZones.h"
|
|
|
|
|
|
|
|
|
|
#include <FancyZonesLib/Layout.h>
|
|
|
|
|
|
2023-01-30 19:39:46 +03:00
|
|
|
HighlightedZones::HighlightedZones() noexcept
|
2023-01-23 20:13:05 +03:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 = {};
|
|
|
|
|
}
|