VisibilityToolColumnHeader.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using UnityEditor.IMGUI.Controls;
  3. using UnityEngine;
  4. namespace UnityEditor.U2D.Animation
  5. {
  6. internal class VisibilityToolColumnHeader : MultiColumnHeader
  7. {
  8. public Action<bool> SetAllVisibility = (b) => {};
  9. public Func<bool> GetAllVisibility = () => true;
  10. public VisibilityToolColumnHeader(MultiColumnHeaderState state)
  11. : base(state)
  12. {
  13. visibilityColumn = -1;
  14. }
  15. public int visibilityColumn { private get; set; }
  16. protected override void ColumnHeaderGUI(MultiColumnHeaderState.Column column, Rect headerRect, int columnIndex)
  17. {
  18. if (columnIndex == visibilityColumn)
  19. {
  20. GUIStyle style = DefaultStyles.columnHeaderCenterAligned;
  21. EditorGUI.BeginChangeCheck();
  22. var visibility = GetAllVisibility();
  23. visibility = GUI.Toggle(headerRect, visibility, visibility ? VisibilityTreeViewBase.VisibilityIconStyle.visibilityOnIcon : VisibilityTreeViewBase.VisibilityIconStyle.visibilityOffIcon, style);
  24. if (EditorGUI.EndChangeCheck())
  25. SetAllVisibility(visibility);
  26. }
  27. else
  28. base.ColumnHeaderGUI(column, headerRect, columnIndex);
  29. }
  30. }
  31. }