Files
UnrealEngineUWP/Engine/Source/Editor/PropertyEditor/Private/SDetailTableRowBase.h
sebastian nordgren 9c285dad01 Details rows now preserve space on the right for the scrollbar.
CustomRow() widgets can now be disabled from customizations.

Favoriting command is now hidden when favoriting is not enabled in a details panel.

Removed unnecessary code for calculating a scroll offset when the favorites category was added or removed since the Favorites category is never removed.

#rb lauren.barnes

[CL 15218520 by sebastian nordgren in ue5-main branch]
2021-01-27 13:22:18 -04:00

102 lines
3.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "InputCoreTypes.h"
#include "Input/Reply.h"
#include "DetailTreeNode.h"
#include "Widgets/Views/STableViewBase.h"
#include "Widgets/Views/STableRow.h"
#include "Textures/SlateIcon.h"
#include "Framework/Commands/UIAction.h"
#include "Widgets/Views/SListView.h"
#include "IDetailsViewPrivate.h"
#include "Layout/WidgetPath.h"
#include "Framework/Application/MenuStack.h"
#include "Framework/Application/SlateApplication.h"
#include "Framework/MultiBox/MultiBoxBuilder.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;
};