Files
UnrealEngineUWP/Engine/Plugins/Runtime/StateTree/Source/StateTreeEditorModule/Private/SStateTreeView.h
mikko mononen 441324a228 StateTree: Added State outliner and made the main tree view more detailed
- Simplied the task icon
- Created common treeview for States, used for state selection and outliner view
- Added common functions to describe state links and transitions
- Made custom expander arrow the main tree view
- Move the task lits on separate row on the main tree view
- Added enter condition list for on main tree view
- Clicking on tasks or enter conditions highlight them in the details panel
- Added state outliner which displays the state list compactly
- Added feedback for the drag and drop, and moved the code to separate file

#rb Yoan.StAmant

[CL 35239895 by mikko mononen in ue5-main branch]
2024-08-01 05:38:41 -04:00

96 lines
3.2 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Widgets/SCompoundWidget.h"
#include "Widgets/Views/STreeView.h"
class FStateTreeViewModel;
class ITableRow;
class SScrollBar;
class STableViewBase;
namespace ESelectInfo { enum Type : int; }
struct FPropertyChangedEvent;
class UStateTreeState;
class SScrollBox;
class FUICommandList;
namespace UE::StateTree::Editor
{
static constexpr float StateRowHeight = 32.0f;
static constexpr float TaskRowHeight = 16.0f;
} // UE::StateTree::Editor
class SStateTreeView : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SStateTreeView) {}
SLATE_END_ARGS()
SStateTreeView();
virtual ~SStateTreeView() override;
void Construct(const FArguments& InArgs, TSharedRef<FStateTreeViewModel> StateTreeViewModel, const TSharedRef<FUICommandList>& InCommandList);
void SavePersistentExpandedStates();
private:
virtual FReply OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent) override;
virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override;
void UpdateTree(bool bExpandPersistent = false);
// ViewModel handlers
void HandleModelAssetChanged();
void HandleModelStatesRemoved(const TSet<UStateTreeState*>& AffectedParents);
void HandleModelStatesMoved(const TSet<UStateTreeState*>& AffectedParents, const TSet<UStateTreeState*>& MovedStates);
void HandleModelStateAdded(UStateTreeState* ParentState, UStateTreeState* NewState);
void HandleModelStatesChanged(const TSet<UStateTreeState*>& AffectedStates, const FPropertyChangedEvent& PropertyChangedEvent);
void HandleModelSelectionChanged(const TArray<TWeakObjectPtr<UStateTreeState>>& SelectedStates);
// Treeview handlers
TSharedRef<ITableRow> HandleGenerateRow(TWeakObjectPtr<UStateTreeState> InState, const TSharedRef<STableViewBase>& InOwnerTableView);
void HandleGetChildren(TWeakObjectPtr<UStateTreeState> InParent, TArray<TWeakObjectPtr<UStateTreeState>>& OutChildren);
void HandleTreeSelectionChanged(TWeakObjectPtr<UStateTreeState> InSelectedItem, ESelectInfo::Type SelectionType);
void HandleTreeExpansionChanged(TWeakObjectPtr<UStateTreeState> InSelectedItem, bool bExpanded);
TSharedPtr<SWidget> HandleContextMenuOpening();
// Action handlers
// @todo: these are also defined in the outliner, figure out how to share code.
UStateTreeState* GetFirstSelectedState() const;
FReply HandleAddStateButton();
void HandleAddSiblingState();
void HandleAddChildState();
void HandleCutSelectedStates();
void HandleCopySelectedStates();
void HandlePasteStatesAsSiblings();
void HandlePasteStatesAsChildren();
void HandleDuplicateSelectedStates();
void HandleRenameState();
void HandleDeleteStates();
void HandleEnableSelectedStates();
void HandleDisableSelectedStates();
bool HasSelection() const;
bool CanPaste() const;
bool CanEnableStates() const;
bool CanDisableStates() const;
void BindCommands();
TSharedPtr<FStateTreeViewModel> StateTreeViewModel;
TSharedPtr<STreeView<TWeakObjectPtr<UStateTreeState>>> TreeView;
TSharedPtr<SScrollBar> ExternalScrollbar;
TSharedPtr<SScrollBox> ViewBox;
TArray<TWeakObjectPtr<UStateTreeState>> Subtrees;
TSharedPtr<FUICommandList> CommandList;
UStateTreeState* RequestedRenameState;
bool bItemsDirty;
bool bUpdatingSelection;
};