From c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sun, 19 Apr 2020 17:19:32 -0400 Subject: Inital commit --- .../Collab/Views/CollabHistoryDropDownItem.cs | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Library/PackageCache/com.unity.collab-proxy@1.2.16/Editor/Collab/Views/CollabHistoryDropDownItem.cs (limited to 'Library/PackageCache/com.unity.collab-proxy@1.2.16/Editor/Collab/Views/CollabHistoryDropDownItem.cs') diff --git a/Library/PackageCache/com.unity.collab-proxy@1.2.16/Editor/Collab/Views/CollabHistoryDropDownItem.cs b/Library/PackageCache/com.unity.collab-proxy@1.2.16/Editor/Collab/Views/CollabHistoryDropDownItem.cs new file mode 100644 index 0000000..3ad43f2 --- /dev/null +++ b/Library/PackageCache/com.unity.collab-proxy@1.2.16/Editor/Collab/Views/CollabHistoryDropDownItem.cs @@ -0,0 +1,53 @@ +using System; +using System.IO; +using System.Linq; +using UnityEngine; + +#if UNITY_2019_1_OR_NEWER +using UnityEngine.UIElements; +#else +using UnityEngine.Experimental.UIElements; +#endif + + +namespace UnityEditor.Collaboration +{ + internal class CollabHistoryDropDownItem : VisualElement + { + public CollabHistoryDropDownItem(string path, string action) + { + var fileName = Path.GetFileName(path); + var isFolder = Path.GetFileNameWithoutExtension(path).Equals(fileName); + var fileIcon = GetIconElement(action, fileName, isFolder); + var metaContainer = new VisualElement(); + var fileNameLabel = new Label + { + name = "FileName", + text = fileName + }; + var filePathLabel = new Label + { + name = "FilePath", + text = path + }; + metaContainer.Add(fileNameLabel); + metaContainer.Add(filePathLabel); + Add(fileIcon); + Add(metaContainer); + } + + private Image GetIconElement(string action, string fileName, bool isFolder) + { + var prefix = isFolder ? "Folder" : "File"; + var actionName = action.First().ToString().ToUpper() + action.Substring(1); + // Use the same icon for renamed and moved files + actionName = actionName.Equals("Renamed") ? "Moved" : actionName; + var iconElement = new Image + { + name = "FileIcon", + image = EditorGUIUtility.LoadIcon("Icons/Collab." + prefix + actionName + ".png") + }; + return iconElement; + } + } +} -- cgit v1.2.3