コード例 #1
0
ファイル: SplitPane.cs プロジェクト: xuyanwen2012/Warband
        public override void draw(Graphics graphics, float parentAlpha)
        {
            validate();

            if (transform)
            {
                applyTransform(graphics, computeTransform());
            }
            if (_firstWidget != null && _firstWidget.isVisible())
            {
                var scissor = ScissorStack.calculateScissors(
                    stage?.camera,
                    graphics.batcher.transformMatrix,
                    _firstWidgetBounds);
                if (ScissorStack.pushScissors(scissor))
                {
                    graphics.batcher.enableScissorTest(true);
                    _firstWidget.draw(graphics, parentAlpha * color.A);
                    graphics.batcher.enableScissorTest(false);
                    ScissorStack.popScissors();
                }
            }

            if (_secondWidget != null && _secondWidget.isVisible())
            {
                var scissor = ScissorStack.calculateScissors(
                    stage?.camera,
                    graphics.batcher.transformMatrix,
                    _secondWidgetBounds);
                if (ScissorStack.pushScissors(scissor))
                {
                    graphics.batcher.enableScissorTest(true);
                    _secondWidget.draw(graphics, parentAlpha * color.A);
                    graphics.batcher.enableScissorTest(false);
                    ScissorStack.popScissors();
                }
            }

            _style.handle.draw(
                graphics,
                _handleBounds.x,
                _handleBounds.y,
                _handleBounds.width,
                _handleBounds.height,
                new Color(color, (int)(color.A * parentAlpha)));

            if (transform)
            {
                resetTransform(graphics);
            }
        }
コード例 #2
0
        /// <summary>
        /// Clips the specified screen aligned rectangle, specified relative to the transform matrix of the stage's Batch. The
        /// transform matrix and the stage's camera must not have rotational components. Calling this method must be followed by a call
        /// to clipEnd() if true is returned.
        /// </summary>
        public bool clipBegin(Batcher batcher, float x, float y, float width, float height)
        {
            if (width <= 0 || height <= 0)
            {
                return(false);
            }

            var tableBounds   = RectangleExt.fromFloats(x, y, width, height);
            var scissorBounds = ScissorStack.calculateScissors(stage?.entity?.scene?.camera, batcher.transformMatrix, tableBounds);

            if (ScissorStack.pushScissors(scissorBounds))
            {
                batcher.enableScissorTest(true);
                return(true);
            }

            return(false);
        }
コード例 #3
0
        public override void debugRender(Graphics graphics)
        {
            if (transform)
            {
                applyTransform(graphics, computeTransform());
            }

            var scissor = ScissorStack.calculateScissors(stage?.camera, graphics.batcher.transformMatrix, _widgetAreaBounds);

            if (ScissorStack.pushScissors(scissor))
            {
                graphics.batcher.enableScissorTest(true);
                debugRenderChildren(graphics, 1f);
                graphics.batcher.enableScissorTest(false);
                ScissorStack.popScissors();
            }

            if (transform)
            {
                resetTransform(graphics);
            }
        }
コード例 #4
0
        public override void draw(Graphics graphics, float parentAlpha)
        {
            if (_widget == null)
            {
                return;
            }

            update();
            validate();

            // setup transform for this group.
            if (transform)
            {
                applyTransform(graphics, computeTransform());
            }

            if (_scrollX)
            {
                _hKnobBounds.X = _hScrollBounds.X + (int)((_hScrollBounds.Width - _hKnobBounds.Width) * getVisualScrollPercentX());
            }
            if (_scrollY)
            {
                _vKnobBounds.Y = _vScrollBounds.Y + (int)((_vScrollBounds.Height - _vKnobBounds.Height) * getVisualScrollPercentY());
            }

            // calculate the widget's position depending on the scroll state and available widget area.
            float eleY = _widgetAreaBounds.Y;

            if (!_scrollY)
            {
                eleY -= _maxY;
            }
            else
            {
                eleY -= _visualAmountY;
            }

            float eleX = _widgetAreaBounds.Y;

            if (_scrollX)
            {
                eleX -= (int)_visualAmountX;
            }

            if (!_fadeScrollBars && _scrollbarsOnTop)
            {
                if (_scrollX && _hScrollOnBottom)
                {
                    var scrollbarHeight = 0f;
                    if (_style.hScrollKnob != null)
                    {
                        scrollbarHeight = _style.hScrollKnob.minHeight;
                    }
                    if (_style.hScroll != null)
                    {
                        scrollbarHeight = Math.Max(scrollbarHeight, _style.hScroll.minHeight);
                    }
                    eleY += scrollbarHeight;
                }
                if (_scrollY && !_vScrollOnRight)
                {
                    var scrollbarWidth = 0f;
                    if (_style.hScrollKnob != null)
                    {
                        scrollbarWidth = _style.hScrollKnob.minWidth;
                    }
                    if (_style.hScroll != null)
                    {
                        scrollbarWidth = Math.Max(scrollbarWidth, _style.hScroll.minWidth);
                    }
                    eleX += scrollbarWidth;
                }
            }

            _widget.setPosition(eleX, eleY);

            // draw the background
            var color = getColor();

            color = new Color(color, color.A * parentAlpha);
            if (_style.background != null)
            {
                _style.background.draw(graphics, 0, 0, getWidth(), getHeight(), color);
            }

            // 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 to consume.
            var scissor = ScissorStack.calculateScissors(stage?.camera, graphics.batcher.transformMatrix, _widgetAreaBounds);

            if (ScissorStack.pushScissors(scissor))
            {
                graphics.batcher.enableScissorTest(true);
                drawChildren(graphics, parentAlpha);
                graphics.batcher.enableScissorTest(false);
                ScissorStack.popScissors();
            }

            // render scrollbars and knobs on top
            var alpha = (float)color.A;

            color.A = (byte)(alpha * (_fadeAlpha / _fadeAlphaSeconds));
            if (_scrollX && _scrollY)
            {
                if (_style.corner != null)
                {
                    _style.corner.draw(graphics, _hScrollBounds.X + _hScrollBounds.Width, _hScrollBounds.Y, _vScrollBounds.Width, _vScrollBounds.Y, color);
                }
            }
            if (_scrollX)
            {
                if (_style.hScroll != null)
                {
                    _style.hScroll.draw(graphics, _hScrollBounds.X, _hScrollBounds.Y, _hScrollBounds.Width, _hScrollBounds.Height, color);
                }
                if (_style.hScrollKnob != null)
                {
                    _style.hScrollKnob.draw(graphics, _hKnobBounds.X, _hKnobBounds.Y, _hKnobBounds.Width, _hKnobBounds.Height, color);
                }
            }
            if (_scrollY)
            {
                if (_style.vScroll != null)
                {
                    _style.vScroll.draw(graphics, _vScrollBounds.X, _vScrollBounds.Y, _vScrollBounds.Width, _vScrollBounds.Height, color);
                }
                if (_style.vScrollKnob != null)
                {
                    _style.vScrollKnob.draw(graphics, _vKnobBounds.X, _vKnobBounds.Y, _vKnobBounds.Width, _vKnobBounds.Height, color);
                }
            }

            if (transform)
            {
                resetTransform(graphics);
            }
        }