CrabUI
Loading...
Searching...
No Matches
CUIComponent.Layout.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Reflection;
5using System.Diagnostics;
6using System.Runtime.CompilerServices;
7using System.IO;
8
9using Barotrauma;
10using Microsoft.Xna.Framework;
11using Microsoft.Xna.Framework.Input;
12using Microsoft.Xna.Framework.Graphics;
13
14using System.Xml;
15using System.Xml.Linq;
16
17namespace CrabUI
18{
19 public partial class CUIComponent
20 {
21 #region Layout --------------------------------------------------------
22
23 protected CUILayout layout;
24 //[CUISerializable]
25 public virtual CUILayout Layout
26 {
27 get => layout;
28 set { layout = value; layout.Host = this; }
29 }
30
31 public event Action OnLayoutUpdated;
32 public void InvokeOnLayoutUpdated() => OnLayoutUpdated?.Invoke();
33
34 /// <summary>
35 /// Triggers recalculation of layouts from parent and below
36 /// </summary>
37 internal void OnPropChanged([CallerMemberName] string memberName = "")
38 {
39 Layout.Changed = true;
40 CUIDebug.Capture(null, this, "OnPropChanged", memberName, "Layout.Changed", "true");
41 MainComponent?.LayoutChanged();
42 }
43 internal void OnSelfAndParentChanged([CallerMemberName] string memberName = "")
44 {
45 Layout.SelfAndParentChanged = true;
46 CUIDebug.Capture(null, this, "OnSelfAndParentChanged", memberName, "Layout.SelfAndParentChanged", "true");
47 MainComponent?.LayoutChanged();
48 }
49
50 /// <summary>
51 /// Triggers recalc of own pseudo components and nothing else
52 /// </summary>
53 internal void OnDecorPropChanged([CallerMemberName] string memberName = "")
54 {
55 Layout.DecorChanged = true;
56 CUIDebug.Capture(null, this, "OnDecorPropChanged", memberName, "Layout.DecorChanged", "true");
57 MainComponent?.LayoutChanged();
58 }
59 /// <summary>
60 /// Notifies parent (only) than it may need to ResizeToContent
61 /// </summary>
62 internal void OnAbsolutePropChanged([CallerMemberName] string memberName = "")
63 {
64 Layout.AbsoluteChanged = true;
65 CUIDebug.Capture(null, this, "OnAbsolutePropChanged", memberName, "Layout.AbsoluteChanged", "true");
66 MainComponent?.LayoutChanged();
67 }
68 /// <summary>
69 /// Triggers recalculation of layouts from this and below
70 /// </summary>
71 internal void OnChildrenPropChanged([CallerMemberName] string memberName = "")
72 {
73 Layout.ChildChanged = true;
74 MainComponent?.LayoutChanged();
75 }
76
77 #endregion
78
79 }
80}
CUIMainComponent MainComponent
Link to CUIMainComponent, passed to children.