int32 SWidget::Paint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const { INC_DWORD_STAT(STAT_SlateNumPaintedWidgets); SLATE_CYCLE_COUNTER_SCOPE_CUSTOM_DETAILED(SLATE_STATS_DETAIL_LEVEL_MED, GSlateOnPaint, GetType()); // Save the current layout cache we're associated with (if any) LayoutCache = Args.GetLayoutCache(); // Record if we're part of a volatility pass, this is critical for ensuring we don't report a child // of a volatile widget as non-volatile, causing the invalidation panel to do work that's not required. bInheritedVolatility = Args.IsVolatilityPass(); // If this paint pass is to cache off our geometry, but we're a volatile widget, // record this widget as volatile in the draw elements so that we get our own tick/paint // pass later when the layout cache draws. if ( Args.IsCaching() && IsVolatile() ) { const int32 VolatileLayerId = LayerId + 1; OutDrawElements.QueueVolatilePainting( FSlateWindowElementList::FVolatilePaint(SharedThis(this), Args, AllottedGeometry, MyClippingRect, VolatileLayerId, InWidgetStyle, bParentEnabled)); return VolatileLayerId; } if ( bFoldTick && bCanTick ) { FGeometry TickGeometry = AllottedGeometry; TickGeometry.AppendTransform( FSlateLayoutTransform(Args.GetWindowToDesktopTransform()) ); SWidget* MutableThis = const_cast<SWidget*>(this); MutableThis->ExecuteActiveTimers( Args.GetCurrentTime(), Args.GetDeltaTime() ); MutableThis->Tick( TickGeometry, Args.GetCurrentTime(), Args.GetDeltaTime() ); } // Record hit test geometry, but only if we're not caching. const FPaintArgs UpdatedArgs = Args.RecordHittestGeometry(this, AllottedGeometry, MyClippingRect); // Paint the geometry of this widget. int32 NewLayerID = OnPaint(UpdatedArgs, AllottedGeometry, MyClippingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled); // Check if we need to show the keyboard focus ring, this is only necessary if the widget could be focused. if ( bCanSupportFocus && SupportsKeyboardFocus() ) { bool bShowUserFocus = FSlateApplicationBase::Get().ShowUserFocus(SharedThis(this)); if (bShowUserFocus) { const FSlateBrush* BrushResource = GetFocusBrush(); if (BrushResource != nullptr) { FSlateDrawElement::MakeBox( OutDrawElements, NewLayerID, AllottedGeometry.ToPaintGeometry(), BrushResource, MyClippingRect, ESlateDrawEffect::None, BrushResource->GetTint(InWidgetStyle) ); } } } return NewLayerID; }