No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VisualElementExtensions.cs 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using UnityEngine.UIElements;
  2. namespace Unity.PlasticSCM.Editor
  3. {
  4. internal static class VisualElementExtensions
  5. {
  6. /// <summary>
  7. /// Shows the element regardless if it is has been hidden or collapsed.
  8. /// </summary>
  9. /// <param name="element">The element to show</param>
  10. /// <typeparam name="T">The element type</typeparam>
  11. internal static void Show<T>(this T element)
  12. where T: VisualElement
  13. {
  14. element.RemoveFromClassList("collapse");
  15. element.RemoveFromClassList("hide");
  16. }
  17. /// <summary>
  18. /// Removes the element from the layout, freeing its space and position.
  19. /// </summary>
  20. /// <param name="element">The element to collapse</param>
  21. /// <typeparam name="T">The element type</typeparam>
  22. internal static void Collapse<T>(this T element)
  23. where T: VisualElement
  24. {
  25. element.AddToClassList("collapse");
  26. }
  27. /// <summary>
  28. /// Hides the element while preserving its space and position in the layout.
  29. /// </summary>
  30. /// <param name="element">The element to hide</param>
  31. /// <typeparam name="T">The element type</typeparam>
  32. internal static void Hide<T>(this T element)
  33. where T: VisualElement
  34. {
  35. element.AddToClassList("hide");
  36. }
  37. }
  38. }