2019-12-26 15:33:43 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2019-06-07 11:22:52 -04:00
# pragma once
2022-08-24 22:45:13 -04:00
# include "Containers/Array.h"
2019-06-07 11:22:52 -04:00
# include "CoreMinimal.h"
2022-08-24 22:45:13 -04:00
# include "Delegates/Delegate.h"
# include "HAL/Platform.h"
# include "Internationalization/Text.h"
2019-06-07 11:22:52 -04:00
# include "Modules/ModuleInterface.h"
2022-08-24 22:45:13 -04:00
# include "Templates/SharedPointer.h"
2019-06-07 11:22:52 -04:00
class IPropertyHandle ;
2022-08-24 22:45:13 -04:00
class IStructViewerFilter ;
class UScriptStruct ;
2019-06-07 11:22:52 -04:00
/** Delegate used with the Struct Viewer in 'struct picking' mode. You'll bind a delegate when the struct viewer widget is created, which will be fired off when a struct is selected in the list */
DECLARE_DELEGATE_OneParam ( FOnStructPicked , const UScriptStruct * ) ;
enum class EStructViewerMode : uint8
{
/** Allows all structs to be browsed and selected; syncs selection with the editor; drag and drop attachment, etc. */
StructBrowsing ,
/** Sets the struct viewer to operate as a struct 'picker'. */
StructPicker ,
} ;
enum class EStructViewerDisplayMode : uint8
{
/** Default will choose what view mode based on if in Viewer or Picker mode. */
DefaultView ,
/** Displays all classes as a tree. */
TreeView ,
/** Displays all classes as a list. */
ListView ,
} ;
enum class EStructViewerNameTypeToDisplay : uint8
{
/** Display both the display name and struct name if they're available and different. */
Dynamic ,
/** Always use the display name */
DisplayName ,
/** Always use the struct name */
StructName ,
} ;
/**
* Settings for the Struct Viewer set by the programmer before spawning an instance of the widget . This
* is used to modify the struct viewer ' s behavior in various ways , such as filtering in or out specific structs .
*/
class FStructViewerInitializationOptions
{
public :
/** The filter to use on structs in this instance. */
TSharedPtr < class IStructViewerFilter > StructFilter ;
/** Mode to operate in */
EStructViewerMode Mode ;
/** Mode to display the structs using. */
EStructViewerDisplayMode DisplayMode ;
/** Shows unloaded structs. Will not be filtered out based on non-bool filter options. */
bool bShowUnloadedStructs ;
/** Shows a "None" option, only available in Picker mode. */
bool bShowNoneOption ;
/** If true, root nodes will be expanded by default. */
bool bExpandRootNodes ;
/** true allows struct dynamic loading on selection */
bool bEnableStructDynamicLoading ;
/** Controls what name is shown for structs */
EStructViewerNameTypeToDisplay NameTypeToDisplay ;
/** the title string of the struct viewer if required. */
FText ViewerTitleString ;
/** The property this struct viewer be working on. */
TSharedPtr < class IPropertyHandle > PropertyHandle ;
/** true (the default) shows the view options at the bottom of the struct picker. */
bool bAllowViewOptions ;
/** true (the default) shows a background border behind the struct viewer widget. */
bool bShowBackgroundBorder ;
/** Defines additional structs you want listed in the "Common Structs" section for the picker. */
TArray < const UScriptStruct * > ExtraPickerCommonStructs ;
public :
/** Constructor */
FStructViewerInitializationOptions ( )
: Mode ( EStructViewerMode : : StructPicker )
, DisplayMode ( EStructViewerDisplayMode : : DefaultView )
, bShowUnloadedStructs ( true )
, bShowNoneOption ( false )
, bExpandRootNodes ( true )
, bEnableStructDynamicLoading ( true )
, NameTypeToDisplay ( EStructViewerNameTypeToDisplay : : StructName )
, bAllowViewOptions ( true )
, bShowBackgroundBorder ( true )
{
}
} ;
/**
* Struct Viewer module
*/
class FStructViewerModule : public IModuleInterface
{
public :
/**
* Called right after the module DLL has been loaded and the module object has been created
*/
virtual void StartupModule ( ) ;
/**
* Called before the module is unloaded , right before the module object is destroyed .
*/
virtual void ShutdownModule ( ) ;
/**
* Creates a struct viewer widget
*
* @ param InitOptions Programmer - driven configuration for this widget instance
* @ param OnStructPickedDelegate Optional callback when a struct is selected in ' struct picking ' mode
*
* @ return New struct viewer widget
*/
virtual TSharedRef < class SWidget > CreateStructViewer ( const FStructViewerInitializationOptions & InitOptions , const FOnStructPicked & OnStructPickedDelegate ) ;
} ;