Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FancyZones] Improve code quality (part 2: WorkArea init) (#23030)
* init WorkArea with a rectangle * keep the highlighted zones state in a separate class
- Loading branch information
1 parent
cc5633d
commit 6f0b16d
Showing
10 changed files
with
201 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include <FancyZonesLib/Zone.h> | ||
|
||
class Layout; | ||
|
||
class HighlightedZones | ||
{ | ||
public: | ||
HighlightedZones(); | ||
~HighlightedZones() = default; | ||
|
||
const ZoneIndexSet& Zones() const noexcept; | ||
bool Empty() const noexcept; | ||
|
||
bool Update(const Layout* layout, POINT const& point, bool selectManyZones) noexcept; | ||
void Reset() noexcept; | ||
|
||
private: | ||
ZoneIndexSet m_initialHighlightZone; | ||
ZoneIndexSet m_highlightZone; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.