CrabUI
Loading...
Searching...
No Matches
Graphic Props.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 /// <summary>
22 /// Used for text, should be in CUITextBlock really
23 /// </summary>
24 [CUISerializable]
25 public Vector2 Padding
26 {
27 get => CUIProps.Padding.Value;
28 set => CUIProps.Padding.SetValue(value);
29 }
30 /// <summary>
31 /// Should be one texture, not sprite sheet
32 /// Or there would be no way to wrap it
33 /// Top side will always point outwards
34 /// </summary>
35 [CUISerializable]
36 public CUISprite BorderSprite { get; set; } = CUISprite.Default;
37
38 /// <summary>
39 /// Container for Color and Thickness
40 /// Border is drawn inside the component and will eat space from content
41 /// If "by side" border prop != null then it'll take presidence
42 /// </summary>
43 [CUISerializable] public CUIBorder Border { get; set; } = new CUIBorder();
44 [CUISerializable] public CUIBorder TopBorder { get; set; }
45 [CUISerializable] public CUIBorder RigthBorder { get; set; }
46 [CUISerializable] public CUIBorder BottomBorder { get; set; }
47 [CUISerializable] public CUIBorder LeftBorder { get; set; }
48
49
50 [CUISerializable]
51 public float OutlineThickness { get; set; } = 1f;
52 /// <summary>
53 /// Outline is like a border, but on the outside of the component
54 /// </summary>
55 [CUISerializable]
56 public Color OutlineColor
57 {
58 get => CUIProps.OutlineColor.Value;
59 set => CUIProps.OutlineColor.SetValue(value);
60 }
61 /// <summary>
62 /// Will be drawn in background with BackgroundColor
63 /// Default is solid white 1x1 texture
64 /// </summary>
65 [CUISerializable]
67 {
68 get => CUIProps.BackgroundSprite.Value;
69 set => CUIProps.BackgroundSprite.SetValue(value);
70 }
71 /// <summary>
72 /// If true, mouse events on transparent pixels will be ignored
73 /// Note: this will buffer texture data and potentially consume a lot of memory
74 /// so use wisely
75 /// </summary>
76 [CUISerializable]
78 {
79 get => CUIProps.IgnoreTransparent.Value;
80 set => CUIProps.IgnoreTransparent.SetValue(value);
81 }
82 //TODO i think those colors could be stored inside sprites
83 // But then it'll be much harder to apply side effects, think about it
84 /// <summary>
85 /// Color of BackgroundSprite, default is black
86 /// If you're using custom sprite and don't see it make sure this color is not black
87 /// </summary>
88 [CUISerializable]
89 public Color BackgroundColor
90 {
91 get => CUIProps.BackgroundColor.Value;
92 set => CUIProps.BackgroundColor.SetValue(value);
93 }
94
95 private float transparency = 1.0f;
96 public float Transparency
97 {
98 get => transparency;
99 set
100 {
101 transparency = value;
102 foreach (CUIComponent child in Children)
103 {
104 if (!child.IgnoreParentTransparency) child.Transparency = value;
105 }
106 }
107 }
108 /// <summary>
109 /// This palette will be used to resolve palette styles
110 /// Primary, Secondary, Tertiary, Quaternary
111 /// </summary>
112 [CUISerializable]
113 public PaletteOrder Palette
114 {
115 get => CUIProps.Palette.Value;
116 set => CUIProps.Palette.SetValue(value);
117 }
118 public PaletteOrder DeepPalette
119 {
120 set
121 {
122 Palette = value;
123 foreach (var child in Children)
124 {
125 child.DeepPalette = value;
126 }
127 }
128 }
129 /// <summary>
130 /// Had to expose resize handle props, because it's not a real component
131 /// and can't really use styles
132 /// </summary>
133 [CUISerializable]
134 public Color ResizeHandleColor { get; set; } = Color.White;
135 [CUISerializable]
136 public Color ResizeHandleGrabbedColor { get; set; } = Color.Cyan;
137
138 /// <summary>
139 /// don't
140 /// </summary>
141 public SamplerState SamplerState { get; set; }
142 }
143}
Base class for all components.
CUISprite BorderSprite
Should be one texture, not sprite sheet Or there would be no way to wrap it Top side will always ...
PaletteOrder Palette
This palette will be used to resolve palette styles Primary, Secondary, Tertiary,...
SamplerState SamplerState
don't
CUIComponentProps CUIProps
Just a wrapper for CUIProps idk how to separate them better.
Definition CUIProps.cs:27
Vector2 Padding
Used for text, should be in CUITextBlock really.
CUIBorder Border
Container for Color and Thickness Border is drawn inside the component and will eat space from cont...
Color BackgroundColor
Color of BackgroundSprite, default is black If you're using custom sprite and don't see it make sur...
bool IgnoreTransparent
If true, mouse events on transparent pixels will be ignored Note: this will buffer texture data and...
Color OutlineColor
Outline is like a border, but on the outside of the component.
Color ResizeHandleColor
Had to expose resize handle props, because it's not a real component and can't really use styles.
CUISprite BackgroundSprite
Will be drawn in background with BackgroundColor Default is solid white 1x1 texture.
Wrapper Containing link to texture and drawing settings, like SourceRedt, DrawMode,...
Definition CUISprite.cs:27
static CUISprite Default
new Sprite that uses 1x1 default texture
Definition CUISprite.cs:35