Inheritance: IDisposable
Exemplo n.º 1
0
        public TextBounds Draw(GdxSpriteBatch spriteBatch, CharSequence str, float x, float y)
        {
            _cache.Clear();
            TextBounds bounds = _cache.AddText(str, x, y, 0, str.Length);

            _cache.Draw(spriteBatch);
            return(bounds);
        }
Exemplo n.º 2
0
        public TextBounds DrawMultiLine(GdxSpriteBatch spriteBatch, CharSequence str, float x, float y, float alignmentWidth, HAlignment alignment)
        {
            _cache.Clear();
            TextBounds bounds = _cache.AddMultiLineText(str, x, y, alignmentWidth, alignment);

            _cache.Draw(spriteBatch);
            return(bounds);
        }
Exemplo n.º 3
0
        public TextBounds Draw(GdxSpriteBatch spriteBatch, CharSequence str, float x, float y, int start, int end)
        {
            _cache.Clear();
            TextBounds bounds = _cache.AddText(str, x, y, start, end);

            _cache.Draw(spriteBatch);
            return(bounds);
        }
Exemplo n.º 4
0
        public TextBounds DrawWrapped(GdxSpriteBatch spriteBatch, CharSequence str, float x, float y, float wrapWidth, HAlignment alignment)
        {
            _cache.Clear();
            TextBounds bounds = _cache.AddWrappedText(str, x, y, wrapWidth, alignment);

            _cache.Draw(spriteBatch);
            return(bounds);
        }
Exemplo n.º 5
0
        protected override void InitializeCore()
        {
            string fontFile = "verdana39.fnt";
            string imageFile = "verdana39.png";

            _batch = new GdxSpriteBatch(Context.GraphicsDevice);
            _font = new BitmapFont(Context.GraphicsDevice, fontFile, imageFile, false);
        }
Exemplo n.º 6
0
        public void Draw(GdxSpriteBatch spriteBatch, float alphaModulation)
        {
            Color oldColor = Color;

            Color = oldColor.MultiplyAlpha(alphaModulation);

            spriteBatch.Draw(Texture, Vertices, 0, 4);

            Color = oldColor;
        }
Exemplo n.º 7
0
        public override void Draw(GdxSpriteBatch spriteBatch, float x, float y, float width, float height)
        {
            Sprite.SetBounds(x, y, width, height);

            Color color = Sprite.Color;
            Sprite.Color = ColorExt.Multiply(color, spriteBatch.Color);

            Sprite.Draw(spriteBatch);
            Sprite.Color = color;
        }
Exemplo n.º 8
0
        public override void Draw(GdxSpriteBatch spriteBatch, float x, float y, float width, float height)
        {
            TextureRegion region = Region;

            float regionWidth = region.RegionWidth;
            float regionHeight = region.RegionHeight;
            float remainingX = width % regionWidth;
            float remainingY = height % regionHeight;

            float startX = x;
            float startY = y;
            float endX = x + width - remainingX;
            float endY = y + height - remainingY;

            while (x < endX) {
                y = startY;
                while (y < endY) {
                    spriteBatch.Draw(region, x, y, regionWidth, regionHeight);
                    y += regionHeight;
                }
                x += regionWidth;
            }

            TextureContext texture = region.Texture;
            float u = region.U;
            float v2 = region.V2;

            if (remainingX > 0) {
                float u2 = u + remainingX / texture.Width;
                float v = region.V;

                y = startY;
                while (y < endY) {
                    spriteBatch.Draw(texture, x, y, remainingX, regionHeight, u, v2, u2, v);
                    y += regionHeight;
                }

                if (remainingY > 0) {
                    v = v2 - remainingY / texture.Height;
                    spriteBatch.Draw(texture, x, y, remainingX, remainingY, u, v2, u2, v);
                }
            }

            if (remainingY > 0) {
                float u2 = region.U2;
                float v = v2 - remainingY / texture.Height;

                x = startX;
                while (x < endX) {
                    spriteBatch.Draw(texture, x, y, regionWidth, remainingY, u, v2, u2, v);
                    x += regionWidth;
                }
            }
        }
Exemplo n.º 9
0
        public void Draw(GdxSpriteBatch spriteBatch, float x, float y, float width, float height)
        {
            float centerColX = x + LeftWidth;
            float rightColX  = x + width - RightWidth;
            float middleRowY = y + BottomHeight;
            float topRowY    = y + height - TopHeight;

            Color color = ColorExt.Multiply(Color, spriteBatch.Color);

            color = Color.FromNonPremultiplied(color.R, color.G, color.B, color.A);

            if (_bottomLeft != -1)
            {
                Set(_bottomLeft, x, y, centerColX - x, middleRowY - y, color);
            }
            if (_bottomCenter != -1)
            {
                Set(_bottomCenter, centerColX, y, rightColX - centerColX, middleRowY - y, color);
            }
            if (_bottomRight != -1)
            {
                Set(_bottomRight, rightColX, y, x + width - rightColX, middleRowY - y, color);
            }
            if (_middleLeft != -1)
            {
                Set(_middleLeft, x, middleRowY, centerColX - x, topRowY - middleRowY, color);
            }
            if (_middleCenter != -1)
            {
                Set(_middleCenter, centerColX, middleRowY, rightColX - centerColX, topRowY - middleRowY, color);
            }
            if (_middleRight != -1)
            {
                Set(_middleRight, rightColX, middleRowY, x + width - rightColX, topRowY - middleRowY, color);
            }
            if (_topLeft != -1)
            {
                Set(_topLeft, x, topRowY, centerColX - x, y + height - topRowY, color);
            }
            if (_topCenter != -1)
            {
                Set(_topCenter, centerColX, topRowY, rightColX - centerColX, y + height - topRowY, color);
            }
            if (_topRight != -1)
            {
                Set(_topRight, rightColX, topRowY, x + width - rightColX, y + height - topRowY, color);
            }

            spriteBatch.Draw(Texture, _vertices, 0, _index);
        }
Exemplo n.º 10
0
        public void Draw(GdxSpriteBatch spriteBatch, float alphaModulation)
        {
            if (alphaModulation == 1)
            {
                Draw(spriteBatch);
                return;
            }

            Color color = _color;

            Color = _color.MultiplyAlpha(alphaModulation);

            Draw(spriteBatch);
            Color = color;
        }
Exemplo n.º 11
0
        protected override void InitializeCore()
        {
            ShowDebug = true;

            //Debugger.Launch();

            _spriteBatch = new GdxSpriteBatch(Context.GraphicsDevice);
            _skin = new Skin(Context.GraphicsDevice, "Data/uiskin.json");
            _texture1 = new TextureContext(Context.GraphicsDevice, "Data/badlogicsmall.jpg", true);
            _texture2 = new TextureContext(Context.GraphicsDevice, "Data/badlogic.jpg", true);

            TextureRegion image = new TextureRegion(_texture1);
            TextureRegion imageFlipped = new TextureRegion(image);
            imageFlipped.Flip(true, true);
            TextureRegion image2 = new TextureRegion(_texture2);
            _stage = new Stage(Context.GraphicsDevice.Viewport.Width, Context.GraphicsDevice.Viewport.Height, true, Context.GraphicsDevice);

            Context.Input.Processor = _stage;

            ImageButtonStyle style = new ImageButtonStyle(_skin.Get<ButtonStyle>()) {
                ImageUp = new TextureRegionDrawable(image),
                ImageDown = new TextureRegionDrawable(imageFlipped),
            };
            ImageButton iconButton = new ImageButton(style);

            Button buttonMulti = new TextButton("Multi\nLine\nToggle", _skin, "toggle") {
                IsToggle = true,
            };
            Button imgButton = new Button(new Image(image), _skin);
            Button imgToggleButton = new Button(new Image(image), _skin, "toggle") {
                IsToggle = true,
            };

            Label myLabel = new Label("This is some text.", _skin);
            myLabel.TextWrapping = true;

            Table t = new Table();
            t.Row();
            t.Add(myLabel);

            t.Layout();

            CheckBox checkbox = new CheckBox("Check me", _skin);
            Slider slider = new Slider(0, 10, 1, false, _skin);
            TextField textField = new TextField("", _skin) {
                MessageText = "Click here!",
            };
            SelectBox dropdown = new SelectBox(selectEntries, _skin);
            Image imageActor = new Image(image2);
            ScrollPane scrollPane = new ScrollPane(imageActor);
            MonoGdx.Scene2D.UI.List list = new MonoGdx.Scene2D.UI.List(listEntries, _skin);
            ScrollPane scrollPane2 = new ScrollPane(list, _skin);
            //scrollPane2.FlickScroll = false;
            SplitPane splitPane = new SplitPane(scrollPane, scrollPane2, false, _skin, "default-horizontal");
            _fpsLabel = new Label("fps:", _skin);

            Label passwordLabel = new Label("Textfield in password mode: ", _skin);
            TextField passwordField = new TextField("", _skin) {
                MessageText = "password",
                PasswordCharacter = '*',
                IsPasswordMode = true,
            };

            Window window = new Window("Dialog", _skin);
            window.SetPosition(0, 0);
            window.Defaults().SpaceBottom = 10;
            window.Row().Configure.Fill().ExpandX();
            window.Add(iconButton);
            window.Add(buttonMulti);
            window.Add(imgButton);
            window.Add(imgToggleButton);
            window.Row();
            window.Add(checkbox);
            window.Add(slider).Configure.MinWidth(100).FillX().Colspan(3);
            window.Row();
            window.Add(dropdown).Configure.MinWidth(100).FillX();
            window.Add(textField).Configure.MinWidth(100).ExpandX().FillX().Colspan(3);
            window.Row();
            window.Add(splitPane).Configure.Fill().Expand().Colspan(4).MaxHeight(200);
            window.Row();
            window.Add(passwordLabel).Configure.Colspan(2);
            window.Add(passwordField).Configure.MinWidth(100).ExpandX().FillX().Colspan(2);

            window.Pack();

            /*textField.KeyUp += (field, c) => {
                if (c == '\n')
                    field.OnscreenKeyboard.Show(false);
            };*/

            _stage.AddActor(window);

            MonoGdx.Scene2D.UI.List list2 = new MonoGdx.Scene2D.UI.List(listEntries, _skin);
            ScrollPane scrollPane22 = new ScrollPane(list2, _skin);
            Window window2 = new Window("ScrollPane", _skin);
            window2.SetPosition(300, 300);
            window2.Defaults().SpaceBottom = 10;
            window2.Row().Configure.Fill().ExpandX();
            window2.Add(scrollPane22).Configure.MaxHeight(250).MaxWidth(150);
            window2.Pack();

            _stage.AddActor(window2);
        }
Exemplo n.º 12
0
 public TextBounds Draw(GdxSpriteBatch spriteBatch, string str, float x, float y, int start, int end)
 {
     _workingSequence.Value = str;
     return(Draw(spriteBatch, _workingSequence, x, y, start, end));
 }
Exemplo n.º 13
0
 protected virtual void DrawBackground(GdxSpriteBatch spriteBatch, float parentAlpha)
 {
     if (Background != null) {
         Color c = Color;
         spriteBatch.Color = new Color(c.R, c.G, c.B, c.A * parentAlpha);
         Background.Draw(spriteBatch, X, Y, Width, Height);
     }
 }
Exemplo n.º 14
0
        public override void Draw(GdxSpriteBatch spriteBatch, float parentAlpha)
        {
            Validate();

            spriteBatch.Color = Color.MultiplyAlpha(parentAlpha);

            float x = X;
            float y = Y;
            float scaleX = ScaleX;
            float scaleY = ScaleY;

            if (_drawable != null) {
                if (_drawable is TextureRegionDrawable) {
                    TextureRegion region = (Drawable as TextureRegionDrawable).Region;
                    float rotation = Rotation;
                    if (scaleX == 1 && scaleY == 1 && rotation == 0)
                        spriteBatch.Draw(region, x + ImageX, y + ImageY, ImageWidth, ImageHeight);
                    else
                        spriteBatch.Draw(region, x + ImageX, y + ImageY, OriginX - ImageX, OriginY - ImageY, ImageWidth, ImageHeight, scaleX, scaleY, rotation);
                }
                else
                    _drawable.Draw(spriteBatch, x + ImageX, y + ImageY, ImageWidth * scaleX, ImageHeight * scaleY);
            }
        }
Exemplo n.º 15
0
 public void Draw(GdxSpriteBatch spriteBatch)
 {
     spriteBatch.Draw(Font.Region.Texture, Vertices, 0, _vertexCount);
 }
Exemplo n.º 16
0
 public TextBounds DrawWrapped(GdxSpriteBatch spriteBatch, string str, float x, float y, float wrapWidth, HAlignment alignment)
 {
     _workingSequence.Value = str;
     return(DrawWrapped(spriteBatch, _workingSequence, x, y, wrapWidth, alignment));
 }
Exemplo n.º 17
0
        public void Draw(GdxSpriteBatch spriteBatch, float alphaModulation)
        {
            Color oldColor = Color;
            Color = oldColor.MultiplyAlpha(alphaModulation);

            spriteBatch.Draw(Texture, Vertices, 0, 4);

            Color = oldColor;
        }
Exemplo n.º 18
0
 public TextBounds DrawMultiLine(GdxSpriteBatch spriteBatch, string str, float x, float y, float alignmentWidth, HAlignment alignment)
 {
     _workingSequence.Value = str;
     return(DrawMultiLine(spriteBatch, _workingSequence, x, y, alignmentWidth, alignment));
 }
Exemplo n.º 19
0
        protected void DrawChildren(GdxSpriteBatch spriteBatch, float parentAlpha)
        {
            parentAlpha *= Color.A / 255f;

            IList<Actor> actors = Children.Begin();
            if (_cullingArea != null) {
                RectangleF cull = _cullingArea.Value;
                float cullLeft = cull.X;
                float cullRight = cullLeft + cull.Width;
                float cullBottom = cull.Y;
                float cullTop = cullBottom + cull.Height;

                // Draw children only if inside the culling area.
                if (IsTransform) {
                    foreach (Actor child in actors) {
                        if (!child.IsVisible)
                            continue;

                        float cx = child.X;
                        float cy = child.Y;
                        if (cx <= cullRight && cy <= cullTop && cx + child.Width >= cullLeft && cy + child.Height >= cullBottom)
                            child.Draw(spriteBatch, parentAlpha);
                    }
                    spriteBatch.Flush();
                }
                else {
                    // No transform for this group, offset each child.
                    float offsetX = X;
                    float offsetY = Y;
                    X = 0;
                    Y = 0;

                    foreach (Actor child in actors) {
                        if (!child.IsVisible)
                            continue;

                        float cx = child.X;
                        float cy = child.Y;
                        if (cx <= cullRight && cy <= cullTop && cx + child.Width >= cullLeft && cy + child.Height >= cullBottom) {
                            child.X = cx + offsetX;
                            child.Y = cy + offsetY;
                            child.Draw(spriteBatch, parentAlpha);
                            child.X = cx;
                            child.Y = cy;
                        }
                    }

                    X = offsetX;
                    Y = offsetY;
                }
            }
            else {
                // No culling, draw all children
                if (IsTransform) {
                    foreach (Actor child in actors) {
                        if (!child.IsVisible)
                            continue;
                        child.Draw(spriteBatch, parentAlpha);
                    }
                    spriteBatch.Flush();
                }
                else {
                    // No transform for this group, offset each child.
                    float offsetX = X;
                    float offsetY = Y;
                    X = 0;
                    Y = 0;

                    foreach (Actor child in actors) {
                        if (!child.IsVisible)
                            continue;

                        float cx = child.X;
                        float cy = child.Y;

                        child.X = cx + offsetX;
                        child.Y = cy + offsetY;
                        child.Draw(spriteBatch, parentAlpha);
                        child.X = cx;
                        child.Y = cy;
                    }

                    X = offsetX;
                    Y = offsetY;
                }
            }
            Children.End();
        }
Exemplo n.º 20
0
 public TextBounds DrawMultiLine(GdxSpriteBatch spriteBatch, string str, float x, float y)
 {
     _workingSequence.Value = str;
     return(DrawMultiLine(spriteBatch, _workingSequence, x, y));
 }
Exemplo n.º 21
0
 protected void ResetTransform(GdxSpriteBatch spriteBatch)
 {
     spriteBatch.TransformMatrix = _oldBatchTransform;
 }
Exemplo n.º 22
0
        public void Draw(GdxSpriteBatch spriteBatch, float x, float y, float width, float height)
        {
            float centerColX = x + LeftWidth;
            float rightColX = x + width - RightWidth;
            float middleRowY = y + BottomHeight;
            float topRowY = y + height - TopHeight;

            Color color = ColorExt.Multiply(Color, spriteBatch.Color);
            color = Color.FromNonPremultiplied(color.R, color.G, color.B, color.A);

            if (_bottomLeft != -1)
                Set(_bottomLeft, x, y, centerColX - x, middleRowY - y, color);
            if (_bottomCenter != -1)
                Set(_bottomCenter, centerColX, y, rightColX - centerColX, middleRowY - y, color);
            if (_bottomRight != -1)
                Set(_bottomRight, rightColX, y, x + width - rightColX, middleRowY - y, color);
            if (_middleLeft != -1)
                Set(_middleLeft, x, middleRowY, centerColX - x, topRowY - middleRowY, color);
            if (_middleCenter != -1)
                Set(_middleCenter, centerColX, middleRowY, rightColX - centerColX, topRowY - middleRowY, color);
            if (_middleRight != -1)
                Set(_middleRight, rightColX, middleRowY, x + width - rightColX, topRowY - middleRowY, color);
            if (_topLeft != -1)
                Set(_topLeft, x, topRowY, centerColX - x, y + height - topRowY, color);
            if (_topCenter != -1)
                Set(_topCenter, centerColX, topRowY, rightColX - centerColX, y + height - topRowY, color);
            if (_topRight != -1)
                Set(_topRight, rightColX, topRowY, x + width - rightColX, y + height - topRowY, color);

            spriteBatch.Draw(Texture, _vertices, 0, _index);
        }
Exemplo n.º 23
0
        public override void Draw(GdxSpriteBatch spriteBatch, float parentAlpha)
        {
            BitmapFont font = _style.Font;
            ISceneDrawable selectedDrawable = _style.Selection;
            Color fontColorSelected = _style.FontColorSelected;
            Color fontColorUnselected = _style.FontColorUnselected;

            spriteBatch.Color = Color.MultiplyAlpha(parentAlpha);

            float x = X;
            float y = Y;

            font.Color = fontColorUnselected.MultiplyAlpha(parentAlpha);
            float itemY = Height;

            for (int i = 0; i < _items.Length; i++) {
                if (_cullingArea.IsEmpty || (itemY - _itemHeight <= _cullingArea.Y + _cullingArea.Height && itemY >= _cullingArea.Y)) {
                    if (_selectedIndex == i) {
                        selectedDrawable.Draw(spriteBatch, x, y + itemY - _itemHeight, Width, ItemHeight);
                        font.Color = fontColorSelected.MultiplyAlpha(parentAlpha);
                    }
                    font.Draw(spriteBatch, _itemsText[i], x + _textOffsetX, y + itemY - _textOffsetY);

                    if (_selectedIndex == i)
                        font.Color = fontColorUnselected.MultiplyAlpha(parentAlpha);
                }
                else if (itemY < _cullingArea.Y)
                    break;

                itemY -= ItemHeight;
            }
        }
Exemplo n.º 24
0
 protected void ApplyTransform(GdxSpriteBatch spriteBatch, Matrix transform)
 {
     _oldBatchTransform = spriteBatch.TransformMatrix;
     spriteBatch.TransformMatrix = transform;
 }
Exemplo n.º 25
0
 public void Draw(GdxSpriteBatch spriteBatch)
 {
     spriteBatch.Draw(Texture, Vertices, 0, 4);
 }
Exemplo n.º 26
0
        public override void Draw(GdxSpriteBatch spriteBatch, float parentAlpha)
        {
            Validate();

            if (_style != null && _style.Background != null) {
                spriteBatch.Color = Color.MultiplyAlpha(parentAlpha);
                _style.Background.Draw(spriteBatch, X, Y, Width, Height);
            }

            base.Draw(spriteBatch, parentAlpha);
        }
Exemplo n.º 27
0
        public override void Draw(GdxSpriteBatch spriteBatch, float parentAlpha)
        {
            Validate();

            if (_style.Background != null) {
                spriteBatch.Color = Color.MultiplyAlpha(parentAlpha);
                _style.Background.Draw(spriteBatch, X, Y, Width, Height);
            }

            _cache.Color = (_style.FontColor == null) ? Color : Color.Multiply(_style.FontColor.Value);
            _cache.SetPosition(X, Y);
            _cache.Draw(spriteBatch, (Color.A / 255f) * parentAlpha);
        }
Exemplo n.º 28
0
        public override void Draw(GdxSpriteBatch spriteBatch, float parentAlpha)
        {
            if (IsTransform)
                ApplyTransform(spriteBatch, ComputeTransform());

            DrawChildren(spriteBatch, parentAlpha);

            if (IsTransform)
                ResetTransform(spriteBatch);
        }
Exemplo n.º 29
0
 public void Draw(GdxSpriteBatch spriteBatch, int start, int end)
 {
     spriteBatch.Draw(Font.Region.Texture, Vertices, start * 4, end * 4);
 }
Exemplo n.º 30
0
 public void Draw(GdxSpriteBatch spriteBatch, int start, int end)
 {
     spriteBatch.Draw(Font.Region.Texture, Vertices, start * 4, end * 4);
 }
Exemplo n.º 31
0
 public override void Draw(GdxSpriteBatch spriteBatch, float x, float y, float width, float height)
 {
     spriteBatch.Draw(Region, x, y, width, height);
 }
Exemplo n.º 32
0
        public override void Draw(GdxSpriteBatch spriteBatch, float parentAlpha)
        {
            Stage stage = Stage;
            if (KeepWithinStage && Parent == stage.Root) {
                float parentWidth = stage.Width;
                float parentHeight = stage.Height;
                if (X < 0)
                    X = 0;
                if (Right > parentWidth)
                    X = parentWidth - Width;
                if (Y < 0)
                    Y = 0;
                if (Top > parentHeight)
                    Y = parentHeight - Height;
            }

            base.Draw(spriteBatch, parentAlpha);
        }
Exemplo n.º 33
0
        public override void Draw(GdxSpriteBatch spriteBatch, float parentAlpha)
        {
            Validate();
            DrawBackground(spriteBatch, parentAlpha);

            if (IsTransform) {
                ApplyTransform(spriteBatch, ComputeTransform());
                if (_clip) {
                    bool draw = Background == null
                        ? ClipBegin(0, 0, Width, Height)
                        : ClipBegin(_layout.PadLeft, _layout.PadBottom, Width - _layout.PadLeft - _layout.PadRight, Height - _layout.PadBottom - _layout.PadTop);

                    if (draw) {
                        DrawChildren(spriteBatch, parentAlpha);
                        ClipEnd();
                    }
                }
                else
                    DrawChildren(spriteBatch, parentAlpha);
                ResetTransform(spriteBatch);
            }
            else
                base.Draw(spriteBatch, parentAlpha);
        }
Exemplo n.º 34
0
 public void Draw(GdxSpriteBatch spriteBatch)
 {
     spriteBatch.Draw(Texture, Vertices, 0, 4);
 }
Exemplo n.º 35
0
        public override void Draw(GdxSpriteBatch spriteBatch, float parentAlpha)
        {
            Validate();

            ISceneDrawable background = null;
            float offsetX = 0;
            float offsetY = 0;

            if (IsPressed && !IsDisabled) {
                background = _style.Down ?? _style.Up;
                offsetX = _style.PressedOffsetX;
                offsetY = _style.PressedOffsetY;
            }
            else {
                if (IsDisabled && _style.Disabled != null)
                    background = _style.Disabled;
                else if (IsChecked && _style.Checked != null)
                    background = IsOver ? (_style.CheckedOver ?? _style.Checked) : _style.Checked;
                else if (IsOver && _style.Over != null)
                    background = _style.Over;
                else
                    background = _style.Up;

                offsetX = _style.UnpressedOffsetX;
                offsetY = _style.UnpressedOffsetY;
            }

            if (background != null) {
                spriteBatch.Color = Color.MultiplyAlpha(parentAlpha);
                background.Draw(spriteBatch, X, Y, Width, Height);
            }

            foreach (var child in Children)
                child.Translate(offsetX, offsetY);

            base.Draw(spriteBatch, parentAlpha);

            foreach (var child in Children)
                child.Translate(-offsetX, -offsetY);
        }
Exemplo n.º 36
0
 public override void Draw(GdxSpriteBatch spriteBatch, float parentAlpha)
 {
     Validate();
 }
Exemplo n.º 37
0
        public override void Draw(GdxSpriteBatch spriteBatch, float parentAlpha)
        {
            if (_widget == null)
                return;

            Validate();

            // Setup transform for this group
            ApplyTransform(spriteBatch, ComputeTransform());

            if (IsScrollX)
                _hKnobBounds.X = _hScrollBounds.X + (int)((_hScrollBounds.Width - _hKnobBounds.Width) * ScrollPercentX);
            if (IsScrollY)
                _vKnobBounds.Y = _vScrollBounds.Y + (int)((_vScrollBounds.Height - _vKnobBounds.Height) * (1 - ScrollPercentY));

            // Calculate the widget's position depending on the scroll state and available widget area.
            float y = _widgetAreaBounds.Y;
            if (!IsScrollY)
                y -= (int)MaxY;
            else
                y -= (int)(MaxY - _visualAmountY);

            if (!_fadeScrollBars && ScrollBarsOnTop && IsScrollX) {
                float scollbarHeight = 0;
                if (_style.HScrollKnob != null)
                    scollbarHeight = _style.HScrollKnob.MinHeight;
                if (_style.HScroll != null)
                    scollbarHeight = Math.Max(scollbarHeight, _style.HScroll.MinHeight);
                y += scollbarHeight;
            }

            float x = _widgetAreaBounds.X;
            if (IsScrollX)
                x -= (int)_visualAmountX;

            _widget.SetPosition(x, y);

            if (_widget is ICullable) {
                _widgetCullingArea.X = -_widget.X + _widgetAreaBounds.X;
                _widgetCullingArea.Y = -_widget.Y + _widgetAreaBounds.Y;
                _widgetCullingArea.Width = _widgetAreaBounds.Width;
                _widgetCullingArea.Height = _widgetAreaBounds.Height;

                (_widget as ICullable).SetCullingArea(_widgetCullingArea);
            }

            // Caculate the scissor bounds based on the batch transform, the available widget area and the camera transform. We need to
            // project those to screen coordinates for OpenGL ES to consume.
            _scissorBounds = ScissorStack.CalculateScissors(Stage.Camera, spriteBatch.TransformMatrix, (Rectangle)_widgetAreaBounds);

            // Draw the background ninepatch
            spriteBatch.Color = Color.MultiplyAlpha(parentAlpha);
            if (_style.Background != null)
                _style.Background.Draw(spriteBatch, 0, 0, Width, Height);
            spriteBatch.Flush();

            // Enable scissors for widget area and draw the widget.
            if (Stage.ScissorStack.PushScissors(_scissorBounds)) {
                DrawChildren(spriteBatch, parentAlpha);
                Stage.ScissorStack.PopScissors();
            }

            // Render scrollbars and knobs on top.
            spriteBatch.Color = Color.MultiplyAlpha(parentAlpha * Interpolation.Fade.Apply(_fadeAlpha / FadeAlphaSeconds));
            if (IsScrollX && IsScrollY) {
                if (_style.Corner != null)
                    _style.Corner.Draw(spriteBatch, _hScrollBounds.X + _hScrollBounds.Width, _hScrollBounds.Y, _vScrollBounds.Width, _vScrollBounds.Height);
            }

            if (IsScrollX) {
                if (_style.HScroll != null)
                    _style.HScroll.Draw(spriteBatch, _hScrollBounds.X, _hScrollBounds.Y, _hScrollBounds.Width, _hScrollBounds.Height);
                if (_style.HScrollKnob != null)
                    _style.HScrollKnob.Draw(spriteBatch, _hKnobBounds.X, _hKnobBounds.Y, _hKnobBounds.Width, _hKnobBounds.Height);
            }

            if (IsScrollY) {
                if (_style.VScroll != null)
                    _style.VScroll.Draw(spriteBatch, _vScrollBounds.X, _vScrollBounds.Y, _vScrollBounds.Width, _vScrollBounds.Height);
                if (_style.VScrollKnob != null)
                    _style.VScrollKnob.Draw(spriteBatch, _vKnobBounds.X, _vKnobBounds.Y, _vKnobBounds.Width, _vKnobBounds.Height);
            }

            ResetTransform(spriteBatch);
        }
Exemplo n.º 38
0
 protected override void DrawBackground(GdxSpriteBatch spriteBatch, float parentAlpha)
 {
 }
Exemplo n.º 39
0
 public void Draw(GdxSpriteBatch spriteBatch)
 {
     spriteBatch.Draw(Font.Region.Texture, Vertices, 0, _vertexCount);
 }
Exemplo n.º 40
0
        public override void Draw(GdxSpriteBatch spriteBatch, float parentAlpha)
        {
            if (IsDisabled)
                _image.Drawable = (IsChecked) ? _style.CheckboxOnDisabled ?? _style.CheckboxOn : _style.CheckboxOffDisabled ?? _style.CheckboxOff;
            else if (IsOver)
                _image.Drawable = (IsChecked) ? _style.CheckboxOnOver ?? _style.CheckboxOn : _style.CheckboxOffOver ?? _style.CheckboxOff;
            else
                _image.Drawable = (IsChecked) ? _style.CheckboxOn : _style.CheckboxOff;

            base.Draw(spriteBatch, parentAlpha);
        }
Exemplo n.º 41
0
        public void Draw(GdxSpriteBatch spriteBatch, float alphaModulation)
        {
            if (alphaModulation == 1) {
                Draw(spriteBatch);
                return;
            }

            Color color = _color;
            Color = _color.MultiplyAlpha(alphaModulation);

            Draw(spriteBatch);
            Color = color;
        }
Exemplo n.º 42
0
 public virtual void Draw(GdxSpriteBatch spriteBatch, float x, float y, float width, float height)
 {
 }
Exemplo n.º 43
0
        protected override void DrawBackground(GdxSpriteBatch spriteBatch, float parentAlpha)
        {
            if (_style.StageBackground != null) {
                spriteBatch.Color = Color.MultiplyAlpha(parentAlpha);

                Stage stage = Stage;
                Vector2 localPos = StageToLocalCoordinates(Vector2.Zero);
                Vector2 localSize = StageToLocalCoordinates(new Vector2(stage.Width, stage.Height));

                _style.StageBackground.Draw(spriteBatch, X + localPos.X, Y + localPos.Y, X + localSize.X, Y + localSize.Y);
            }

            base.DrawBackground(spriteBatch, parentAlpha);

            float x = X;
            float y = Y + Height;
            TextBounds bounds = _titleCache.Bounds;

            if ((_titleAlignment & Alignment.Left) != 0)
                x += PadLeft;
            else if ((_titleAlignment & Alignment.Right) != 0)
                x += Width - bounds.Width - PadRight;
            else
                x += (Width - bounds.Width) / 2;

            if ((_titleAlignment & Alignment.Top) == 0) {
                if ((_titleAlignment & Alignment.Bottom) != 0)
                    y -= PadTop - bounds.Height;
                else
                    y -= (PadTop - bounds.Height) / 2;
            }

            _titleCache.Color = Color.Multiply(_style.TitleFontColor);
            _titleCache.SetPosition((int)x, (int)y);
            _titleCache.Draw(spriteBatch, parentAlpha);
        }
Exemplo n.º 44
0
        public override void Draw(GdxSpriteBatch spriteBatch, float parentAlpha)
        {
            Stage stage = Stage;

            Validate();

            ISceneDrawable handle = _style.Handle;
            ApplyTransform(spriteBatch, ComputeTransform());
            Matrix transform = spriteBatch.TransformMatrix;

            if (_firstWidget != null) {
                _firstScissors = ScissorStack.CalculateScissors(stage.Camera, spriteBatch.TransformMatrix, (Rectangle)_firstWidgetBounds);
                if (stage.ScissorStack.PushScissors(_firstScissors)) {
                    if (_firstWidget.IsVisible)
                        _firstWidget.Draw(spriteBatch, parentAlpha * Color.A / 255f);
                    spriteBatch.Flush();
                    stage.ScissorStack.PopScissors();
                }
            }

            if (_secondWidget != null) {
                _secondScissors = ScissorStack.CalculateScissors(stage.Camera, spriteBatch.TransformMatrix, (Rectangle)_secondWidgetBounds);
                if (stage.ScissorStack.PushScissors(_secondScissors)) {
                    if (_secondWidget.IsVisible)
                        _secondWidget.Draw(spriteBatch, parentAlpha * Color.A / 255f);
                    spriteBatch.Flush();
                    stage.ScissorStack.PopScissors();
                }
            }

            spriteBatch.Color = Color;
            handle.Draw(spriteBatch, _handleBounds.X, _handleBounds.Y, _handleBounds.Width, _handleBounds.Height);
            ResetTransform(spriteBatch);
        }