Add "at anchor" skin selector.

This commit is contained in:
2022-12-22 17:14:48 +08:00
parent 95628f07d1
commit 1f0ac2a2e9
2 changed files with 18 additions and 1 deletions

View File

@@ -28,7 +28,7 @@ namespace Cryville.Crtr {
GetChar();
if (cc == '.') {
GetChar();
s.Add(new SkinSelector.State(GetIdentifier()));
s.Add(new SkinSelector.AtAnchor(GetIdentifier()));
key = null;
}
else {

View File

@@ -104,6 +104,23 @@ namespace Cryville.Crtr {
return h.Handler.Anchors[Name].Opened;
}
}
public class AtAnchor : SkinSelector {
public int Name { get; private set; }
public AtAnchor(string name) {
Name = IdentifierManager.SharedInstance.Request(name);
}
public override bool IsStatic {
get { return false; }
}
public override Transform Match(ContainerState h, Transform a, bool dyn = false) {
if (!dyn) throw new SelectorNotStaticException();
return IsUpdatable(h) ? a : null;
}
public override bool IsUpdatable(ContainerState h) {
return h.Handler.Anchors[Name].Opened;
}
}
public class Property : SkinSelector {
readonly PdtExpression _exp;
readonly PdtOperator _op;