Files
UnrealEngineUWP/Engine/Source/Editor/PropertyEditor/Private/SDetailTableRowBase.h
karen jirak 02a8dc9818 Details Panel - Component card layout actions
The categories on the components for core entities now have an action menu. It has many things in it that will log.

#jira UE-194008
#rb  Brooke.Hubert

[CL 27717413 by karen jirak in ue5-main branch]
2023-09-08 13:15:51 -04:00

118 lines
4.4 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; }
/** Retrieve all property nodes represented by this row, and it's children if Recursive specified. */
TArray<TSharedPtr<FPropertyNode>> GetPropertyNodes(const bool& bRecursive = false) const;
/** Retrieve all property handles represented by this row, and it's children if Recursive specified. */
virtual TArray<TSharedPtr<IPropertyHandle>> GetPropertyHandles(const bool& bRecursive = false) const;
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:
/**
* A weak pointer to the STableViewBase from which we can get information such as if the scrollbar is showing.
*/
TWeakPtr<STableViewBase> OwnerTableViewWeak;
TWeakPtr<FDetailTreeNode> OwnerTreeNode;
/**
* The @code DetailsDisplayManager @endcode which provides an API to manage some of the characteristics of the
* details display
*/
TSharedPtr<FDetailsDisplayManager> DisplayManager;
};