-
Notifications
You must be signed in to change notification settings - Fork 1
/
EleBaseSizer.cs
81 lines (65 loc) · 2.52 KB
/
EleBaseSizer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// <copyright file="EleBaseSizer.cs" company="Pixel Precision LLC">
// Copyright (c) 2020 All Rights Reserved
// </copyright>
// <author>William Leu</author>
// <date>09/25/2020</date>
// <summary></summary>
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace PxPre.UIL
{
public abstract class EleBaseSizer : Ele
{
bool active = true;
public override bool Active { get { return this.active; } }
public static void DoRectProcessing(ref Vector2 pos, ref Vector2 size, Vector2 entireRegion, LFlag finFlag)
{
if ((finFlag & LFlag.GrowHoriz) != 0)
size.x = entireRegion.x;
else if ((finFlag & LFlag.AlignHorizCenter) != 0)
pos.x += (entireRegion.x - size.x) * 0.5f;
else if ((finFlag & LFlag.AlignRight) != 0)
pos.x += entireRegion.x - size.x;
if ((finFlag & LFlag.GrowVert) != 0)
size.y = entireRegion.y;
else if ((finFlag & LFlag.AlignVertCenter) != 0)
pos.y += (entireRegion.y - size.y) * 0.5f;
else if ((finFlag & LFlag.AlignBot) != 0)
pos.y += entireRegion.y - size.y;
}
public EleBaseSizer(){ }
public EleBaseSizer(EleBaseRect rect, string name = "")
: base(name)
{
rect.SetSizer(this);
}
public EleBaseSizer(string name = "")
: base(name)
{ }
public EleBaseSizer(EleBaseSizer parent, float proportion, LFlag flags, string name = "")
: base(name)
{
parent.Add(this, proportion, flags);
}
public abstract void Add(Ele child, float proportion, LFlag flags);
public abstract bool Remove(Ele child);
public abstract bool HasEntry(Ele child);
public void AddHorizontalSpace(float width, float proportion = 0.0f, LFlag flags = 0)
{
this.AddSpace(new Vector2(width, 0.0f), proportion, flags);
}
public void AddVerticalSpace(float height, float proportion = 0.0f, LFlag flags = 0)
{
this.AddSpace(new Vector2(0.0f, height), proportion, flags);
}
public void AddSpace(Vector2 space, float proportion = 0.0f, LFlag flags = 0)
{
this.Add(new EleSpace(space), proportion, flags);
}
public void AddSpace(float space, float proportion = 0.0f, LFlag flags = 0)
{
this.Add(new EleSpace(space), proportion, flags);
}
}
}