Implement Clipboard and Notifications, misc cleanups

This commit is contained in:
Sinai
2022-01-18 20:19:20 +11:00
parent c79223f537
commit ea7b91f7fd
30 changed files with 518 additions and 333 deletions

View File

@ -9,52 +9,49 @@ using UniverseLib.UI.Models;
using UnityExplorer.UI.Widgets;
using UniverseLib.UI;
using UniverseLib;
using UnityExplorer.UI.Panels;
namespace UnityExplorer.Inspectors
{
public class InspectorTab : IPooledObject
{
public GameObject UIRoot { get; set; }
public float DefaultHeight => 25f;
public ButtonRef TabButton;
public Text TabText;
public ButtonRef CloseButton;
private static readonly Color _enabledTabColor = new Color(0.15f, 0.22f, 0.15f);
private static readonly Color _disabledTabColor = new Color(0.13f, 0.13f, 0.13f);
private static readonly Color enabledTabColor = new(0.15f, 0.22f, 0.15f);
private static readonly Color disabledTabColor = new(0.13f, 0.13f, 0.13f);
public void SetTabColor(bool active)
{
if (active)
RuntimeProvider.Instance.SetColorBlock(TabButton.Component, _enabledTabColor, _enabledTabColor * 1.2f);
else
RuntimeProvider.Instance.SetColorBlock(TabButton.Component, _disabledTabColor, _disabledTabColor * 1.2f);
Color color = active ? enabledTabColor : disabledTabColor;
RuntimeProvider.Instance.SetColorBlock(TabButton.Component, color, color * 1.2f);
}
public GameObject CreateContent(GameObject parent)
{
UIRoot = UIFactory.CreateHorizontalGroup(parent, "TabObject", false, true, true, true, 0,
UIRoot = UIFactory.CreateHorizontalGroup(parent, "TabObject", false, true, true, true, 1,
default, new Color(0.13f, 0.13f, 0.13f), childAlignment: TextAnchor.MiddleLeft);
UIFactory.SetLayoutElement(UIRoot, minWidth: 200, flexibleWidth: 0);
UIRoot.AddComponent<Mask>();
UIRoot.AddComponent<Outline>();
TabButton = UIFactory.CreateButton(UIRoot, "TabButton", "");
UIFactory.SetLayoutElement(TabButton.Component.gameObject, minWidth: 175, flexibleWidth: 0);
UIFactory.SetLayoutElement(TabButton.Component.gameObject, minWidth: 173, flexibleWidth: 0);
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(TabButton.Component.gameObject, false, false, true, true, 0, 0, 0, 3);
TabText = TabButton.Component.GetComponentInChildren<Text>();
UIFactory.SetLayoutElement(TabText.gameObject, minHeight: 25, minWidth: 175, flexibleWidth: 0);
UIFactory.SetLayoutElement(TabText.gameObject, minHeight: 25, minWidth: 173, flexibleWidth: 0);
TabText.alignment = TextAnchor.MiddleLeft;
TabText.fontSize = 12;
TabText.horizontalOverflow = HorizontalWrapMode.Overflow;
CloseButton = UIFactory.CreateButton(UIRoot, "CloseButton", "X", new Color(0.2f, 0.2f, 0.2f, 1));
CloseButton = UIFactory.CreateButton(UIRoot, "CloseButton", "X", new Color(0.15f, 0.15f, 0.15f, 1));
UIFactory.SetLayoutElement(CloseButton.Component.gameObject, minHeight: 25, minWidth: 25, flexibleWidth: 0);
var closeBtnText = CloseButton.Component.GetComponentInChildren<Text>();
closeBtnText.color = Color.red;
CloseButton.ButtonText.color = Color.red;
return UIRoot;
}