Files
UnrealEngineUWP/Engine/Source/Editor/IntroTutorials/Private/STutorialContent.h

274 lines
9.8 KiB
C
Raw Normal View History

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#pragma once
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
#include "CoreMinimal.h"
#include "Misc/Attribute.h"
#include "Layout/Visibility.h"
#include "Layout/Geometry.h"
#include "Animation/CurveSequence.h"
#include "Styling/SlateColor.h"
#include "Input/Reply.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Widgets/SWidget.h"
#include "Widgets/SCompoundWidget.h"
#include "EditorTutorial.h"
#include "STutorialOverlay.h"
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
class FPaintArgs;
class FSlateWindowElementList;
class IDocumentationPage;
struct FSlateBrush;
/**
* The widget which displays 'floating' content
*/
class STutorialContent : public SCompoundWidget
{
SLATE_BEGIN_ARGS( STutorialContent )
{
_Visibility = EVisibility::SelfHitTestInvisible;
_IsStandalone = false;
}
/** Alignment of content relative to widget, note "Fill" is not supported */
SLATE_ATTRIBUTE(EVerticalAlignment, VAlign)
/** Alignment of content relative to widget, note "Fill" is not supported */
SLATE_ATTRIBUTE(EHorizontalAlignment, HAlign)
/** Offset form the widget we annotate */
SLATE_ATTRIBUTE(FVector2D, Offset)
/** Whether this a standalone widget (with its own close button) or part of a group of other widgets, paired with tutorial navigation */
SLATE_ARGUMENT(bool, IsStandalone)
/** Delegate fired when the close button is clicked */
SLATE_EVENT(FSimpleDelegate, OnClosed)
/** Delegate fired when the back button is clicked */
SLATE_EVENT(FSimpleDelegate, OnBackClicked)
/** Delegate fired when the home button is clicked */
SLATE_EVENT(FSimpleDelegate, OnHomeClicked)
/** Delegate fired when the next button is clicked */
SLATE_EVENT(FSimpleDelegate, OnNextClicked)
/** Attribute controlling enabled state of back functionality */
SLATE_ATTRIBUTE(bool, IsBackEnabled)
/** Attribute controlling enabled state of home functionality */
SLATE_ATTRIBUTE(bool, IsHomeEnabled)
/** Attribute controlling enabled state of next functionality */
SLATE_ATTRIBUTE(bool, IsNextEnabled)
/** Where text should be wrapped */
SLATE_ARGUMENT(float, WrapTextAt)
/** Anchor if required */
SLATE_ARGUMENT(FTutorialContentAnchor, Anchor)
/** Whether we can show full window content in this overlay (i.e. in the same window as the navigation controls) */
SLATE_ARGUMENT(bool, AllowNonWidgetContent)
/** Delegate for querying whether a widget was drawn */
SLATE_EVENT(FOnWasWidgetDrawn, OnWasWidgetDrawn)
/** Text to display on next/home button */
SLATE_ATTRIBUTE(FText, NextButtonText)
/** Text to display on back button */
SLATE_ATTRIBUTE(FText, BackButtonText)
SLATE_END_ARGS()
void Construct(const FArguments& InArgs, UEditorTutorial* InTutorial, const FTutorialContent& InContent);
/** SWidget implementation */
---- Merging with SlateDev branch ---- 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]
2014-12-17 16:07:57 -05:00
virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
virtual FReply OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnMouseButtonDoubleClick(const FGeometry& InMyGeometry, const FPointerEvent& InMouseEvent) override;
/** Helper function to generate widgets from an FTutorialContent struct */
static TSharedRef<SWidget> GenerateContentWidget(const FTutorialContent& InContent, TSharedPtr<IDocumentationPage>& OutDocumentationPage, const TAttribute<FText>& InHighlightText = TAttribute<FText>(), bool bAutoWrapText = true, float WrapTextAt = 0.0f);
/** Handle repositioning the widget */
FVector2D GetPosition() const;
/** Handle resizing the widget */
FVector2D GetSize() const;
/** Delegate handler called back from the overlay paint routines to flag whether we should paint as well (i.e. if this widget content is highlighted for the current stage) */
void HandlePaintNamedWidget(TSharedRef<SWidget> InWidget, const FGeometry& InGeometry);
/** Called back from the overlay paint routines to reset the flag we check for painting with */
void HandleResetNamedWidget();
/** Handle caching window size - called back from overlay paint routine */
void HandleCacheWindowSize(const FVector2D& InWindowSize);
private:
/** Get the visibility of this content */
EVisibility GetVisibility() const;
/** Handle close button clicked - forward to delegate */
FReply OnCloseButtonClicked();
/** Get close button visibility - varies depending on whether we are standalone or not */
EVisibility GetCloseButtonVisibility() const;
/** Get menu button visibility - varies depending on whether we are standalone or not */
EVisibility GetMenuButtonVisibility() const;
/** Alter the background color depending on hover state */
FSlateColor GetBackgroundColor() const;
/** Get zoom level padding for content (animated for intro) */
float GetAnimatedZoom() const;
/** Get inverse zoom level padding for content - needed because rich text content doesnt scale well */
float GetInverseAnimatedZoom() const;
/** Get the content for the navigation menu */
TSharedRef<SWidget> HandleGetMenuContent();
/** Delegate handler for exiting the tutorial */
void HandleExitSelected();
/** Delegate handler for going to the previous stage of the tutorial (From dropdown menu) */
void HandleBackSelected();
/** Delegate handler for going to the next stage of the tutorial (From dropdown menu) */
void HandleNextSelected();
/** Delegate handler for restarting the tutorial */
void HandleRestartSelected();
/** Delegate handler for exiting the tutorial to the browser */
void HandleBrowseSelected();
/** Delegate handler for going to the next stage of the tutorial (From button) */
FReply HandleNextClicked();
/** Delegate handler for going to the previous stage of the tutorial (From button) */
FReply HandleBackButtonClicked();
/** Delegate handler allowing us to change the brush of the 'next' button depending on context */
const FSlateBrush* GetNextButtonBrush() const;
/** Delegate handler allowing us to change the tootlip of the 'next' button depending on context */
FText GetNextButtonTooltip() const;
/** Change next button color based on hover state */
FText GetNextButtonLabel() const;
/** We need to override the border ourselves, rather than let the button handle it, as we are using a larger apparent hitbox */
const FSlateBrush* GetNextButtonBorder() const;
---- Merging with SlateDev branch ---- 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]
2014-12-17 16:07:57 -05:00
/** Helper to determine the proper animation values for the border pulse */
void GetAnimationValues(float& OutAlphaFactor, float& OutPulseFactor, FLinearColor& OutShadowTint, FLinearColor& OutBorderTint) const;
/** Delegate handler allowing us to change the brush of the 'back' button depending on context */
const FSlateBrush* GetBackButtonBrush() const;
/** Delegate handler allowing us to change the tootlip of the 'back' button depending on context */
FText GetBackButtonTooltip() const;
/** Change back button color based on hover state */
FText GetBackButtonLabel() const;
/** We need to override the border ourselves, rather than let the button handle it, as we are using a larger apparent hitbox */
const FSlateBrush* GetBackButtonBorder() const;
/* Get the visibilty of the back button */
EVisibility GetBackButtonVisibility() const;
private:
/** Copy of the window size we were last draw at */
FVector2D CachedWindowSize;
/** Copy of the geometry our widget was last drawn with */
FGeometry CachedGeometry;
/** Copy of the geometry our content was last drawn with */
mutable FGeometry CachedContentGeometry;
/** Container for widget content */
TSharedPtr<SWidget> ContentWidget;
/** Alignment of content relative to widget, note "Fill" is not supported */
TAttribute<EVerticalAlignment> VerticalAlignment;
/** Alignment of content relative to widget, note "Fill" is not supported */
TAttribute<EHorizontalAlignment> HorizontalAlignment;
/** Offset form the widget we annotate */
TAttribute<FVector2D> WidgetOffset;
/** Copy of the anchor for this tutorial content */
FTutorialContentAnchor Anchor;
/** Whether this a standalone widget (with its own close button) or part of a group of other widgets, paired with tutorial navigation */
bool bIsStandalone;
/** Whether this overlay is currently visible */
bool bIsVisible;
/** Delegate fired when the close button is clicked */
FSimpleDelegate OnClosed;
/** Delegate fired when the next button is clicked */
FSimpleDelegate OnNextClicked;
/** Delegate fired when the home button is clicked */
FSimpleDelegate OnHomeClicked;
/** Delegate fired when the back button is clicked */
FSimpleDelegate OnBackClicked;
/** Attribute controlling enabled state of back functionality */
TAttribute<bool> IsBackEnabled;
/** Attribute controlling enabled state of home functionality */
TAttribute<bool> IsHomeEnabled;
/** Attribute controlling enabled state of next functionality */
TAttribute<bool> IsNextEnabled;
/** Animation curves for displaying border */
FCurveSequence BorderPulseAnimation;
FCurveSequence BorderIntroAnimation;
/** Animation curve for displaying content */
FCurveSequence ContentIntroAnimation;
/** Documentation page reference to use if we are displaying a UDN doc - we need this otherwise the page will be freed */
TSharedPtr<IDocumentationPage> DocumentationPage;
/** The tutorial we are referencing */
TWeakObjectPtr<UEditorTutorial> Tutorial;
/** Next button widget */
TSharedPtr<SWidget> NextButton;
/** Back button widget */
TSharedPtr<SWidget> BackButton;
/** Whether we can show full window content in this overlay (i.e. in the same window as the navigation controls) */
bool bAllowNonWidgetContent;
/** Delegate for querying whether a widget was drawn */
FOnWasWidgetDrawn OnWasWidgetDrawn;
/** Text for next/home button */
TAttribute<FText> NextButtonText;
/** Text for next/home button */
TAttribute<FText> BackButtonText;
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
};