当前位置: 首页>>代码示例>>C++>>正文


C++ TSharedPtr::ArrangeChildren方法代码示例

本文整理汇总了C++中TSharedPtr::ArrangeChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ TSharedPtr::ArrangeChildren方法的具体用法?C++ TSharedPtr::ArrangeChildren怎么用?C++ TSharedPtr::ArrangeChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TSharedPtr的用法示例。


在下文中一共展示了TSharedPtr::ArrangeChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetGeometryForSlot

bool UCanvasPanel::GetGeometryForSlot(UCanvasPanelSlot* Slot, FGeometry& ArrangedGeometry) const
{
	if ( Slot->Content == NULL )
	{
		return false;
	}

	TSharedPtr<SConstraintCanvas> Canvas = GetCanvasWidget();
	if ( Canvas.IsValid() )
	{
		FArrangedChildren ArrangedChildren(EVisibility::All);
		Canvas->ArrangeChildren(Canvas->GetCachedGeometry(), ArrangedChildren);

		for ( int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ChildIndex++ )
		{
			if ( ArrangedChildren[ChildIndex].Widget == Slot->Content->TakeWidget() )
			{
				ArrangedGeometry = ArrangedChildren[ChildIndex].Geometry;
				return true;
			}
		}
	}

	return false;
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:25,代码来源:CanvasPanel.cpp

示例2: ArrangedChildren

FWeakWidgetPath::EPathResolutionResult::Result FWeakWidgetPath::ToWidgetPath( FWidgetPath& WidgetPath, EInterruptedPathHandling::Type InterruptedPathHandling, const FPointerEvent* PointerEvent ) const
{
	SCOPE_CYCLE_COUNTER(STAT_ToWidgetPath);

	TArray<FWidgetAndPointer> PathWithGeometries;
	TArray< TSharedPtr<SWidget> > WidgetPtrs;
		
	// Convert the weak pointers into shared pointers because we are about to do something with this path instead of just observe it.
	TSharedPtr<SWindow> TopLevelWindowPtr = Window.Pin();
	for( TArray< TWeakPtr<SWidget> >::TConstIterator SomeWeakWidgetPtr( Widgets ); SomeWeakWidgetPtr; ++SomeWeakWidgetPtr )
	{
		WidgetPtrs.Add( SomeWeakWidgetPtr->Pin() );
	}	
	
	// The path can get interrupted if some subtree of widgets disappeared, but we still maintain weak references to it.
	bool bPathUninterrupted = false;

	// For each widget in the path compute the geometry. We are able to do this starting with the top-level window because it knows its own geometry.
	if ( TopLevelWindowPtr.IsValid() )
	{
		bPathUninterrupted = true;

		FGeometry ParentGeometry = TopLevelWindowPtr->GetWindowGeometryInScreen();
		PathWithGeometries.Add( FWidgetAndPointer(
			FArrangedWidget( TopLevelWindowPtr.ToSharedRef(), ParentGeometry ),
			// @todo slate: this should be the cursor's virtual position in window space.
			TSharedPtr<FVirtualPointerPosition>() ) );
		
		FArrangedChildren ArrangedChildren(EVisibility::Visible, true);
		
		TSharedPtr<FVirtualPointerPosition> VirtualPointerPos;
		// For every widget in the vertical slice...
		for( int32 WidgetIndex = 0; bPathUninterrupted && WidgetIndex < WidgetPtrs.Num()-1; ++WidgetIndex )
		{
			TSharedPtr<SWidget> CurWidget = WidgetPtrs[WidgetIndex];

			bool bFoundChild = false;
			if ( CurWidget.IsValid() )
			{
				// Arrange the widget's children to find their geometries.
				ArrangedChildren.Empty();
				CurWidget->ArrangeChildren(ParentGeometry, ArrangedChildren);
				
				// Find the next widget in the path among the arranged children.
				for( int32 SearchIndex = 0; !bFoundChild && SearchIndex < ArrangedChildren.Num(); ++SearchIndex )
				{					
					FArrangedWidget& ArrangedWidget = ArrangedChildren[SearchIndex];

					if ( ArrangedWidget.Widget == WidgetPtrs[WidgetIndex+1] )
					{
						if( PointerEvent && !VirtualPointerPos.IsValid() )
						{
							VirtualPointerPos = CurWidget->TranslateMouseCoordinateFor3DChild( ArrangedWidget.Widget, ParentGeometry, PointerEvent->GetScreenSpacePosition(), PointerEvent->GetLastScreenSpacePosition() );
						}

						bFoundChild = true;
						// Remember the widget, the associated geometry, and the pointer position in a transformed space.
						PathWithGeometries.Add( FWidgetAndPointer(ArrangedChildren[SearchIndex], VirtualPointerPos) );
						// The next child in the vertical slice will be arranged with respect to its parent's geometry.
						ParentGeometry = ArrangedChildren[SearchIndex].Geometry;
					}
				}
			}

			bPathUninterrupted = bFoundChild;
			if (!bFoundChild && InterruptedPathHandling == EInterruptedPathHandling::ReturnInvalid )
			{
				return EPathResolutionResult::Truncated;
			}
		}			
	}
	
	WidgetPath = FWidgetPath( PathWithGeometries );
	return bPathUninterrupted ? EPathResolutionResult::Live : EPathResolutionResult::Truncated;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:75,代码来源:WidgetPath.cpp


注:本文中的TSharedPtr::ArrangeChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。