protected override void Draw()
            {
                if (listBody.Collection.Count > 0)
                {
                    Vector2 bodySize    = listBody.Size,
                            bodyPadding = listBody.Padding;

                    float memberWidth = 0f;
                    int   visCount    = 0;
                    var   entries     = listBody.Collection;

                    for (int i = 0; i < entries.Count && visCount < listBody.VisCount; i++)
                    {
                        int            j       = Math.Min(listBody.VisStart + i, entries.Count - 1);
                        HudElementBase element = entries[j].Element;

                        if (element.Visible)
                        {
                            memberWidth = Math.Max(memberWidth, element.Width);
                            visCount++;
                        }
                    }

                    memberWidth += bodyPadding.X + listBody.ScrollBar.Width + listBody.Divider.Width;
                    layout.Width = Math.Max(memberWidth, layout.MemberMinSize.X);

                    highlightBox.Size = new Vector2(
                        bodySize.X - listBody.Divider.Width - listBody.ScrollBar.Width,
                        listBody[selectionIndex].Element.Height + 2f
                        );
                    highlightBox.Offset = new Vector2(0f, listBody[selectionIndex].Element.Offset.Y - 1f);
                }
                ;
            }
            public TerminalPageBase(HudElementBase assocMember)
            {
                SetElement(new Label());
                AssocMember           = assocMember;
                assocMember.IsMasking = true;

                Name    = "NewPage";
                Enabled = true;
            }
        public WindowBase(HudParentBase parent) : base(parent)
        {
            header = new LabelBoxButton(this)
            {
                DimAlignment     = DimAlignments.Width,
                Height           = 32f,
                ParentAlignment  = ParentAlignments.Top | ParentAlignments.Inner,
                ZOffset          = 1,
                Format           = GlyphFormat.White.WithAlignment(TextAlignment.Center),
                HighlightEnabled = false,
                AutoResize       = false,
            };

            body = new EmptyHudElement(header)
            {
                DimAlignment    = DimAlignments.Width,
                ParentAlignment = ParentAlignments.Bottom,
            };

            bodyBg = new TexturedBox(body)
            {
                DimAlignment = DimAlignments.Both | DimAlignments.IgnorePadding,
                ZOffset      = -2,
            };

            border = new BorderBox(this)
            {
                ZOffset      = 1,
                Thickness    = 1f,
                DimAlignment = DimAlignments.Both,
            };

            resizeInput = new MouseInputElement(this)
            {
                ZOffset          = sbyte.MaxValue,
                Padding          = new Vector2(16f),
                DimAlignment     = DimAlignments.Both,
                CanIgnoreMasking = true
            };

            inputInner = new MouseInputElement(resizeInput)
            {
                DimAlignment = DimAlignments.Both | DimAlignments.IgnorePadding,
            };

            AllowResizing = true;
            CanDrag       = true;
            UseCursor     = true;
            ShareCursor   = false;
            IsMasking     = true;
            MinimumSize   = new Vector2(200f, 200f);

            LoseFocusCallback = LoseFocus;
            GetFocus();
        }
Exemple #4
0
            public EditorToggleButton(HudElementBase parent = null) : base(parent)
            {
                // This overlay will be drawn over the button when it's disabled
                disabledOverlay = new TexturedBox(this)
                {
                    Visible      = false,
                    DimAlignment = DimAlignments.Both | DimAlignments.IgnorePadding
                };

                Color          = TerminalFormatting.OuterSpace;
                HighlightColor = TerminalFormatting.Atomic;
                SelectColor    = new Color(58, 68, 77);
                DisabledColor  = new Color(0, 0, 0, 80);

                AutoResize = false;
                Enabled    = true;

                Size = new Vector2(42f, 30f);

                MouseInput.LeftClicked += LeftClick;
            }
Exemple #5
0
 public ListInputElement(IReadOnlyHudCollection <TElementContainer, TElement> entries, HudElementBase parent = null) : base(parent)
 {
     Entries        = entries;
     SelectionIndex = -1;
 }