Ejemplo n.º 1
0
        private void InitializeDrawElements(GuiSystem guiSystem)
        {
            var itemDescriptor = guiSystem.GetSkinItemDescriptor <ButtonSkinItemDescriptor>();

            _normalSprite = new NinePatchSprite(itemDescriptor.SkinTexture, itemDescriptor.NormalRectangle, itemDescriptor.ButtonBorder);
            _hoverSprite  = new NinePatchSprite(itemDescriptor.SkinTexture, itemDescriptor.HoverRectangle, itemDescriptor.ButtonBorder);
        }
Ejemplo n.º 2
0
        public NinePatchDrawable(NinePatchSprite sprite)
        {
            _sprite  = sprite;
            MinWidth = _sprite.NinePatchRects[MIDDLE_LEFT].Width + _sprite.NinePatchRects[MIDDLE_CENTER].Width +
                       _sprite.NinePatchRects[MIDDLE_RIGHT].Width;
            MinHeight = _sprite.NinePatchRects[TOP_CENTER].Height +
                        _sprite.NinePatchRects[MIDDLE_CENTER].Height +
                        _sprite.NinePatchRects[BOTTOM_CENTER].Height;

            // by default, if padding isn't given, we will pad the content by the nine patch margins
            if (_sprite.HasPadding)
            {
                LeftWidth    = _sprite.PadLeft;
                RightWidth   = _sprite.PadRight;
                TopHeight    = _sprite.PadTop;
                BottomHeight = _sprite.PadBottom;
            }
            else
            {
                LeftWidth    = _sprite.Left;
                RightWidth   = _sprite.Right;
                TopHeight    = _sprite.Top;
                BottomHeight = _sprite.Bottom;
            }
        }
Ejemplo n.º 3
0
        public override void Initialize(IResolver resolver)
        {
            var fontDef = new FontDefinition("DefaultFont", 12);

            this.lbl = new Label(fontDef)
            {
                FontSize  = 12,
                Alignment = TextAlignment.Left,
                Tint      = Color.White,
                Text      = this.Text
            };
            this.Add(this.lbl);

            var inst = new NinePatchInstruction
            {
                TopLeft      = new Rectangle(0, 0, 12, 12),
                TopCenter    = new Rectangle(12, 0, 8, 12),
                TopRight     = new Rectangle(20, 0, 12, 12),
                MiddleLeft   = new Rectangle(0, 12, 12, 8),
                MiddleCenter = new Rectangle(12, 12, 16, 16),
                MiddleRight  = new Rectangle(20, 12, 12, 8),
                BottomLeft   = new Rectangle(0, 20, 12, 12),
                BottomCenter = new Rectangle(12, 20, 8, 12),
                BottomRight  = new Rectangle(20, 20, 12, 12),
            };

            this.patch = new NinePatchSprite(new TextureAssetInstruction {
                Asset = "ninepatch"
            }, inst);
            this.lbl.Components.Add(this.patch);

            this.Opacity = this.Opacity;

            base.Initialize(resolver);
        }
Ejemplo n.º 4
0
        private void InitializeDrawElements(GuiSystem guiSystem)
        {
            var itemDescriptor = guiSystem.GetSkinItemDescriptor <FrameSkinItemDescriptor>();

            _headerFont    = itemDescriptor.BigFont;
            _contentBorder = new NinePatchSprite(itemDescriptor.SkinTexture, itemDescriptor.SourceRectangle, itemDescriptor.FrameBorder);
            _headerBorder  = new NinePatchSprite(itemDescriptor.SkinTexture, itemDescriptor.SourceRectangle, itemDescriptor.FrameBorder);
        }
Ejemplo n.º 5
0
        public Button2(Game2D game, string text, Rectangle rectangle, Action onClick)
        {
            _onClick = onClick;
            Text     = text;
            Bounds   = rectangle;

            _currentSprite   = new NinePatchSprite(game.Content.Load <Texture2D>("textures/selector"), new Rectangle(0, 0, 32, 32), 15, 15);
            FocusedAnimation = new UiDiscreteAnimation <NinePatchSprite>(0.5f, new []
            {
                _currentSprite,
                new NinePatchSprite(game.Content.Load <Texture2D>("textures/selector"), new Rectangle(32, 0, 32, 32), 15, 15)
            }, c => _currentSprite = c, true);
        }
Ejemplo n.º 6
0
        private void InitializeDrawElements()
        {
            var itemDescriptor = GuiSystem.GetSkinItemDescriptor <TextBoxSkinItemDescriptor>();

            _border = new NinePatchSprite(itemDescriptor.SkinTexture, itemDescriptor.NormalRectangle, itemDescriptor.Border);

            _spriteText = new SpriteText(itemDescriptor.NormalFont);
            _spriteText.HorizontalAlignment = HorizontalAlignment.Left;

            _cursorAnimatorTimer = new ActionTimer(OnCursorAnimateTick, 0.5f, true);
            _cursorAnimatorTimer.Start();

            _inputController = new StringInputController(InputType.AlphaNumeric);
        }
Ejemplo n.º 7
0
 public NinePatchImage(NinePatchSprite sprite, Rectangle bounds)
 {
     _sprite = sprite;
     Bounds  = bounds;
 }
Ejemplo n.º 8
0
 public Border(Game2D game) : base(game)
 {
     _ninePatchTexture = Game.Content.Load <Texture2D>("Textures/border");
     _ninePatch        = new NinePatchSprite(_ninePatchTexture, BorderSize);
 }