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); } }
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); } }
/// <summary> /// Ends clipping begun by clipBegin(Batcher, float, float, float, float) /// </summary> /// <returns>The end.</returns> public void clipEnd(Batcher batcher) { batcher.enableScissorTest(false); ScissorStack.popScissors(); }
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); } }