You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Introduces the concept of "Active Ticking" to allow Slate to go to sleep when there is no need to update the UI.
While asleep, Slate will skip the Tick & Paint pass for that frame entirely.
- There are TWO ways to "wake" Slate and cause a Tick/Paint pass:
1. Provide some sort of input (mouse movement, clicks, and key presses). Slate will always tick when the user is active.
- Therefore, if the logic in a given widget's Tick is only relevant in response to user action, there is no need to register an active tick.
2. Register an Active Tick. Currently this is an all-or-nothing situation, so if a single active tick needs to execute, all of Slate will be ticked.
- The purpose of an Active Tick is to allow a widget to "drive" Slate and guarantee a Tick/Paint pass in the absence of any user action.
- Examples include animation, async operations that update periodically, progress updates, loading bars, etc.
- An empty active tick is registered for viewports when they are real-time, so game project widgets are unaffected by this change and should continue to work as before.
- An Active Tick is registered by creating an FWidgetActiveTickDelegate and passing it to SWidget::RegisterActiveTick()
- There are THREE ways to unregister an active tick:
1. Return EActiveTickReturnType::StopTicking from the active tick function
2. Pass the FActiveTickHandle returned by RegisterActiveTick() to SWidget::UnregisterActiveTick()
3. Destroy the widget responsible for the active tick
- Sleeping is currently disabled, can be enabled with Slate.AllowSlateToSleep cvar
- There is currently a little buffer time during which Slate continues to tick following any input. Long-term, this is planned to be removed.
- The duration of the buffer can be adjusted using Slate.SleepBufferPostInput cvar (defaults to 1.0f)
- The FCurveSequence API has been updated to work with the active tick system
- Playing a curve sequence now requires that you pass the widget being animated by the sequence
- The active tick will automatically be registered on behalf of the widget and unregister when the sequence is complete
- GetLerpLooping() has been removed. Instead, pass true as the second param to Play() to indicate that the animation will loop. This causes the active tick to be registered indefinitely until paused or jumped to the start/end.
[CL 2391669 by Dan Hertzka in Main branch]
339 lines
9.4 KiB
C++
339 lines
9.4 KiB
C++
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
#include "GraphEditorCommon.h"
|
|
#include "SGraphNodeDocumentation.h"
|
|
#include "IDocumentation.h"
|
|
#include "SLevelOfDetailBranchNode.h"
|
|
#include "TutorialMetaData.h"
|
|
#include "SInlineEditableTextBlock.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "SGraphNodeDocumentation"
|
|
|
|
namespace GraphNodeDocumentationDefs
|
|
{
|
|
/** Size of the hit result border for the window borders */
|
|
static const FSlateRect HitTestBorderSize( 10, 10, 8, 14 );
|
|
|
|
/** Minimum size for node */
|
|
static const FVector2D MinNodeSize( 200.0f, 10.0f );
|
|
|
|
/** Maximum size for node */
|
|
static const FVector2D MaximumNodeSize( 4000.0f, 10.0f );
|
|
|
|
/** Default documentation content size */
|
|
static const FVector2D DefaultContentSize( 600.0f, 400.0f );
|
|
|
|
/** Placeholder documentation content size */
|
|
static const FVector2D PlaceholderContentSize( 380.0f, 45.0f );
|
|
|
|
/** Default content border */
|
|
static const FMargin DefaultContentBorder( 4.0f, 2.0f, 4.0f, 10.0f );
|
|
|
|
/** Line wrap adjustment from node width, to account for scroll bar */
|
|
static const float LineWrapAdjustment = 20.f;
|
|
}
|
|
|
|
void SGraphNodeDocumentation::Construct( const FArguments& InArgs, UEdGraphNode* InNode )
|
|
{
|
|
GraphNode = InNode;
|
|
|
|
// Set up animation
|
|
{
|
|
ZoomCurve = SpawnAnim.AddCurve( 0, 0.1f );
|
|
FadeCurve = SpawnAnim.AddCurve( 0.15f, 0.15f );
|
|
}
|
|
UserSize.X = InNode->NodeWidth;
|
|
UserSize.Y = InNode->NodeHeight;
|
|
bUserIsDragging = false;
|
|
UpdateGraphNode();
|
|
}
|
|
|
|
void SGraphNodeDocumentation::UpdateGraphNode()
|
|
{
|
|
// No pins in a document box
|
|
InputPins.Empty();
|
|
OutputPins.Empty();
|
|
|
|
// Avoid standard box model too
|
|
RightNodeBox.Reset();
|
|
LeftNodeBox.Reset();
|
|
|
|
TSharedPtr<SWidget> ErrorText = SetupErrorReporting();
|
|
|
|
// Create Node Title
|
|
TSharedPtr<SNodeTitle> NodeTitle = SNew( SNodeTitle, GraphNode );
|
|
|
|
// Setup a meta tag for this node
|
|
FGraphNodeMetaData TagMeta(TEXT("Graphnode"));
|
|
PopulateMetaTag(&TagMeta);
|
|
|
|
TSharedRef<SOverlay> DefaultTitleAreaWidget =
|
|
SNew( SOverlay )
|
|
.AddMetaData<FGraphNodeMetaData>(TagMeta)
|
|
+SOverlay::Slot()
|
|
[
|
|
SNew( SImage )
|
|
.Image( FEditorStyle::GetBrush( "Graph.Node.TitleGloss" ))
|
|
]
|
|
+SOverlay::Slot()
|
|
.HAlign( HAlign_Left )
|
|
.VAlign( VAlign_Center )
|
|
[
|
|
SNew( SBorder )
|
|
.BorderImage( FEditorStyle::GetBrush( "Graph.Node.ColorSpill" ))
|
|
.Padding( FMargin( 10, 5, 30, 3 ))
|
|
.BorderBackgroundColor( this, &SGraphNodeDocumentation::GetNodeTitleColor )
|
|
[
|
|
SNew( SVerticalBox )
|
|
+SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
[
|
|
SAssignNew( InlineEditableText,SInlineEditableTextBlock )
|
|
.Style( FEditorStyle::Get(), "Graph.Node.NodeTitleInlineEditableText" )
|
|
.Text( this, &SGraphNodeDocumentation::GetDocumentationTitle )
|
|
]
|
|
+SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
[
|
|
NodeTitle.ToSharedRef()
|
|
]
|
|
]
|
|
]
|
|
+SOverlay::Slot()
|
|
.VAlign( VAlign_Top )
|
|
[
|
|
SNew( SBorder )
|
|
.Visibility( EVisibility::HitTestInvisible )
|
|
.BorderImage( FEditorStyle::GetBrush( "Graph.Node.TitleHighlight" ))
|
|
[
|
|
SNew( SSpacer )
|
|
.Size( FVector2D( 20, 20 ))
|
|
]
|
|
];
|
|
|
|
// Create Node content
|
|
SAssignNew( TitleBar, SLevelOfDetailBranchNode )
|
|
.UseLowDetailSlot( this, &SGraphNodeDocumentation::UseLowDetailNodeTitles )
|
|
.LowDetail()
|
|
[
|
|
SNew(SBorder)
|
|
.BorderImage( FEditorStyle::GetBrush( "Graph.Node.ColorSpill" ))
|
|
.BorderBackgroundColor( this, &SGraphNodeDocumentation::GetNodeTitleColor )
|
|
]
|
|
.HighDetail()
|
|
[
|
|
DefaultTitleAreaWidget
|
|
];
|
|
|
|
// Create Documentation Page
|
|
TSharedPtr<SWidget> DocumentationPage = CreateDocumentationPage();
|
|
|
|
TSharedPtr<SVerticalBox> InnerVerticalBox;
|
|
GetOrAddSlot( ENodeZone::Center )
|
|
.HAlign( HAlign_Center )
|
|
.VAlign( VAlign_Center )
|
|
[
|
|
SNew( SVerticalBox )
|
|
+SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.HAlign( HAlign_Fill )
|
|
.VAlign( VAlign_Fill )
|
|
[
|
|
SNew( SBorder )
|
|
.BorderImage( FEditorStyle::GetBrush( "Graph.Node.Body" ))
|
|
.Visibility( this, &SGraphNodeDocumentation::GetWidgetVisibility )
|
|
.Padding( 0.f )
|
|
[
|
|
SAssignNew( InnerVerticalBox, SVerticalBox )
|
|
+SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.HAlign( HAlign_Fill )
|
|
.VAlign( VAlign_Top )
|
|
[
|
|
TitleBar.ToSharedRef()
|
|
]
|
|
+SVerticalBox::Slot()
|
|
.HAlign( HAlign_Left )
|
|
.VAlign( VAlign_Top )
|
|
[
|
|
DocumentationPage.ToSharedRef()
|
|
]
|
|
]
|
|
]
|
|
];
|
|
}
|
|
|
|
FText SGraphNodeDocumentation::GetDocumentationTitle() const
|
|
{
|
|
return FText::Format( LOCTEXT( "DocumentationNode", "UDN - {0}" ), FText::FromString( GraphNode->GetDocumentationExcerptName() ));
|
|
}
|
|
|
|
TSharedPtr<SWidget> SGraphNodeDocumentation::CreateDocumentationPage()
|
|
{
|
|
TSharedPtr<SWidget> DocumentationWidget;
|
|
|
|
if( IDocumentation::Get()->PageExists( GraphNode->GetDocumentationLink() ))
|
|
{
|
|
TSharedRef< IDocumentationPage > DocumentationPage = IDocumentation::Get()->GetPage( GraphNode->GetDocumentationLink(), NULL );
|
|
TMap< FString, FString > InVariables;
|
|
FExcerpt DesiredExcerpt( GraphNode->GetDocumentationExcerptName(), SNullWidget::NullWidget, InVariables, 0 );
|
|
|
|
// Set attributes to control documentation WrapAt and optional width
|
|
DocumentationPage->SetTextWrapAt( TAttribute<float>( this, &SGraphNodeDocumentation::GetDocumentationWrapWidth ) );
|
|
|
|
if( DocumentationPage->GetExcerptContent( DesiredExcerpt ))
|
|
{
|
|
// Create Content
|
|
SAssignNew( DocumentationWidget, SBox )
|
|
.WidthOverride( this, &SGraphNodeDocumentation::GetContentWidth )
|
|
.HeightOverride( this, &SGraphNodeDocumentation::GetContentHeight )
|
|
[
|
|
SAssignNew( ContentWidget, SVerticalBox )
|
|
+SVerticalBox::Slot()
|
|
.Padding( GraphNodeDocumentationDefs::DefaultContentBorder )
|
|
[
|
|
SNew( SBorder )
|
|
.HAlign( HAlign_Left )
|
|
.Content()
|
|
[
|
|
SNew( SScrollBox )
|
|
+SScrollBox::Slot()
|
|
[
|
|
DesiredExcerpt.Content.ToSharedRef()
|
|
]
|
|
]
|
|
]
|
|
];
|
|
// Find Maximum Content area for resizing
|
|
UserSize = GraphNodeDocumentationDefs::MaximumNodeSize;
|
|
ContentWidget->SlatePrepass();
|
|
DocumentationSize = ContentWidget->GetDesiredSize();
|
|
if( GraphNode->NodeWidth != 0.f && GraphNode->NodeHeight != 0.f )
|
|
{
|
|
// restore node size
|
|
UserSize.X = GraphNode->NodeWidth;
|
|
UserSize.Y = GraphNode->NodeHeight;
|
|
}
|
|
else
|
|
{
|
|
// set initial size
|
|
UserSize = GraphNodeDocumentationDefs::DefaultContentSize;
|
|
ContentWidget->SlatePrepass();
|
|
UserSize = ContentWidget->GetDesiredSize();
|
|
}
|
|
}
|
|
}
|
|
if( !DocumentationWidget.IsValid() )
|
|
{
|
|
// Create Placeholder
|
|
SAssignNew( DocumentationWidget, SBox )
|
|
.WidthOverride( this, &SGraphNodeDocumentation::GetContentWidth )
|
|
.HeightOverride( this, &SGraphNodeDocumentation::GetContentHeight )
|
|
[
|
|
SAssignNew( ContentWidget, SVerticalBox )
|
|
+SVerticalBox::Slot()
|
|
.Padding( GraphNodeDocumentationDefs::DefaultContentBorder )
|
|
[
|
|
SNew( SBorder )
|
|
.HAlign( HAlign_Left )
|
|
.Content()
|
|
[
|
|
SNew( SScrollBox )
|
|
+SScrollBox::Slot()
|
|
[
|
|
SNew( STextBlock )
|
|
.WrapTextAt( this, &SGraphNodeDocumentation::GetDocumentationWrapWidth )
|
|
.Text( LOCTEXT( "InvalidContentNotification", "No valid content to display.Please choose a valid link and excerpt in the details panel" ))
|
|
]
|
|
]
|
|
]
|
|
];
|
|
// Find Maximum Content area for resizing
|
|
UserSize = GraphNodeDocumentationDefs::PlaceholderContentSize;
|
|
DocumentationSize = GraphNodeDocumentationDefs::PlaceholderContentSize;
|
|
}
|
|
// Cache link/excerpt this widget was based on
|
|
CachedDocumentationLink = GraphNode->GetDocumentationLink();
|
|
CachedDocumentationExcerpt = GraphNode->GetDocumentationExcerptName();
|
|
|
|
return DocumentationWidget;
|
|
}
|
|
|
|
FOptionalSize SGraphNodeDocumentation::GetContentWidth() const
|
|
{
|
|
return UserSize.X;
|
|
}
|
|
|
|
FOptionalSize SGraphNodeDocumentation::GetContentHeight() const
|
|
{
|
|
return UserSize.Y;
|
|
}
|
|
|
|
float SGraphNodeDocumentation::GetDocumentationWrapWidth() const
|
|
{
|
|
return UserSize.X - GraphNodeDocumentationDefs::LineWrapAdjustment;
|
|
}
|
|
|
|
FVector2D SGraphNodeDocumentation::ComputeDesiredSize() const
|
|
{
|
|
return FVector2D( UserSize.X, UserSize.Y + GetTitleBarHeight() );
|
|
}
|
|
|
|
FVector2D SGraphNodeDocumentation::GetNodeMinimumSize() const
|
|
{
|
|
return GraphNodeDocumentationDefs::MinNodeSize;
|
|
}
|
|
|
|
FVector2D SGraphNodeDocumentation::GetNodeMaximumSize() const
|
|
{
|
|
return FVector2D( DocumentationSize.X, ContentWidget->GetDesiredSize().Y );
|
|
}
|
|
|
|
FReply SGraphNodeDocumentation::OnMouseWheel( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent )
|
|
{
|
|
return FReply::Unhandled();
|
|
}
|
|
|
|
EVisibility SGraphNodeDocumentation::GetWidgetVisibility() const
|
|
{
|
|
return ChildWidgetVisibility;
|
|
}
|
|
|
|
float SGraphNodeDocumentation::GetTitleBarHeight() const
|
|
{
|
|
return TitleBar.IsValid() ? TitleBar->GetDesiredSize().Y : 0.f;
|
|
}
|
|
|
|
FSlateRect SGraphNodeDocumentation::GetHitTestingBorder( float InverseZoomFactor ) const
|
|
{
|
|
return GraphNodeDocumentationDefs::HitTestBorderSize;
|
|
}
|
|
|
|
void SGraphNodeDocumentation::Tick( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime )
|
|
{
|
|
if( !bUserIsDragging )
|
|
{
|
|
ChildWidgetVisibility = EVisibility::HitTestInvisible;
|
|
FVector2D LocalMouseCoordinates = AllottedGeometry.AbsoluteToLocal( FSlateApplication::Get().GetCursorPos() );
|
|
|
|
EResizableWindowZone CurrMouseZone = FindMouseZone( LocalMouseCoordinates );
|
|
|
|
if( CurrMouseZone == CRWZ_InWindow )
|
|
{
|
|
ChildWidgetVisibility = EVisibility::Visible;
|
|
}
|
|
}
|
|
// Check Cached Links to determine if we need to update the documention link/excerpt
|
|
if( CachedDocumentationLink != GraphNode->GetDocumentationLink() ||
|
|
CachedDocumentationExcerpt != GraphNode->GetDocumentationExcerptName())
|
|
{
|
|
GraphNode->NodeWidth = 0.f;
|
|
GraphNode->NodeHeight = 0.f;
|
|
UpdateGraphNode();
|
|
}
|
|
}
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
#undef LOCTEXT_NAMESPACE |