GUIUtil.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using UnityEngine;
  6. namespace XUnity.AutoTranslator.Plugin.Core.UI
  7. {
  8. internal static class GUIUtil
  9. {
  10. public const int WindowTitleClearance = 10;
  11. public const int ComponentSpacing = 10;
  12. public const int LabelWidth = 60;
  13. public const int LabelHeight = 21;
  14. public const int RowHeight = 21;
  15. public static readonly RectOffset Empty = new RectOffset( 0, 0, 0, 0 );
  16. public static readonly GUIStyle LabelCenter = new GUIStyle( GUI.skin.label )
  17. {
  18. alignment = TextAnchor.UpperCenter,
  19. richText = true
  20. };
  21. public static readonly GUIStyle LabelRight = new GUIStyle( GUI.skin.label )
  22. {
  23. alignment = TextAnchor.UpperRight
  24. };
  25. public static readonly GUIStyle LabelRich = new GUIStyle( GUI.skin.label )
  26. {
  27. richText = true
  28. };
  29. public static readonly GUIStyle NoMarginButtonStyle = new GUIStyle( GUI.skin.button ) { margin = Empty };
  30. public static readonly GUIStyle NoMarginButtonPressedStyle = new GUIStyle( GUI.skin.button )
  31. {
  32. margin = Empty,
  33. onNormal = GUI.skin.button.onActive,
  34. onFocused = GUI.skin.button.onActive,
  35. onHover = GUI.skin.button.onActive,
  36. normal = GUI.skin.button.onActive,
  37. focused = GUI.skin.button.onActive,
  38. hover = GUI.skin.button.onActive,
  39. };
  40. public static readonly GUIStyle NoSpacingBoxStyle = new GUIStyle( GUI.skin.box )
  41. {
  42. margin = Empty,
  43. padding = Empty
  44. };
  45. public static Rect R( int x, int y, int width, int height ) => new Rect( x, y, width, height );
  46. }
  47. }