Implemented PageHandler proof of concept, fixed something with scrollviews

This commit is contained in:
sinaioutlander
2020-10-24 00:41:55 +11:00
parent 76c578a9ea
commit 25747503cc
5 changed files with 202 additions and 19 deletions

View File

@ -2,8 +2,10 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ExplorerBeta;
using ExplorerBeta.UI;
using ExplorerBeta.UI.Main;
using ExplorerBeta.UI.Shared;
using UnityEngine;
using UnityEngine.UI;
@ -13,7 +15,7 @@ namespace Explorer.UI.Main.Pages
{
public override string Name => "Home";
private GameObject m_mainViewport;
private PageHandler m_sceneListPages;
public override void Init()
{
@ -31,8 +33,8 @@ namespace Explorer.UI.Main.Pages
{
var parent = MainMenu.Instance.PageViewport;
m_mainViewport = UIFactory.CreateHorizontalGroup(parent);
var mainGroup = m_mainViewport.GetComponent<HorizontalLayoutGroup>();
Content = UIFactory.CreateHorizontalGroup(parent);
var mainGroup = Content.GetComponent<HorizontalLayoutGroup>();
mainGroup.padding.left = 3;
mainGroup.padding.right = 3;
mainGroup.padding.top = 3;
@ -43,7 +45,7 @@ namespace Explorer.UI.Main.Pages
mainGroup.childControlHeight = true;
mainGroup.childControlWidth = true;
var leftPaneObj = UIFactory.CreateVerticalGroup(m_mainViewport, new Color(72f / 255f, 72f / 255f, 72f / 255f));
var leftPaneObj = UIFactory.CreateVerticalGroup(Content, new Color(72f / 255f, 72f / 255f, 72f / 255f));
var leftLayout = leftPaneObj.AddComponent<LayoutElement>();
leftLayout.minWidth = 350;
leftLayout.flexibleWidth = 0;
@ -59,7 +61,7 @@ namespace Explorer.UI.Main.Pages
leftGroup.childForceExpandWidth = false;
leftGroup.childForceExpandHeight = true;
var rightPaneObj = UIFactory.CreateVerticalGroup(m_mainViewport, new Color(72f / 255f, 72f / 255f, 72f / 255f));
var rightPaneObj = UIFactory.CreateVerticalGroup(Content, new Color(72f / 255f, 72f / 255f, 72f / 255f));
var rightLayout = rightPaneObj.AddComponent<LayoutElement>();
rightLayout.flexibleWidth = 999999;
@ -68,6 +70,28 @@ namespace Explorer.UI.Main.Pages
rightGroup.childForceExpandWidth = true;
rightGroup.childControlHeight = true;
rightGroup.childControlWidth = true;
ConstructScenePane(leftPaneObj);
}
private void ConstructScenePane(GameObject leftPane)
{
m_sceneListPages = new PageHandler(100);
m_sceneListPages.ConstructUI(leftPane);
m_sceneListPages.OnPageChanged += RefreshSceneObjectList;
var scrollTest = UIFactory.CreateScrollView(leftPane, out GameObject content);
for (int i = 0; i < 50; i++)
{
var obj = UIFactory.CreateLabel(content, TextAnchor.MiddleCenter);
var text = obj.GetComponent<Text>();
text.text = "Hello world " + i;
}
}
private void RefreshSceneObjectList()
{
ExplorerCore.Log("Would update scene list here");
}
#endregion