Files
UnrealEngineUWP/Engine/Source/Editor/SceneOutliner/Private/ActorFolderPickingMode.cpp
richard malo 41b81f0c91 Added support for Level Instances to have a folder hierarchy in the World Outliner. Actor Folders can now have a root object which serves as a context for folder hierarchy.
#jira UE-134605
#rb patrick.enfedaque
#preflight 619d3a42cb49ea94934aa11d

#ROBOMERGE-AUTHOR: richard.malo
#ROBOMERGE-SOURCE: CL 18273663 in //UE5/Release-5.0/... via CL 18273683
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469)

[CL 18273700 by richard malo in ue5-release-engine-test branch]
2021-11-23 14:43:39 -05:00

56 lines
2.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "ActorFolderPickingMode.h"
#include "ActorFolderTreeItem.h"
#include "ActorFolderHierarchy.h"
#define LOCTEXT_NAMESPACE "SceneOutliner_ActoFolderPickingMode"
FActorFolderPickingMode::FActorFolderPickingMode(SSceneOutliner* InSceneOutliner, FOnSceneOutlinerItemPicked InOnItemPicked, TWeakObjectPtr<UWorld> InSpecifiedWorldToDisplay, const FFolder::FRootObject& InRootObject)
: FActorMode(FActorModeParams(InSceneOutliner, InSpecifiedWorldToDisplay))
, OnItemPicked(InOnItemPicked)
, RootObject(InRootObject)
{
Rebuild();
}
TUniquePtr<ISceneOutlinerHierarchy> FActorFolderPickingMode::CreateHierarchy()
{
return MakeUnique<FActorFolderHierarchy>(this, RepresentingWorld, RootObject);
}
void FActorFolderPickingMode::OnItemSelectionChanged(FSceneOutlinerTreeItemPtr Item, ESelectInfo::Type SelectionType, const FSceneOutlinerItemSelection& Selection)
{
// fire off the notification to whoever is listening.
// This may often cause the widget itself to be enqueued for destruction
auto SelectedItems = SceneOutliner->GetSelectedItems();
if (SelectedItems.Num() > 0)
{
auto FirstItem = SelectedItems[0];
if (FirstItem->CanInteract())
{
OnItemPicked.ExecuteIfBound(FirstItem.ToSharedRef());
}
}
}
void FActorFolderPickingMode::OnFilterTextCommited(FSceneOutlinerItemSelection& Selection, ETextCommit::Type CommitType)
{
// In folder picking mode, we check to see if we have a selected folder, and if so, fire
// off the notification to whoever is listening. This may often cause the widget itself
// to be enqueued for destruction
TArray<FActorFolderTreeItem*> Folders;
Selection.Get(Folders);
if (Folders.Num() == 1 && Folders[0])
{
// Signal that a folder was selected. We assume it is valid as it wouldn't not have been added to the selection if not
SceneOutliner->SetItemSelection(Folders[0]->AsShared(), true, ESelectInfo::OnKeyPress);
}
}
void FActorFolderPickingMode::CreateViewContent(FMenuBuilder& MenuBuilder)
{
FActorMode::BuildWorldPickerMenu(MenuBuilder);
}
#undef LOCTEXT_NAMESPACE