void SSequencerTrackArea::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { for (int32 ChildIndex = 0; ChildIndex < Children.Num(); ++ChildIndex) { const FTrackAreaSlot& CurChild = Children[ChildIndex]; const EVisibility ChildVisibility = CurChild.GetWidget()->GetVisibility(); if (!ArrangedChildren.Accepts(ChildVisibility)) { continue; } const FMargin Padding(0, CurChild.GetVerticalOffset(), 0, 0); AlignmentArrangeResult XResult = AlignChild<Orient_Horizontal>(AllottedGeometry.Size.X, CurChild, Padding, 1.0f, false); AlignmentArrangeResult YResult = AlignChild<Orient_Vertical>(AllottedGeometry.Size.Y, CurChild, Padding, 1.0f, false); ArrangedChildren.AddWidget(ChildVisibility, AllottedGeometry.MakeChild( CurChild.GetWidget(), FVector2D(XResult.Offset,YResult.Offset), FVector2D(XResult.Size, YResult.Size) ) ); } }
void SUniformGridPanel::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { if ( Children.Num() > 0 ) { const FVector2D CellSize(AllottedGeometry.Size.X / NumColumns, AllottedGeometry.Size.Y / NumRows); const FMargin& CurrentSlotPadding(SlotPadding.Get()); for ( int32 ChildIndex=0; ChildIndex < Children.Num(); ++ChildIndex ) { const FSlot& Child = Children[ChildIndex]; const EVisibility ChildVisibility = Child.GetWidget()->GetVisibility(); if ( ArrangedChildren.Accepts(ChildVisibility) ) { // Do the standard arrangement of elements within a slot // Takes care of alignment and padding. AlignmentArrangeResult XAxisResult = AlignChild<Orient_Horizontal>(CellSize.X, Child, CurrentSlotPadding); AlignmentArrangeResult YAxisResult = AlignChild<Orient_Vertical>(CellSize.Y, Child, CurrentSlotPadding); ArrangedChildren.AddWidget(ChildVisibility, AllottedGeometry.MakeChild(Child.GetWidget(), FVector2D(CellSize.X*Child.Column + XAxisResult.Offset, CellSize.Y*Child.Row + YAxisResult.Offset), FVector2D(XAxisResult.Size, YAxisResult.Size) )); } } } }
void SAnimationOutlinerView::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { const float Padding = SequencerLayoutConstants::NodePadding; const float IndentAmount = SequencerLayoutConstants::IndentAmount; float CurrentHeight = 0; for (int32 WidgetIndex = 0; WidgetIndex < Children.Num(); ++WidgetIndex) { const TSharedRef<SAnimationOutlinerTreeNode>& Widget = Children[WidgetIndex]; EVisibility Visibility = Widget->GetVisibility(); if( ArrangedChildren.Accepts( Visibility ) ) { const TSharedPtr<const FSequencerDisplayNode>& DisplayNode = Widget->GetDisplayNode(); // How large to make this node float HeightIncrement = DisplayNode->GetNodeHeight(); // How far to indent the widget float WidgetIndentOffset = IndentAmount*DisplayNode->GetTreeLevel(); // Place the widget at the current height, at the nodes desired size ArrangedChildren.AddWidget( Visibility, AllottedGeometry.MakeChild( Widget, FVector2D( WidgetIndentOffset, CurrentHeight ), FVector2D( AllottedGeometry.GetDrawSize().X-WidgetIndentOffset, HeightIncrement ) ) ); // Compute the start height for the next widget CurrentHeight += HeightIncrement+Padding; } } }
void SScaleBox::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { const EVisibility ChildVisibility = ChildSlot.GetWidget()->GetVisibility(); if ( ArrangedChildren.Accepts(ChildVisibility) ) { FVector2D DesiredSize = ChildSlot.GetWidget()->GetDesiredSize(); float FinalScale = 1; EStretch::Type CurrentStretch = Stretch.Get(); EStretchDirection::Type CurrentStretchDirection = StretchDirection.Get(); if ( DesiredSize.X != 0 && DesiredSize.Y != 0 ) { switch ( CurrentStretch ) { case EStretch::None: break; case EStretch::Fill: DesiredSize = AllottedGeometry.Size; break; case EStretch::ScaleToFit: FinalScale = FMath::Min(AllottedGeometry.Size.X / DesiredSize.X, AllottedGeometry.Size.Y / DesiredSize.Y); break; case EStretch::ScaleToFill: FinalScale = FMath::Max(AllottedGeometry.Size.X / DesiredSize.X, AllottedGeometry.Size.Y / DesiredSize.Y); break; } switch ( CurrentStretchDirection ) { case EStretchDirection::DownOnly: FinalScale = FMath::Min(FinalScale, 1.0f); break; case EStretchDirection::UpOnly: FinalScale = FMath::Max(FinalScale, 1.0f); break; } } FVector2D FinalOffset(0, 0); if ( CurrentStretch != EStretch::Fill ) { const FMargin SlotPadding(ChildSlot.SlotPadding.Get()); AlignmentArrangeResult XResult = AlignChild<Orient_Horizontal>(AllottedGeometry.Size.X, ChildSlot, SlotPadding, FinalScale, false); AlignmentArrangeResult YResult = AlignChild<Orient_Vertical>(AllottedGeometry.Size.Y, ChildSlot, SlotPadding, FinalScale, false); FinalOffset = FVector2D(XResult.Offset, YResult.Offset) * ( 1.0f / FinalScale ); } ArrangedChildren.AddWidget(ChildVisibility, AllottedGeometry.MakeChild( ChildSlot.GetWidget(), FinalOffset, DesiredSize, FinalScale ) ); } }
void SScrollBarTrack::OnArrangeChildren(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const { const float Width = AllottedGeometry.Size.X; const float Height = AllottedGeometry.Size.Y; // We only need to show all three children when the thumb is visible, otherwise we only need to show the track if (IsNeeded()) { FTrackSizeInfo TrackSizeInfo = this->GetTrackSizeInfo(AllottedGeometry); // Arrange top half of the track FVector2D ChildSize = (Orientation == Orient_Horizontal) ? FVector2D(TrackSizeInfo.ThumbStart, Height) : FVector2D(Width, TrackSizeInfo.ThumbStart); FVector2D ChildPos(0, 0); ArrangedChildren.AddWidget( AllottedGeometry.MakeChild(Children[TOP_SLOT_INDEX].GetWidget(), ChildPos, ChildSize) ); // Arrange bottom half of the track ChildPos = (Orientation == Orient_Horizontal) ? FVector2D(TrackSizeInfo.GetThumbEnd(), 0) : FVector2D(0, TrackSizeInfo.GetThumbEnd()); ChildSize = (Orientation == Orient_Horizontal) ? FVector2D(AllottedGeometry.Size.X - TrackSizeInfo.GetThumbEnd(), Height) : FVector2D(Width, AllottedGeometry.Size.Y - TrackSizeInfo.GetThumbEnd()); ArrangedChildren.AddWidget( AllottedGeometry.MakeChild(Children[BOTTOM_SLOT_INDEX].GetWidget(), ChildPos, ChildSize) ); // Arrange the thumb ChildPos = (Orientation == Orient_Horizontal) ? FVector2D(TrackSizeInfo.ThumbStart, 0) : FVector2D(0, TrackSizeInfo.ThumbStart); ChildSize = (Orientation == Orient_Horizontal) ? FVector2D(TrackSizeInfo.ThumbSize, Height) : FVector2D(Width, TrackSizeInfo.ThumbSize); ArrangedChildren.AddWidget( AllottedGeometry.MakeChild(Children[THUMB_SLOT_INDEX].GetWidget(), ChildPos, ChildSize) ); } else { // No thumb is visible, so just show the top half of the track at the current width/height ArrangedChildren.AddWidget( AllottedGeometry.MakeChild(Children[TOP_SLOT_INDEX].GetWidget(), FVector2D(0, 0), FVector2D(Width, Height)) ); } }
void SFxWidget::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { const EVisibility MyVisibility = this->GetVisibility(); if ( ArrangedChildren.Accepts( MyVisibility ) ) { // Only layout scale affects the arranged geometry. const FSlateLayoutTransform LayoutTransform(LayoutScale.Get()); ArrangedChildren.AddWidget( AllottedGeometry.MakeChild( this->ChildSlot.GetWidget(), TransformVector(Inverse(LayoutTransform), AllottedGeometry.Size), LayoutTransform)); } }
void SWeakWidget::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { // We just want to show the child that we are presenting. Always stretch it to occupy all of the space. TSharedRef<SWidget> MyContent = WeakChild.GetWidget(); if( MyContent!=SNullWidget::NullWidget && ArrangedChildren.Accepts(MyContent->GetVisibility()) ) { ArrangedChildren.AddWidget( AllottedGeometry.MakeChild( MyContent, FVector2D(0,0), AllottedGeometry.Size ) ); } }
int32 SPanel::PaintArrangedChildren( const FPaintArgs& Args, const FArrangedChildren& ArrangedChildren, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const { // Because we paint multiple children, we must track the maximum layer id that they produced in case one of our parents // wants to an overlay for all of its contents. int32 MaxLayerId = LayerId; const FPaintArgs NewArgs = Args.WithNewParent(this); for (int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex) { const FArrangedWidget& CurWidget = ArrangedChildren[ChildIndex]; bool bWereOverlapping; FSlateRect ChildClipRect = MyClippingRect.IntersectionWith(CurWidget.Geometry.GetClippingRect(), bWereOverlapping); if ( bWereOverlapping ) { const int32 CurWidgetsMaxLayerId = CurWidget.Widget->Paint(NewArgs, CurWidget.Geometry, ChildClipRect, OutDrawElements, LayerId, InWidgetStyle, ShouldBeEnabled(bParentEnabled)); MaxLayerId = FMath::Max(MaxLayerId, CurWidgetsMaxLayerId); } } return MaxLayerId; }
void SFlarePlanetaryBox::OnArrangeChildren(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const { const FFlareStyleCatalog& Theme = FFlareStyleSet::GetDefaultTheme(); for (int32 ChildIndex = 0; ChildIndex < Children.Num(); ++ChildIndex) { // Get all required data const SFlarePlanetaryBox::FSlot& CurChild = Children[ChildIndex]; const EVisibility ChildVisibility = CurChild.GetWidget()->GetVisibility(); FVector2D WidgetSize = CurChild.GetWidget()->GetDesiredSize(); FVector2D Offset = FVector2D::ZeroVector; // Child with index 0 is the main body, index 1 is probably the name but we don't care, others are sectors if (ChildIndex > 0) { float X, Y; float Angle = (360 / (Children.Num() - 1)) * (ChildIndex - 1) - 90; FMath::PolarToCartesian(Radius, FMath::DegreesToRadians(Angle), X, Y); Offset = FVector2D(X, Y); WidgetSize = FVector2D(CurChild.GetWidget()->GetDesiredSize().X, Theme.SectorButtonHeight); } // Arrange the child FVector2D Location = (AllottedGeometry.GetLocalSize() - WidgetSize) / 2 + Offset; ArrangedChildren.AddWidget(ChildVisibility, AllottedGeometry.MakeChild( CurChild.GetWidget(), Location, CurChild.GetWidget()->GetDesiredSize() )); } }
void SDPIScaler::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { const EVisibility MyVisibility = this->GetVisibility(); if ( ArrangedChildren.Accepts( MyVisibility ) ) { const float MyDPIScale = DPIScale.Get(); ArrangedChildren.AddWidget( AllottedGeometry.MakeChild( this->ChildSlot.GetWidget(), FVector2D::ZeroVector, AllottedGeometry.Size / MyDPIScale, MyDPIScale )); } }
virtual void OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const override { if (Children.Num() == 0) { return; } const float Alpha = 1.f - SlideCurve.GetLerp(); float PositionSoFar = AllottedGeometry.GetLocalSize().Y + StartSlideOffset*Alpha; for (int32 Index = 0; Index < NumSlots(); ++Index) { const SBoxPanel::FSlot& CurChild = Children[Index]; const EVisibility ChildVisibility = CurChild.GetWidget()->GetVisibility(); if (ChildVisibility != EVisibility::Collapsed) { const FVector2D ChildDesiredSize = CurChild.GetWidget()->GetDesiredSize(); const FMargin SlotPadding(CurChild.SlotPadding.Get()); const FVector2D SlotSize(AllottedGeometry.Size.X, ChildDesiredSize.Y + SlotPadding.GetTotalSpaceAlong<Orient_Vertical>()); const AlignmentArrangeResult XAlignmentResult = AlignChild<Orient_Horizontal>( SlotSize.X, CurChild, SlotPadding ); const AlignmentArrangeResult YAlignmentResult = AlignChild<Orient_Vertical>( SlotSize.Y, CurChild, SlotPadding ); ArrangedChildren.AddWidget( ChildVisibility, AllottedGeometry.MakeChild( CurChild.GetWidget(), FVector2D( XAlignmentResult.Offset, PositionSoFar - SlotSize.Y + YAlignmentResult.Offset ), FVector2D( XAlignmentResult.Size, YAlignmentResult.Size ) )); PositionSoFar -= SlotSize.Y; } } }
void SZoomPan::OnArrangeChildren(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const { const EVisibility ChildVisibility = ChildSlot.GetWidget()->GetVisibility(); if ( ArrangedChildren.Accepts(ChildVisibility) ) { const FMargin SlotPadding(ChildSlot.SlotPadding.Get()); AlignmentArrangeResult XResult = AlignChild<Orient_Horizontal>(AllottedGeometry.Size.X, ChildSlot, SlotPadding, 1); AlignmentArrangeResult YResult = AlignChild<Orient_Vertical>(AllottedGeometry.Size.Y, ChildSlot, SlotPadding, 1); ArrangedChildren.AddWidget( ChildVisibility, AllottedGeometry.MakeChild( ChildSlot.GetWidget(), FVector2D(XResult.Offset, YResult.Offset) - ViewOffset.Get(), ChildSlot.GetWidget()->GetDesiredSize(), ZoomAmount.Get() ) ); } }
void FSlateWidgetRun::ArrangeChildren( const TSharedRef< ILayoutBlock >& Block, const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { // The block size and offset values are pre-scaled, so we need to account for that when converting the block offsets into paint geometry const float InverseScale = Inverse(AllottedGeometry.Scale); ArrangedChildren.AddWidget( AllottedGeometry.MakeChild(Info.Widget, TransformVector(InverseScale, Block->GetSize()), FSlateLayoutTransform(TransformPoint(InverseScale, Block->GetLocationOffset()))) ); }
void SBox::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { const EVisibility& MyCurrentVisibility = this->GetVisibility(); if ( ArrangedChildren.Accepts( MyCurrentVisibility ) ) { const FMargin SlotPadding(ChildSlot.SlotPadding.Get()); AlignmentArrangeResult XAlignmentResult = AlignChild<Orient_Horizontal>( AllottedGeometry.Size.X, ChildSlot, SlotPadding ); AlignmentArrangeResult YAlignmentResult = AlignChild<Orient_Vertical>( AllottedGeometry.Size.Y, ChildSlot, SlotPadding ); ArrangedChildren.AddWidget( AllottedGeometry.MakeChild( ChildSlot.GetWidget(), FVector2D(XAlignmentResult.Offset, YAlignmentResult.Offset), FVector2D(XAlignmentResult.Size, YAlignmentResult.Size) ) ); } }
void SDockingTabWell::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { // The specialized TabWell is dedicated to arranging tabs. // Tabs have uniform sizing (all tabs the same size). // TabWell also ignores widget visibilit, as it is not really // relevant. // The tab that is being dragged by the user, if any. TSharedPtr<SDockTab> TabBeingDragged = TabBeingDraggedPtr; const int32 NumChildren = Tabs.Num(); // Tabs have a uniform size. const FVector2D ChildSize = ComputeChildSize(AllottedGeometry); const float DraggedChildCenter = ChildBeingDraggedOffset + ChildSize.X / 2; // Arrange all the tabs left to right. float XOffset = 0; for( int32 TabIndex=0; TabIndex < NumChildren; ++TabIndex ) { const TSharedRef<SDockTab> CurTab = Tabs[TabIndex]; const float ChildWidthWithOverlap = ChildSize.X - CurTab->GetOverlapWidth(); // Is this spot reserved from the tab that is being dragged? if ( TabBeingDragged.IsValid() && XOffset <= DraggedChildCenter && DraggedChildCenter < (XOffset + ChildWidthWithOverlap) ) { // if so, leave some room to signify that this is where the dragged tab would end up XOffset += ChildWidthWithOverlap; } ArrangedChildren.AddWidget( AllottedGeometry.MakeChild(CurTab, FVector2D(XOffset, 0), ChildSize) ); XOffset += ChildWidthWithOverlap; } // Arrange the tab currently being dragged by the user, if any if ( TabBeingDragged.IsValid() ) { ArrangedChildren.AddWidget( AllottedGeometry.MakeChild( TabBeingDragged.ToSharedRef(), FVector2D(ChildBeingDraggedOffset,0), ChildSize) ); } }
/** * Panels arrange their children in a space described by the AllottedGeometry parameter. The results of the arrangement * should be returned by appending a FArrangedWidget pair for every child widget. See StackPanel for an example */ void SSplitter::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { TArray<FLayoutGeometry> LayoutChildren = ArrangeChildrenForLayout(AllottedGeometry); // Arrange the children horizontally or vertically. for (int32 ChildIndex=0; ChildIndex < Children.Num(); ++ChildIndex) { ArrangedChildren.AddWidget( AllottedGeometry.MakeChild( Children[ChildIndex].GetWidget(), LayoutChildren[ChildIndex] ) ); } }
/** SWidget interface */ virtual void OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const override { for (int32 ChildIndex=0; ChildIndex < VisibleChildren.Num(); ++ChildIndex) { const auto Child = StaticCastSharedRef<SWorldTileItem>(VisibleChildren[ChildIndex]); const EVisibility ChildVisibility = Child->GetVisibility(); if (ArrangedChildren.Accepts(ChildVisibility)) { FVector2D ChildPos = Child->GetPosition(); ArrangedChildren.AddWidget(ChildVisibility, AllottedGeometry.MakeChild(Child, ChildPos - GetViewOffset(), Child->GetDesiredSize(), GetZoomAmount() )); } } }
void SMenuAnchor::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { ArrangeSingleChild( AllottedGeometry, ArrangedChildren, Children[0], FVector2D::UnitVector ); const TSharedPtr<SWindow> PresentingWindow = PopupWindowPtr.Pin(); if (IsOpenAndReusingWindow() && PresentingWindow.IsValid()) { const FPopupPlacement LocalPlacement(AllottedGeometry, Children[1].GetWidget()->GetDesiredSize(), Placement.Get()); ArrangedChildren.AddWidget(AllottedGeometry.MakeChild(Children[1].GetWidget(), LocalPlacement.LocalPopupSize, FSlateLayoutTransform(LocalPopupPosition))); } }
void SMenuAnchor::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { ArrangeSingleChild( AllottedGeometry, ArrangedChildren, Children[0], FVector2D::UnitVector); if ( IsOpen() ) { // @todo umg na AllottedGeometry here is in Window-Space when computed via OnPaint. // The incorrect geometry causes the popup to fail workspace-edge tests. const FGeometry PopupGeometry = ComputeMenuPlacement( AllottedGeometry, Children[1].GetWidget()->GetDesiredSize(), Placement.Get() ); ArrangedChildren.AddWidget( FArrangedWidget( Children[1].GetWidget(), PopupGeometry ) ); } }
void SSplitter2x2::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { TArray<FLayoutGeometry> LayoutChildren = ArrangeChildrenForLayout(AllottedGeometry); for (int32 ChildIndex=0; ChildIndex < Children.Num(); ++ChildIndex) { const FSlot& CurSlot = Children[ChildIndex]; // put them in their spot ArrangedChildren.AddWidget( AllottedGeometry.MakeChild( Children[ChildIndex].GetWidget(), LayoutChildren[ChildIndex] ) ); } }
void SSequencerSectionAreaView::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { int32 MaxRowIndex = 0; for( int32 WidgetIndex = 0; WidgetIndex < Children.Num(); ++WidgetIndex ) { const TSharedRef<SSection>& Widget = Children[WidgetIndex]; TSharedPtr<ISequencerSection> SectionInterface = Widget->GetSectionInterface(); MaxRowIndex = FMath::Max(MaxRowIndex, SectionInterface->GetSectionObject()->GetRowIndex()); } int32 MaxTracks = MaxRowIndex + 1; float SectionHeight = GetSectionAreaHeight(); FTimeToPixel TimeToPixelConverter = GetTimeToPixel( AllottedGeometry ); for( int32 WidgetIndex = 0; WidgetIndex < Children.Num(); ++WidgetIndex ) { const TSharedRef<SSection>& Widget = Children[WidgetIndex]; TSharedPtr<ISequencerSection> SectionInterface = Widget->GetSectionInterface(); int32 RowIndex = SectionInterface->GetSectionObject()->GetRowIndex(); FGeometry SectionGeometry = SequencerSectionUtils::GetSectionGeometry( AllottedGeometry, RowIndex, MaxTracks, SectionHeight, SectionInterface, TimeToPixelConverter ); EVisibility Visibility = Widget->GetVisibility(); if( ArrangedChildren.Accepts( Visibility ) ) { Widget->CacheParentGeometry(AllottedGeometry); ArrangedChildren.AddWidget( Visibility, AllottedGeometry.MakeChild( Widget, SectionGeometry.Position, SectionGeometry.GetDrawSize() ) ); } } }
void SGraphPanel::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { SNodePanel::OnArrangeChildren(AllottedGeometry, ArrangedChildren); FArrangedChildren MyArrangedChildren(ArrangedChildren.GetFilter()); for (int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex) { FArrangedWidget& CurWidget = ArrangedChildren[ChildIndex]; TSharedRef<SGraphNode> ChildNode = StaticCastSharedRef<SGraphNode>(CurWidget.Widget); TArray<FOverlayWidgetInfo> OverlayWidgets = ChildNode->GetOverlayWidgets(false, CurWidget.Geometry.Size); for (int32 WidgetIndex = 0; WidgetIndex < OverlayWidgets.Num(); ++WidgetIndex) { FOverlayWidgetInfo& OverlayInfo = OverlayWidgets[WidgetIndex]; MyArrangedChildren.AddWidget(AllottedGeometry.MakeChild( OverlayInfo.Widget.ToSharedRef(), CurWidget.Geometry.Position + OverlayInfo.OverlayOffset, OverlayInfo.Widget->GetDesiredSize(), GetZoomAmount() )); } } ArrangedChildren.Append(MyArrangedChildren); }
void SGraphPanel::ArrangeChildrenForContextMenuSummon(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const { // First pass nodes for (int32 ChildIndex = 0; ChildIndex < VisibleChildren.Num(); ++ChildIndex) { const TSharedRef<SNode>& SomeChild = VisibleChildren[ChildIndex]; if (!SomeChild->RequiresSecondPassLayout()) { ArrangedChildren.AddWidget( AllottedGeometry.MakeChild( SomeChild, SomeChild->GetPosition() - ViewOffset, SomeChild->GetDesiredSizeForMarquee(), GetZoomAmount() ) ); } } // Second pass nodes for (int32 ChildIndex = 0; ChildIndex < VisibleChildren.Num(); ++ChildIndex) { const TSharedRef<SNode>& SomeChild = VisibleChildren[ChildIndex]; if (SomeChild->RequiresSecondPassLayout()) { SomeChild->PerformSecondPassLayout(NodeToWidgetLookup); ArrangedChildren.AddWidget( AllottedGeometry.MakeChild( SomeChild, SomeChild->GetPosition() - ViewOffset, SomeChild->GetDesiredSizeForMarquee(), GetZoomAmount() ) ); } } }
void FBehaviorTreeConnectionDrawingPolicy::Draw(TMap<TSharedRef<SWidget>, FArrangedWidget>& PinGeometries, FArrangedChildren& ArrangedNodes) { // Build an acceleration structure to quickly find geometry for the nodes NodeWidgetMap.Empty(); for (int32 NodeIndex = 0; NodeIndex < ArrangedNodes.Num(); ++NodeIndex) { FArrangedWidget& CurWidget = ArrangedNodes[NodeIndex]; TSharedRef<SGraphNode> ChildNode = StaticCastSharedRef<SGraphNode>(CurWidget.Widget); NodeWidgetMap.Add(ChildNode->GetNodeObj(), NodeIndex); } // Now draw FConnectionDrawingPolicy::Draw(PinGeometries, ArrangedNodes); }
void SAutoFolding::OnArrangeChildren(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const { //这里处理添加到content里面的逻辑,对齐方式,显示方式 areaSize = AllottedGeometry.GetLocalSize(); float startX = contentMargin.Left; float startY = contentMargin.Top; for (int32 ChildIndex = 0; ChildIndex < Children.Num(); ++ChildIndex) { const SBoxPanel::FSlot& CurChild = Children[ChildIndex]; const EVisibility ChildVisibility = CurChild.GetWidget()->GetVisibility(); FVector2D size = CurChild.GetWidget()->GetDesiredSize(); ArrangedChildren.AddWidget(ChildVisibility, AllottedGeometry.MakeChild(CurChild.GetWidget(), FVector2D(startX, startY), FVector2D(size.X, size.Y))); } }
virtual void OnArrangeChildren(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const override { CachedSize = AllottedGeometry.GetLocalSize(); const TSharedRef<SWidget>& ChildWidget = ChildSlot.GetWidget(); if (ChildWidget->GetVisibility() != EVisibility::Collapsed) { const FVector2D& WidgetDesiredSize = ChildWidget->GetDesiredSize(); // Clamp the pan offset based on our current geometry SScrollableSnapshotImage* const NonConstThis = const_cast<SScrollableSnapshotImage*>(this); NonConstThis->ClampViewOffset(WidgetDesiredSize, CachedSize); ArrangedChildren.AddWidget(AllottedGeometry.MakeChild(ChildWidget, PhysicalOffset, WidgetDesiredSize)); } }
void SWrapBox::OnArrangeChildren(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const { const float WidthToWrapAt = PreferredWidth.Get(); FChildArranger::Arrange(*this, [&](const FSlot& Slot, const FChildArranger::FArrangementData& ArrangementData) { // Calculate offset and size in slot using alignment. const AlignmentArrangeResult XResult = AlignChild<Orient_Horizontal>(ArrangementData.SlotSize.X, Slot, Slot.SlotPadding.Get()); const AlignmentArrangeResult YResult = AlignChild<Orient_Vertical>(ArrangementData.SlotSize.Y, Slot, Slot.SlotPadding.Get()); // Note: Alignment offset is relative to slot offset. const FVector2D PostAlignmentOffset = ArrangementData.SlotOffset + FVector2D(XResult.Offset, YResult.Offset); const FVector2D PostAlignmentSize = FVector2D(XResult.Size, YResult.Size); ArrangedChildren.AddWidget(AllottedGeometry.MakeChild(Slot.GetWidget(), PostAlignmentOffset, PostAlignmentSize)); }); }
int32 SWidget::FindChildUnderPosition( const FArrangedChildren& Children, const FVector2D& ArrangedSpacePosition ) { const int32 NumChildren = Children.Num(); for( int32 ChildIndex=NumChildren-1; ChildIndex >= 0; --ChildIndex ) { const FArrangedWidget& Candidate = Children[ChildIndex]; const bool bCandidateUnderCursor = // Candidate is physically under the cursor Candidate.Geometry.IsUnderLocation( ArrangedSpacePosition ); if (bCandidateUnderCursor) { return ChildIndex; } } return INDEX_NONE; }
void STrack::ArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { for ( auto TrackIter = TrackNodes.CreateConstIterator() ; TrackIter ; ++TrackIter ) { TSharedRef<STrackNode> TrackNode = (*TrackIter); if (TrackNode->bBeingDragged) { continue; } // our desired size is sum of all children // this isn't precisely correct size, but it is minimal required size TrackNode->CacheTrackGeometry(AllottedGeometry); FVector2D Offset = TrackNode->GetOffsetRelativeToParent(AllottedGeometry); FVector2D Size = TrackNode->GetSizeRelativeToParent(AllottedGeometry); ArrangedChildren.AddWidget( AllottedGeometry.MakeChild(TrackNode, Offset, Size) ); } }
void SClippingHorizontalBox::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const { // If WrapButton hasn't been initialized, that means AddWrapButton() hasn't // been called and this method isn't going to behave properly check(WrapButton.IsValid()); SHorizontalBox::OnArrangeChildren(AllottedGeometry, ArrangedChildren); // Remove children that are clipped by the allotted geometry const int32 NumChildren = ArrangedChildren.Num(); int32 IndexClippedAt = NumChildren; for (int32 ChildIdx = NumChildren - 2; ChildIdx >= 0; --ChildIdx) { const FArrangedWidget& CurWidget = ArrangedChildren[ChildIdx]; if (FMath::TruncToInt(CurWidget.Geometry.AbsolutePosition.X + CurWidget.Geometry.Size.X * CurWidget.Geometry.Scale) > FMath::TruncToInt(AllottedGeometry.AbsolutePosition.X + AllottedGeometry.Size.X * CurWidget.Geometry.Scale)) { ArrangedChildren.Remove(ChildIdx); IndexClippedAt = ChildIdx; } } if (IndexClippedAt == NumChildren) { // None of the children are being clipped, so remove the wrap button ArrangedChildren.Remove(ArrangedChildren.Num() - 1); } else { // Right align the wrap button FArrangedWidget& ArrangedButton = ArrangedChildren[ArrangedChildren.Num() - 1]; ArrangedButton.Geometry = AllottedGeometry.MakeChild(ArrangedButton.Geometry.Size, FSlateLayoutTransform(AllottedGeometry.Size - ArrangedButton.Geometry.Size)); const int32 WrapButtonXPosition = FMath::TruncToInt(ArrangedButton.Geometry.AbsolutePosition.X); // Further remove any children that the wrap button overlaps with for (int32 ChildIdx = IndexClippedAt - 1; ChildIdx >= 0; --ChildIdx) { const FArrangedWidget& CurWidget = ArrangedChildren[ChildIdx]; if (FMath::TruncToInt(CurWidget.Geometry.AbsolutePosition.X + CurWidget.Geometry.Size.X * CurWidget.Geometry.Scale) > WrapButtonXPosition) { ArrangedChildren.Remove(ChildIdx); } } } }