Skip to content

Commit

Permalink
Wrap around colorIndex in a colors array (#669)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyoyuppe authored and enricogior committed Nov 7, 2019
1 parent c4fc673 commit a9518c2
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions src/modules/fancyzones/lib/ZoneWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,33 +817,36 @@ void ZoneWindow::DrawActiveZoneSet(wil::unique_hdc& hdc, RECT const& clientRect)
ColorSetting const colorFlash { 200, RGB(81, 92, 107), 200, RGB(104, 118, 138), -2 };

auto zones = m_activeZoneSet->GetZones();
size_t colorIndex = zones.size() - 1;
const size_t maxColorIndex = min(size(zones) - 1, size(colors) - 1);
size_t colorIndex = maxColorIndex;
for (auto iter = zones.rbegin(); iter != zones.rend(); iter++)
{
if (winrt::com_ptr<IZone> zone = iter->try_as<IZone>())
winrt::com_ptr<IZone> zone = iter->try_as<IZone>();
if (!zone)
{
if (zone != m_highlightZone)
continue;
}
if (zone != m_highlightZone)
{
if (m_flashMode)
{
if (m_flashMode)
{
DrawZone(hdc, colorFlash, zone);
}
else if (m_drawHints)
{
DrawZone(hdc, colorHints, zone);
}
else if (m_editorMode)
{
DrawZone(hdc, colorEditorMode, zone);
}
else
{
colorViewer.fill = colors[colorIndex];
DrawZone(hdc, colorViewer, zone);
}
DrawZone(hdc, colorFlash, zone);
}
else if (m_drawHints)
{
DrawZone(hdc, colorHints, zone);
}
else if (m_editorMode)
{
DrawZone(hdc, colorEditorMode, zone);
}
else
{
colorViewer.fill = colors[colorIndex];
DrawZone(hdc, colorViewer, zone);
}
colorIndex--;
}
colorIndex = colorIndex != 0 ? colorIndex - 1 : maxColorIndex;
}

if (m_highlightZone)
Expand Down

0 comments on commit a9518c2

Please sign in to comment.