/// <summary> /// Creates the visual elements tree for the title bar. /// </summary> private VisualElement CreateTitlebar() { var background = new BorderedRectangle(TitlebarBackgroundColor, TitlebarBorderColor, 0); background.style.height = 34; var paddedContainer = new VisualElement(); paddedContainer.Set().Padding(4); paddedContainer.StretchToParentSize(); paddedContainer.style.flexDirection = FlexDirection.Row; RegisterMove(paddedContainer); var leftContainer = HUMRetained.Container(); leftContainer.style.position = Position.Relative; leftContainer.style.flexDirection = FlexDirection.Row; leftContainer.style.flexGrow = 1; var icon = new Image(); icon.image = headerIcon; icon.style.flexDirection = FlexDirection.Row; icon.style.position = Position.Relative; icon.style.height = 34; icon.style.width = 34; icon.Set().Padding(4); var headerTitle = label; headerTitle.style.flexDirection = FlexDirection.Row; headerTitle.style.position = Position.Relative; headerTitle.Set().Padding(4); if (headerIcon == null) { headerTitle.style.paddingLeft = 10; } background.style.height = 40; background.Add(paddedContainer); if (headerIcon != null) { leftContainer.Add(icon); } leftContainer.Add(headerTitle); leftContainer.AlignItems(Align.Center); leftContainer.Justification(Justify.FlexStart); leftContainer.style.unityTextAlign = TextAnchor.MiddleCenter; var rightContainer = WindowStatus(); paddedContainer.Add(leftContainer); paddedContainer.Add(rightContainer); paddedContainer.AlignItems(Align.Center); paddedContainer.Justification(Justify.FlexEnd); return(background); }