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.

OverlayRect.cs 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using UnityEngine;
  2. namespace Unity.PlasticSCM.Editor.UI
  3. {
  4. internal class OverlayRect
  5. {
  6. internal static Rect GetOverlayRect(
  7. Rect selectionRect,
  8. float iconOffset)
  9. {
  10. if (selectionRect.width > selectionRect.height)
  11. return GetOverlayRectForSmallestSize(
  12. selectionRect);
  13. return GetOverlayRectForOtherSizes(selectionRect, iconOffset);
  14. }
  15. internal static Rect GetCenteredRect(
  16. Rect selectionRect)
  17. {
  18. return new Rect(
  19. selectionRect.x + 3f,
  20. selectionRect.y + 1f,
  21. UnityConstants.OVERLAY_STATUS_ICON_SIZE,
  22. UnityConstants.OVERLAY_STATUS_ICON_SIZE);
  23. }
  24. static Rect GetOverlayRectForSmallestSize(
  25. Rect selectionRect)
  26. {
  27. return new Rect(
  28. selectionRect.x + 5f,
  29. selectionRect.y + 4f,
  30. UnityConstants.OVERLAY_STATUS_ICON_SIZE,
  31. UnityConstants.OVERLAY_STATUS_ICON_SIZE);
  32. }
  33. static Rect GetOverlayRectForOtherSizes(
  34. Rect selectionRect,
  35. float iconOffset)
  36. {
  37. float widthRatio = selectionRect.width /
  38. UNITY_STANDARD_ICON_SIZE;
  39. float heightRatio = selectionRect.height /
  40. UNITY_STANDARD_ICON_SIZE;
  41. return new Rect(
  42. selectionRect.x + (iconOffset * widthRatio) - 1f,
  43. selectionRect.y + (iconOffset * heightRatio) - 13f,
  44. UnityConstants.OVERLAY_STATUS_ICON_SIZE * widthRatio,
  45. UnityConstants.OVERLAY_STATUS_ICON_SIZE * heightRatio);
  46. }
  47. const int UNITY_STANDARD_ICON_SIZE = 32;
  48. }
  49. }