Rework drawer target

This commit is contained in:
VladV 2022-01-08 20:25:50 +03:00
parent bfaf46f661
commit 2e2bacb490
5 changed files with 9 additions and 7 deletions

View File

@ -4,8 +4,7 @@ using TriInspector;
using TriInspector.Drawers;
using TriInspector.Elements;
[assembly: RegisterTriAttributeDrawer(typeof(ShowDrawerChainDrawer), TriDrawerOrder.System,
Target = TriTargetPropertyType.SelfAndArrayElements)]
[assembly: RegisterTriAttributeDrawer(typeof(ShowDrawerChainDrawer), TriDrawerOrder.System)]
namespace TriInspector.Drawers
{

View File

@ -13,7 +13,7 @@ namespace TriInspector
public Type DrawerType { get; }
public int Order { get; }
public TriTargetPropertyType Target { get; set; } = TriTargetPropertyType.SelfAndArrayElements;
public TriTargetPropertyType Target { get; set; } = TriTargetPropertyType.Self;
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]

View File

@ -17,8 +17,8 @@ namespace TriInspector.Elements
var drawers = property.AllDrawers;
for (var index = drawers.Count - 1; index >= 0; index--)
{
if (_property.IsArrayElement && (drawers[index].Target & TriTargetPropertyType.ArrayElements) == 0 ||
!_property.IsArrayElement && (drawers[index].Target & TriTargetPropertyType.Self) == 0)
if (_property.IsArray && (drawers[index].Target & TriTargetPropertyType.Array) == 0 ||
!_property.IsArray && (drawers[index].Target & TriTargetPropertyType.Self) == 0)
{
continue;
}

View File

@ -129,6 +129,9 @@ namespace TriInspector
[PublicAPI]
public bool IsArrayElement => _definition.IsArrayElement;
[PublicAPI]
public bool IsArray => _definition.IsArray;
public int IndexInArray => IsArrayElement
? _propertyIndex
: throw new InvalidOperationException("Cannot read IndexInArray for !IsArrayElement");

View File

@ -6,7 +6,7 @@ namespace TriInspector
public enum TriTargetPropertyType
{
Self = 1 << 0,
ArrayElements = 1 << 2,
SelfAndArrayElements = Self | ArrayElements,
Array = 1 << 2,
SelfAndArray = Self | Array,
}
}