2014-08-05 09:04:35 -04:00
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
# pragma once
# include "IDocumentation.h"
# include "IDocumentationPage.h"
# include "EditorTutorial.h"
2014-09-22 09:42:52 -04:00
# include "STutorialOverlay.h"
2014-08-05 09:04:35 -04:00
/**
* 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 */
2014-09-22 09:42:52 -04:00
SLATE_EVENT ( FSimpleDelegate , OnClosed )
2014-08-05 09:04:35 -04:00
2014-09-16 10:26:36 -04:00
/** Delegate fired when the back button is clicked */
2014-09-22 09:42:52 -04:00
SLATE_EVENT ( FSimpleDelegate , OnBackClicked )
2014-09-16 10:26:36 -04:00
/** Delegate fired when the home button is clicked */
2014-09-22 09:42:52 -04:00
SLATE_EVENT ( FSimpleDelegate , OnHomeClicked )
2014-09-16 10:26:36 -04:00
/** Delegate fired when the next button is clicked */
2014-09-22 09:42:52 -04:00
SLATE_EVENT ( FSimpleDelegate , OnNextClicked )
2014-09-16 10:26:36 -04:00
/** 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 )
2014-08-05 09:04:35 -04:00
/** Where text should be wrapped */
SLATE_ARGUMENT ( float , WrapTextAt )
/** Anchor if required */
SLATE_ARGUMENT ( FTutorialContentAnchor , Anchor )
2014-09-18 13:30:40 -04:00
/** Whether we can show full window content in this overlay (i.e. in the same window as the navigation controls) */
SLATE_ARGUMENT ( bool , AllowNonWidgetContent )
2014-09-22 09:42:52 -04:00
/** Delegate for querying whether a widget was drawn */
SLATE_EVENT ( FOnWasWidgetDrawn , OnWasWidgetDrawn )
2014-09-30 11:37:26 -04:00
/** Text to display on next/home button */
SLATE_ATTRIBUTE ( FText , NextButtonText )
2014-08-05 09:04:35 -04:00
SLATE_END_ARGS ( )
2014-09-16 10:26:36 -04:00
void Construct ( const FArguments & InArgs , UEditorTutorial * InTutorial , const FTutorialContent & InContent ) ;
2014-08-05 09:04:35 -04:00
/** SWidget implementation */
virtual int32 OnPaint ( const FPaintArgs & Args , const FGeometry & AllottedGeometry , const FSlateRect & MyClippingRect , FSlateWindowElementList & OutDrawElements , int32 LayerId , const FWidgetStyle & InWidgetStyle , bool bParentEnabled ) const override ;
2014-09-18 08:10:29 -04:00
virtual FReply OnMouseButtonUp ( const FGeometry & MyGeometry , const FPointerEvent & MouseEvent ) override ;
2014-09-29 10:05:13 -04:00
virtual FReply OnMouseButtonDown ( const FGeometry & MyGeometry , const FPointerEvent & MouseEvent ) override ;
virtual FReply OnMouseButtonDoubleClick ( const FGeometry & InMyGeometry , const FPointerEvent & InMouseEvent ) override ;
2014-08-05 09:04:35 -04:00
/** Helper function to generate widgets from an FTutorialContent struct */
2014-10-13 06:46:06 -04:00
static TSharedRef < SWidget > GenerateContentWidget ( const FTutorialContent & InContent , TSharedPtr < IDocumentationPage > & OutDocumentationPage , const TAttribute < FText > & InHighlightText = TAttribute < FText > ( ) , bool bAutoWrapText = true , float WrapTextAt = 0.0f ) ;
2014-08-05 09:04:35 -04:00
/** 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 ;
2014-09-16 10:26:36 -04:00
/** Get menu button visibility - varies depending on whether we are standalone or not */
EVisibility GetMenuButtonVisibility ( ) const ;
2014-08-28 06:22:40 -04:00
/** Alter the background color depending on hover state */
FSlateColor GetBackgroundColor ( ) const ;
2014-09-09 12:19:28 -04:00
/** 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 ;
2014-09-16 10:26:36 -04:00
/** 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 */
void HandleBackSelected ( ) ;
2014-09-18 08:10:29 -04:00
/** Delegate handler for going to the next stage of the tutorial */
void HandleNextSelected ( ) ;
2014-09-16 10:26:36 -04:00
/** 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 */
FReply HandleNextClicked ( ) ;
/** 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 ;
2014-09-29 10:05:13 -04:00
/** Change next button color based on hover state */
2014-09-30 11:37:26 -04:00
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 ;
2014-09-16 10:26:36 -04:00
2014-08-28 06:22:40 -04:00
private :
2014-08-05 09:04:35 -04:00
/** Copy of the window size we were last draw at */
FVector2D CachedWindowSize ;
/** Copy of the geometry our widget was last drawn with */
FGeometry CachedGeometry ;
2014-08-28 06:22:40 -04:00
/** Copy of the geometry our content was last drawn with */
mutable FGeometry CachedContentGeometry ;
2014-08-05 09:04:35 -04:00
/** 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 ;
2014-09-16 10:26:36 -04:00
/** 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 ;
2014-08-05 09:04:35 -04:00
/** Animation curves for displaying border */
FCurveSequence BorderPulseAnimation ;
FCurveSequence BorderIntroAnimation ;
2014-09-09 12:19:28 -04:00
/** Animation curve for displaying content */
FCurveSequence ContentIntroAnimation ;
2014-08-05 09:04:35 -04:00
/** Documentation page reference to use if we are displaying a UDN doc - we need this otherwise the page will be freed */
TSharedPtr < IDocumentationPage > DocumentationPage ;
2014-09-16 10:26:36 -04:00
/** The tutorial we are referencing */
TWeakObjectPtr < UEditorTutorial > Tutorial ;
/** Next button widget */
TSharedPtr < SWidget > NextButton ;
2014-09-18 13:30:40 -04:00
/** Whether we can show full window content in this overlay (i.e. in the same window as the navigation controls) */
bool bAllowNonWidgetContent ;
2014-09-22 09:42:52 -04:00
/** Delegate for querying whether a widget was drawn */
FOnWasWidgetDrawn OnWasWidgetDrawn ;
2014-09-30 11:37:26 -04:00
/** Text for next/home button */
TAttribute < FText > NextButtonText ;
2014-08-05 09:04:35 -04:00
} ;