Files
UnrealEngineUWP/Engine/Source/Developer/AutomationWindow/Private/SAutomationTestTreeView.h
dan hertzka d41799712f Unblocking robomerge
- Merge was a little involved, ran SlateViewer and things seem to be working as expected

ListView improvements
- Added horizontal layout option to both SListView and STileView.
- Added smooth inertial scrolling. Doing so naturally requires more refreshes, so it's not intended for use in perf-sensitive scenarios and is disabled by default.
- Added option to establish a consistent fixed offset when scrolling (to, for example, ensure the top item is always flush with the top of the list, or that the bottom 25% of the preceeding item is always visible above). Note that enabling this will override the NavigationScrollOffset property, as the two concepts fully conflict.
- Exposed all new functionality to the UMG counterparts of the slate lists
- Updated SlateViewer's ListView testing tab to include a horizontal list, a horizontal tile view, and options for enabling animated scrolling and fixed offsets. Also tinkered a bit with the default sizing and open tab, as the default size seemed universally too small.

#rb Matt.Loesby, Josh.Gross, Nick.Darnell
[FYI] Matt.Kuhlenschmidt, Chris.Gagnon, Stephan.Jiang, Saad.Nader, Philip.Buuck, Don.Eubanks, Matt.Stone, Geoff.Wong, Ryan.Reed


#ROBOMERGE-OWNER: dan.hertzka
#ROBOMERGE-AUTHOR: dan.hertzka
#ROBOMERGE-SOURCE: CL 7634094 via CL 7642338
#ROBOMERGE-BOT: (v372-7473910)

[CL 7642344 by dan hertzka in Main branch]
2019-07-26 16:57:25 -04:00

154 lines
4.6 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Framework/SlateDelegates.h"
#include "Widgets/Views/STableViewBase.h"
#include "Framework/Views/TableViewTypeTraits.h"
#include "Widgets/Text/STextBlock.h"
#include "Widgets/Views/STreeView.h"
/**
* Implements the automation test tree view. Same slate interface as STreeView but adds the ability to clear the internal widget cache.
*/
template<typename ItemType>
class SAutomationTestTreeView
: public STreeView< ItemType >
{
public:
typedef typename TListTypeTraits< ItemType >::NullableType NullableItemType;
typedef typename TSlateDelegates< ItemType >::FOnGetChildren FOnGetChildren;
typedef typename TSlateDelegates< ItemType >::FOnGenerateRow FOnGenerateRow;
typedef typename TSlateDelegates< ItemType >::FOnSetExpansionRecursive FOnSetExpansionRecursive;
typedef typename TSlateDelegates< ItemType >::FOnItemScrolledIntoView FOnItemScrolledIntoView;
typedef typename TSlateDelegates< NullableItemType >::FOnSelectionChanged FOnSelectionChanged;
typedef typename TSlateDelegates< ItemType >::FOnMouseButtonDoubleClick FOnMouseButtonDoubleClick;
typedef typename TSlateDelegates< ItemType >::FOnExpansionChanged FOnExpansionChanged;
public:
SLATE_BEGIN_ARGS( SAutomationTestTreeView )
: _OnGenerateRow()
, _OnGetChildren()
, _OnSetExpansionRecursive()
, _TreeItemsSource( static_cast< TArray<ItemType>* >(NULL) ) //@todo Slate Syntax: Initializing from NULL without a cast
, _ItemHeight(16)
, _OnContextMenuOpening()
, _OnMouseButtonDoubleClick()
, _OnSelectionChanged()
, _OnExpansionChanged()
, _SelectionMode(ESelectionMode::Multi)
, _ClearSelectionOnClick(true)
, _ExternalScrollbar()
{}
SLATE_EVENT( FOnGenerateRow, OnGenerateRow )
SLATE_EVENT( FOnTableViewScrolled, OnTreeViewScrolled )
SLATE_EVENT( FOnItemScrolledIntoView, OnItemScrolledIntoView )
SLATE_EVENT( FOnGetChildren, OnGetChildren )
SLATE_EVENT( FOnSetExpansionRecursive, OnSetExpansionRecursive )
SLATE_ARGUMENT( TArray<ItemType>* , TreeItemsSource )
SLATE_ATTRIBUTE( float, ItemHeight )
SLATE_EVENT( FOnContextMenuOpening, OnContextMenuOpening )
SLATE_EVENT( FOnMouseButtonDoubleClick, OnMouseButtonDoubleClick )
SLATE_EVENT( FOnSelectionChanged, OnSelectionChanged )
SLATE_EVENT( FOnExpansionChanged, OnExpansionChanged )
SLATE_ATTRIBUTE( ESelectionMode::Type, SelectionMode )
SLATE_ARGUMENT( TSharedPtr<SHeaderRow>, HeaderRow )
SLATE_ARGUMENT ( bool, ClearSelectionOnClick )
SLATE_ARGUMENT( TSharedPtr<SScrollBar>, ExternalScrollbar )
SLATE_END_ARGS()
/**
* Construct this widget
*
* @param InArgs The declaration data for this widget
*/
void Construct( const FArguments& InArgs )
{
this->OnGenerateRow = InArgs._OnGenerateRow;
this->OnItemScrolledIntoView = InArgs._OnItemScrolledIntoView;
this->OnGetChildren = InArgs._OnGetChildren;
this->OnSetExpansionRecursive = InArgs._OnSetExpansionRecursive;
this->TreeItemsSource = InArgs._TreeItemsSource;
this->OnContextMenuOpening = InArgs._OnContextMenuOpening;
this->OnDoubleClick = InArgs._OnMouseButtonDoubleClick;
this->OnSelectionChanged = InArgs._OnSelectionChanged;
this->OnExpansionChanged = InArgs._OnExpansionChanged;
this->SelectionMode = InArgs._SelectionMode;
this->bClearSelectionOnClick = InArgs._ClearSelectionOnClick;
// Check for any parameters that the coder forgot to specify.
FString ErrorString;
{
if ( !this->OnGenerateRow.IsBound() )
{
ErrorString += TEXT("Please specify an OnGenerateRow. \n");
}
if ( this->TreeItemsSource == NULL )
{
ErrorString += TEXT("Please specify a TreeItemsSource. \n");
}
if ( !this->OnGetChildren.IsBound() )
{
ErrorString += TEXT("Please specify an OnGetChildren. \n");
}
}
if (ErrorString.Len() > 0)
{
// Let the coder know what they forgot
this->ChildSlot
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.Text(FText::FromString(ErrorString))
];
}
else
{
// Make the TableView
this->ConstructChildren( 0, InArgs._ItemHeight, EListItemAlignment::LeftAligned, InArgs._HeaderRow, InArgs._ExternalScrollbar, Orient_Vertical, InArgs._OnTreeViewScrolled );
}
}
SAutomationTestTreeView()
: STreeView< ItemType >()
{
}
public:
/**
* Clears the internal widget cache and recreates the tree
*/
void ReCreateTreeView()
{
this->WidgetGenerator.Clear();
this->RequestTreeRefresh();
}
};