Exemplo n.º 1
0
        public override void OnMouseUp(UiContext context, RectangleF parentRectangle)
        {
            var myPos       = context.AnchorPosition(parentRectangle, Anchor, X, Y, Width, Height);
            var myRectangle = new RectangleF(myPos.X, myPos.Y, Width, Height);

            Scrollbar.OnMouseUp(context, myRectangle);
        }
Exemplo n.º 2
0
        public override void OnMouseClick(UiContext context, RectangleF parentRectangle)
        {
            var myPos       = context.AnchorPosition(parentRectangle, Anchor, X, Y, Width, Height);
            var myRectangle = new RectangleF(myPos.X, myPos.Y, Width, Height);

            if (_lastScroll > 0 || AlwaysShowScrollbar)
            {
                Scrollbar.OnMouseUp(context, myRectangle);
            }
            for (int i = childOffset; i < childOffset + MaxDisplayChildren() && i < Children.Count; i++)
            {
                Children[i].OnMouseClick(context, myRectangle);
                if (i >= Children.Count)
                {
                    break;
                }
                if (Children[i].DoSelect)
                {
                    UnselectAll();
                    Children[i].Selected = true;
                    selectedIndex        = i;
                    SelectedIndexChanged?.Invoke();
                }
            }
        }
Exemplo n.º 3
0
        RectangleF GetMyRectangle(UiContext context, RectangleF parentRectangle)
        {
            var myPos       = context.AnchorPosition(parentRectangle, Anchor, X, Y, Width, Height);
            var myRectangle = new RectangleF(myPos.X, myPos.Y, Width, Height);

            return(myRectangle);
        }
        public override void Render(UiContext context, RectangleF parentRectangle)
        {
            if (!Visible)
            {
                return;
            }
            var myPos       = context.AnchorPosition(parentRectangle, Anchor, X, Y, Width, Height);
            var myRectangle = new RectangleF(myPos.X, myPos.Y, Width, Height);

            if (Fill)
            {
                myRectangle = parentRectangle;
            }
            if (Background != null)
            {
                Background.Draw(context, myRectangle);
            }
            if (!loaded)
            {
                texture = context.GetTextureFile(Path);
                loaded  = true;
            }
            if (texture != null)
            {
                context.Mode2D();
                var color = (Tint ?? InterfaceColor.White).Color;
                context.Renderer2D.DrawImageStretched(texture, context.PointsToPixels(myRectangle), color, Flip);
            }
        }
Exemplo n.º 5
0
        RectangleF GetMyRectangle(UiContext context, RectangleF parentRectangle)
        {
            var myPos = context.AnchorPosition(parentRectangle, Anchor, X, Y, Width, Height);

            Update(context, myPos);
            myPos = AnimatedPosition(myPos);
            var myRect = new RectangleF(myPos.X, myPos.Y, Width, Height);

            //layout children
            float x = 0;

            if (ItemA != null)
            {
                ItemA.Height = Height;
                ItemA.X      = 0;
                ItemA.Y      = 0;
                x            = ItemA.Width;
                if (ItemB == null)
                {
                    ItemA.Width = Width;
                }
                rectangleA = new RectangleF(myPos.X, myPos.Y, ItemA.Width, Height);
            }

            x += ItemMarginX;
            if (ItemB != null)
            {
                ItemB.X      = x;
                ItemB.Y      = 0;
                ItemB.Width  = Width - x;
                ItemB.Height = Height;
                rectangleB   = new RectangleF(myPos.X + x, myPos.Y, ItemB.Width, ItemB.Height);
            }
            return(myRect);
        }
Exemplo n.º 6
0
        void Layout(UiContext context, RectangleF parent, out RectangleF myRectangle, out RectangleF track)
        {
            var height = Cascade(Style?.Height, null, Height);
            var myPos  = context.AnchorPosition(parent, Anchor, X, Y, Width, height);

            myRectangle = new RectangleF(myPos.X, myPos.Y, Width, height);
            var heightAdjust = (Style?.ButtonMarginY ?? 0) * 2;

            leftbutton.Height  = myRectangle.Height - heightAdjust;
            rightbutton.Height = myRectangle.Height - heightAdjust;
            track        = myRectangle;
            track.X     += leftbutton.GetDimensions().X;
            track.Width -= (leftbutton.GetDimensions().X + rightbutton.GetDimensions().X);
            if (Style != null)
            {
                track.X      += Style.TrackMarginX;
                track.Width  -= Style.TrackMarginX * 2;
                track.Y      += Style.TrackMarginY;
                track.Height -= Style.TrackMarginY * 2;
            }
            thumb.Width  = track.Width * ThumbSize;
            thumb.X      = ScrollOffset * (track.Width - thumb.Width);
            thumb.Height = track.Height;
            if (thumb.Dragging && (track.Width - thumb.Width) >= 0.01f)
            {
                var newX = MathHelper.Clamp(thumb.DragOffset.X + dragXStart, 0, track.Width - thumb.Width);
                ScrollOffset = newX / (track.Width - thumb.Width);
            }
        }
Exemplo n.º 7
0
        public override void Render(UiContext context, RectangleF parentRectangle)
        {
            if (!Visible)
            {
                return;
            }
            var myPos       = context.AnchorPosition(parentRectangle, Anchor, X, Y, Width, Height);
            var myRectangle = new RectangleF(myPos.X, myPos.Y, Width, Height);

            if (Fill)
            {
                myRectangle = parentRectangle;
            }
            if (Background != null)
            {
                Background.Draw(context, myRectangle);
            }
            if (!string.IsNullOrEmpty(Name) && (!loaded || texture == null || texture.IsDisposed))
            {
                texture = context.Data.ResourceManager.FindTexture(Name) as Texture2D;
                loaded  = true;
            }
            if (texture != null)
            {
                var color = (Tint ?? InterfaceColor.White).Color;
                context.RenderContext.Renderer2D.DrawImageStretched(texture, context.PointsToPixels(myRectangle), color, Flip);
            }
        }
Exemplo n.º 8
0
        protected virtual RectangleF GetMyRectangle(UiContext context, RectangleF parentRectangle)
        {
            var myPos = context.AnchorPosition(parentRectangle, Anchor, X, Y, Width, Height);

            Update(context, myPos);
            myPos = AnimatedPosition(myPos);
            var myRect = new RectangleF(myPos.X, myPos.Y, Width, Height);

            return(myRect);
        }
Exemplo n.º 9
0
        public override void OnMouseWheel(UiContext context, RectangleF parentRectangle, float delta)
        {
            var myPos       = context.AnchorPosition(parentRectangle, Anchor, X, Y, Width, Height);
            var myRectangle = new RectangleF(myPos.X, myPos.Y, Width, Height);

            if (myRectangle.Contains(context.MouseX, context.MouseY))
            {
                Scrollbar.OnMouseWheel(delta);
            }
        }
Exemplo n.º 10
0
        public override void Render(UiContext context, RectangleF parentRectangle)
        {
            var myPos       = context.AnchorPosition(parentRectangle, Anchor, X, Y, Width, Height);
            var myRectangle = new RectangleF(myPos.X, myPos.Y, Width, Height);

            foreach (var child in Children)
            {
                child.Render(context, myRectangle);
            }
            Scrollbar.Render(context, myRectangle);
        }
Exemplo n.º 11
0
        RectangleF GetMyRectangle(UiContext context, RectangleF parentRectangle)
        {
            var width  = Cascade(style?.Width, null, Width);
            var height = Cascade(style?.Height, null, Height);
            var myPos  = context.AnchorPosition(parentRectangle, Anchor, X, Y, width, height);

            Update(context, myPos);
            myPos = AnimatedPosition(myPos);
            var myRect = new RectangleF(myPos.X, myPos.Y, width, height);

            return(myRect);
        }
Exemplo n.º 12
0
        public override void OnMouseUp(UiContext context, RectangleF parentRectangle)
        {
            var myPos       = context.AnchorPosition(parentRectangle, Anchor, X, Y, Width, Height);
            var myRectangle = new RectangleF(myPos.X, myPos.Y, Width, Height);

            if (_lastScroll > 0 || AlwaysShowScrollbar)
            {
                Scrollbar.OnMouseUp(context, myRectangle);
            }
            for (int i = childOffset; i < childOffset + MaxDisplayChildren() && i < Children.Count; i++)
            {
                Children[i].OnMouseUp(context, myRectangle);
            }
        }
Exemplo n.º 13
0
        public override void Render(UiContext context, RectangleF parentRectangle)
        {
            if (!Visible)
            {
                return;
            }
            var myPos       = context.AnchorPosition(parentRectangle, Anchor, X, Y, Width, Height);
            var myRectangle = new RectangleF(myPos.X, myPos.Y, Width, Height);

            Background?.Draw(context, myRectangle);
            var fillRect = myRectangle;

            fillRect.Width *= PercentFilled;
            Fill?.DrawWithClip(context, myRectangle, fillRect);
            Border?.Draw(context, myRectangle);
        }
Exemplo n.º 14
0
        public override void Render(UiContext context, RectangleF parentRectangle)
        {
            var myPos       = context.AnchorPosition(parentRectangle, Anchor, X, Y, Width, Height);
            var myRectangle = new RectangleF(myPos.X, myPos.Y, Width, Height);

            Background?.Draw(context, myRectangle);
            //Update scrolling
            int scrollCount = ScrollCount();

            if (scrollCount <= 0)
            {
                childOffset            = 0;
                Scrollbar.ScrollOffset = 0;
                Scrollbar.Tick         = 0;
                Scrollbar.ThumbSize    = 1;
                _lastScroll            = 0;
            }
            else if (scrollCount != _lastScroll)
            {
                _lastScroll            = scrollCount;
                Scrollbar.ThumbSize    = 1.0f - (Math.Min(scrollCount, 9) * 0.1f);
                Scrollbar.Tick         = 1.0f / scrollCount;
                Scrollbar.ScrollOffset = childOffset / (float)scrollCount;
            }
            else
            {
                childOffset = (int)(Scrollbar.ScrollOffset * scrollCount);
            }

            for (int i = childOffset; i < childOffset + MaxDisplayChildren() && i < Children.Count; i++)
            {
                var child = Children[i];
                child.Height = ItemHeight;
                child.Width  = Math.Max(Width - ((scrollCount > 0 || AlwaysShowScrollbar) ? Scrollbar.Style.Width + 2 : 0), 3);
                child.X      = 0;
                child.Y      = ItemHeight * (i - childOffset);
                child.Render(context, myRectangle);
            }
            if (scrollCount > 0 || AlwaysShowScrollbar)
            {
                Scrollbar.Render(context, myRectangle);
            }
            Border?.Draw(context, myRectangle);
        }
        public override void Render(UiContext context, RectangleF parentRectangle)
        {
            if (!Visible)
            {
                return;
            }
            var myPos       = context.AnchorPosition(parentRectangle, Anchor, X, Y, Width, Height);
            var myRectangle = new RectangleF(myPos.X, myPos.Y, Width, Height);

            if (Background != null)
            {
                foreach (var elem in Background.Elements)
                {
                    elem.Render(context, myRectangle);
                }
            }

            if (!string.IsNullOrEmpty(Text))
            {
                DrawText(context, myRectangle, TextSize, Font, TextColor, TextShadow, HorizontalAlignment, VerticalAlignment, Clip,
                         Text);
            }
        }