2021-05-03 01:29:02 +10:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
2021-05-05 21:27:09 +10:00
|
|
|
|
using UnityExplorer.UI.Inspectors;
|
|
|
|
|
using UnityExplorer.UI.IValues;
|
2021-05-03 01:29:02 +10:00
|
|
|
|
using UnityExplorer.UI.Widgets;
|
|
|
|
|
|
2021-05-05 21:27:09 +10:00
|
|
|
|
namespace UnityExplorer.UI.CacheObject.Views
|
2021-05-03 01:29:02 +10:00
|
|
|
|
{
|
|
|
|
|
public class CacheKeyValuePairCell : CacheObjectCell
|
|
|
|
|
{
|
|
|
|
|
public Image Image { get; private set; }
|
|
|
|
|
public InteractiveDictionary DictOwner => Occupant.Owner as InteractiveDictionary;
|
|
|
|
|
|
|
|
|
|
public LayoutElement KeyGroupLayout;
|
|
|
|
|
public Text KeyLabel;
|
|
|
|
|
public ButtonRef KeyInspectButton;
|
2021-05-07 17:06:56 +10:00
|
|
|
|
public InputFieldRef KeyInputField;
|
2021-05-03 01:29:02 +10:00
|
|
|
|
public Text KeyInputTypeLabel;
|
|
|
|
|
|
|
|
|
|
public static Color EvenColor = new Color(0.07f, 0.07f, 0.07f);
|
|
|
|
|
public static Color OddColor = new Color(0.063f, 0.063f, 0.063f);
|
|
|
|
|
|
2021-05-07 06:27:23 +10:00
|
|
|
|
public int AdjustedWidth => (int)Rect.rect.width - 70;
|
|
|
|
|
|
|
|
|
|
//public int HalfWidth => (int)(0.5f * Rect.rect.width) - 75;
|
|
|
|
|
//public int AdjustedKeyWidth => HalfWidth - 50;
|
|
|
|
|
//public int AdjustedRightWidth => HalfWidth;
|
2021-05-03 01:29:02 +10:00
|
|
|
|
|
|
|
|
|
private void KeyInspectClicked()
|
|
|
|
|
{
|
|
|
|
|
InspectorManager.Inspect((Occupant as CacheKeyValuePair).DictKey, this.Occupant);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override GameObject CreateContent(GameObject parent)
|
|
|
|
|
{
|
|
|
|
|
var root = base.CreateContent(parent);
|
|
|
|
|
|
|
|
|
|
Image = root.AddComponent<Image>();
|
|
|
|
|
|
2021-05-07 06:27:23 +10:00
|
|
|
|
this.NameLayout.minWidth = 70;
|
|
|
|
|
this.NameLayout.flexibleWidth = 0;
|
2021-05-03 01:29:02 +10:00
|
|
|
|
this.NameLayout.minHeight = 30;
|
2021-05-05 21:27:09 +10:00
|
|
|
|
this.NameLayout.flexibleHeight = 0;
|
2021-05-03 01:29:02 +10:00
|
|
|
|
this.NameLabel.alignment = TextAnchor.MiddleRight;
|
|
|
|
|
|
2021-05-07 06:27:23 +10:00
|
|
|
|
this.RightGroupLayout.minWidth = AdjustedWidth * 0.55f;
|
2021-05-03 01:29:02 +10:00
|
|
|
|
|
|
|
|
|
// Key area
|
|
|
|
|
var keyGroup = UIFactory.CreateUIObject("KeyHolder", root.transform.Find("HoriGroup").gameObject);
|
|
|
|
|
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(keyGroup, false, false, true, true, 2, 0, 0, 4, 4, childAlignment: TextAnchor.MiddleLeft);
|
2021-05-07 06:27:23 +10:00
|
|
|
|
KeyGroupLayout = UIFactory.SetLayoutElement(keyGroup, minHeight: 30, minWidth: (int)(AdjustedWidth * 0.44f), flexibleWidth: 0);
|
2021-05-03 01:29:02 +10:00
|
|
|
|
|
|
|
|
|
// set to be after the NameLabel (our index label), and before the main horizontal group.
|
|
|
|
|
keyGroup.transform.SetSiblingIndex(1);
|
|
|
|
|
|
|
|
|
|
// key Inspect
|
|
|
|
|
|
|
|
|
|
KeyInspectButton = UIFactory.CreateButton(keyGroup, "KeyInspectButton", "Inspect", new Color(0.15f, 0.15f, 0.15f));
|
|
|
|
|
UIFactory.SetLayoutElement(KeyInspectButton.Button.gameObject, minWidth: 60, flexibleWidth: 0, minHeight: 25, flexibleHeight: 0);
|
2021-05-09 02:22:03 +10:00
|
|
|
|
KeyInspectButton.OnClick += KeyInspectClicked;
|
2021-05-03 01:29:02 +10:00
|
|
|
|
|
|
|
|
|
// label
|
|
|
|
|
|
2021-05-03 21:02:01 +10:00
|
|
|
|
KeyLabel = UIFactory.CreateLabel(keyGroup, "KeyLabel", "<i>empty</i>", TextAnchor.MiddleLeft);
|
2021-05-05 21:27:09 +10:00
|
|
|
|
UIFactory.SetLayoutElement(KeyLabel.gameObject, minWidth: 50, flexibleWidth: 999, minHeight: 25);
|
2021-05-03 01:29:02 +10:00
|
|
|
|
|
|
|
|
|
// Type label for input field
|
|
|
|
|
|
2021-05-03 21:02:01 +10:00
|
|
|
|
KeyInputTypeLabel = UIFactory.CreateLabel(keyGroup, "InputTypeLabel", "<i>null</i>", TextAnchor.MiddleLeft);
|
2021-05-05 21:27:09 +10:00
|
|
|
|
UIFactory.SetLayoutElement(KeyInputTypeLabel.gameObject, minWidth: 55, flexibleWidth: 0, minHeight: 25, flexibleHeight: 0);
|
2021-05-03 01:29:02 +10:00
|
|
|
|
|
|
|
|
|
// input field
|
|
|
|
|
|
2021-05-07 17:06:56 +10:00
|
|
|
|
KeyInputField = UIFactory.CreateInputField(keyGroup, "KeyInput", "empty");
|
|
|
|
|
UIFactory.SetLayoutElement(KeyInputField.UIRoot, minHeight: 25, flexibleHeight: 0, flexibleWidth: 0, preferredWidth: 200);
|
2021-05-03 01:29:02 +10:00
|
|
|
|
//KeyInputField.lineType = InputField.LineType.MultiLineNewline;
|
2021-05-07 17:06:56 +10:00
|
|
|
|
KeyInputField.InputField.readOnly = true;
|
2021-05-03 01:29:02 +10:00
|
|
|
|
|
|
|
|
|
return root;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ConstructEvaluateHolder(GameObject parent)
|
|
|
|
|
{
|
|
|
|
|
// not used
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|