Browse Source

Add more GUI utilities

habeebweeb 4 years ago
parent
commit
2b67ce8362
1 changed files with 9 additions and 0 deletions
  1. 9 0
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/MiscGUI.cs

+ 9 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/MiscGUI.cs

@@ -5,9 +5,12 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
     internal static class MiscGUI
     {
         public static readonly GUILayoutOption HalfSlider = GUILayout.Width(98);
+        public static readonly Texture2D white = Utility.MakeTex(2, 2, Color.white);
+        public static readonly Texture2D transparentBlack = Utility.MakeTex(2, 2, new Color(0f, 0f, 0f, 0.8f));
         private static GUIStyle lineStyleWhite;
         private static GUIStyle lineStyleBlack;
         private static GUIStyle textureBoxStyle;
+
         static MiscGUI()
         {
             lineStyleWhite = new GUIStyle(GUI.skin.box);
@@ -20,6 +23,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             textureBoxStyle = new GUIStyle(GUI.skin.box);
             textureBoxStyle.normal.background = Utility.MakeTex(2, 2, new Color(0f, 0f, 0f, 0f));
+            textureBoxStyle.padding = textureBoxStyle.margin = new RectOffset(0, 0, 0, 0);
         }
 
         private static void Line(GUIStyle style) => GUILayout.Box(GUIContent.none, style, GUILayout.Height(1));
@@ -33,6 +37,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             GUILayout.Box(texture, textureBoxStyle, layoutOptions);
         }
 
+        public static int ClampFont(int size, int min, int max)
+        {
+            return Mathf.Clamp(Utility.GetPix(size), min, max);
+        }
+
         public static void Header(string text, params GUILayoutOption[] layoutOptions)
         {
             GUIStyle style = new GUIStyle(GUI.skin.label);