Beispiel #1
0
        public static int GetOffsetY(ComponentInfo info, Cursor cursor, ComponentReference previous)
        {
            int y = 0;

            if (info.OffsetHandling == OffsetHandling.Additive)
            {
                y = cursor.Y;
            }

            if (info.OffsetY != 0)
            {
                y += info.OffsetY;
            }

            if (info.PreviousOffsetInherit.HasFlag(SizeInherit.Height))
            {
                y += previous.Height;
            }

            if (info.PreviousOffsetInherit.HasFlag(SizeInherit.PaddingHeight))
            {
                y += previous.PaddingHeight;
            }

            return(y);
        }
Beispiel #2
0
        public static int GetOffsetX(ComponentInfo info, Cursor cursor, ComponentReference previous)
        {
            int x = 0;

            if (info.OffsetHandling == OffsetHandling.Additive)
            {
                x = cursor.X;
            }

            if (info.OffsetX != 0)
            {
                x += info.OffsetX;
            }

            if (info.PreviousOffsetInherit.HasFlag(SizeInherit.Width))
            {
                x += previous.Width;
            }

            if (info.PreviousOffsetInherit.HasFlag(SizeInherit.PaddingWidth))
            {
                x += previous.PaddingWidth;
            }

            return(x);
        }
Beispiel #3
0
        public void Draw(Drawable card, ref Cursor cursor, ref ComponentReference previous)
        {
            // Get the layer offsets
            int offsetX = CardInfo.GetOffsetX(Info, cursor, previous);
            int offsetY = CardInfo.GetOffsetY(Info, cursor, previous);

            // Get the image source
            var sheet  = new Sheet(ReferencePath, CropWidth, CropHeight);
            var sprite = sheet.GetSprite(ReferenceIndex);
            var icon   = ImageHelper.SetColorMap(sprite, GammaPalette.Default, Fill.Palette);

            // Build the new layer
            var layer = new BitmapLayer(icon)
            {
                Offset = new Coordinate(offsetX, offsetY)
            };

            layer.Properties.Padding = Info.Padding;

            // Try to offset the cursor
            if (Info.CursorOffset.HasFlag(CursorOffset.X))
            {
                cursor.X += layer.Source.Width + layer.Properties.Padding.Width;
            }

            if (Info.CursorOffset.HasFlag(CursorOffset.Y))
            {
                cursor.Y += layer.Source.Height + layer.Properties.Padding.Height;
            }

            // Finally, update the component reference
            previous.Update(layer.Source.Width, layer.Source.Height, layer.Properties.Padding);

            // Add the layer to the card
            card.AddLayer(layer);
        }
Beispiel #4
0
 public void Draw(Drawable card, ref Cursor cursor, ref ComponentReference previous)
 {
 }