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); if (_widget is ICullable) { var cull = new Rectangle( (int)(-_widget.getX() + _widgetAreaBounds.X), (int)(-_widget.getY() + _widgetAreaBounds.Y), _widgetAreaBounds.Width, _widgetAreaBounds.Height); ((ICullable)_widget).setCullingArea(cull); } // draw the background var color = getColor(); color = new Color(color, (int)(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); } }