Exemplo n.º 1
0
        void update_layout()
        {
            FixedBoxModelElement frameBounds = BoxModel.PaddedBounds(this, Padding);
            Vector2f             topLeft     = BoxModel.GetBoxPosition(frameBounds, BoxPosition.TopLeft);
            float fZ = -0.01f * Width;

            if (ParametersList != null)
            {
                BoxModel.SetObjectPosition(ParametersList, BoxPosition.TopLeft, topLeft, fZ);
            }
        }
Exemplo n.º 2
0
        protected override void update_layout()
        {
            base.update_layout();

            FixedBoxModelElement contentBounds = BoxModel.PaddedContentBounds(this, Padding);
            Vector2f             topLeft       = BoxModel.GetBoxPosition(contentBounds, BoxPosition.TopLeft);

            float fZ = 0.05f * Width;

            Background.Shape = new HUDShape(HUDShapeType.Rectangle, this.VisibleListWidth, this.VisibleListHeight);
            BoxModel.SetObjectPosition(Background, BoxPosition.TopLeft, topLeft, fZ);
        }
Exemplo n.º 3
0
        protected virtual void update_layout()
        {
            FixedBoxModelElement contentBounds = BoxModel.PaddedContentBounds(this, Padding);
            Vector2f             topLeft       = BoxModel.GetBoxPosition(contentBounds, BoxPosition.TopLeft);
            Vector2f             insertPos     = topLeft;

            int   N             = ListItems.Count;
            int   visible       = 0;
            float spaceRequired = 0;

            for (int i = 0; i < N; ++i)
            {
                if (ListItems[i].IsVisible)
                {
                    visible++;
                    IBoxModelElement boxelem = ListItems[i] as IBoxModelElement;
                    spaceRequired += (Direction == ListDirection.Vertical) ? boxelem.Size2D.y : boxelem.Size2D.x;
                    if (i < N - 1)
                    {
                        spaceRequired += Spacing;
                    }
                }
            }
            if (Direction == ListDirection.Vertical)
            {
                VisibleListHeight = spaceRequired;
                VisibleListWidth  = Width;
            }
            else
            {
                VisibleListHeight = Height;
                VisibleListWidth  = spaceRequired;
            }


            BoxPosition sourcePos = BoxPosition.TopLeft;

            if (Direction == ListDirection.Horizontal)
            {
                if (VertAlign == VerticalAlignment.Center)
                {
                    sourcePos = BoxPosition.CenterLeft;
                    insertPos = BoxModel.GetBoxPosition(contentBounds, BoxPosition.CenterLeft);
                }
                else if (VertAlign == VerticalAlignment.Bottom)
                {
                    sourcePos = BoxPosition.BottomLeft;
                    insertPos = BoxModel.GetBoxPosition(contentBounds, BoxPosition.BottomLeft);
                }
                if (HorzAlign == HorizontalAlignment.Center)
                {
                    insertPos.x += (this.Size2D.x - spaceRequired) / 2;
                }
                else if (HorzAlign == HorizontalAlignment.Right)
                {
                    insertPos.x += this.Size2D.x - spaceRequired;
                }
            }
            else
            {
                if (HorzAlign == HorizontalAlignment.Center)
                {
                    sourcePos = BoxPosition.CenterTop;
                    insertPos = BoxModel.GetBoxPosition(contentBounds, BoxPosition.CenterTop);
                }
                else if (HorzAlign == HorizontalAlignment.Right)
                {
                    sourcePos = BoxPosition.TopRight;
                    insertPos = BoxModel.GetBoxPosition(contentBounds, BoxPosition.TopRight);
                }
            }


            for (int i = 0; i < N; ++i)
            {
                IBoxModelElement boxelem = ListItems[i] as IBoxModelElement;
                if (ListItems[i].IsVisible == false)
                {
                    BoxModel.SetObjectPosition(boxelem, BoxPosition.TopLeft, topLeft);
                    continue;
                }

                Vector2f usePos = insertPos + ItemNudge[i].xy;
                BoxModel.SetObjectPosition(boxelem, sourcePos, usePos, ItemNudge[i].z);

                if (Direction == ListDirection.Vertical)
                {
                    insertPos.y -= boxelem.Size2D.y + Spacing;
                }
                else
                {
                    insertPos.x += boxelem.Size2D.x + Spacing;
                }
            }

            is_layout_valid = true;
        }
Exemplo n.º 4
0
        protected virtual void update_layout()
        {
            int N = ListItems.Count;

            if (N == 0)
            {
                return;
            }

            // update initial visibility
            int total_visible = 0;

            for (int i = 0; i < ListItems.Count; ++i)
            {
                if (ListItems[i].IsVisible)
                {
                    InternalVisibility[i] = VisibleState.WasVisible;
                    total_visible++;
                }
                else
                {
                    InternalVisibility[i] = VisibleState.WasHidden;
                }
            }

            // this is messy. does multiple things:
            //  - computes visible dimensions / required space
            //  - in limit-to-bounds mode, figures out how many items are visible,
            //     and hides items that should not be visible
            //  - ??
            int   Nstop          = -1;
            int   actual_visible = 0;
            float spaceRequired  = 0;
            float otherDimMax    = 0;
            float availableSpace = (Direction == ListDirection.Vertical) ? Height : Width;
            int   li             = 0;

            if (size_mode == SizeModes.FixedSize_LimitItemsToBounds)
            {
                // skip first scroll_index items
                int items_hidden = 0;
                while (li < N && items_hidden < scroll_index)
                {
                    if (InternalVisibility[li] == VisibleState.WasVisible)
                    {
                        InternalVisibility[li]  = VisibleState.WasVisible_SetHidden;
                        ListItems[li].IsVisible = false;
                        items_hidden++;
                    }
                    li++;
                }
            }
            while (li < N)
            {
                if (InternalVisibility[li] == VisibleState.WasHidden)
                {
                    li++;
                    continue;
                }
                if (Nstop >= 0)
                {
                    InternalVisibility[li]  = VisibleState.WasVisible_SetHidden;
                    ListItems[li].IsVisible = false;
                    li++;
                    continue;
                }

                actual_visible++;
                IBoxModelElement boxelem  = ListItems[li] as IBoxModelElement;
                Vector2f         elemSize = boxelem.Size2D;
                if (Direction == ListDirection.Vertical)
                {
                    spaceRequired += elemSize.y;
                    otherDimMax    = Math.Max(otherDimMax, elemSize.x);
                }
                else
                {
                    spaceRequired += elemSize.x;
                    otherDimMax    = Math.Max(otherDimMax, elemSize.y);
                }
                if (size_mode == SizeModes.FixedSize_LimitItemsToBounds && spaceRequired > availableSpace)
                {
                    InternalVisibility[li]  = VisibleState.WasVisible_SetHidden;
                    ListItems[li].IsVisible = false;
                    Nstop         = li;
                    spaceRequired = availableSpace;
                    actual_visible--;
                }
                else if (li < N - 1)
                {
                    spaceRequired += Spacing;
                }
                ++li;
            }
            if (Direction == ListDirection.Vertical)
            {
                VisibleListHeight = spaceRequired;
                VisibleListWidth  = otherDimMax;
            }
            else
            {
                VisibleListHeight = otherDimMax;
                VisibleListWidth  = spaceRequired;
            }

            // in auto-size mode, we can auto-size now that we know dimensions
            if (SizeMode == SizeModes.AutoSizeToFit)
            {
                float auto_width  = VisibleListWidth + 2 * Padding;
                float auto_height = VisibleListHeight + 2 * Padding;
                if (Math.Abs(Width - auto_width) > 0.001f || Math.Abs(Height - auto_height) > 0.001f)
                {
                    Width  = VisibleListWidth + 2 * Padding;
                    Height = VisibleListHeight + 2 * Padding;
                }
            }

            // track number of items that fit in bounds
            scroll_items = 0;
            if (size_mode == SizeModes.FixedSize_LimitItemsToBounds)
            {
                scroll_items = total_visible - actual_visible;
            }

            // now do actual layout

            FixedBoxModelElement contentBounds = BoxModel.PaddedContentBounds(this, Padding);
            Vector2f             topLeft       = BoxModel.GetBoxPosition(contentBounds, BoxPosition.TopLeft);
            Vector2f             insertPos     = topLeft;

            // compute insertion position based on alignment settings
            BoxPosition sourcePos = BoxPosition.TopLeft;

            if (Direction == ListDirection.Horizontal)
            {
                if (VertAlign == VerticalAlignment.Center)
                {
                    sourcePos = BoxPosition.CenterLeft;
                    insertPos = BoxModel.GetBoxPosition(contentBounds, BoxPosition.CenterLeft);
                }
                else if (VertAlign == VerticalAlignment.Bottom)
                {
                    sourcePos = BoxPosition.BottomLeft;
                    insertPos = BoxModel.GetBoxPosition(contentBounds, BoxPosition.BottomLeft);
                }
                if (HorzAlign == HorizontalAlignment.Center)
                {
                    insertPos.x += (this.Size2D.x - spaceRequired) / 2;
                }
                else if (HorzAlign == HorizontalAlignment.Right)
                {
                    insertPos.x += this.Size2D.x - spaceRequired;
                }
            }
            else
            {
                if (HorzAlign == HorizontalAlignment.Center)
                {
                    sourcePos = BoxPosition.CenterTop;
                    insertPos = BoxModel.GetBoxPosition(contentBounds, BoxPosition.CenterTop);
                }
                else if (HorzAlign == HorizontalAlignment.Right)
                {
                    sourcePos = BoxPosition.TopRight;
                    insertPos = BoxModel.GetBoxPosition(contentBounds, BoxPosition.TopRight);
                }
            }

            // position visible elements
            for (int i = 0; i < N; ++i)
            {
                IBoxModelElement boxelem = ListItems[i] as IBoxModelElement;
                if (ListItems[i].IsVisible == false)
                {
                    BoxModel.SetObjectPosition(boxelem, BoxPosition.TopLeft, topLeft);
                    continue;
                }
                Vector2f usePos = insertPos + ItemNudge[i].xy;
                BoxModel.SetObjectPosition(boxelem, sourcePos, usePos, ItemNudge[i].z);

                if (Direction == ListDirection.Vertical)
                {
                    insertPos.y -= boxelem.Size2D.y + Spacing;
                }
                else
                {
                    insertPos.x += boxelem.Size2D.x + Spacing;
                }
            }

            is_layout_valid = true;
        }