Skip to content

Commit

Permalink
fix key exclusions with Bitmap Layers
Browse files Browse the repository at this point in the history
  • Loading branch information
Aytackydln committed Nov 2, 2024
1 parent 1eb8561 commit 41d33dd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Project-Aurora/Project-Aurora/EffectsEngine/EffectLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public BitmapEffectLayer(string name, bool persistent) : this(name)
/// </summary>
public Color Get(DeviceKeys key)
{
if (KeyExcluded(key))
{
return TransparentColor;
}

var keyRectangle = Effects.Canvas.GetRectangle(key);

if (keyRectangle.IsEmpty)
Expand Down Expand Up @@ -1041,6 +1046,7 @@ private void PercentEffect(ColorSpectrum spectrum, FreeFormObject freeform, doub
}

private KeySequence _excludeSequence = new();
private readonly ZoneKeysCache _excludeKeysCache = new();

/// <inheritdoc />
public void Exclude(KeySequence sequence)
Expand All @@ -1066,5 +1072,18 @@ public void OnlyInclude(KeySequence sequence)
Invalidate();
}

private bool KeyExcluded(DeviceKeys key)
{
switch (_excludeSequence.Type)
{
case KeySequenceType.Sequence:
return _excludeSequence.Keys.Contains(key);
case KeySequenceType.FreeForm:
return _excludeKeysCache.GetKeys(_excludeSequence.Freeform).Contains(key);
}

return false;
}

public override string ToString() => _name;
}

0 comments on commit 41d33dd

Please sign in to comment.