Exemple #1
0
        public UIScrollWindow()
        {
            this.AutoSize = false;

            ScrollBar               = new UIScrollBarWithArrows();
            ScrollBar.DrawBounds    = false;
            ScrollBar.ValueChanged += scrollBar_ValueChanged;

            ScrollPanel                  = new UIScrollPanel();
            ScrollPanel.AutoSize         = false;
            ScrollPanel.DrawBounds       = false;
            ScrollPanel.AbsorbPointer    = false;
            ScrollPanel.ContentScrolled += scrollPanel_ContentScrolled;

            ScrollBar.AddConstraint(Edge.Vertical | Edge.Right, this, Edge.Vertical | Edge.Right);
            ScrollPanel.AddConstraint(Edge.Vertical | Edge.Left, this, Edge.Vertical | Edge.Left);
            ScrollPanel.AddConstraint(Edge.Right, ScrollBar, Edge.Left);

            base.AddChild(ScrollBar);
            base.AddChild(ScrollPanel);
        }
Exemple #2
0
        public UIScrollWindow(ScrollBarMode mode = ScrollBarMode.Vertical)
        {
            this.mode  = mode;
            AutoSize   = false;
            DebugColor = Color.White;

            ScrollPanel                      = new UIScrollPanel();
            ScrollPanel.AutoSize             = true;
            ScrollPanel.DrawBounds           = false;
            ScrollPanel.AbsorbPointer        = false;
            ScrollPanel.AllowInsideScrolling = false;
            ScrollPanel.ContentScrolled     += scrollPanel_ContentScrolled;

            if (mode == ScrollBarMode.Both)
            {
                fillerPanel          = new UIPanel();
                fillerPanel.Color    = new Color(240, 240, 240);
                fillerPanel.AutoSize = false;
                fillerPanel.Size     = new Vector2(16, 16);
                fillerPanel.Alpha    = 1f;
                fillerPanel.AddConstraint(Edge.BottomRight, this, Edge.BottomRight);
                base.AddChild(fillerPanel);
            }

            if (mode.ContainsFlag(ScrollBarMode.Vertical))
            {
                VerticalScrollBar = new UIScrollBar(UIScrollBar.ScrollBarOrientation.Vertical);
                VerticalScrollBar.ValueChanged += scrollBar_ValueChanged;
                VerticalScrollBar.Width         = 16f;
                VerticalScrollBar.AddConstraint(Edge.TopRight, this, Edge.TopRight);

                if (fillerPanel != null)
                {
                    VerticalScrollBar.AddConstraint(Edge.Bottom, fillerPanel, Edge.Top);
                }
                else
                {
                    VerticalScrollBar.AddConstraint(Edge.Bottom, this, Edge.Bottom, mode.ContainsFlag(ScrollBarMode.Horizontal) ? VerticalScrollBar.Width : 0);
                }
                ScrollPanel.AddConstraint(Edge.Left, this, Edge.Left, 1);
                ScrollPanel.AddConstraint(Edge.Right, VerticalScrollBar, Edge.Left, -1);
                base.AddChild(VerticalScrollBar);
            }
            else
            {
                ScrollPanel.AddConstraint(Edge.Left, this, Edge.Left, 1);
                ScrollPanel.AddConstraint(Edge.Right, this, Edge.Right, -1);
            }

            if (mode.ContainsFlag(ScrollBarMode.Horizontal))
            {
                HorizontalScrollBar = new UIScrollBar(UIScrollBar.ScrollBarOrientation.Horizontal);
                HorizontalScrollBar.ValueChanged += scrollBar_ValueChanged;
                HorizontalScrollBar.Height        = 16f;
                HorizontalScrollBar.AddConstraint(Edge.BottomLeft, this, Edge.BottomLeft);

                if (fillerPanel != null)
                {
                    HorizontalScrollBar.AddConstraint(Edge.Right, fillerPanel, Edge.Left);
                }
                else
                {
                    HorizontalScrollBar.AddConstraint(Edge.Right, this, Edge.Right, mode.ContainsFlag(ScrollBarMode.Vertical) ? HorizontalScrollBar.Height : 0);
                }

                ScrollPanel.AddConstraint(Edge.Top, this, Edge.Top, 1);
                ScrollPanel.AddConstraint(Edge.Bottom, HorizontalScrollBar, Edge.Top, -1);
                base.AddChild(HorizontalScrollBar);
            }
            else
            {
                ScrollPanel.AddConstraint(Edge.Top, this, Edge.Top, 1);
                ScrollPanel.AddConstraint(Edge.Bottom, this, Edge.Bottom, -1);
            }



            base.AddChild(ScrollPanel);
        }