mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
[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:
55
src/modules/fancyzones/FancyZonesLib/HighlightedZones.cpp
Normal file
55
src/modules/fancyzones/FancyZonesLib/HighlightedZones.cpp
Normal 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 = {};
|
||||
}
|
||||
Reference in New Issue
Block a user