Exemple #1
0
        public static Frame AddButton(Frame parent, SpriteFont font, int x, int y, int w, int h, string text, FrameAnchor anchor, Action action, Color bcol, bool visibility = true)
        {
            var button = new Frame(parent.Game, x, y, w, h, text, Color.White)
            {
                Anchor = anchor,
                TextAlignment = Alignment.MiddleCenter,
                PaddingLeft = 0,
                Font = font,
                Visible = visibility,
            };

            if (action != null)
            {
                button.Click += (s, e) =>
                {
                    action();
                };
            }
            button.StatusChanged += (s, e) =>
            {
                if (e.Status == FrameStatus.None) { button.BackColor = bcol; }
                if (e.Status == FrameStatus.Hovered) { button.BackColor = new Color(25, 71, 138, 255); }
                if (e.Status == FrameStatus.Pushed) { button.BackColor = new Color(99, 132, 181, 255); }
            };
            parent.Add(button);
            return button;
        }
Exemple #2
0
        public int AnchorPointY(Frame frame, FrameAnchor anchor)
        {
            if (frame == null)
            {
                return(0);
            }
            switch (anchor)
            {
            case FrameAnchor.TopMid:
            case FrameAnchor.TopLeft:
            case FrameAnchor.TopRight:
            {
                return(0);
            }

            case FrameAnchor.MidRight:
            case FrameAnchor.MidMid:
            case FrameAnchor.MidLeft:
            {
                return(frame.Height / 2);
            }

            case FrameAnchor.BottomLeft:
            case FrameAnchor.BottomRight:
            case FrameAnchor.BottomMid:
            {
                return(frame.Height);
            }
            }
            return(0);
        }
Exemple #3
0
        public void Draw(SpriteBatch b, Frame parent)
        {
            FrameAnchor temp            = anchor;
            FrameAnchor tempParent      = parentAnchor;
            int         internalYOffset = 0;//Change offsetting here if you want to do interesting layouts

            //layout is by default just vertical elements
            if (!CheckFrameOnScreen())
            {
                anchor       = Flip(temp);
                parentAnchor = Flip(temp);
                if (!CheckFrameOnScreen(true))
                {
                    //problem
                    anchor       = temp;
                    parentAnchor = tempParent;
                }
            }
            foreach (IFrameDrawable d in components)
            {
                d.Draw(b, GlobalX, GlobalY + internalYOffset, this);
                internalYOffset += d.SizeY;
            }
            foreach (Frame f in children)
            {
                f.Draw(b, this);
            }
            anchor       = temp;
            parentAnchor = tempParent;
        }
Exemple #4
0
 public Frame(int x, int y, Color color, FrameAnchor anchor = FrameAnchor.TopLeft, FrameAnchor parentAnchor = FrameAnchor.TopLeft, List <IFrameDrawable> components = null, Frame parent = null)
 {
     children = new List <Frame>();
     if (components == null)
     {
         components = new List <IFrameDrawable>();
     }
     localX            = x;
     localY            = y;
     this.color        = color;
     this.parent       = parent;
     this.anchor       = anchor;
     this.parentAnchor = parentAnchor;
 }
Exemple #5
0
 public Tooltip(int x, int y, Color color, FrameAnchor anchor = FrameAnchor.TopLeft, FrameAnchor parentAnchor = FrameAnchor.TopLeft, List <IFrameDrawable> components = null, Frame parent = null, string header = "", string text = "") : base(x, y, color, anchor, parentAnchor, components, parent)
 {
     this.header  = new ShadowText(text, Game1.dialogueFont, Game1.textColor);
     this.body    = new ShadowText(text, Game1.smallFont, Game1.textColor);
     this.content = new FrameContent(x, y, color, FrameAnchor.TopLeft, parentAnchor, parent: null, xPadding: 20, yPadding: 20)
     {
         components = new List <IFrameDrawable>()
         {
             this.header,
             this.body
         }
     };
     this.components = new List <IFrameDrawable>()
     {
         new TextureBox(color),
         content
     };
 }
Exemple #6
0
        public HoverText(int x, int y, Color color, FrameAnchor anchor = FrameAnchor.MidMid, List <IFrameDrawable> components = null) : base(x, y, color, anchor, FrameAnchor.TopLeft, components, null)
        {
            Text    = new ShadowText("", Game1.smallFont, Game1.textColor);
            Content = new FrameContent(x, y, color, FrameAnchor.TopLeft, FrameAnchor.TopLeft, xPadding: 15, yPadding: 15)
            {
                components = new List <IFrameDrawable>()
                {
                    Text
                }
            };
            Alpha = 100;
            Color col = new Color(new Vector4(color.ToVector3(), Alpha));

            this.components = new List <IFrameDrawable>()
            {
                new TextureBox(col), Content
            };
            this.edgeTolerance    = 1980;
            Content.edgeTolerance = 1980;
        }
Exemple #7
0
        /// <summary>
        /// Reflection of FrameAnchor about the Y axis.
        /// </summary>
        /// <param name="f">The FrameAnchor to reflect</param>
        /// <returns>The Reflection about the Y axis.</returns>
        public virtual FrameAnchor Flip(FrameAnchor f)
        {
            switch (f)
            {
            case FrameAnchor.BottomLeft:
            {
                return(FrameAnchor.BottomRight);
            }

            case FrameAnchor.MidLeft:
            {
                return(FrameAnchor.MidRight);
            }

            case FrameAnchor.TopLeft:
            {
                return(FrameAnchor.TopRight);
            }

            case FrameAnchor.BottomRight:
            {
                return(FrameAnchor.BottomLeft);
            }

            case FrameAnchor.MidRight:
            {
                return(FrameAnchor.MidLeft);
            }

            case FrameAnchor.TopRight:
            {
                return(FrameAnchor.TopLeft);
            }
            }
            return(f);
        }
 public override FrameAnchor Flip(FrameAnchor f)
 {
     return(f);
 }
 public TooltipContent(int x, int y, Color color, FrameAnchor anchor = FrameAnchor.TopLeft, FrameAnchor parentAnchor = FrameAnchor.TopLeft, List <IFrameDrawable> components = null, Frame parent = null, int xPadding = 0, int yPadding = 0) : base(x, y, color, anchor, parentAnchor, components, parent)
 {
     this.xPadding = xPadding;
     this.yPadding = yPadding;
 }