Falco Engine 3.9.0.1 (beta)
UIElement.cs
Go to the documentation of this file.
1using System;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5namespace FalcoEngine
6{
7 public class UIElement : Component
8 {
9 internal UIElement()
10 {
11
12 }
13
17 public enum CanvasHorizontalAlignment { Left, Center, Right };
18
22 public enum CanvasVerticalAlignment { Top, Middle, Bottom };
23
24 public delegate void MouseButtonEvent(UIElement sender, int button, Vector2 cursorPosition);
25 public delegate void MouseMoveEvent(UIElement sender, Vector2 cursorPosition);
31
36 {
37 get
38 {
39 return (CanvasHorizontalAlignment)INTERNAL_getHorizontalAlignment();
40 }
41 set
42 {
43 INTERNAL_setHorizontalAlignment((int)value);
44 }
45 }
46
51 {
52 get
53 {
54 return (CanvasVerticalAlignment)INTERNAL_getVerticalAlignment();
55 }
56 set
57 {
58 INTERNAL_setVerticalAlignment((int)value);
59 }
60 }
61
65 public Color color
66 {
67 get
68 {
69 INTERNAL_getColor(out Color value);
70 return value;
71 }
72 set
73 {
74 INTERNAL_setColor(ref value);
75 }
76 }
77
82 {
83 get
84 {
85 INTERNAL_getAnchor(out Vector2 value);
86 return value;
87 }
88 set
89 {
90 INTERNAL_setAnchor(ref value);
91 }
92 }
93
98 {
99 get
100 {
101 INTERNAL_getSize(out Vector2 value);
102 return value;
103 }
104 set
105 {
106 INTERNAL_setSize(ref value);
107 }
108 }
109
113 public bool hovered { [MethodImpl(MethodImplOptions.InternalCall)] get; }
114
118 public Canvas canvas { [MethodImpl(MethodImplOptions.InternalCall)] get; }
119
121 {
122 get
123 {
124 INTERNAL_getPosition(out Vector3 value);
125 return value;
126 }
127 set
128 {
129 INTERNAL_setPosition(ref value);
130 }
131 }
132
133 public Rect rect
134 {
135 get
136 {
137 INTERNAL_getRect(out Rect value);
138 return value;
139 }
140 }
141
145 public object userData { get; set; }
146
147 /*----------- INTERNAL CALLS ------------*/
148
149 [MethodImpl(MethodImplOptions.InternalCall)]
150 private extern void INTERNAL_getColor(out Color value);
151
152 [MethodImpl(MethodImplOptions.InternalCall)]
153 private extern void INTERNAL_setColor(ref Color value);
154
155 [MethodImpl(MethodImplOptions.InternalCall)]
156 private extern void INTERNAL_getAnchor(out Vector2 value);
157
158 [MethodImpl(MethodImplOptions.InternalCall)]
159 private extern void INTERNAL_setAnchor(ref Vector2 value);
160
161 [MethodImpl(MethodImplOptions.InternalCall)]
162 private extern int INTERNAL_getHorizontalAlignment();
163
164 [MethodImpl(MethodImplOptions.InternalCall)]
165 private extern void INTERNAL_setHorizontalAlignment(int value);
166
167 [MethodImpl(MethodImplOptions.InternalCall)]
168 private extern int INTERNAL_getVerticalAlignment();
169
170 [MethodImpl(MethodImplOptions.InternalCall)]
171 private extern void INTERNAL_setVerticalAlignment(int value);
172
173 [MethodImpl(MethodImplOptions.InternalCall)]
174 private extern void INTERNAL_getSize(out Vector2 value);
175
176 [MethodImpl(MethodImplOptions.InternalCall)]
177 private extern void INTERNAL_setSize(ref Vector2 value);
178
179 [MethodImpl(MethodImplOptions.InternalCall)]
180 private extern void INTERNAL_getPosition(out Vector3 value);
181
182 [MethodImpl(MethodImplOptions.InternalCall)]
183 private extern void INTERNAL_setPosition(ref Vector3 value);
184
185 [MethodImpl(MethodImplOptions.InternalCall)]
186 private extern void INTERNAL_getRect(out Rect value);
187
188 private void CallOnMouseDown(UIElement sender, int button, Vector2 cursorPosition)
189 {
190 onMouseDown?.Invoke(sender, button, cursorPosition);
191 }
192
193 private void CallOnMouseUp(UIElement sender, int button, Vector2 cursorPosition)
194 {
195 onMouseUp?.Invoke(sender, button, cursorPosition);
196 }
197
198 private void CallOnMouseMove(UIElement sender, Vector2 cursorPosition)
199 {
200 onMouseMove?.Invoke(sender, cursorPosition);
201 }
202
203 private void CallOnMouseEnter(UIElement sender, Vector2 cursorPosition)
204 {
205 onMouseEnter?.Invoke(sender, cursorPosition);
206 }
207
208 private void CallOnMouseExit(UIElement sender, Vector2 cursorPosition)
209 {
210 onMouseExit?.Invoke(sender, cursorPosition);
211 }
212 }
213}
MouseButtonEvent onMouseUp
Definition: UIElement.cs:27
object userData
Get or set the user data
Definition: UIElement.cs:145
CanvasVerticalAlignment
CanvasVerticalAlignment enum
Definition: UIElement.cs:22
Color color
Get or set the main color of this element
Definition: UIElement.cs:66
MouseMoveEvent onMouseExit
Definition: UIElement.cs:30
bool hovered
Returns if this element is hovered by mouse cursor
Definition: UIElement.cs:113
CanvasVerticalAlignment verticalAlignment
Get or set vertical alignment of this element
Definition: UIElement.cs:51
CanvasHorizontalAlignment
CanvasHorizontalAlignment enum
Definition: UIElement.cs:17
MouseMoveEvent onMouseEnter
Definition: UIElement.cs:29
delegate void MouseMoveEvent(UIElement sender, Vector2 cursorPosition)
Vector2 anchor
Get or set the anchor of this element (pivot point)
Definition: UIElement.cs:82
delegate void MouseButtonEvent(UIElement sender, int button, Vector2 cursorPosition)
CanvasHorizontalAlignment horizontalAlignment
Get or set horizontal alignment of this element
Definition: UIElement.cs:36
Vector2 size
Get or set the size of this element (width and height)
Definition: UIElement.cs:98
MouseMoveEvent onMouseMove
Definition: UIElement.cs:28
MouseButtonEvent onMouseDown
Definition: UIElement.cs:26
Canvas canvas
Returns a canvas of this element
Definition: UIElement.cs:118