Beispiel #1
0
 public DecoratedBox(
     Key key = null,
     Decoration decoration       = null,
     DecorationPosition position = DecorationPosition.background,
     Widget child = null
     ) : base(key, child)
 {
     D.assert(decoration != null);
     this.position   = position;
     this.decoration = decoration;
 }
Beispiel #2
0
 public DecoratedBoxTransition(
     Key key = null,
     Animation <Decoration> decoration = null,
     DecorationPosition position       = DecorationPosition.background,
     Widget child = null
     ) : base(key: key, listenable: decoration)
 {
     D.assert(decoration != null);
     D.assert(child != null);
     this.decoration = decoration;
     this.position   = position;
     this.child      = child;
 }
Beispiel #3
0
        public static int2 CreateMargin(this DecorationPosition pos, int2 margin)
        {
            switch (pos)
            {
            case DecorationPosition.TopLeft: return(margin);

            case DecorationPosition.TopRight: return(new int2(-margin.X, margin.Y));

            case DecorationPosition.BottomLeft: return(new int2(margin.X, -margin.Y));

            case DecorationPosition.BottomRight: return(-margin);

            case DecorationPosition.Top: return(new int2(0, margin.Y));

            default: return(int2.Zero);
            }
        }
        protected override int2 GetDecorationPosition(Actor self, WorldRenderer wr, DecorationPosition pos)
        {
            var bounds = selectable.DecorationBounds(self, wr);

            switch (pos)
            {
            case DecorationPosition.TopLeft: return(bounds.Vertices[1]);

            case DecorationPosition.TopRight: return(bounds.Vertices[5]);

            case DecorationPosition.BottomLeft: return(bounds.Vertices[2]);

            case DecorationPosition.BottomRight: return(bounds.Vertices[4]);

            case DecorationPosition.Top: return(new int2((bounds.Vertices[1].X + bounds.Vertices[5].X) / 2, bounds.Vertices[1].Y));

            default: return(bounds.BoundingRect.TopLeft + new int2(bounds.BoundingRect.Size.Width / 2, bounds.BoundingRect.Size.Height / 2));
            }
        }
Beispiel #5
0
        protected override int2 GetDecorationPosition(Actor self, WorldRenderer wr, DecorationPosition pos)
        {
            var bounds = interactable.DecorationBounds(self, wr);

            switch (pos)
            {
            case DecorationPosition.TopLeft: return(bounds.TopLeft);

            case DecorationPosition.TopRight: return(bounds.TopRight);

            case DecorationPosition.BottomLeft: return(bounds.BottomLeft);

            case DecorationPosition.BottomRight: return(bounds.BottomRight);

            case DecorationPosition.Top: return(new int2(bounds.Left + bounds.Size.Width / 2, bounds.Top));

            default: return(bounds.TopLeft + new int2(bounds.Size.Width / 2, bounds.Size.Height / 2));
            }
        }
Beispiel #6
0
 protected abstract int2 GetDecorationPosition(Actor self, WorldRenderer wr, DecorationPosition pos);