| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using System.Linq; |
| | 4 | | using DCL; |
| | 5 | | using DCL.Controllers; |
| | 6 | | using DCL.ECS7; |
| | 7 | | using DCL.ECS7.UI; |
| | 8 | | using DCL.ECSComponents; |
| | 9 | | using DCL.ECSRuntime; |
| | 10 | | using DCL.Models; |
| | 11 | | using UnityEngine; |
| | 12 | | using UnityEngine.EventSystems; |
| | 13 | | using UnityEngine.UIElements; |
| | 14 | | using Environment = DCL.Environment; |
| | 15 | | using Random = UnityEngine.Random; |
| | 16 | |
|
| | 17 | | namespace DCL.ECS7 |
| | 18 | | { |
| | 19 | | public struct VisualElementRepresentation |
| | 20 | | { |
| | 21 | | public long entityId; |
| | 22 | | public long parentId; |
| | 23 | | public VisualElement visualElement; |
| | 24 | | public VisualElement parentVisualElement; |
| | 25 | | } |
| | 26 | |
|
| | 27 | | public class CanvasPainter |
| | 28 | | { |
| | 29 | | private const string UI_DOCUMENT_PREFAB_PATH = "RootNode"; |
| | 30 | | private const int FRAMES_PER_PAINT = 10; |
| | 31 | |
|
| | 32 | | internal readonly UIDocument rootNode; |
| | 33 | | internal readonly IUIDataContainer dataContainer; |
| | 34 | | private readonly RendererState rendererState; |
| | 35 | | private readonly BaseList<IParcelScene> loadedScenes; |
| | 36 | | private readonly IUpdateEventHandler updateEventHandler; |
| | 37 | | private readonly IWorldState worldState; |
| | 38 | | private readonly ECSComponentsManager componentsManager; |
| | 39 | |
|
| | 40 | | internal UISceneDataContainer sceneDataContainerToUse; |
| | 41 | | private IParcelScene scene; |
| | 42 | |
|
| 8 | 43 | | internal Dictionary<long, VisualElementRepresentation> visualElements = new Dictionary<long, VisualElementRepres |
| 8 | 44 | | internal List<VisualElementRepresentation> orphanVisualElements = new List<VisualElementRepresentation>(); |
| | 45 | |
|
| | 46 | | internal IECSReadOnlyComponentsGroup<PBUiTransform, PBUiText> textComponentGroup; |
| | 47 | |
|
| | 48 | | internal int framesCounter = 0; |
| | 49 | | internal bool canvasCleared = false; |
| | 50 | |
|
| 8 | 51 | | public CanvasPainter(DataStore_ECS7 dataStoreEcs7, RendererState rendererState, IUpdateEventHandler updateEventH |
| | 52 | | { |
| 8 | 53 | | this.updateEventHandler = updateEventHandler; |
| 8 | 54 | | this.loadedScenes = dataStoreEcs7.scenes; |
| 8 | 55 | | this.rendererState = rendererState; |
| 8 | 56 | | this.dataContainer = dataStoreEcs7.uiDataContainer; |
| 8 | 57 | | this.worldState = worldState; |
| | 58 | |
|
| 8 | 59 | | var prefab = Resources.Load<UIDocument>(UI_DOCUMENT_PREFAB_PATH); |
| 8 | 60 | | rootNode = GameObject.Instantiate(prefab); |
| | 61 | |
|
| 8 | 62 | | updateEventHandler.AddListener(IUpdateEventHandler.EventType.Update, Update); |
| | 63 | |
|
| | 64 | | // Group Components |
| 8 | 65 | | textComponentGroup = componentsManager.CreateComponentGroup<PBUiTransform, PBUiText>(ComponentID.UI_TRANSFOR |
| | 66 | | #if UNITY_EDITOR |
| 8 | 67 | | rootNode.name = "Scene Canvas"; |
| | 68 | | #endif |
| 8 | 69 | | } |
| | 70 | |
|
| | 71 | | public void Dispose() |
| | 72 | | { |
| 8 | 73 | | GameObject.Destroy(rootNode.gameObject); |
| 8 | 74 | | updateEventHandler.RemoveListener(IUpdateEventHandler.EventType.Update, Update); |
| 8 | 75 | | if(sceneDataContainerToUse != null) |
| 4 | 76 | | sceneDataContainerToUse.OnUITransformRemoved -= RemoveVisualElement; |
| 8 | 77 | | } |
| | 78 | |
|
| | 79 | | internal void SetScene(IParcelScene scene) |
| | 80 | | { |
| 5 | 81 | | this.scene = scene; |
| | 82 | |
|
| 5 | 83 | | if(sceneDataContainerToUse != null) |
| 1 | 84 | | sceneDataContainerToUse.OnUITransformRemoved -= RemoveVisualElement; |
| | 85 | |
|
| | 86 | | // We get the UI information of the scene to paint their canvas |
| 5 | 87 | | sceneDataContainerToUse = dataContainer.GetDataContainer(scene); |
| 5 | 88 | | sceneDataContainerToUse.OnUITransformRemoved += RemoveVisualElement; |
| 5 | 89 | | ClearAndHideRootLayout(); |
| 5 | 90 | | } |
| | 91 | |
|
| | 92 | | private void ClearAndHideRootLayout() |
| | 93 | | { |
| 5 | 94 | | rootNode.rootVisualElement.visible = false; |
| 5 | 95 | | rootNode.rootVisualElement.Clear(); |
| 5 | 96 | | canvasCleared = true; |
| 5 | 97 | | } |
| | 98 | |
|
| | 99 | | private void RemoveVisualElement(IDCLEntity entity) |
| | 100 | | { |
| | 101 | | // We try to get the parent |
| 1 | 102 | | if (visualElements.TryGetValue(entity.entityId, out VisualElementRepresentation visualElementRepresentantion |
| | 103 | | { |
| 1 | 104 | | if (visualElementRepresentantion.parentVisualElement != null) |
| 0 | 105 | | visualElementRepresentantion.parentVisualElement.Remove(visualElementRepresentantion.visualElement); |
| | 106 | |
|
| 1 | 107 | | visualElements.Remove(entity.entityId); |
| | 108 | | } |
| 1 | 109 | | } |
| | 110 | |
|
| | 111 | | internal void Update() |
| | 112 | | { |
| 1 | 113 | | framesCounter++; |
| 1 | 114 | | if (!rendererState.Get() || framesCounter < FRAMES_PER_PAINT) |
| 0 | 115 | | return; |
| | 116 | |
|
| 1 | 117 | | framesCounter = 0; |
| | 118 | |
|
| | 119 | | // We look in which scene is the player, and draw the UI of that scene |
| 1 | 120 | | bool sceneFound = false; |
| 4 | 121 | | for (int i = 0; i < loadedScenes.Count; i++) |
| | 122 | | { |
| 2 | 123 | | if(loadedScenes[i].sceneData.id != worldState.currentSceneId) |
| | 124 | | continue; |
| 1 | 125 | | sceneFound = true; |
| 1 | 126 | | DrawUI(loadedScenes[i]); |
| 1 | 127 | | break; |
| | 128 | | } |
| | 129 | |
|
| | 130 | | // If we are entering in an empty parcel, or ECS6 scene, we should also clear the UI |
| 1 | 131 | | if (!sceneFound && !canvasCleared) |
| 0 | 132 | | ClearAndHideRootLayout(); |
| 1 | 133 | | } |
| | 134 | |
|
| | 135 | | private void DrawUI(IParcelScene scene) |
| | 136 | | { |
| 1 | 137 | | if(this.scene != scene || canvasCleared) |
| 1 | 138 | | SetScene(scene); |
| | 139 | |
|
| 1 | 140 | | DrawUI(); |
| 1 | 141 | | } |
| | 142 | |
|
| | 143 | | private void DrawUI() |
| | 144 | | { |
| | 145 | | // If the canvas hasn't change or if there is no canvas we skip |
| 1 | 146 | | if (!canvasCleared && (!sceneDataContainerToUse.IsDirty() || !sceneDataContainerToUse.sceneCanvasTransform.A |
| 0 | 147 | | return; |
| | 148 | |
|
| 1 | 149 | | canvasCleared = false; |
| 1 | 150 | | sceneDataContainerToUse.UIRendered(); |
| | 151 | |
|
| | 152 | | // We ensure that the root canvas is visible |
| 1 | 153 | | rootNode.rootVisualElement.visible = true; |
| | 154 | |
|
| | 155 | | // This should be the way to go when we implement the UI events |
| | 156 | | // visualElement.RegisterCallback<ClickEvent>(ev => Debug.Log("Clicked")); |
| | 157 | |
|
| | 158 | | // It can happen that we received or processed the child before the parent, that make some elements orphan |
| | 159 | | // If we have some orphan elements, we try to search and assign the parent here, if we don't found it, we wi |
| 1 | 160 | | TryToSetOrphanParents(); |
| | 161 | |
|
| 1 | 162 | | List<long> entitiesWithRendererComponent = new List<long>(); |
| | 163 | |
|
| | 164 | | // This will create the text elements along their UITransform |
| 1 | 165 | | CreateTextElements(entitiesWithRendererComponent); |
| | 166 | |
|
| | 167 | | // This will create the containers to position the elements |
| 1 | 168 | | CreateContainers(entitiesWithRendererComponent); |
| | 169 | |
|
| | 170 | | // We set the parent of all the elements that has been created |
| 2 | 171 | | foreach (KeyValuePair<long,VisualElementRepresentation> kvp in visualElements) |
| | 172 | | { |
| 0 | 173 | | var visualElement = kvp.Value; |
| 0 | 174 | | SetParent(ref visualElement); |
| | 175 | | } |
| 1 | 176 | | } |
| | 177 | |
|
| | 178 | | internal void CreateContainers(List<long> excludedEntities) |
| | 179 | | { |
| 2 | 180 | | var enumerator = sceneDataContainerToUse.sceneCanvasTransform.GetEnumerator(); |
| | 181 | | try |
| | 182 | | { |
| | 183 | | // We create all the elements that doesn't have a rendering ( Image, Text...etc) since we need them to p |
| 3 | 184 | | while (enumerator.MoveNext()) |
| | 185 | | { |
| 1 | 186 | | var kvp = enumerator.Current; |
| | 187 | | // If the entity doesn't exist we skip |
| 1 | 188 | | if (!scene.entities.TryGetValue( kvp.Key, out IDCLEntity entity)) |
| | 189 | | continue; |
| | 190 | |
|
| | 191 | | // If the entity already have a rendering element, we skip since we don't need to create it again |
| 1 | 192 | | if (excludedEntities.Contains(entity.entityId)) |
| | 193 | | continue; |
| | 194 | |
|
| | 195 | | // We create the element to position the rendering element correctly |
| 1 | 196 | | var visualElement = TransformToVisualElement(kvp.Value, new Image()); |
| 1 | 197 | | visualElements[entity.entityId] = new VisualElementRepresentation() |
| | 198 | | { |
| | 199 | | entityId = entity.entityId, |
| | 200 | | parentId = entity.parentId, |
| | 201 | | visualElement = visualElement |
| | 202 | | }; |
| | 203 | | } |
| 2 | 204 | | } |
| | 205 | | finally |
| | 206 | | { |
| 2 | 207 | | enumerator.Dispose(); |
| 2 | 208 | | } |
| 2 | 209 | | } |
| | 210 | |
|
| | 211 | | internal void CreateTextElements(List<long> entitiesWithRendererComponent) |
| | 212 | | { |
| | 213 | | IECSReadOnlyComponentData<PBUiTransform> componentData; |
| | 214 | |
|
| | 215 | | // We create all the text elements |
| 2 | 216 | | for(int i = 0; i < textComponentGroup.group.Count; i++) |
| | 217 | | { |
| 0 | 218 | | componentData = textComponentGroup.group[i].componentData1; |
| | 219 | |
|
| 0 | 220 | | var textElement = new TextElement(); |
| 0 | 221 | | textElement.text = textComponentGroup.group[i].componentData2.model.Text; |
| 0 | 222 | | var color = textComponentGroup.group[i].componentData2.model.TextColor; |
| 0 | 223 | | textElement.style.color = new UnityEngine.Color(color.R, color.G,color.B,1); |
| | 224 | |
|
| | 225 | | // We create the text element |
| 0 | 226 | | var visualElement = TransformToVisualElement(componentData.model, textElement, false); |
| | 227 | |
|
| 0 | 228 | | visualElements[componentData.entity.entityId] = new VisualElementRepresentation() |
| | 229 | | { |
| | 230 | | entityId = componentData.entity.entityId, |
| | 231 | | parentId = componentData.entity.parentId, |
| | 232 | | visualElement = visualElement |
| | 233 | | }; |
| | 234 | |
|
| | 235 | | // We add the entity to a list so it doesn't create a visual element for the PBUiTransform since the tra |
| 0 | 236 | | entitiesWithRendererComponent.Add(componentData.entity.entityId); |
| | 237 | | } |
| 1 | 238 | | } |
| | 239 | |
|
| | 240 | | internal void TryToSetOrphanParents() |
| | 241 | | { |
| 2 | 242 | | for(int i = 0; i < orphanVisualElements.Count; i++) |
| | 243 | | { |
| 0 | 244 | | var visualElement = orphanVisualElements[i]; |
| 0 | 245 | | SetParent(ref visualElement, false); |
| | 246 | |
|
| | 247 | | // If we found the parent, we remove it and set it visible |
| 0 | 248 | | if (orphanVisualElements[i].parentVisualElement != null) |
| | 249 | | { |
| 0 | 250 | | orphanVisualElements[i].visualElement.visible = true; |
| 0 | 251 | | orphanVisualElements.Remove(orphanVisualElements[i]); |
| | 252 | | } |
| | 253 | | } |
| 1 | 254 | | } |
| | 255 | |
|
| | 256 | | internal void SetParent(ref VisualElementRepresentation visualElementRepresentation, bool addToOrphanList = true |
| | 257 | | { |
| | 258 | | // if the parent is the root canvas, it doesn't have parent, we skip |
| 3 | 259 | | if (visualElementRepresentation.parentId == SpecialEntityId.SCENE_ROOT_ENTITY) |
| | 260 | | { |
| 1 | 261 | | rootNode.rootVisualElement.Add(visualElementRepresentation.visualElement); |
| 1 | 262 | | visualElementRepresentation.parentVisualElement = rootNode.rootVisualElement; |
| 1 | 263 | | } |
| | 264 | | else |
| | 265 | | { |
| | 266 | | // We try to get the parent |
| 2 | 267 | | if (visualElements.TryGetValue(visualElementRepresentation.parentId, out VisualElementRepresentation par |
| | 268 | | { |
| 1 | 269 | | parentVisualElementRepresentantion.visualElement.Add(visualElementRepresentation.visualElement); |
| 1 | 270 | | visualElementRepresentation.parentVisualElement = parentVisualElementRepresentantion.visualElement; |
| 1 | 271 | | } |
| 1 | 272 | | else if (addToOrphanList) |
| | 273 | | { |
| | 274 | | // There is no father so it is orphan right now. We can try to find the father the next time, we hid |
| 1 | 275 | | visualElementRepresentation.visualElement.visible = false; |
| 1 | 276 | | orphanVisualElements.Add(visualElementRepresentation); |
| | 277 | | } |
| | 278 | | } |
| 1 | 279 | | } |
| | 280 | |
|
| | 281 | | internal VisualElement TransformToVisualElement(PBUiTransform model, VisualElement element, bool randomColor = t |
| | 282 | | { |
| 2 | 283 | | element.style.display = GetDisplay(model.Display); |
| 2 | 284 | | element.style.overflow = GetOverflow(model.Overflow); |
| | 285 | |
|
| | 286 | | // Flex |
| 2 | 287 | | element.style.flexDirection = GetFlexDirection(model.FlexDirection); |
| 2 | 288 | | if (!float.IsNaN(model.FlexBasis)) |
| 2 | 289 | | element.style.flexBasis = new Length(model.FlexBasis, GetUnit(model.FlexBasisUnit)); |
| | 290 | |
|
| 2 | 291 | | element.style.flexGrow = model.FlexGrow; |
| 2 | 292 | | element.style.flexShrink = model.FlexShrink; |
| 2 | 293 | | element.style.flexWrap = GetWrap(model.FlexWrap); |
| | 294 | |
|
| | 295 | | // Align |
| 2 | 296 | | if (model.AlignContent != YGAlign.FlexStart) |
| 2 | 297 | | element.style.alignContent = GetAlign(model.AlignContent); |
| 2 | 298 | | if (model.AlignItems != YGAlign.Auto) |
| 2 | 299 | | element.style.alignItems = GetAlign(model.AlignItems); |
| 2 | 300 | | if (model.AlignSelf != YGAlign.Auto) |
| 2 | 301 | | element.style.alignSelf = GetAlign(model.AlignSelf); |
| 2 | 302 | | element.style.justifyContent = GetJustify(model.JustifyContent); |
| | 303 | |
|
| | 304 | | // Layout size |
| 2 | 305 | | if (!float.IsNaN(model.Height)) |
| 2 | 306 | | element.style.height = new Length(model.Height, GetUnit(model.HeightUnit)); |
| 2 | 307 | | if (!float.IsNaN(model.Width)) |
| 2 | 308 | | element.style.width = new Length(model.Width, GetUnit(model.WidthUnit)); |
| | 309 | |
|
| 2 | 310 | | if (!float.IsNaN(model.MaxWidth)) |
| 2 | 311 | | element.style.maxWidth = new Length(model.MaxWidth, GetUnit(model.MaxWidthUnit)); |
| 2 | 312 | | if (!float.IsNaN(model.MaxHeight)) |
| 2 | 313 | | element.style.maxHeight = new Length(model.MaxHeight, GetUnit(model.MaxHeightUnit)); |
| | 314 | |
|
| 2 | 315 | | if (!float.IsNaN(model.MinHeight)) |
| 2 | 316 | | element.style.minHeight = new Length(model.MinHeight, GetUnit(model.MinHeightUnit)); |
| 2 | 317 | | if (!float.IsNaN(model.MinWidth)) |
| 2 | 318 | | element.style.minWidth = new Length(model.MinWidth, GetUnit(model.MinWidthUnit)); |
| | 319 | |
|
| | 320 | | // Paddings |
| 2 | 321 | | if (!Mathf.Approximately(model.PaddingBottom, 0)) |
| 2 | 322 | | element.style.paddingBottom = new Length(model.PaddingBottom, GetUnit(model.PaddingBottomUnit)); |
| 2 | 323 | | if (!Mathf.Approximately(model.PaddingLeft, 0)) |
| 2 | 324 | | element.style.paddingLeft = new Length(model.PaddingLeft, GetUnit(model.PaddingLeftUnit)); |
| 2 | 325 | | if (!Mathf.Approximately(model.PaddingRight, 0)) |
| 2 | 326 | | element.style.paddingRight = new Length(model.PaddingRight, GetUnit(model.PaddingRightUnit)); |
| 2 | 327 | | if (!Mathf.Approximately(model.PaddingTop, 0)) |
| 2 | 328 | | element.style.paddingTop = new Length(model.PaddingTop, GetUnit(model.PaddingTopUnit)); |
| | 329 | |
|
| | 330 | | // Margins |
| 2 | 331 | | if (!Mathf.Approximately(model.MarginLeft, 0)) |
| 2 | 332 | | element.style.marginLeft = new Length(model.MarginLeft, GetUnit(model.MarginLeftUnit)); |
| 2 | 333 | | if (!Mathf.Approximately(model.MarginRight, 0)) |
| 2 | 334 | | element.style.marginRight = new Length(model.MarginRight, GetUnit(model.MarginRightUnit)); |
| 2 | 335 | | if (!Mathf.Approximately(model.MarginBottom, 0)) |
| 2 | 336 | | element.style.marginBottom = new Length(model.MarginBottom, GetUnit(model.MarginBottomUnit)); |
| 2 | 337 | | if (!Mathf.Approximately(model.MarginTop, 0)) |
| 2 | 338 | | element.style.marginTop = new Length(model.MarginTop, GetUnit(model.MarginTopUnit)); |
| | 339 | |
|
| | 340 | | // Borders |
| 2 | 341 | | element.style.borderBottomWidth = model.BorderBottom; |
| 2 | 342 | | element.style.borderLeftWidth = model.BorderLeft; |
| 2 | 343 | | element.style.borderRightWidth = model.BorderRight; |
| 2 | 344 | | element.style.borderTopWidth = model.BorderTop; |
| | 345 | |
|
| | 346 | | // Position |
| 2 | 347 | | element.style.position = GetPosition(model.PositionType); |
| | 348 | |
|
| | 349 | | // This is for debugging purposes, we will change this to a proper approach so devs can debug the UI easily. |
| 2 | 350 | | if (randomColor) |
| 2 | 351 | | element.style.backgroundColor = Random.ColorHSV(); |
| | 352 | |
|
| 2 | 353 | | return element; |
| | 354 | | } |
| | 355 | |
|
| | 356 | | internal LengthUnit GetUnit(YGUnit unit) |
| | 357 | | { |
| | 358 | | switch (unit) |
| | 359 | | { |
| | 360 | | case YGUnit.Point: |
| 0 | 361 | | return LengthUnit.Pixel; |
| | 362 | | case YGUnit.Percent: |
| 0 | 363 | | return LengthUnit.Percent; |
| | 364 | | default: |
| 0 | 365 | | return LengthUnit.Pixel; |
| | 366 | | } |
| | 367 | | } |
| | 368 | |
|
| | 369 | | internal StyleEnum<Overflow> GetOverflow (YGOverflow overflow) |
| | 370 | | { |
| | 371 | | switch (overflow) |
| | 372 | | { |
| | 373 | | case YGOverflow.Visible: |
| 0 | 374 | | return Overflow.Visible; |
| | 375 | | case YGOverflow.Hidden: |
| 3 | 376 | | return Overflow.Hidden; |
| | 377 | | default: |
| 0 | 378 | | return Overflow.Visible; |
| | 379 | | } |
| | 380 | | } |
| | 381 | |
|
| | 382 | | internal StyleEnum<DisplayStyle> GetDisplay (YGDisplay display) |
| | 383 | | { |
| | 384 | | switch (display) |
| | 385 | | { |
| | 386 | | case YGDisplay.Flex: |
| 3 | 387 | | return DisplayStyle.Flex; |
| | 388 | | break; |
| | 389 | | case YGDisplay.None: |
| 0 | 390 | | return DisplayStyle.None; |
| | 391 | | default: |
| 0 | 392 | | return DisplayStyle.Flex; |
| | 393 | | } |
| | 394 | | } |
| | 395 | |
|
| | 396 | | internal StyleEnum<Justify> GetJustify (YGJustify justify) |
| | 397 | | { |
| | 398 | | switch (justify) |
| | 399 | | { |
| | 400 | | case YGJustify.FlexStart: |
| 0 | 401 | | return Justify.FlexStart; |
| | 402 | | case YGJustify.Center: |
| 3 | 403 | | return Justify.Center; |
| | 404 | | case YGJustify.FlexEnd: |
| 0 | 405 | | return Justify.FlexEnd; |
| | 406 | | case YGJustify.SpaceBetween: |
| 0 | 407 | | return Justify.SpaceBetween; |
| | 408 | | case YGJustify.SpaceAround: |
| 0 | 409 | | return Justify.SpaceAround; |
| | 410 | | default: |
| 0 | 411 | | return Justify.FlexStart; |
| | 412 | | } |
| | 413 | | } |
| | 414 | |
|
| | 415 | | internal StyleEnum<Wrap> GetWrap (YGWrap wrap) |
| | 416 | | { |
| | 417 | | switch (wrap) |
| | 418 | | { |
| | 419 | | case YGWrap.NoWrap: |
| 0 | 420 | | return Wrap.NoWrap; |
| | 421 | | case YGWrap.Wrap: |
| 3 | 422 | | return Wrap.Wrap; |
| | 423 | | case YGWrap.WrapReverse: |
| 0 | 424 | | return Wrap.WrapReverse; |
| | 425 | | default: |
| 0 | 426 | | return Wrap.Wrap; |
| | 427 | | } |
| | 428 | | } |
| | 429 | |
|
| | 430 | | internal StyleEnum<FlexDirection> GetFlexDirection (YGFlexDirection direction) |
| | 431 | | { |
| | 432 | | switch (direction) |
| | 433 | | { |
| | 434 | | case YGFlexDirection.Column: |
| 3 | 435 | | return FlexDirection.Column; |
| | 436 | | case YGFlexDirection.ColumnReverse: |
| 0 | 437 | | return FlexDirection.ColumnReverse; |
| | 438 | | case YGFlexDirection.Row: |
| 0 | 439 | | return FlexDirection.Row; |
| | 440 | | case YGFlexDirection.RowReverse: |
| 0 | 441 | | return FlexDirection.RowReverse; |
| | 442 | | default: |
| 0 | 443 | | return FlexDirection.Row; |
| | 444 | | } |
| | 445 | | } |
| | 446 | |
|
| | 447 | | internal StyleEnum<Position> GetPosition(YGPositionType positionType) |
| | 448 | | { |
| | 449 | | switch (positionType) |
| | 450 | | { |
| | 451 | | case YGPositionType.Relative: |
| 0 | 452 | | return Position.Relative; |
| | 453 | | case YGPositionType.Absolute: |
| 4 | 454 | | return Position.Absolute; |
| | 455 | | default: |
| 0 | 456 | | return Position.Relative; |
| | 457 | | } |
| | 458 | | } |
| | 459 | |
|
| | 460 | | internal StyleEnum<Align> GetAlign(YGAlign align) |
| | 461 | | { |
| | 462 | | switch (align) |
| | 463 | | { |
| | 464 | | case YGAlign.Auto: |
| 0 | 465 | | return Align.Auto; |
| | 466 | | case YGAlign.FlexStart: |
| 0 | 467 | | return Align.FlexStart; |
| | 468 | | case YGAlign.Center: |
| 9 | 469 | | return Align.Center; |
| | 470 | | case YGAlign.FlexEnd: |
| 0 | 471 | | return Align.FlexEnd; |
| | 472 | | case YGAlign.Stretch: |
| 0 | 473 | | return Align.Stretch; |
| | 474 | | default: |
| 0 | 475 | | return Align.Auto; |
| | 476 | | } |
| | 477 | | } |
| | 478 | | } |
| | 479 | | } |