You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
The AppFramework module is intended to be used for compound widgets and UI related classes that are too specific (not basic enough) for Slate, but also not Editor specific (reusable in non-Editor applications and games). The test suite has been moved in its entirety for now, but core widget specific test classes will eventually be split off and moved back into Slate, so that they can live alongside of their corresponding widgets. Other changes: - moved to "include what you use" scheme for SColorPicker - broke out color picker related widgets that may be reusable - added forward declarations to reduce header include dependencies #CodeReview: saul.abreu [CL 2275496 by Max Preussner in Main branch]
265 lines
7.8 KiB
C++
265 lines
7.8 KiB
C++
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "PropertyEditorPrivatePCH.h"
|
|
#include "PropertyEditorHelpers.h"
|
|
#include "ObjectPropertyNode.h"
|
|
#include "PropertyEditor.h"
|
|
#include "PropertyDetailsUtilities.h"
|
|
#include "SPropertyEditor.h"
|
|
#include "ScopedTransaction.h"
|
|
#include "SResetToDefaultPropertyEditor.h"
|
|
#include "SStructureDetailsView.h"
|
|
#include "StructurePropertyNode.h"
|
|
#include "SColorPicker.h"
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "SStructureDetailsView"
|
|
|
|
|
|
SStructureDetailsView::~SStructureDetailsView()
|
|
{
|
|
SaveExpandedItems();
|
|
}
|
|
|
|
UScriptStruct* SStructureDetailsView::GetBaseScriptStruct() const
|
|
{
|
|
const UScriptStruct* Struct = StructData.IsValid() ? StructData->GetStruct() : NULL;
|
|
return const_cast<UScriptStruct*>(Struct);
|
|
}
|
|
|
|
void SStructureDetailsView::Construct(const FArguments& InArgs)
|
|
{
|
|
DetailsViewArgs = InArgs._DetailsViewArgs;
|
|
bHasActiveFilter = false;
|
|
bIsLocked = false;
|
|
bHasOpenColorPicker = false;
|
|
|
|
CustomName = InArgs._CustomName;
|
|
|
|
// Create the root property now
|
|
RootNode = MakeShareable(new FStructurePropertyNode);
|
|
|
|
PropertyUtilities = MakeShareable( new FPropertyDetailsUtilities( *this ) );
|
|
|
|
ColumnWidth = 0.65f;
|
|
ColumnSizeData.LeftColumnWidth = TAttribute<float>(this, &SStructureDetailsView::OnGetLeftColumnWidth);
|
|
ColumnSizeData.RightColumnWidth = TAttribute<float>(this, &SStructureDetailsView::OnGetRightColumnWidth);
|
|
ColumnSizeData.OnWidthChanged = SSplitter::FOnSlotResized::CreateSP(this, &SStructureDetailsView::OnSetColumnWidth);
|
|
|
|
TSharedRef<SScrollBar> ExternalScrollbar =
|
|
SNew(SScrollBar)
|
|
.AlwaysShowScrollbar( true );
|
|
|
|
FMenuBuilder DetailViewOptions( true, NULL );
|
|
|
|
FUIAction ShowOnlyModifiedAction(
|
|
FExecuteAction::CreateSP(this, &SStructureDetailsView::OnShowOnlyModifiedClicked),
|
|
FCanExecuteAction(),
|
|
FIsActionChecked::CreateSP(this, &SStructureDetailsView::IsShowOnlyModifiedChecked)
|
|
);
|
|
|
|
if (DetailsViewArgs.bShowModifiedPropertiesOption)
|
|
{
|
|
DetailViewOptions.AddMenuEntry(
|
|
LOCTEXT("ShowOnlyModified", "Show Only Modified Properties"),
|
|
LOCTEXT("ShowOnlyModified_ToolTip", "Displays only properties which have been changed from their default"),
|
|
FSlateIcon(),
|
|
ShowOnlyModifiedAction,
|
|
NAME_None,
|
|
EUserInterfaceActionType::ToggleButton
|
|
);
|
|
}
|
|
|
|
FUIAction ShowAllAdvancedAction(
|
|
FExecuteAction::CreateSP(this, &SStructureDetailsView::OnShowAllAdvancedClicked),
|
|
FCanExecuteAction(),
|
|
FIsActionChecked::CreateSP(this, &SStructureDetailsView::IsShowAllAdvancedChecked)
|
|
);
|
|
|
|
DetailViewOptions.AddMenuEntry(
|
|
LOCTEXT("ShowAllAdvanced", "Show All Advanced Details"),
|
|
LOCTEXT("ShowAllAdvanced_ToolTip", "Shows all advanced detail sections in each category"),
|
|
FSlateIcon(),
|
|
ShowAllAdvancedAction,
|
|
NAME_None,
|
|
EUserInterfaceActionType::ToggleButton
|
|
);
|
|
|
|
DetailViewOptions.AddMenuEntry(
|
|
LOCTEXT("CollapseAll", "Collapse All Categories"),
|
|
LOCTEXT("CollapseAll_ToolTip", "Collapses all root level categories"),
|
|
FSlateIcon(),
|
|
FUIAction(FExecuteAction::CreateSP(this, &SStructureDetailsView::SetRootExpansionStates, /*bExpanded=*/false, /*bRecurse=*/false)));
|
|
DetailViewOptions.AddMenuEntry(
|
|
LOCTEXT("ExpandAll", "Expand All Categories"),
|
|
LOCTEXT("ExpandAll_ToolTip", "Expands all root level categories"),
|
|
FSlateIcon(),
|
|
FUIAction(FExecuteAction::CreateSP(this, &SStructureDetailsView::SetRootExpansionStates, /*bExpanded=*/true, /*bRecurse=*/false)));
|
|
|
|
TSharedRef<SHorizontalBox> FilterRow = SNew( SHorizontalBox )
|
|
.Visibility(this, &SStructureDetailsView::GetFilterBoxVisibility)
|
|
+SHorizontalBox::Slot()
|
|
.FillWidth( 1 )
|
|
.VAlign( VAlign_Center )
|
|
[
|
|
// Create the search box
|
|
SAssignNew( SearchBox, SSearchBox )
|
|
.OnTextChanged(this, &SStructureDetailsView::OnFilterTextChanged)
|
|
];
|
|
|
|
if (DetailsViewArgs.bShowOptions)
|
|
{
|
|
FilterRow->AddSlot()
|
|
.HAlign(HAlign_Right)
|
|
.AutoWidth()
|
|
[
|
|
SNew( SComboButton )
|
|
.ContentPadding(0)
|
|
.ForegroundColor( FSlateColor::UseForeground() )
|
|
.ButtonStyle( FEditorStyle::Get(), "ToggleButton" )
|
|
.MenuContent()
|
|
[
|
|
DetailViewOptions.MakeWidget()
|
|
]
|
|
.ButtonContent()
|
|
[
|
|
SNew(SImage)
|
|
.Image( FEditorStyle::GetBrush("GenericViewButton") )
|
|
]
|
|
];
|
|
}
|
|
|
|
SAssignNew(DetailTree, SDetailTree)
|
|
.Visibility(this, &SStructureDetailsView::GetTreeVisibility)
|
|
.TreeItemsSource(&RootTreeNodes)
|
|
.OnGetChildren(this, &SStructureDetailsView::OnGetChildrenForDetailTree)
|
|
.OnSetExpansionRecursive(this, &SStructureDetailsView::SetNodeExpansionStateRecursive)
|
|
.OnGenerateRow(this, &SStructureDetailsView::OnGenerateRowForDetailTree)
|
|
.OnExpansionChanged(this, &SStructureDetailsView::OnItemExpansionChanged)
|
|
.SelectionMode(ESelectionMode::None)
|
|
.ExternalScrollbar(ExternalScrollbar);
|
|
|
|
ChildSlot
|
|
[
|
|
SNew( SVerticalBox )
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding( 0.0f, 0.0f, 0.0f, 2.0f )
|
|
[
|
|
FilterRow
|
|
]
|
|
+ SVerticalBox::Slot()
|
|
.FillHeight(1)
|
|
.Padding(0)
|
|
[
|
|
SNew( SHorizontalBox )
|
|
+ SHorizontalBox::Slot()
|
|
[
|
|
DetailTree.ToSharedRef()
|
|
]
|
|
+ SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
[
|
|
SNew( SBox )
|
|
.WidthOverride( 16.0f )
|
|
[
|
|
ExternalScrollbar
|
|
]
|
|
]
|
|
]
|
|
];
|
|
}
|
|
|
|
void SStructureDetailsView::SetStructureData(TSharedPtr<FStructOnScope> InStructData)
|
|
{
|
|
//PRE SET
|
|
SaveExpandedItems();
|
|
RootNode->SetStructure(NULL);
|
|
RootNodePendingKill = RootNode;
|
|
RootNode = MakeShareable(new FStructurePropertyNode);
|
|
|
|
//SET
|
|
StructData = InStructData;
|
|
RootNode->SetStructure(StructData);
|
|
if (!StructData.IsValid() || !StructData->IsValid())
|
|
{
|
|
bIsLocked = false;
|
|
}
|
|
|
|
//POST SET
|
|
DestroyColorPicker();
|
|
ColorPropertyNode = NULL;
|
|
|
|
FPropertyNodeInitParams InitParams;
|
|
InitParams.ParentNode = NULL;
|
|
InitParams.Property = NULL;
|
|
InitParams.ArrayOffset = 0;
|
|
InitParams.ArrayIndex = INDEX_NONE;
|
|
InitParams.bAllowChildren = true;
|
|
InitParams.bForceHiddenPropertyVisibility = FPropertySettings::Get().ShowHiddenProperties();
|
|
InitParams.bCreateCategoryNodes = false;
|
|
|
|
RootNode->InitNode(InitParams);
|
|
RootNode->SetDisplayNameOverride(CustomName);
|
|
|
|
RestoreExpandedItems();
|
|
|
|
UpdatePropertyMap();
|
|
}
|
|
|
|
int32 SStructureDetailsView::OnPaint(const FPaintArgs& Args, FGeometry const& AllottedGeometry, FSlateRect const& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, FWidgetStyle const& InWidgetStyle, bool bParentEnabled) const
|
|
{
|
|
int32 LayerIdOut = LayerId;
|
|
// if the details table is still in need of a refresh, then wait for it to
|
|
// update before we paint (the tree view is probably holding onto some out
|
|
// of date properties, and painting those rows could cause a crash)
|
|
//
|
|
// @TODO: this is a temp fix to get 4.3 out the door, we need to find a
|
|
// better, lower level solution (this could happen for other detail panels)
|
|
if (!DetailTree->IsPendingRefresh())
|
|
{
|
|
LayerIdOut = SDetailsViewBase::OnPaint(Args, AllottedGeometry, MyClippingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled);
|
|
}
|
|
|
|
return LayerIdOut;
|
|
}
|
|
|
|
void SStructureDetailsView::ForceRefresh()
|
|
{
|
|
SetStructureData(StructData);
|
|
}
|
|
|
|
const TArray< TWeakObjectPtr<UObject> >& SStructureDetailsView::GetSelectedObjects() const
|
|
{
|
|
static const TArray< TWeakObjectPtr<UObject> > DummyRef;
|
|
return DummyRef;
|
|
}
|
|
|
|
const TArray< TWeakObjectPtr<AActor> >& SStructureDetailsView::GetSelectedActors() const
|
|
{
|
|
static const TArray< TWeakObjectPtr<AActor> > DummyRef;
|
|
return DummyRef;
|
|
}
|
|
|
|
const FSelectedActorInfo& SStructureDetailsView::GetSelectedActorInfo() const
|
|
{
|
|
static const FSelectedActorInfo DummyRef;
|
|
return DummyRef;
|
|
}
|
|
|
|
bool SStructureDetailsView::IsConnected() const
|
|
{
|
|
return StructData.IsValid() && StructData->IsValid() && RootNode.IsValid() && RootNode->IsValid();
|
|
}
|
|
|
|
TSharedPtr<class FComplexPropertyNode> SStructureDetailsView::GetRootNode()
|
|
{
|
|
return RootNode;
|
|
}
|
|
|
|
void SStructureDetailsView::CustomUpdatePropertyMap()
|
|
{
|
|
DetailLayout->DefaultCategory(NAME_None).SetDisplayName(NAME_None, CustomName);
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE |