LayoutOverlay.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using UnityEditor.U2D.Animation;
  2. using UnityEngine.UIElements;
  3. namespace UnityEditor.U2D.Layout
  4. {
  5. internal class LayoutOverlay : VisualElement
  6. {
  7. public class LayoutOverlayFactory : UxmlFactory<LayoutOverlay, LayoutOverlayUxmlTraits> {}
  8. public class LayoutOverlayUxmlTraits : UxmlTraits {}
  9. private ScrollableToolbar m_HorizontalToolbar;
  10. private ScrollableToolbar m_VerticalToolbar;
  11. private VisualElement m_HorizontalHolder;
  12. private VisualElement m_LeftOverlay;
  13. private VisualElement m_RightOverlay;
  14. private DropdownMenu m_DropdownOverlay;
  15. public ScrollableToolbar horizontalToolbar
  16. {
  17. get
  18. {
  19. if (m_HorizontalToolbar == null)
  20. m_HorizontalToolbar = this.Q<ScrollableToolbar>("HorizontalToolbar");
  21. return m_HorizontalToolbar;
  22. }
  23. }
  24. public ScrollableToolbar verticalToolbar
  25. {
  26. get
  27. {
  28. if (m_VerticalToolbar == null)
  29. m_VerticalToolbar = this.Q<ScrollableToolbar>("VerticalToolbar");
  30. return m_VerticalToolbar;
  31. }
  32. }
  33. public VisualElement horizontalHolder
  34. {
  35. get
  36. {
  37. if (m_HorizontalHolder == null)
  38. m_HorizontalHolder = this.Q<VisualElement>("HorizontalHolder");
  39. return m_HorizontalHolder;
  40. }
  41. }
  42. public VisualElement leftOverlay
  43. {
  44. get
  45. {
  46. if (m_LeftOverlay == null)
  47. m_LeftOverlay = this.Q<VisualElement>("LeftOverlay");
  48. return m_LeftOverlay;
  49. }
  50. }
  51. public VisualElement rightOverlay
  52. {
  53. get
  54. {
  55. if (m_RightOverlay == null)
  56. m_RightOverlay = this.Q<VisualElement>("RightOverlay");
  57. return m_RightOverlay;
  58. }
  59. }
  60. public void VisibilityWindowOn(bool on)
  61. {
  62. if(on)
  63. rightOverlay.AddToClassList("VisibilityWindowOn");
  64. else
  65. rightOverlay.RemoveFromClassList("VisibilityWindowOn");
  66. }
  67. public DropdownMenu dropdownOverlay
  68. {
  69. get
  70. {
  71. if (m_DropdownOverlay == null)
  72. m_DropdownOverlay = this.Q<DropdownMenu>("DropdownOverlay");
  73. return m_DropdownOverlay;
  74. }
  75. }
  76. public bool hasScrollbar
  77. {
  78. get { return this.ClassListContains("HasScrollbar"); }
  79. set
  80. {
  81. if (value)
  82. this.AddToClassList("HasScrollbar");
  83. else
  84. this.RemoveFromClassList("HasScrollbar");
  85. }
  86. }
  87. public LayoutOverlay()
  88. {
  89. this.StretchToParentSize();
  90. styleSheets.Add(ResourceLoader.Load<StyleSheet>("LayoutOverlay/LayoutOverlayStyle.uss"));
  91. }
  92. }
  93. }