mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +02:00
56 lines
1.1 KiB
C++
56 lines
1.1 KiB
C++
|
|
#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 = {};
|
||
|
|
}
|