protected override void Render() { Rendering.DrawText(new Rectangle( ContentPosition.x, ContentPosition.y, InnerWidth, CurrentStyle.Get <float>(Styles.FontSize)), Text, CurrentStyle); }
public void RecalculateBox() { _position = CurrentStyle.Position(); _margin = CurrentStyle.Get <Dim>(Styles.Margin); _padding = CurrentStyle.Get <Dim>(Styles.Padding); _border = CurrentStyle.Get <Dim>(Styles.Border); _innerWidth = InnerWidth; _innerHeight = InnerHeight; _contentBox = new Rectangle(ContentPosition.x, ContentPosition.y, _innerWidth, _innerHeight); if (!CurrentStyle.Get <bool>(Styles.Hidden)) { _box = new Rectangle(); _box.x = Position.x; _box.y = Position.y; // margin left right border padding width _box.width = _margin.Left + _border.Left + _padding.Left + _margin.Right + _border.Right + _padding.Right + _innerWidth; _box.height = _margin.Top + _border.Top + _padding.Top + _margin.Bottom + _border.Bottom + _padding.Bottom + _innerHeight; } }
public void Draw() { if (!_isThemeApplied) { Initialize(); } if (CurrentStyle.Get <bool>(Styles.Hidden)) { return; } RecalculateBox(); // update all events UpdateEvents(); var marginOffset = new Vec2(Position.x + _margin.Left, Position.y + _margin.Top); // Raw background var contentBox = ContentBox; contentBox.height += _padding.Top + _padding.Bottom; contentBox.width += _padding.Left + _padding.Right; contentBox.x -= _padding.Left; contentBox.y -= _padding.Top; var bg = CurrentStyle.Get <Col>(Styles.BackgroundColor); if (bg.a > 0.001f) { Rendering.DrawRect(contentBox, bg); } // Draw border var borderColor = CurrentStyle.Get <Col>(Styles.BorderColor); float widthWithBorder = _border.Left + InnerWidth + _padding.Left + _border.Right + _padding.Right; float heightWithBorder = _border.Top + InnerHeight + _padding.Top + _border.Bottom + _padding.Bottom; if (_border.Top > float.Epsilon) { Rendering.DrawRect(new Rectangle(marginOffset.x + _border.Left, marginOffset.y, widthWithBorder - _border.Right - _border.Left, _border.Top), borderColor); } if (_border.Left > float.Epsilon) { Rendering.DrawRect(new Rectangle(marginOffset.x, marginOffset.y, _border.Left, heightWithBorder), borderColor); } if (_border.Right > float.Epsilon) { Rendering.DrawRect(new Rectangle(marginOffset.x + _border.Left + _padding.Left + InnerWidth + _padding.Right, marginOffset.y, _border.Right, heightWithBorder), borderColor); } if (_border.Bottom > float.Epsilon) { Rendering.DrawRect(new Rectangle(marginOffset.x + _border.Left, marginOffset.y + _border.Top + _padding.Top + InnerHeight + _padding.Bottom, widthWithBorder - _border.Right - _border.Left, _border.Bottom), borderColor); } Render(); foreach (var child in Children) { var drawable = (child as Widget); if (drawable != null) { drawable.DeferRender(); } } if (CurrentStyle.Exists(Styles.Outline)) { var outline = CurrentStyle.Get <GUIPanels.Outline>(Styles.Outline); Rendering.DrawLineBox(contentBox, outline.Width, outline.Color); } if (_shouldShowTooltip) { if (_tooltip != null) { _tooltip.Draw(); } } }