mirror of
https://github.com/codewriter-packages/Tri-Inspector.git
synced 2025-01-22 08:18:49 -05:00
Rework drawer target
This commit is contained in:
parent
bfaf46f661
commit
2e2bacb490
@ -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
|
||||
{
|
||||
|
@ -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)]
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -6,7 +6,7 @@ namespace TriInspector
|
||||
public enum TriTargetPropertyType
|
||||
{
|
||||
Self = 1 << 0,
|
||||
ArrayElements = 1 << 2,
|
||||
SelfAndArrayElements = Self | ArrayElements,
|
||||
Array = 1 << 2,
|
||||
SelfAndArray = Self | Array,
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user