本文整理汇总了C++中FSlateRect类的典型用法代码示例。如果您正苦于以下问题:C++ FSlateRect类的具体用法?C++ FSlateRect怎么用?C++ FSlateRect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FSlateRect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnPaint
int32 SBorder::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const
{
const FSlateBrush* BrushResource = BorderImage.Get();
const bool bEnabled = ShouldBeEnabled(bParentEnabled);
const bool bShowDisabledEffect = ShowDisabledEffect.Get();
ESlateDrawEffect::Type DrawEffects = bShowDisabledEffect && !bEnabled ? ESlateDrawEffect::DisabledEffect : ESlateDrawEffect::None;
if ( BrushResource && BrushResource->DrawAs != ESlateBrushDrawType::NoDrawType )
{
FSlateDrawElement::MakeBox(
OutDrawElements,
LayerId,
AllottedGeometry.ToPaintGeometry(),
BrushResource,
MyClippingRect,
DrawEffects,
BrushResource->GetTint( InWidgetStyle ) * InWidgetStyle.GetColorAndOpacityTint() * BorderBackgroundColor.Get().GetColor( InWidgetStyle )
);
}
FWidgetStyle CompoundedWidgetStyle = FWidgetStyle(InWidgetStyle)
.BlendColorAndOpacityTint(ColorAndOpacity.Get())
.SetForegroundColor( ForegroundColor.Get() );
return SCompoundWidget::OnPaint(Args, AllottedGeometry, MyClippingRect.IntersectionWith( AllottedGeometry.GetClippingRect() ), OutDrawElements, LayerId, CompoundedWidgetStyle, bEnabled );
}
示例2: OnPaint
int32 SARResourceBarWidget::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
{
const FSlateBrush* BrushResource = new FSlateBrush();
FSlateDrawElement::MakeBox(
OutDrawElements,
LayerId,
AllottedGeometry.ToPaintGeometry(),
BrushResource,
MyClippingRect,
ESlateDrawEffect::None,
FLinearColor::Gray * 0.35f
);
if (MyAttrComp.IsValid())
{
FVector2D WidgetSize = MyClippingRect.GetSize();
//float HealthWidth = (MyAttrComp->Health * WidgetSize.X) / MyAttrComp->MaxHealth;
float HealthWidth = (CurrentValue.Get() * WidgetSize.X) / MaxValue.Get();
// Draw current health
FSlateDrawElement::MakeBox(
OutDrawElements,
LayerId,
AllottedGeometry.ToPaintGeometry(FVector2D::ZeroVector, FVector2D(HealthWidth, WidgetSize.Y)),
BrushResource,
MyClippingRect,
ESlateDrawEffect::None,
FLinearColor::Red *.9f
);
}
return SCompoundWidget::OnPaint(Args, AllottedGeometry, MyClippingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled);
}
示例3: ArrangedChildren
/** SWidget Interface */
int32 SSequencerSectionAreaView::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const
{
FArrangedChildren ArrangedChildren(EVisibility::Visible);
ArrangeChildren(AllottedGeometry, ArrangedChildren);
if( SectionAreaNode.IsValid() )
{
// Draw a region around the entire section area
FSlateDrawElement::MakeBox(
OutDrawElements,
LayerId,
AllottedGeometry.ToPaintGeometry(),
BackgroundBrush,
MyClippingRect,
ESlateDrawEffect::None,
SequencerSectionAreaConstants::BackgroundColor
);
}
for (int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex)
{
FArrangedWidget& CurWidget = ArrangedChildren[ChildIndex];
FSlateRect ChildClipRect = MyClippingRect.IntersectionWith( CurWidget.Geometry.GetClippingRect() );
const int32 CurWidgetsMaxLayerId = CurWidget.Widget->Paint( Args.WithNewParent(this), CurWidget.Geometry, ChildClipRect, OutDrawElements, LayerId+1, InWidgetStyle, ShouldBeEnabled( bParentEnabled ) );
}
return LayerId+1;
}
示例4: PaintArrangedChildren
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;
}
示例5: Concatenate
/**
* This widget was created before render transforms existed for each widget, and it chose to apply the render transform AFTER the layout transform.
* This means leveraging the render transform of FGeometry would be expensive, as we would need to use Concat(LayoutTransform, RenderTransform, Inverse(LayoutTransform).
* Instead, we maintain the old way of doing it by modifying the AllottedGeometry only during rendering to append the widget's implied RenderTransform to the existing LayoutTransform.
*/
int32 SFxWidget::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const
{
// Convert the 0..1 origin into local space extents.
const FVector2D ScaleOrigin = RenderScaleOrigin.Get() * AllottedGeometry.Size;
const FVector2D Offset = VisualOffset.Get() * AllottedGeometry.Size;
// create the render transform as a scale around ScaleOrigin and offset it by Offset.
const auto RenderTransform = Concatenate(Inverse(ScaleOrigin), RenderScale.Get(), ScaleOrigin, Offset);
// This will append the render transform to the layout transform, and we only use it for rendering.
FGeometry ModifiedGeometry = AllottedGeometry.MakeChild(AllottedGeometry.Size, RenderTransform);
FArrangedChildren ArrangedChildren(EVisibility::Visible);
this->ArrangeChildren(ModifiedGeometry, ArrangedChildren);
// There may be zero elements in this array if our child collapsed/hidden
if( ArrangedChildren.Num() > 0 )
{
// We can only have one direct descendant.
check( ArrangedChildren.Num() == 1 );
const FArrangedWidget& TheChild = ArrangedChildren[0];
// SFxWidgets are able to ignore parent clipping.
const FSlateRect ChildClippingRect = (bIgnoreClipping.Get())
? ModifiedGeometry.GetClippingRect()
: MyClippingRect.IntersectionWith(ModifiedGeometry.GetClippingRect());
FWidgetStyle CompoundedWidgetStyle = FWidgetStyle(InWidgetStyle)
.BlendColorAndOpacityTint(ColorAndOpacity.Get())
.SetForegroundColor( ForegroundColor );
return TheChild.Widget->Paint( Args.WithNewParent(this), TheChild.Geometry, ChildClippingRect, OutDrawElements, LayerId + 1, CompoundedWidgetStyle, ShouldBeEnabled( bParentEnabled ) );
}
return LayerId;
}
示例6: ArrangedChildren
int32 SDockingTabWell::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const
{
// When we are dragging a tab, it must be painted on top of the other tabs, so we cannot
// just reuse the Panel's default OnPaint.
// The TabWell has no visualization of its own; it just visualizes its child tabs.
FArrangedChildren ArrangedChildren(EVisibility::Visible);
this->ArrangeChildren(AllottedGeometry, ArrangedChildren);
// 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;
TSharedPtr<SDockTab> ForegroundTab = GetForegroundTab();
FArrangedWidget* ForegroundTabGeometry = NULL;
// Draw all inactive tabs first
for (int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex)
{
FArrangedWidget& CurWidget = ArrangedChildren[ChildIndex];
if (CurWidget.Widget == ForegroundTab)
{
ForegroundTabGeometry = &CurWidget;
}
else
{
FSlateRect ChildClipRect = MyClippingRect.IntersectionWith( CurWidget.Geometry.GetClippingRect() );
const int32 CurWidgetsMaxLayerId = CurWidget.Widget->Paint( Args.WithNewParent(this), CurWidget.Geometry, ChildClipRect, OutDrawElements, MaxLayerId, InWidgetStyle, ShouldBeEnabled( bParentEnabled ) );
MaxLayerId = FMath::Max( MaxLayerId, CurWidgetsMaxLayerId );
}
}
// Draw active tab in front
if (ForegroundTab != TSharedPtr<SDockTab>())
{
FSlateRect ChildClipRect = MyClippingRect.IntersectionWith( ForegroundTabGeometry->Geometry.GetClippingRect() );
const int32 CurWidgetsMaxLayerId = ForegroundTabGeometry->Widget->Paint( Args.WithNewParent(this), ForegroundTabGeometry->Geometry, ChildClipRect, OutDrawElements, MaxLayerId, InWidgetStyle, ShouldBeEnabled( bParentEnabled ) );
MaxLayerId = FMath::Max( MaxLayerId, CurWidgetsMaxLayerId );
}
return MaxLayerId;
}
示例7: ArrangedChildren
int32 SGridPanel::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const
{
FArrangedChildren ArrangedChildren(EVisibility::All);
this->ArrangeChildren(AllottedGeometry, ArrangedChildren);
// 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;
// We need to iterate over slots, because slots know the GridLayers. This isn't available in the arranged children.
// Some slots do not show up (they are hidden/collapsed). We need a 2nd index to skip over them.
//
// GridLayers must ensure that everything in LayerN is below LayerN+1. In other words,
// every grid layer group must start at the current MaxLayerId (similar to how SOverlay works).
int32 LastGridLayer = 0;
for (int32 ChildIndex = 0; ChildIndex < Slots.Num(); ++ChildIndex)
{
FArrangedWidget& CurWidget = ArrangedChildren[ChildIndex];
if (CurWidget.Widget->GetVisibility().IsVisible())
{
const FSlot& CurSlot = Slots[ChildIndex];
FSlateRect ChildClipRect = MyClippingRect.IntersectionWith( CurWidget.Geometry.GetClippingRect() );
if ( LastGridLayer != CurSlot.LayerParam )
{
// We starting a new grid layer group?
LastGridLayer = CurSlot.LayerParam;
// Ensure that everything here is drawn on top of
// previously drawn grid content.
LayerId = MaxLayerId+1;
}
const int32 CurWidgetsMaxLayerId = CurWidget.Widget->Paint(
Args.WithNewParent(this),
CurWidget.Geometry,
ChildClipRect,
OutDrawElements,
LayerId,
InWidgetStyle,
ShouldBeEnabled( bParentEnabled )
);
MaxLayerId = FMath::Max( MaxLayerId, CurWidgetsMaxLayerId );
}
}
//#define LAYOUT_DEBUG
#ifdef LAYOUT_DEBUG
LayerId = LayoutDebugPaint( AllottedGeometry, MyClippingRect, OutDrawElements, LayerId );
#endif
return MaxLayerId;
}
示例8: check
int32 FHittestGrid::InsertWidget( const int32 ParentHittestIndex, const EVisibility& Visibility, const FArrangedWidget& Widget, const FVector2D InWindowOffset, const FSlateRect& InClippingRect )
{
check( ParentHittestIndex < WidgetsCachedThisFrame->Num() );
// Update the FGeometry to transform into desktop space.
FArrangedWidget WindowAdjustedWidget(Widget);
WindowAdjustedWidget.Geometry.AppendTransform(FSlateLayoutTransform(InWindowOffset));
const FSlateRect WindowAdjustedRect = InClippingRect.OffsetBy(InWindowOffset);
// Remember this widget, its geometry, and its place in the logical hierarchy.
const int32 WidgetIndex = WidgetsCachedThisFrame->Add( FCachedWidget( ParentHittestIndex, WindowAdjustedWidget, WindowAdjustedRect ) );
check( WidgetIndex < WidgetsCachedThisFrame->Num() );
if (ParentHittestIndex != INDEX_NONE)
{
(*WidgetsCachedThisFrame)[ParentHittestIndex].AddChild( WidgetIndex );
}
if (Visibility.IsHitTestVisible())
{
// Mark any cell that is overlapped by this widget.
// Compute the render space clipping rect, and compute it's aligned bounds so we can insert conservatively into the hit test grid.
FSlateRect GridRelativeBoundingClipRect =
TransformRect(
Concatenate(
Inverse(WindowAdjustedWidget.Geometry.GetAccumulatedLayoutTransform()),
WindowAdjustedWidget.Geometry.GetAccumulatedRenderTransform()
),
FSlateRotatedRect(WindowAdjustedWidget.Geometry.GetClippingRect().IntersectionWith(WindowAdjustedRect))
)
.ToBoundingRect()
.OffsetBy(-GridOrigin);
// Starting and ending cells covered by this widget.
const FIntPoint UpperLeftCell = FIntPoint(
FMath::Max(0, FMath::FloorToInt(GridRelativeBoundingClipRect.Left / CellSize.X)),
FMath::Max(0, FMath::FloorToInt(GridRelativeBoundingClipRect.Top / CellSize.Y)));
const FIntPoint LowerRightCell = FIntPoint(
FMath::Min( NumCells.X-1, FMath::FloorToInt(GridRelativeBoundingClipRect.Right / CellSize.X)),
FMath::Min( NumCells.Y-1, FMath::FloorToInt(GridRelativeBoundingClipRect.Bottom / CellSize.Y)));
for (int32 XIndex=UpperLeftCell.X; XIndex <= LowerRightCell.X; ++ XIndex )
{
for(int32 YIndex=UpperLeftCell.Y; YIndex <= LowerRightCell.Y; ++YIndex)
{
CellAt(XIndex, YIndex).CachedWidgetIndexes.Add( WidgetIndex );
}
}
}
return WidgetIndex;
}
示例9: GetHandleBeingResizedFromMousePosition
int32 SSplitter::GetHandleBeingResizedFromMousePosition( float PhysicalSplitterHandleSize, float HitDetectionSplitterHandleSize, FVector2D LocalMousePos, const TArray<FLayoutGeometry>& ChildGeometries )
{
const int32 AxisIndex = (SplitterOrientation == Orient_Horizontal) ? 0 : 1;
const float HalfHitDetectionSplitterHandleSize = ( HitDetectionSplitterHandleSize / 2 );
const float HalfPhysicalSplitterHandleSize = ( PhysicalSplitterHandleSize / 2 );
// Search for the two widgets between which the cursor currently resides.
for ( int32 ChildIndex = 1; ChildIndex < ChildGeometries.Num(); ++ChildIndex )
{
FSlateRect PrevChildRect = ChildGeometries[ChildIndex - 1].GetRectInParentSpace();
FVector2D NextChildOffset = ChildGeometries[ChildIndex].GetOffsetInParentSpace();
float PrevBound = PrevChildRect.GetTopLeft().Component(AxisIndex) + PrevChildRect.GetSize().Component(AxisIndex) - HalfHitDetectionSplitterHandleSize + HalfPhysicalSplitterHandleSize;
float NextBound = NextChildOffset.Component(AxisIndex) + HalfHitDetectionSplitterHandleSize - HalfPhysicalSplitterHandleSize;
if ( LocalMousePos.Component(AxisIndex) > PrevBound && LocalMousePos.Component(AxisIndex) < NextBound )
{
return ChildIndex - 1;
}
}
return INDEX_NONE;
}
示例10: ArrangedChildren
int32 SConstraintCanvas::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const
{
FArrangedChildren ArrangedChildren(EVisibility::Visible);
this->ArrangeChildren(AllottedGeometry, ArrangedChildren);
// 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;
for (int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex)
{
FArrangedWidget& CurWidget = ArrangedChildren[ChildIndex];
FSlateRect ChildClipRect = MyClippingRect.IntersectionWith(CurWidget.Geometry.GetClippingRect());
const int32 CurWidgetsMaxLayerId = CurWidget.Widget->Paint( Args.WithNewParent(this), CurWidget.Geometry, ChildClipRect, OutDrawElements, MaxLayerId + 1, InWidgetStyle, ShouldBeEnabled(bParentEnabled));
MaxLayerId = FMath::Max(MaxLayerId, CurWidgetsMaxLayerId);
}
return MaxLayerId;
}
示例11: ArrangedChildren
int32 SSequencerTrackArea::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const
{
FArrangedChildren ArrangedChildren(EVisibility::Visible);
ArrangeChildren(AllottedGeometry, ArrangedChildren);
for (int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex)
{
FArrangedWidget& CurWidget = ArrangedChildren[ChildIndex];
FSlateRect ChildClipRect = MyClippingRect.IntersectionWith( CurWidget.Geometry.GetClippingRect() );
const int32 ThisWidgetLayerId = CurWidget.Widget->Paint( Args.WithNewParent(this), CurWidget.Geometry, ChildClipRect, OutDrawElements, LayerId + 1, InWidgetStyle, ShouldBeEnabled( bParentEnabled ) );
LayerId = FMath::Max(LayerId, ThisWidgetLayerId);
}
auto SequencerPin = SequencerWidget.Pin();
if (SequencerPin.IsValid())
{
return SequencerPin->GetEditTool().OnPaint(AllottedGeometry, MyClippingRect, OutDrawElements, LayerId + 1);
}
return LayerId;
}
示例12: ArrangedChildren
int32 SResponsiveGridPanel::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const
{
FArrangedChildren ArrangedChildren(EVisibility::All);
this->ArrangeChildren(AllottedGeometry, ArrangedChildren);
// 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;
// We need to iterate over slots, because slots know the GridLayers. This isn't available in the arranged children.
// Some slots do not show up (they are hidden/collapsed). We need a 2nd index to skip over them.
for (int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex)
{
FArrangedWidget& CurWidget = ArrangedChildren[ChildIndex];
if (CurWidget.Widget->GetVisibility().IsVisible())
{
FSlateRect ChildClipRect = MyClippingRect.IntersectionWith( CurWidget.Geometry.GetClippingRect() );
const int32 CurWidgetsMaxLayerId = CurWidget.Widget->Paint(
Args.WithNewParent(this),
CurWidget.Geometry,
ChildClipRect,
OutDrawElements,
LayerId,
InWidgetStyle,
ShouldBeEnabled( bParentEnabled )
);
MaxLayerId = FMath::Max( MaxLayerId, CurWidgetsMaxLayerId );
}
}
#ifdef LAYOUT_DEBUG
LayerId = LayoutDebugPaint( AllottedGeometry, MyClippingRect, OutDrawElements, LayerId );
#endif
return MaxLayerId;
}
示例13: check
void SProfilerThreadView::DrawUIStackNodes() const
{
// SCOPE_LOG_TIME_FUNC();
check( PaintState );
const double ThreadViewOffsetPx = PositionXMS*NumPixelsPerMillisecond;
PaintState->LayerId++;
static const FSlateBrush* BorderBrush = FEditorStyle::GetBrush( "Profiler.ThreadView.SampleBorder" );
const FColor GameThreadColor = FColorList::Red;
const FColor RenderThreadColor = FColorList::Blue;
const FColor ThreadColors[2] = {GameThreadColor, RenderThreadColor};
// Draw nodes.
for( const auto& RowOfNodes : ProfilerUIStream.LinearRowsOfNodes )
{
int32 NodeIndex = 0;
for( const auto& UIStackNode : RowOfNodes )
{
NodeIndex++;
// Check if the node is visible.
//if( UIStackNode->IsVisible() )
{
const FVector2D PositionPx = UIStackNode->GetLocalPosition( ThreadViewOffsetPx, PositionY ) * FVector2D( 1.0f, NUM_PIXELS_PER_ROW );
const FVector2D SizePx = FVector2D( FMath::Max( UIStackNode->WidthPx - 1.0, 0.0 ), NUM_PIXELS_PER_ROW );
const FSlateRect ClippedNodeRect = PaintState->LocalClippingRect.IntersectionWith( FSlateRect( PositionPx, PositionPx + SizePx ) );
// Check if this node is inside the visible area.
if( ClippedNodeRect.IsEmpty() )
{
continue;
}
FColor NodeColor = UIStackNode->bIsCombined ? ThreadColors[UIStackNode->ThreadIndex].WithAlpha( 64 ) : ThreadColors[UIStackNode->ThreadIndex].WithAlpha( 192 );
NodeColor.G += NodeIndex % 2 ? 0 : 64;
// Draw a cycle counter for this profiler UI stack node.
FSlateDrawElement::MakeBox
(
PaintState->OutDrawElements,
PaintState->LayerId,
PaintState->AllottedGeometry.ToPaintGeometry( ClippedNodeRect.GetTopLeft(), ClippedNodeRect.GetSize() ),
BorderBrush,
PaintState->AbsoluteClippingRect,
PaintState->DrawEffects,
NodeColor
);
}
}
}
// @TODO yrx 2014-04-29 Separate layer for makebox, makeshadowtext, maketext.
PaintState->LayerId++;
const float MarkerPosYOffsetPx = ((float)NUM_PIXELS_PER_ROW - PaintState->SummaryFont8Height)*0.5f;
// Draw nodes' descriptions.
for( const auto& RowOfNodes : ProfilerUIStream.LinearRowsOfNodes )
{
for( const auto& UIStackNode : RowOfNodes )
{
const FVector2D PositionPx = UIStackNode->GetLocalPosition( ThreadViewOffsetPx, PositionY ) * FVector2D( 1.0f, NUM_PIXELS_PER_ROW );
const FVector2D SizePx = FVector2D( UIStackNode->WidthPx, NUM_PIXELS_PER_ROW );
const FSlateRect ClippedNodeRect = PaintState->LocalClippingRect.IntersectionWith( FSlateRect( PositionPx, PositionPx + SizePx ) );
// Check if this node is inside the visible area.
if( ClippedNodeRect.IsEmpty() )
{
continue;
}
FString StringStatName = UIStackNode->StatName.GetPlainNameString();
FString StringStatNameWithTime = StringStatName + FString::Printf( TEXT( " (%.4f MS)" ), UIStackNode->GetDurationMS() );
if( UIStackNode->bIsCulled )
{
StringStatName += TEXT( " [C]" );
StringStatNameWithTime += TEXT( " [C]" );
}
// Update position of the text to be always visible and try to center it.
const float StatNameWidthPx = PaintState->FontMeasureService->Measure( StringStatName, PaintState->SummaryFont8 ).X;
const float StatNameWithTimeWidthPx = PaintState->FontMeasureService->Measure( StringStatNameWithTime, PaintState->SummaryFont8 ).X;
const float TextAreaWidthPx = ClippedNodeRect.GetSize().X;
bool bUseShortVersion = true;
FVector2D AdjustedPositionPx;
// Center the stat name with timing if we can.
if( TextAreaWidthPx > StatNameWithTimeWidthPx )
{
AdjustedPositionPx = FVector2D( ClippedNodeRect.Left + (TextAreaWidthPx - StatNameWithTimeWidthPx)*0.5f, PositionPx.Y + MarkerPosYOffsetPx );
bUseShortVersion = false;
}
// Center the stat name.
else if( TextAreaWidthPx > StatNameWidthPx )
{
AdjustedPositionPx = FVector2D( ClippedNodeRect.Left + (TextAreaWidthPx - StatNameWidthPx)*0.5f, PositionPx.Y + MarkerPosYOffsetPx );
}
// Move to the edge.
else
{
AdjustedPositionPx = FVector2D( ClippedNodeRect.Left, PositionPx.Y + MarkerPosYOffsetPx );
//.........这里部分代码省略.........
示例14: FSlateColorBrush
void SProfilerThreadView::DrawFramesBackgroundAndTimelines() const
{
static const FSlateColorBrush SolidWhiteBrush = FSlateColorBrush( FColorList::White );
check( PaintState );
const double ThreadViewOffsetPx = PositionXMS*NumPixelsPerMillisecond;
PaintState->LayerId++;
TArray<FVector2D> LinePoints;
// Draw frames background for easier reading.
for( const auto& ThreadNode : ProfilerUIStream.ThreadNodes )
{
if( ThreadNode.StatName == NAME_GameThread )
{
const FVector2D PositionPx = ThreadNode.GetLocalPosition( ThreadViewOffsetPx, -1.0f );
const FVector2D SizePx = FVector2D( ThreadNode.WidthPx, PaintState->Size2D().Y );
const FSlateRect ClippedFrameBackgroundRect = PaintState->LocalClippingRect.IntersectionWith( FSlateRect( PositionPx, PositionPx + SizePx ) );
FSlateDrawElement::MakeBox
(
PaintState->OutDrawElements,
PaintState->LayerId,
PaintState->AllottedGeometry.ToPaintGeometry( ClippedFrameBackgroundRect.GetTopLeft(), ClippedFrameBackgroundRect.GetSize() ),
&SolidWhiteBrush,
PaintState->AbsoluteClippingRect,
PaintState->DrawEffects,
ThreadNode.FrameIndex % 2 ? FColorList::White.WithAlpha( 64 ) : FColorList::White.WithAlpha( 128 )
);
// Check if this frame time marker is inside the visible area.
const float LocalPositionXPx = PositionPx.X + SizePx.X;
if( LocalPositionXPx < 0.0f || LocalPositionXPx > PaintState->Size2D().X )
{
continue;
}
LinePoints.Reset( 2 );
LinePoints.Add( FVector2D( LocalPositionXPx, 0.0f ) );
LinePoints.Add( FVector2D( LocalPositionXPx, PaintState->Size2D().Y ) );
// Draw frame time marker.
FSlateDrawElement::MakeLines
(
PaintState->OutDrawElements,
PaintState->LayerId,
PaintState->AllottedGeometry.ToPaintGeometry(),
LinePoints,
PaintState->AbsoluteClippingRect,
PaintState->DrawEffects,
PaintState->WidgetStyle.GetColorAndOpacityTint() * FColorList::SkyBlue,
false
);
}
}
PaintState->LayerId++;
const double PositionXStartPx = FMath::TruncToFloat( PositionXMS*NumPixelsPerMillisecond / (double)NUM_PIXELS_BETWEEN_TIMELINE )*(double)NUM_PIXELS_BETWEEN_TIMELINE;
const double PositionXEndPx = PositionXStartPx + RangeXMS*NumPixelsPerMillisecond;
for( double TimelinePosXPx = PositionXStartPx; TimelinePosXPx < PositionXEndPx; TimelinePosXPx += (double)NUM_PIXELS_BETWEEN_TIMELINE )
{
LinePoints.Reset( 2 );
LinePoints.Add( FVector2D( TimelinePosXPx - ThreadViewOffsetPx, 0.0f ) );
LinePoints.Add( FVector2D( TimelinePosXPx - ThreadViewOffsetPx, PaintState->Size2D().Y ) );
// Draw time line.
FSlateDrawElement::MakeLines
(
PaintState->OutDrawElements,
PaintState->LayerId,
PaintState->AllottedGeometry.ToPaintGeometry(),
LinePoints,
PaintState->AbsoluteClippingRect,
PaintState->DrawEffects,
PaintState->WidgetStyle.GetColorAndOpacityTint() * FColorList::LimeGreen,
false
);
}
}
示例15: ShutDownEditor
void FMainFrameHandler::ShutDownEditor()
{
FEditorDelegates::OnShutdownPostPackagesSaved.Broadcast();
// Any pending autosaves should not happen. A tick will go by before the editor shuts down and we want to avoid auto-saving during this time.
GUnrealEd->GetPackageAutoSaver().ResetAutoSaveTimer();
GEditor->RequestEndPlayMap();
// End any play on console/PC games still happening
GEditor->EndPlayOnLocalPc();
// Cancel any current Launch On in progress
GEditor->CancelPlayingViaLauncher();
TSharedPtr<SWindow> RootWindow = RootWindowPtr.Pin();
// Save root window placement so we can restore it.
if (RootWindow.IsValid())
{
FSlateRect WindowRect = RootWindow->GetNonMaximizedRectInScreen();
FRootWindowLocation RootWindowLocation(FVector2D(WindowRect.Left, WindowRect.Top), WindowRect.GetSize(), RootWindow->IsWindowMaximized());
RootWindowLocation.SaveToIni();
}
// Save the visual state of the editor before we even
// ask whether we can shut down.
TSharedRef<FGlobalTabmanager> GlobalTabManager = FGlobalTabmanager::Get();
if (FUnrealEdMisc::Get().IsSavingLayoutOnClosedAllowed())
{
GlobalTabManager->SaveAllVisualState();
}
else
{
GConfig->EmptySection(TEXT("EditorLayouts"), *GEditorLayoutIni);
}
// Clear the callback for destructionfrom the main tab; otherwise it will re-enter this shutdown function.
if (MainTabPtr.IsValid())
{
MainTabPtr.Pin()->SetOnTabClosed(SDockTab::FOnTabClosedCallback());
}
// Inform the AssetEditorManager that the editor is exiting so that it may save open assets
// and report usage stats
FAssetEditorManager::Get().OnExit();
if (RootWindow.IsValid())
{
RootWindow->SetRequestDestroyWindowOverride(FRequestDestroyWindowOverride());
RootWindow->RequestDestroyWindow();
}
// Save out any config settings for the editor so they don't get lost
GEditor->SaveConfig();
GLevelEditorModeTools().SaveConfig();
// Delete user settings, if requested
if (FUnrealEdMisc::Get().IsDeletePreferences())
{
IFileManager::Get().Delete(*GEditorPerProjectIni);
}
// Take a screenshot of this project for the project browser
if (FApp::HasGameName())
{
const FString ExistingBaseFilename = FString(FApp::GetGameName()) + TEXT(".png");
const FString ExistingScreenshotFilename = FPaths::Combine(*FPaths::GameDir(), *ExistingBaseFilename);
// If there is already a screenshot, no need to take an auto screenshot
if (!FPaths::FileExists(ExistingScreenshotFilename))
{
const FString ScreenShotFilename = FPaths::Combine(*FPaths::GameSavedDir(), TEXT("AutoScreenshot.png"));
FViewport* Viewport = GEditor->GetActiveViewport();
if (Viewport)
{
UThumbnailManager::CaptureProjectThumbnail(Viewport, ScreenShotFilename, false);
}
}
}
// Shut down the editor
// NOTE: We can't close the editor from within this stack frame as it will cause various DLLs
// (such as MainFrame) to become unloaded out from underneath the code pointer. We'll shut down
// as soon as it's safe to do so.
// Note this is the only place in slate that should be calling QUIT_EDITOR
GEngine->DeferredCommands.Add(TEXT("QUIT_EDITOR"));
}