Allow negative spacing between zones up to -10 (#7284)

This commit is contained in:
vldmr11080 2020-10-14 17:42:47 +02:00 committed by GitHub
parent d1372af581
commit 944e605f06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 5 deletions

View File

@ -54,6 +54,8 @@ namespace FancyZonesEditor
public const ushort _blankCustomModelId = 0xFFFA; public const ushort _blankCustomModelId = 0xFFFA;
public const ushort _lastDefinedId = _blankCustomModelId; public const ushort _lastDefinedId = _blankCustomModelId;
private const int MaxNegativeSpacing = -10;
// Localizable strings // Localizable strings
private const string ErrorMessageBoxTitle = "FancyZones Editor Error"; private const string ErrorMessageBoxTitle = "FancyZones Editor Error";
private const string ErrorParsingDeviceInfo = "Error parsing device info data."; private const string ErrorParsingDeviceInfo = "Error parsing device info data.";
@ -209,7 +211,7 @@ namespace FancyZonesEditor
{ {
if (_spacing != value) if (_spacing != value)
{ {
_spacing = Math.Max(0, value); _spacing = Math.Max(MaxNegativeSpacing, value);
FirePropertyChanged(); FirePropertyChanged();
} }
} }

View File

@ -15,7 +15,11 @@ namespace
{ {
int width = rect.right - rect.left; int width = rect.right - rect.left;
int height = rect.bottom - rect.top; int height = rect.bottom - rect.top;
return rect.left >= 0 && rect.right >= 0 && rect.top >= 0 && rect.bottom >= 0 && width >= 0 && height >= 0; return rect.left >= ZoneConstants::MAX_NEGATIVE_SPACING &&
rect.right >= ZoneConstants::MAX_NEGATIVE_SPACING &&
rect.top >= ZoneConstants::MAX_NEGATIVE_SPACING &&
rect.bottom >= ZoneConstants::MAX_NEGATIVE_SPACING &&
width >= 0 && height >= 0;
} }
BOOL CALLBACK saveDisplayToVector(HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM data) BOOL CALLBACK saveDisplayToVector(HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM data)

View File

@ -1,5 +1,10 @@
#pragma once #pragma once
namespace ZoneConstants
{
constexpr int MAX_NEGATIVE_SPACING = -10;
}
/** /**
* Class representing one zone inside applied zone layout, which is basically wrapper around rectangle structure. * Class representing one zone inside applied zone layout, which is basically wrapper around rectangle structure.
*/ */

View File

@ -156,7 +156,8 @@ namespace FancyZonesUnitTests
TEST_METHOD (MakeZoneFromInvalidRectCoords) TEST_METHOD (MakeZoneFromInvalidRectCoords)
{ {
winrt::com_ptr<IZone> zone = MakeZone({ -1, -1, -1, -1 }, 1); const int invalid = ZoneConstants::MAX_NEGATIVE_SPACING - 1;
winrt::com_ptr<IZone> zone = MakeZone({ invalid, invalid, invalid, invalid }, 1);
Assert::IsNull(zone.get()); Assert::IsNull(zone.get());
} }
@ -846,9 +847,9 @@ namespace FancyZonesUnitTests
} }
} }
TEST_METHOD (NegativeSpacing) TEST_METHOD (LargeNegativeSpacing)
{ {
const int spacing = -1; const int spacing = ZoneConstants::MAX_NEGATIVE_SPACING - 1;
const int zoneCount = 10; const int zoneCount = 10;
for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++) for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++)