mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
[FancyZones] Rework grid editor (#10116)
* Started rewriting * Making progress * Fix resizers not moving around * Implemented splitting, fixed some bugs * Removed more code, renamed methods * Merging zones works * Fix Shift key behavior * Added spacing (has bugs) * Implement minimum size restriction * Match preview and editor visuals * Snapping works * Show when splitting is not possible * Fix spell checker complaining * Tweak FZ Lib function computing grid zones * Fix potential crash when loading old zone layouts * Fix dead objects talking * Fix splitters being shown when they shouldn't be * Fix index numbering * Fix small glitch with the shift key * Do not snap to borders outside the zone
This commit is contained in:
@@ -825,8 +825,8 @@ bool ZoneSet::CalculateCustomLayout(Rect workArea, int spacing) noexcept
|
||||
|
||||
bool ZoneSet::CalculateGridZones(Rect workArea, FancyZonesDataTypes::GridLayoutInfo gridLayoutInfo, int spacing)
|
||||
{
|
||||
long totalWidth = workArea.width() - (spacing * (gridLayoutInfo.columns() + 1));
|
||||
long totalHeight = workArea.height() - (spacing * (gridLayoutInfo.rows() + 1));
|
||||
long totalWidth = workArea.width();
|
||||
long totalHeight = workArea.height();
|
||||
struct Info
|
||||
{
|
||||
long Extent;
|
||||
@@ -841,18 +841,18 @@ bool ZoneSet::CalculateGridZones(Rect workArea, FancyZonesDataTypes::GridLayoutI
|
||||
int totalPercents = 0;
|
||||
for (int row = 0; row < gridLayoutInfo.rows(); row++)
|
||||
{
|
||||
rowInfo[row].Start = totalPercents * totalHeight / C_MULTIPLIER + (row + 1) * spacing;
|
||||
rowInfo[row].Start = totalPercents * totalHeight / C_MULTIPLIER;
|
||||
totalPercents += gridLayoutInfo.rowsPercents()[row];
|
||||
rowInfo[row].End = totalPercents * totalHeight / C_MULTIPLIER + (row + 1) * spacing;
|
||||
rowInfo[row].End = totalPercents * totalHeight / C_MULTIPLIER;
|
||||
rowInfo[row].Extent = rowInfo[row].End - rowInfo[row].Start;
|
||||
}
|
||||
|
||||
totalPercents = 0;
|
||||
for (int col = 0; col < gridLayoutInfo.columns(); col++)
|
||||
{
|
||||
columnInfo[col].Start = totalPercents * totalWidth / C_MULTIPLIER + (col + 1) * spacing;
|
||||
columnInfo[col].Start = totalPercents * totalWidth / C_MULTIPLIER;
|
||||
totalPercents += gridLayoutInfo.columnsPercents()[col];
|
||||
columnInfo[col].End = totalPercents * totalWidth / C_MULTIPLIER + (col + 1) * spacing;
|
||||
columnInfo[col].End = totalPercents * totalWidth / C_MULTIPLIER;
|
||||
columnInfo[col].Extent = columnInfo[col].End - columnInfo[col].Start;
|
||||
}
|
||||
|
||||
@@ -881,6 +881,11 @@ bool ZoneSet::CalculateGridZones(Rect workArea, FancyZonesDataTypes::GridLayoutI
|
||||
long right = columnInfo[maxCol].End;
|
||||
long bottom = rowInfo[maxRow].End;
|
||||
|
||||
top += row == 0 ? spacing : spacing / 2;
|
||||
bottom -= row == gridLayoutInfo.rows() - 1 ? spacing : spacing / 2;
|
||||
left += col == 0 ? spacing : spacing / 2;
|
||||
right -= col == gridLayoutInfo.columns() - 1 ? spacing : spacing / 2;
|
||||
|
||||
auto zone = MakeZone(RECT{ left, top, right, bottom }, i);
|
||||
if (zone)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user