[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:
stefansjfw 2020-07-08 15:34:19 +02:00 committed by GitHub
parent db229cf1bf
commit 106c316442
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 6 deletions

View File

@ -149,13 +149,14 @@ namespace FancyZonesEditor
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
{
model.Persist();
model.Apply();
}
Close();

View File

@ -19,6 +19,7 @@ namespace FancyZonesEditor.Models
{
lastWorkAreaWidth = workAreaWidth;
lastWorkAreaHeight = workAreaHeight;
IsScaled = false;
if (ShouldScaleLayout())
{
@ -32,6 +33,12 @@ namespace FancyZonesEditor.Models
public CanvasLayoutModel(string name, LayoutType 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;
public bool IsScaled { get; private set; }
// RemoveZoneAt
// Removes the specified index from the Zones list, and fires a property changed notification for the Zones property
public void RemoveZoneAt(int index)
@ -63,7 +72,7 @@ namespace FancyZonesEditor.Models
// Clones the data from this CanvasLayoutModel to a new CanvasLayoutModel
public override LayoutModel Clone()
{
CanvasLayoutModel layout = new CanvasLayoutModel(Name, Type);
CanvasLayoutModel layout = new CanvasLayoutModel(Name);
foreach (Int32Rect zone in Zones)
{
@ -107,6 +116,7 @@ namespace FancyZonesEditor.Models
lastWorkAreaHeight = (int)Settings.WorkArea.Height;
lastWorkAreaWidth = (int)Settings.WorkArea.Width;
IsScaled = true;
}
private struct Zone

View File

@ -420,8 +420,8 @@ bool ZoneSet::CalculateFocusLayout(Rect workArea, int zoneCount) noexcept
long left{ long(workArea.width() * 0.1) };
long top{ long(workArea.height() * 0.1) };
long right{ long(workArea.width() * 0.6) };
long bottom{ long(workArea.height() * 0.6) };
long right{ left + long(workArea.width() * 0.6) };
long bottom{ top + long(workArea.height() * 0.6) };
RECT focusZoneRect{ left, top, right, bottom };