mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 20:57:22 +02:00
[FancyZones] Don't create new custom layout when applying Focus layout (#4755)
* Only persist data when applying existing layout if it is scaled * Fix applying edited Focus layout * Fix different Focus zone sizes in editor and engine * Fix codestyle
This commit is contained in:
@@ -149,13 +149,14 @@ namespace FancyZonesEditor
|
|||||||
|
|
||||||
if (mainEditor.DataContext is LayoutModel model)
|
if (mainEditor.DataContext is LayoutModel model)
|
||||||
{
|
{
|
||||||
if (model is GridLayoutModel)
|
// If custom canvas layout has been scaled, persisting is needed
|
||||||
|
if (model is CanvasLayoutModel && (model as CanvasLayoutModel).IsScaled)
|
||||||
{
|
{
|
||||||
model.Apply();
|
model.Persist();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
model.Persist();
|
model.Apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ namespace FancyZonesEditor.Models
|
|||||||
{
|
{
|
||||||
lastWorkAreaWidth = workAreaWidth;
|
lastWorkAreaWidth = workAreaWidth;
|
||||||
lastWorkAreaHeight = workAreaHeight;
|
lastWorkAreaHeight = workAreaHeight;
|
||||||
|
IsScaled = false;
|
||||||
|
|
||||||
if (ShouldScaleLayout())
|
if (ShouldScaleLayout())
|
||||||
{
|
{
|
||||||
@@ -32,6 +33,12 @@ namespace FancyZonesEditor.Models
|
|||||||
|
|
||||||
public CanvasLayoutModel(string name, LayoutType type)
|
public CanvasLayoutModel(string name, LayoutType type)
|
||||||
: base(name, type)
|
: base(name, type)
|
||||||
|
{
|
||||||
|
IsScaled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CanvasLayoutModel(string name)
|
||||||
|
: base(name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,6 +49,8 @@ namespace FancyZonesEditor.Models
|
|||||||
|
|
||||||
private int lastWorkAreaHeight = (int)Settings.WorkArea.Height;
|
private int lastWorkAreaHeight = (int)Settings.WorkArea.Height;
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
// RemoveZoneAt
|
// RemoveZoneAt
|
||||||
// Removes the specified index from the Zones list, and fires a property changed notification for the Zones property
|
// Removes the specified index from the Zones list, and fires a property changed notification for the Zones property
|
||||||
public void RemoveZoneAt(int index)
|
public void RemoveZoneAt(int index)
|
||||||
@@ -63,7 +72,7 @@ namespace FancyZonesEditor.Models
|
|||||||
// Clones the data from this CanvasLayoutModel to a new CanvasLayoutModel
|
// Clones the data from this CanvasLayoutModel to a new CanvasLayoutModel
|
||||||
public override LayoutModel Clone()
|
public override LayoutModel Clone()
|
||||||
{
|
{
|
||||||
CanvasLayoutModel layout = new CanvasLayoutModel(Name, Type);
|
CanvasLayoutModel layout = new CanvasLayoutModel(Name);
|
||||||
|
|
||||||
foreach (Int32Rect zone in Zones)
|
foreach (Int32Rect zone in Zones)
|
||||||
{
|
{
|
||||||
@@ -107,6 +116,7 @@ namespace FancyZonesEditor.Models
|
|||||||
|
|
||||||
lastWorkAreaHeight = (int)Settings.WorkArea.Height;
|
lastWorkAreaHeight = (int)Settings.WorkArea.Height;
|
||||||
lastWorkAreaWidth = (int)Settings.WorkArea.Width;
|
lastWorkAreaWidth = (int)Settings.WorkArea.Width;
|
||||||
|
IsScaled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct Zone
|
private struct Zone
|
||||||
|
|||||||
@@ -420,8 +420,8 @@ bool ZoneSet::CalculateFocusLayout(Rect workArea, int zoneCount) noexcept
|
|||||||
|
|
||||||
long left{ long(workArea.width() * 0.1) };
|
long left{ long(workArea.width() * 0.1) };
|
||||||
long top{ long(workArea.height() * 0.1) };
|
long top{ long(workArea.height() * 0.1) };
|
||||||
long right{ long(workArea.width() * 0.6) };
|
long right{ left + long(workArea.width() * 0.6) };
|
||||||
long bottom{ long(workArea.height() * 0.6) };
|
long bottom{ top + long(workArea.height() * 0.6) };
|
||||||
|
|
||||||
RECT focusZoneRect{ left, top, right, bottom };
|
RECT focusZoneRect{ left, top, right, bottom };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user