summaryrefslogtreecommitdiff
path: root/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Animation/BindingTreeViewDataSourceGUI.cs
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2020-04-19 17:19:32 -0400
committerAndrew Lee <alee14498@protonmail.com>2020-04-19 17:19:32 -0400
commitc55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78 (patch)
treeee4d51c7c1d633e11f46453ef1edd3c77c4ef9f7 /Library/PackageCache/com.unity.timeline@1.2.13/Editor/Animation/BindingTreeViewDataSourceGUI.cs
downloadProject-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.gz
Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.bz2
Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.zip
Inital commit
Diffstat (limited to 'Library/PackageCache/com.unity.timeline@1.2.13/Editor/Animation/BindingTreeViewDataSourceGUI.cs')
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Editor/Animation/BindingTreeViewDataSourceGUI.cs80
1 files changed, 80 insertions, 0 deletions
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Animation/BindingTreeViewDataSourceGUI.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Animation/BindingTreeViewDataSourceGUI.cs
new file mode 100644
index 0000000..443a216
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Animation/BindingTreeViewDataSourceGUI.cs
@@ -0,0 +1,80 @@
+using UnityEditor;
+using UnityEditor.IMGUI.Controls;
+using UnityEngine;
+
+namespace UnityEditorInternal
+{
+ class BindingTreeViewGUI : TreeViewGUI
+ {
+ static readonly float s_RowRightOffset = 10;
+ static readonly float s_ColorIndicatorTopMargin = 3;
+ static readonly Color s_KeyColorForNonCurves = new Color(0.7f, 0.7f, 0.7f, 0.5f);
+ static readonly Color s_ChildrenCurveLabelColor = new Color(1.0f, 1.0f, 1.0f, 0.7f);
+
+ public BindingTreeViewGUI(TreeViewController treeView)
+ : base(treeView, true)
+ {
+ k_IconWidth = 13.0f;
+ }
+
+ public override void OnRowGUI(Rect rowRect, TreeViewItem node, int row, bool selected, bool focused)
+ {
+ Color originalColor = GUI.color;
+ GUI.color = node.parent == null ||
+ node.parent.id == BindingTreeViewDataSource.RootID ||
+ node.parent.id == BindingTreeViewDataSource.GroupID ?
+ Color.white :
+ s_ChildrenCurveLabelColor;
+
+ base.OnRowGUI(rowRect, node, row, selected, focused);
+
+ GUI.color = originalColor;
+ DoCurveColorIndicator(rowRect, node as CurveTreeViewNode);
+ }
+
+ protected override bool IsRenaming(int id)
+ {
+ return false;
+ }
+
+ public override bool BeginRename(TreeViewItem item, float delay)
+ {
+ return false;
+ }
+
+ void DoCurveColorIndicator(Rect rect, CurveTreeViewNode node)
+ {
+ if (node == null)
+ return;
+
+ if (Event.current.type != EventType.Repaint)
+ return;
+
+ Color originalColor = GUI.color;
+
+ if (node.bindings.Length == 1 && !node.bindings[0].isPPtrCurve)
+ GUI.color = CurveUtility.GetPropertyColor(node.bindings[0].propertyName);
+ else
+ GUI.color = s_KeyColorForNonCurves;
+
+ Texture icon = CurveUtility.GetIconCurve();
+ rect = new Rect(rect.xMax - s_RowRightOffset - (icon.width * 0.5f) - 5, rect.yMin + s_ColorIndicatorTopMargin, icon.width, icon.height);
+
+ GUI.DrawTexture(rect, icon, ScaleMode.ScaleToFit, true, 1);
+
+ GUI.color = originalColor;
+ }
+
+ protected override Texture GetIconForItem(TreeViewItem item)
+ {
+ var node = item as CurveTreeViewNode;
+ if (node == null)
+ return null;
+
+ if (node.bindings == null || node.bindings.Length == 0)
+ return null;
+
+ return AssetPreview.GetMiniTypeThumbnail(node.bindings[0].type);
+ }
+ }
+}