CrabUI
Loading...
Searching...
No Matches
CrabUITest.PropTest Class Reference

Testing separate props. More...

Inheritance diagram for CrabUITest.PropTest:
CrabUITest.FillMethods CrabUITest.FillMethods CrabUITest.FillMethods CrabUITest.FillMethods CrabUITest.FillMethods CrabUITest.FillMethods CrabUITest.FillMethods CrabUITest.FillMethods CrabUITest.FillMethods CrabUITest.FillMethods CrabUITest.FillMethods CrabUITest.FillMethods CrabUITest.FillMethods CrabUITest.FillMethods

Static Public Member Functions

static void Animation (CUIComponent Main)
 
static void Border (CUIComponent Main)
 
static void ClickOnTransparent (CUIComponent Main)
 
static void CrossRelative (CUIComponent Main)
 
static void FillEmptySpace (CUIComponent Main)
 
static void FillEmptySpace2 (CUIComponent Main)
 
static void Ghost (CUIComponent Main)
 
static void ListGap (CUIComponent Main)
 
static void PGNAssets (CUIComponent Main)
 
static void ResizeToContent (CUIComponent Main)
 FitContent in simple layout.
 
static void ResizeToContent2 (CUIComponent Main)
 FitContent in list.
 
static void ResizeToContent3 (CUIComponent Main)
 FitContent of List itself.
 
static void ResizeToSprite (CUIComponent Main)
 
static void SpriteRotation (CUIComponent Main)
 
static void Style (CUIComponent Main)
 
static void TextWrap (CUIComponent Main)
 
static void WeakEvents (CUIComponent Main)
 It just demonstates the problem idk how to solve it yet no, i'm not gonna use other weak event managers.
 
- Static Public Member Functions inherited from CrabUITest.FillMethods
static bool IsTestMethod (MethodInfo mi)
 

Detailed Description

Testing separate props.

Definition at line 17 of file WeakEvents.cs.

Member Function Documentation

◆ Animation()

static void CrabUITest.PropTest.Animation ( CUIComponent Main)
static

Definition at line 19 of file Animation.cs.

20 {
21 CUIFrame frame = new CUIFrame()
22 {
23 Absolute = new CUINullRect(200, 0, 200, 400),
24 Anchor = CUIAnchor.Center,
25 };
26
27 frame.Animations["fade"] = new CUIAnimation()
28 {
29 StartValue = new Color(0, 0, 0, 32),
30 EndValue = new Color(0, 0, 32, 255),
31 Property = "BackgroundColor",
32 Duration = 0.1,
33 };
34
35
36 frame.OnMouseEnter += (e) =>
37 {
38 frame.Animations["fade"].Direction = CUIDirection.Straight;
39 frame.Animations["fade"].Start();
40 };
41
42 frame.OnMouseLeave += (e) =>
43 {
44 frame.Animations["fade"].Direction = CUIDirection.Reverse;
45 frame.Animations["fade"].Start();
46 };
47
48 Main.Append(frame);
49 }
CUIAnchor is just a Vector2 This is a static class containing some helper methods.
Definition CUIAnchor.cs:18
WIP, can animate any property on any object Can run back and forth in [0..1] interval and interpolate...
virtual CUIComponent Append(CUIComponent child, string name=null, [CallerMemberName] string memberName="")
Adds children to the end of the list.
Draggable and resizable container for other components.
Definition CUIFrame.cs:16
Rectangle with float?
Definition CUIRect.cs:104

◆ Border()

static void CrabUITest.PropTest.Border ( CUIComponent Main)
static

Definition at line 21 of file Border.cs.

22 {
23 CUIFrame frame = new CUIFrame()
24 {
25 Anchor = CUIAnchor.Center,
26 Absolute = new CUINullRect(250, 0, 200, 200),
27 CullChildren = false,
28 };
29
30 frame.Append(new CUIComponent()
31 {
32 Relative = new CUINullRect(0, 0, 1, 1),
33 Border = new CUIBorder(Color.White, 15),
34 BorderSprite = CUI.TextureManager.GetSprite("border.png"),
35 });
36
37 frame.Append(new CUIComponent()
38 {
39 Absolute = new CUINullRect(80, 80, 40, 40),
40 Border = new CUIBorder(new Color(0, 255, 255, 100), 0),
41 });
42
43 frame.Append(new CUIComponent()
44 {
45 Absolute = new CUINullRect(80, 120, 40, 40),
46 Border = new CUIBorder(new Color(0, 255, 255, 100), 1),
47 });
48
49 frame.Append(new CUIComponent()
50 {
51 Absolute = new CUINullRect(120, 80, 40, 40),
52 Border = new CUIBorder(new Color(0, 255, 255, 100), 2),
53 });
54
55 frame.Append(new CUIComponent()
56 {
57 Absolute = new CUINullRect(40, 80, 40, 40),
58 Border = new CUIBorder(new Color(0, 255, 255, 100), 3),
59 });
60
61 CUIComponent c = frame.Append(new CUIComponent()
62 {
63 Absolute = new CUINullRect(80, 40, 40, 40),
64 //Border = new CUIBorder(new Color(0, 255, 255, 100), 4),
65 });
66
67 c.TopBorder = new CUIBorder(Color.Red * 0.5f, 10);
68 c.RigthBorder = new CUIBorder(Color.Lime * 0.5f, 10);
69 c.BottomBorder = new CUIBorder(Color.Blue * 0.5f, 10);
70 c.LeftBorder = new CUIBorder(Color.Yellow * 0.5f, 10);
71 //c.BorderSprite = CUI.TextureManager.GetSprite("Dev.png");
72
73 Main.Append(frame);
74 }
Base class for all components.
In fact a static class managing static things.
Definition CUIErrors.cs:16
static CUITextureManager TextureManager
Safe texture manager </summary.
Definition CUI.cs:97

◆ ClickOnTransparent()

static void CrabUITest.PropTest.ClickOnTransparent ( CUIComponent Main)
static

Definition at line 20 of file ClickOnTransparent.cs.

21 {
22 CUIFrame frame = new CUIFrame()
23 {
24 Anchor = CUIAnchor.Center,
25 ResizeToSprite = true,
26 Draggable = false,
27 BackgroundSprite = new CUISprite("Dev2.png"),
28 BackgroundColor = Color.White,
29 IgnoreTransparent = true,
30 };
31
32 frame.OnMouseDown += (e) => frame.BackgroundColor = Color.Pink;
33 frame.OnMouseUp += (e) => frame.BackgroundColor = Color.White;
34
35 Main.Append(frame);
36 }
Color BackgroundColor
Color of BackgroundSprite, default is black If you're using custom sprite and don't see it make sur...
Wrapper Containing link to texture and drawing settings, like SourceRedt, DrawMode,...
Definition CUISprite.cs:27

◆ CrossRelative()

static void CrabUITest.PropTest.CrossRelative ( CUIComponent Main)
static

Definition at line 21 of file CrossRelative.cs.

22 {
23 CUIFrame frame = new CUIFrame()
24 {
25 Anchor = CUIAnchor.Center,
26 Relative = new CUINullRect(w: 0.4f, h: 0.4f),
27 };
28
29 frame["box"] = new CUIComponent()
30 {
31 Anchor = CUIAnchor.Center,
32 Relative = new CUINullRect(w: 0.5f),
33 CrossRelative = new CUINullRect(h: 0.5f),
34 };
35
36 Main.Append(frame);
37 }

◆ FillEmptySpace()

static void CrabUITest.PropTest.FillEmptySpace ( CUIComponent Main)
static

Definition at line 22 of file FillEmptySpace.cs.

23 {
24 CUIFrame frame = new CUIFrame(0.6f, 0.2f, 0.2f, 0.4f);
25 frame["list"] = new CUIVerticalList()
26 {
27 Relative = new CUINullRect(0, 0, 1, 1),
28 BackgroundColor = Color.Blue,
29 };
30
31 frame["header"] = frame["list"].Append(new CUITextBlock("header")
32 {
33 TextAlign = new Vector2(0.5f, 0.5f),
34 });
35 frame["middle"] = frame["list"].Append(new CUIHorizontalList()
36 {
37 FillEmptySpace = new CUIBool2(false, true),
38 BackgroundColor = Color.Brown,
39 });
40 frame["footer"] = frame["list"].Append(new CUITextBlock("footer")
41 {
42 TextAlign = new Vector2(0.5f, 0.5f),
43 });
44
45 frame["leftmenu"] = frame["middle"].Append(new CUITextBlock("left menu")
46 {
47 Wrap = true,
48 Vertical = true,
49 Relative = new CUINullRect(w: 0.2f),
50 });
51
52 frame["content"] = frame["middle"].Append(new CUIComponent()
53 {
54 BackgroundColor = Color.Green,
55 FillEmptySpace = new CUIBool2(true, false),
56 });
57
58 frame["rightmenu"] = frame["middle"].Append(new CUITextBlock("right menu")
59 {
60 Wrap = true,
61 Vertical = false,
62 Relative = new CUINullRect(w: 0.2f),
63 });
64
65 Main.Append(frame);
66 }
Resizing components to it's Height and placing them sequentially.
Passive block of text.
Resizing components to it's Width and placing them sequentially.
Vector2 but with bools.
Definition CUIBool2.cs:17

◆ FillEmptySpace2()

static void CrabUITest.PropTest.FillEmptySpace2 ( CUIComponent Main)
static

Definition at line 68 of file FillEmptySpace.cs.

69 {
70 CUIFrame frame = new CUIFrame(0.6f, 0.2f, 0.2f, 0.4f);
71 frame["list"] = new CUIVerticalList()
72 {
73 Relative = new CUINullRect(0, 0, 1, 1),
74 BackgroundColor = Color.Blue,
75 };
76
77 frame["header"] = frame["list"].Append(new CUITextBlock("header")
78 {
79 TextAlign = new Vector2(0.5f, 0.5f),
80 FillEmptySpace = new CUIBool2(false, true),
81 });
82 frame["middle"] = frame["list"].Append(new CUIHorizontalList()
83 {
84 Absolute = new CUINullRect(h: 100f),
85 BackgroundColor = Color.Brown,
86 });
87 frame["footer"] = frame["list"].Append(new CUITextBlock("footer")
88 {
89 TextAlign = new Vector2(0.5f, 0.5f),
90 FillEmptySpace = new CUIBool2(false, true),
91 });
92
93
94 frame["leftmenu"] = frame["middle"].Append(new CUITextBlock("left menu")
95 {
96 FillEmptySpace = new CUIBool2(true, false),
97 Wrap = true,
98 });
99
100 frame["content"] = frame["middle"].Append(new CUIComponent()
101 {
102 BackgroundColor = Color.Green,
103 Absolute = new CUINullRect(w: 100f),
104 });
105
106 frame["rightmenu"] = frame["middle"].Append(new CUITextBlock("right menu")
107 {
108 FillEmptySpace = new CUIBool2(true, false),
109 Wrap = true,
110 });
111
112
113
114 Main.Append(frame);
115 }

◆ Ghost()

static void CrabUITest.PropTest.Ghost ( CUIComponent Main)
static

Definition at line 19 of file Ghost.cs.

20 {
21 CUIFrame frame = new CUIFrame()
22 {
23 Absolute = new CUINullRect(0, 0, 500, 500),
24 Anchor = CUIAnchor.Center,
25 };
26
27 CUIComponent Box(bool x, bool y) => new CUIComponent()
28 {
29 Absolute = new CUINullRect(0, 0, 20, 20),
30 Ghost = new CUIBool2(x, y),
31 BackgroundColor = Color.Lime * 0.7f,
32 };
33
34 float offset = 20;
35 void AddContainer(CUIComponent container, bool x, bool y)
36 {
37 float yOffset = 0;
38 if (!x && !y) yOffset = 0;
39 if (!x && y) yOffset = 1;
40 if (x && !y) yOffset = 2;
41 if (x && y) yOffset = 3;
42
43 container.FitContent = new CUIBool2(true, true);
44 container.BackgroundColor = Color.Yellow;
45 container.Absolute = new CUINullRect(offset, 100 + yOffset * 40);
46 container.AbsoluteMin = new CUINullRect(w: 10, h: 10);
47 container.AKA = $"{container.GetType().Name} [{x},{y}]";
48 container.Append(Box(x, y));
49 frame.Append(container);
50 };
51
52 void AddContainerType(Type type)
53 {
54 frame.Append(new CUITextBlock(type.Name)
55 {
56 Absolute = new CUINullRect(offset, 80),
57 });
58 AddContainer((CUIComponent)Activator.CreateInstance(type), false, false);
59 AddContainer((CUIComponent)Activator.CreateInstance(type), false, true);
60 AddContainer((CUIComponent)Activator.CreateInstance(type), true, false);
61 AddContainer((CUIComponent)Activator.CreateInstance(type), true, true);
62 offset += 120;
63 };
64
65 AddContainerType(typeof(CUIComponent));
66 AddContainerType(typeof(CUIHorizontalList));
67 AddContainerType(typeof(CUIVerticalList));
68 AddContainerType(typeof(CUIGrid));
69
70 Main.Append(frame);
71 }
A Grid containing children in its cells.
Definition CUIGrid.cs:16

◆ ListGap()

static void CrabUITest.PropTest.ListGap ( CUIComponent Main)
static

Definition at line 19 of file List Gap.cs.

20 {
21 CUIFrame frame = new CUIFrame()
22 {
23 Absolute = new CUINullRect(0, 0, 500, 500),
24 Anchor = CUIAnchor.Center,
25 };
26
27 CUIComponent Box() => new CUIComponent()
28 {
29 Absolute = new CUINullRect(w: 20, h: 20),
30 BackgroundColor = Color.Lime,
31 };
32
33 frame["list"] = new CUIHorizontalList()
34 {
35 Absolute = new CUINullRect(20, 20, null, 20),
36 FitContent = new CUIBool2(true, false),
37 Gap = 10,
38 BackgroundColor = Color.Blue,
39 };
40 frame["list"].Append(Box());
41 frame["list"].Append(Box());
42 frame["list"].Append(Box());
43 frame["list"].Append(Box());
44 frame["list"].Append(Box());
45 frame["list"].Append(Box());
46 frame["list"].Append(Box());
47 frame["list"].Append(Box());
48
49 Main.Append(frame);
50 }

◆ PGNAssets()

static void CrabUITest.PropTest.PGNAssets ( CUIComponent Main)
static

Definition at line 21 of file PGNAssets.cs.

22 {
23 CUIFrame frame = new CUIFrame()
24 {
25 Anchor = CUIAnchor.Center,
26 Relative = new CUINullRect(w: 0.4f, h: 0.4f),
27 BackgroundSprite = new CUISprite("Dev.png"),
28 BackgroundColor = Color.White,
29 };
30
31 Main.Append(frame);
32 }

◆ ResizeToContent()

static void CrabUITest.PropTest.ResizeToContent ( CUIComponent Main)
static

FitContent in simple layout.

Parameters
Main

Definition at line 23 of file ResizeToContent.cs.

24 {
25 CUIFrame frame = new CUIFrame(0.6f, 0.2f, 0.2f, 0.6f);
26
27 frame["line"] = new CUIComponent()
28 {
29 Relative = new CUINullRect(w: 1),
30 FitContent = new CUIBool2(false, true),
31 Anchor = new Vector2(0.5f, 0.5f),
32 BackgroundColor = Color.Blue,
33 };
34
35 frame["content"] = frame["line"].Append(new CUIComponent()
36 {
37 BackgroundColor = Color.Lime,
38 Relative = new CUINullRect(w: 0.25f),
39 Absolute = new CUINullRect(h: 50),
40 Anchor = new Vector2(0.5f, 0.5f),
41 });
42
43 Main.Append(frame);
44 }

◆ ResizeToContent2()

static void CrabUITest.PropTest.ResizeToContent2 ( CUIComponent Main)
static

FitContent in list.

Parameters
Main

Definition at line 50 of file ResizeToContent.cs.

51 {
52 CUIFrame frame = new CUIFrame(0.6f, 0.2f, 0.2f, 0.6f);
53
54 frame["list"] = new CUIVerticalList()
55 {
56 Relative = new CUINullRect(w: 1, h: 1),
57 BackgroundColor = Color.Blue,
58 };
59
60 frame["list"].Append(new CUIComponent() { Absolute = new CUINullRect(h: 50), });
61 frame["list"]["center"] = new CUIComponent()
62 {
63 BackgroundColor = Color.Lime,
64 FitContent = new CUIBool2(false, true),
65 };
66 frame["list"].Append(new CUIComponent() { Absolute = new CUINullRect(h: 50), });
67
68
69 frame["list"]["center"].Append(new CUITextBlock("bebebe")
70 {
71 BackgroundColor = Color.Red,
72 Anchor = new Vector2(0.5f, 0.5f),
73 TextScale = 2f,
74 });
75
76
77
78
79 Main.Append(frame);
80 }

◆ ResizeToContent3()

static void CrabUITest.PropTest.ResizeToContent3 ( CUIComponent Main)
static

FitContent of List itself.

Parameters
Main

Definition at line 86 of file ResizeToContent.cs.

87 {
88 CUIFrame frame = new CUIFrame(0.6f, 0.2f, 0.2f, 0.6f);
89
90 frame["vlist"] = new CUIVerticalList()
91 {
92 FitContent = new CUIBool2(true, true),
93 Anchor = new Vector2(0.0f, 0.5f),
94 BackgroundColor = Color.Blue,
95 };
96
97 frame["vlist"].Append(new CUIComponent()
98 {
99 BackgroundColor = new Color(255, 0, 0, 100),
100 Absolute = new CUINullRect(w: 50, h: 50),
101 });
102
103 frame["hlist"] = new CUIHorizontalList()
104 {
105 FitContent = new CUIBool2(true, true),
106 Anchor = new Vector2(1.0f, 0.5f),
107 BackgroundColor = Color.Blue,
108 };
109
110 frame["hlist"].Append(new CUIComponent()
111 {
112 BackgroundColor = new Color(255, 0, 0, 100),
113 Absolute = new CUINullRect(w: 50, h: 50),
114 });
115
116 Main.Append(frame);
117 }

◆ ResizeToSprite()

static void CrabUITest.PropTest.ResizeToSprite ( CUIComponent Main)
static

Definition at line 21 of file ResizeToSprite.cs.

22 {
23 CUIFrame frame = new CUIFrame()
24 {
25 Anchor = CUIAnchor.Center,
26 BackgroundColor = Color.White,
27 ResizeToSprite = true,
28 BackgroundSprite = new CUISprite(Path.Combine(CUITest.PNGAssetsPath, "Dev.png"))
29 {
30 DrawMode = CUISpriteDrawMode.StaticDeep,
31 },
32 };
33
34 Main.Append(frame);
35 }

◆ SpriteRotation()

static void CrabUITest.PropTest.SpriteRotation ( CUIComponent Main)
static

Definition at line 19 of file Sprite rotation.cs.

20 {
21 CUIFrame frame = new CUIFrame()
22 {
23 Anchor = CUIAnchor.Center,
24 ResizeToSprite = true,
25 Draggable = false,
26 BackgroundSprite = new CUISprite("Dev2.png")
27 {
28 RotationAngle = 30,
29 Offset = new Vector2(0.5f, 0.5f),
30 },
31 BackgroundColor = Color.White,
32 IgnoreTransparent = true,
33 };
34
35 frame.BackgroundSprite = CUISprite.Parse($"{frame.BackgroundSprite}");
36
38
39 frame.OnMouseDown += (e) => frame.BackgroundColor = Color.Pink;
40 frame.OnMouseUp += (e) => frame.BackgroundColor = Color.White;
41
42 Main.Append(frame);
43 }
CUISprite BackgroundSprite
Will be drawn in background with BackgroundColor Default is solid white 1x1 texture.
static void Log(object msg, Color? color=null, [CallerFilePath] string source="", [CallerLineNumber] int lineNumber=0)
Prints a message to console.

◆ Style()

static void CrabUITest.PropTest.Style ( CUIComponent Main)
static

Definition at line 20 of file Style.cs.

21 {
22 CUIFrame frame = new CUIFrame()
23 {
24 Absolute = new CUINullRect(200, 0, 200, 400),
25 Anchor = CUIAnchor.Center,
26 };
27
28 frame["content"] = new CUIComponent()
29 {
30 Relative = new CUINullRect(0.1f, 0.1f, 0.8f, 0.8f),
31 };
32
33 CUITextInput input = new CUITextInput()
34 {
35 AddOnTextChanged = (s) => CUITypeMetaData.Get(typeof(CUIComponent)).DefaultStyle["BackgroundColor"] = s,
36 };
37
38 frame["content"]["input"] = input;
39
40 Main.Append(frame);
41 }
virtual CUIComponent Get(string name)
Returns memorized component by name.

◆ TextWrap()

static void CrabUITest.PropTest.TextWrap ( CUIComponent Main)
static

Definition at line 20 of file TextWrap.cs.

21 {
22 CUIFrame frame = new CUIFrame(0.6f, 0.2f, 0.2f, 0.6f)
23 {
24
25 };
26
27 frame["center"] = new CUIComponent()
28 {
29 Relative = new CUINullRect(h: 0.5f),
30 FitContent = new CUIBool2(true, false),
31 Anchor = new Vector2(0.5f, 0.5f),
32 CullChildren = true,
33 };
34
35 frame["center"].Append(new CUITextBlock("bebebe bebe be b")
36 {
37 //BackgroundSpritePath = Mod.ModDir + "/Ignore/123.png",
38 BackgroundColor = Color.White,
39 Wrap = false,
40 Vertical = false,
41 TextScale = 2,
42 TextAlign = new Vector2(0.5f, 0.5f),
43 TextColor = Color.Black,
44 Relative = new CUINullRect(0, 0, 1, 1),
45 Debug = true,
46 });
47
48 Main.Append(frame);
49 }

◆ WeakEvents()

static void CrabUITest.PropTest.WeakEvents ( CUIComponent Main)
static

It just demonstates the problem idk how to solve it yet no, i'm not gonna use other weak event managers.

Parameters
Main

Definition at line 31 of file WeakEvents.cs.

32 {
33 CUIFrame frame = new CUIFrame(0.6f, 0.2f, 0.2f, 0.6f);
34
35 bool state = false;
36
38 {
39 Absolute = new CUINullRect(100, 100, 100, 100),
40 BackgroundColor = Color.Blue,
41 };
42
43 Main.OnMouseDown += (e) =>
44 {
45 state = !state;
46 c.BackgroundColor = state ? Color.Blue : Color.Green;
47 };
48
49
50 // And just throw it away
51 //frame.Append(c);
52 Main.Append(frame);
53 }

The documentation for this class was generated from the following files: