using System; using System.Collections.Generic; using UnityEngine.UIElements; namespace UnityEditor.U2D.Animation { internal interface IInfluenceWindow { void UpdateList(List transformsList); void UpdateSelection(IEnumerable newSelection); void ToggleAddButton(bool enabled); void ToggleRemoveButton(bool enabled); string headerText { get; set; } string listLabelText { set; } void SetHiddenFromLayout(bool hide); void SetTooltips(string addButtonTooltip, string removeButtonTooltip); bool visible { get; } event Action onAddElement; event Action onRemoveElement; event Action> onReordered; event Action> onSelectionChanged; } internal class InfluenceWindow : VisualElement, IInfluenceWindow { public class CustomUxmlFactory : UxmlFactory { } public event Action onAddElement = () => {}; public event Action onRemoveElement = () => {}; public event Action> onReordered = _ => {}; public event Action> onSelectionChanged = _ => {}; UnityEngine.UIElements.PopupWindow m_HeaderLabel; Label m_ListLabel; IEnumerable m_Selection; ListView m_ListView; List m_Influences = new List(); Button m_AddButton; Button m_RemoveButton; bool m_IgnoreSelectionChange = false; public string headerText { get => m_HeaderLabel.text; set => m_HeaderLabel.text = value; } public string listLabelText { get => m_ListLabel.text; set => m_ListLabel.text = value; } public void SetTooltips(string addButtonTooltip, string removeButtonTooltip) { m_AddButton.tooltip = addButtonTooltip; m_RemoveButton.tooltip = removeButtonTooltip; } internal static InfluenceWindow CreateFromUxml() { var visualTree = ResourceLoader.Load("SkinningModule/InfluenceWindow.uxml"); var ve = (InfluenceWindow)visualTree.CloneTree().Q("InfluenceWindow"); ve.styleSheets.Add(ResourceLoader.Load("SkinningModule/InfluenceWindowStyle.uss")); if (EditorGUIUtility.isProSkin) ve.AddToClassList("Dark"); ve.LocalizeTextInChildren(); ve.BindElements(); return ve; } public void SetListReorderable(bool reorderable) { m_ListView.reorderable = reorderable; } public void SetAllowMultiselect(bool allowMultiselect) { m_ListView.selectionType = allowMultiselect ? SelectionType.Multiple : SelectionType.Single; } private void BindElements() { m_HeaderLabel = this.Q(); m_ListLabel = this.Q