Files
UnrealEngineUWP/Engine/Source/Editor/PropertyEditor/Private/SDetailTableRowBase.h
sebastian nordgren 70aa782414 ICWYU. Removed "CoreMinimal.h" from Private headers in PropertyEditor module.
#preflight 613224fcd031a400011e3bd8

[CL 17435887 by sebastian nordgren in ue5-main branch]
2021-09-06 03:20:36 -04:00

101 lines
3.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "DetailTreeNode.h"
#include "IDetailsViewPrivate.h"
#include "InputCoreTypes.h"
#include "Framework/Application/MenuStack.h"
#include "Framework/Application/SlateApplication.h"
#include "Framework/Commands/UIAction.h"
#include "Framework/MultiBox/MultiBoxBuilder.h"
#include "Input/Reply.h"
#include "Layout/WidgetPath.h"
#include "Textures/SlateIcon.h"
#include "Widgets/Views/SListView.h"
#include "Widgets/Views/STableViewBase.h"
#include "Widgets/Views/STableRow.h"
class SDetailTableRowBase : public STableRow< TSharedPtr< FDetailTreeNode > >
{
public:
virtual FReply OnMouseButtonUp( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent ) override
{
if( OwnerTreeNode.IsValid() && MouseEvent.GetEffectingButton() == EKeys::RightMouseButton && !StaticCastSharedRef<STableViewBase>( OwnerTablePtr.Pin()->AsWidget() )->IsRightClickScrolling() )
{
FMenuBuilder MenuBuilder( true, nullptr, nullptr, true );
FDetailNodeList VisibleChildren;
OwnerTreeNode.Pin()->GetChildren( VisibleChildren );
bool bShouldOpenMenu = false;
// Open context menu if this node can be expanded
if( VisibleChildren.Num() )
{
bShouldOpenMenu = true;
FUIAction ExpandAllAction( FExecuteAction::CreateSP( this, &SDetailTableRowBase::OnExpandAllClicked ) );
FUIAction CollapseAllAction( FExecuteAction::CreateSP( this, &SDetailTableRowBase::OnCollapseAllClicked ) );
MenuBuilder.BeginSection( NAME_None, NSLOCTEXT("PropertyView", "ExpansionHeading", "Expansion") );
MenuBuilder.AddMenuEntry( NSLOCTEXT("PropertyView", "CollapseAll", "Collapse All"), NSLOCTEXT("PropertyView", "CollapseAll_ToolTip", "Collapses this item and all children"), FSlateIcon(), CollapseAllAction );
MenuBuilder.AddMenuEntry( NSLOCTEXT("PropertyView", "ExpandAll", "Expand All"), NSLOCTEXT("PropertyView", "ExpandAll_ToolTip", "Expands this item and all children"), FSlateIcon(), ExpandAllAction );
MenuBuilder.EndSection();
}
bShouldOpenMenu |= OnContextMenuOpening(MenuBuilder);
if( bShouldOpenMenu )
{
FWidgetPath WidgetPath = MouseEvent.GetEventPath() != nullptr ? *MouseEvent.GetEventPath() : FWidgetPath();
FSlateApplication::Get().PushMenu(AsShared(), WidgetPath, MenuBuilder.MakeWidget(), MouseEvent.GetScreenSpacePosition(), FPopupTransitionEffect::ContextMenu);
return FReply::Handled();
}
}
return STableRow< TSharedPtr< FDetailTreeNode > >::OnMouseButtonUp( MyGeometry, MouseEvent );
}
int32 GetIndentLevelForBackgroundColor() const;
static bool IsScrollBarVisible(TWeakPtr<STableViewBase> OwnerTableViewWeak);
static const float ScrollBarPadding;
protected:
/**
* Called when the user opens the context menu on this row
*
* @param MenuBuilder The menu builder to add menu items to
* @return true if menu items were added
*/
virtual bool OnContextMenuOpening( FMenuBuilder& MenuBuilder ) { return false; }
private:
void OnExpandAllClicked()
{
TSharedPtr<FDetailTreeNode> OwnerTreeNodePin = OwnerTreeNode.Pin();
if( OwnerTreeNodePin.IsValid() )
{
const bool bRecursive = true;
const bool bIsExpanded = true;
OwnerTreeNodePin->GetDetailsView()->SetNodeExpansionState( OwnerTreeNodePin.ToSharedRef(), bIsExpanded, bRecursive );
}
}
void OnCollapseAllClicked()
{
TSharedPtr<FDetailTreeNode> OwnerTreeNodePin = OwnerTreeNode.Pin();
if( OwnerTreeNodePin.IsValid() )
{
const bool bRecursive = true;
const bool bIsExpanded = false;
OwnerTreeNodePin->GetDetailsView()->SetNodeExpansionState( OwnerTreeNodePin.ToSharedRef(), bIsExpanded, bRecursive );
}
}
protected:
TWeakPtr<FDetailTreeNode> OwnerTreeNode;
};