コード例 #1
0
        protected override Vector3f layout_item(SceneUIElement e)
        {
            AxisAlignedBox2f box = Container.Bounds2D;

            Vector3f vNewPos3 = Vector3f.Zero;   // 2.5d center coordinate

            IBoxModelElement boxElem = e as IBoxModelElement;

            if (PinConstraints.ContainsKey(e))
            {
                Pin pin = PinConstraints[e];

                Vector2f SourcePos = pin.FromF();
                Vector2f PinToPos  = pin.ToF();
                vNewPos3 = BoxModel.SetObjectPosition(boxElem, SourcePos, PinToPos, pin.fZ);
            }
            else if (boxElem != null)
            {
                vNewPos3 = BoxModel.SetObjectPosition(boxElem, BoxPosition.Center, box.Center, 0);
            }
            else
            {
                // do nothing?
            }

            return(vNewPos3);
        }
コード例 #2
0
        void update_layout()
        {
            AxisAlignedBox2f contentBounds = BoxModel.PaddedContentBounds(this, Padding);
            Vector2f         insertPos     = contentBounds.TopLeft;

            int N = ListItems.Count;

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

                BoxModel.SetObjectPosition(boxelem, BoxPosition.TopLeft, insertPos);

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

            is_layout_valid = true;
        }
コード例 #3
0
ファイル: HUDLayout.cs プロジェクト: ly774508966/frame3Sharp
        public override void RecomputeLayout()
        {
            AxisAlignedBox2f box = container.Bounds2D;

            foreach (SceneUIElement e in LayoutItems)
            {
                IBoxModelElement boxElem = e as IBoxModelElement;
                if (PinConstraints.ContainsKey(e))
                {
                    Pin pin = PinConstraints[e];

                    Vector2f SourcePos = pin.FromF();
                    Vector2f PinToPos  = pin.ToF();
                    BoxModel.SetObjectPosition(boxElem, SourcePos, PinToPos, pin.fZ);
                }
                else if (boxElem != null)
                {
                    BoxModel.SetObjectPosition(boxElem, BoxPosition.Center, box.Center, 0);
                }
                else
                {
                    // do nothing?
                }
            }
        }
コード例 #4
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);
            }
        }
コード例 #5
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);
        }
コード例 #6
0
        protected override void layout_item(SceneUIElement e)
        {
            AxisAlignedBox2f box = Container.Bounds2D;

            IBoxModelElement boxElem = e as IBoxModelElement;

            if (PinConstraints.ContainsKey(e))
            {
                Pin pin = PinConstraints[e];

                Vector2f SourcePos = pin.FromF();
                Vector2f PinToPos  = pin.ToF();
                BoxModel.SetObjectPosition(boxElem, SourcePos, PinToPos, pin.fZ);
            }
            else if (boxElem != null)
            {
                BoxModel.SetObjectPosition(boxElem, BoxPosition.Center, box.Center, 0);
            }
            else
            {
                // do nothing?
            }
        }
コード例 #7
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;
        }
コード例 #8
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;
        }