mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-27 02:22:33 +08:00
Rewrite EvaluateWidget, add BaseArgumentHandler, use autocomplete for InteractiveEnum
This commit is contained in:
51
src/UI/Widgets/EvaluateWidget/BaseArgumentHandler.cs
Normal file
51
src/UI/Widgets/EvaluateWidget/BaseArgumentHandler.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityExplorer.UI.Widgets.AutoComplete;
|
||||
using UniverseLib.UI;
|
||||
using UniverseLib.UI.Models;
|
||||
|
||||
namespace UnityExplorer.UI.Widgets
|
||||
{
|
||||
public abstract class BaseArgumentHandler : IPooledObject
|
||||
{
|
||||
protected EvaluateWidget evaluator;
|
||||
|
||||
internal Text argNameLabel;
|
||||
internal InputFieldRef inputField;
|
||||
internal TypeCompleter typeCompleter;
|
||||
|
||||
// IPooledObject
|
||||
public float DefaultHeight => 25f;
|
||||
public GameObject UIRoot { get; set; }
|
||||
|
||||
public abstract void CreateSpecialContent();
|
||||
|
||||
public GameObject CreateContent(GameObject parent)
|
||||
{
|
||||
UIRoot = UIFactory.CreateUIObject("ArgRow", parent);
|
||||
UIFactory.SetLayoutElement(UIRoot, minHeight: 25, flexibleHeight: 50, minWidth: 50, flexibleWidth: 9999);
|
||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(UIRoot, false, false, true, true, 5);
|
||||
UIRoot.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
|
||||
argNameLabel = UIFactory.CreateLabel(UIRoot, "ArgLabel", "not set", TextAnchor.MiddleLeft);
|
||||
UIFactory.SetLayoutElement(argNameLabel.gameObject, minWidth: 40, flexibleWidth: 90, minHeight: 25, flexibleHeight: 50);
|
||||
argNameLabel.horizontalOverflow = HorizontalWrapMode.Wrap;
|
||||
|
||||
inputField = UIFactory.CreateInputField(UIRoot, "InputField", "...");
|
||||
UIFactory.SetLayoutElement(inputField.UIRoot, minHeight: 25, flexibleHeight: 50, minWidth: 100, flexibleWidth: 1000);
|
||||
inputField.Component.lineType = InputField.LineType.MultiLineNewline;
|
||||
inputField.UIRoot.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
|
||||
typeCompleter = new TypeCompleter(typeof(object), this.inputField);
|
||||
typeCompleter.Enabled = false;
|
||||
|
||||
CreateSpecialContent();
|
||||
|
||||
return UIRoot;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user