| | |
| | | IsLocked = plugin.Manifest.DefaultLayout.Locked, |
| | | ClickThrough = plugin.Manifest.DefaultLayout.ClickThrough, |
| | | Opacity = Clamp(plugin.Manifest.DefaultLayout.Opacity, MinOpacity, MaxOpacity), |
| | | Scale = Clamp(plugin.Manifest.DefaultLayout.Scale, MinScale, MaxScale) |
| | | Scale = Clamp(plugin.Manifest.DefaultLayout.Scale, MinScale, MaxScale), |
| | | DisplayLayer = plugin.Manifest.DefaultLayout.DisplayLayer |
| | | }; |
| | | |
| | | lock (_gate) |
| | |
| | | IsLocked = patch.IsLocked ?? layout.IsLocked, |
| | | Opacity = patch.Opacity ?? layout.Opacity, |
| | | ClickThrough = patch.ClickThrough ?? layout.ClickThrough, |
| | | Scale = patch.Scale ?? layout.Scale |
| | | }); |
| | | Scale = patch.Scale ?? layout.Scale, |
| | | DisplayLayer = patch.DisplayLayer ?? layout.DisplayLayer |
| | | }, allowLocked: IsUnlockPatch(patch)); |
| | | } |
| | | |
| | | public IReadOnlyList<WidgetLayout> ReconcileMonitors(IReadOnlyList<MonitorInfo> monitors) |
| | |
| | | } |
| | | } |
| | | |
| | | private OperationResult<WidgetLayout> Mutate(WidgetInstanceId instanceId, Func<WidgetLayout, WidgetLayout> update) |
| | | private OperationResult<WidgetLayout> Mutate(WidgetInstanceId instanceId, Func<WidgetLayout, WidgetLayout> update, bool allowLocked = false) |
| | | { |
| | | lock (_gate) |
| | | { |
| | |
| | | } |
| | | |
| | | var current = _document.Instances[index]; |
| | | if (current.IsLocked) |
| | | if (current.IsLocked && !allowLocked) |
| | | { |
| | | return OperationResult<WidgetLayout>.Failure("WidgetLayoutLocked", $"Widget layout {instanceId} is locked."); |
| | | } |
| | |
| | | |
| | | private static double Clamp(double value, double min, double max) |
| | | => Math.Min(Math.Max(value, min), max); |
| | | |
| | | private static bool IsUnlockPatch(WidgetLayoutPatch patch) |
| | | => patch.IsLocked == false && |
| | | patch.Bounds is null && |
| | | patch.MonitorId is null && |
| | | patch.IsVisible is null && |
| | | patch.Opacity is null && |
| | | patch.ClickThrough is null && |
| | | patch.Scale is null && |
| | | patch.DisplayLayer is null; |
| | | } |