Bläddra i källkod

添加树状结构节点

maboren 2 månader sedan
förälder
incheckning
1401f758b7

+ 17 - 0
Ability/Plugins/EzAbility/Source/EzAbilityEditor/Private/SEzAbleTreeViewRowWidget.cpp

@@ -0,0 +1,17 @@
+// Fill out your copyright notice in the Description page of Project Settings.
+
+
+#include "SEzAbleTreeViewRowWidget.h"
+#include "SlateOptMacros.h"
+
+BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
+void SEzAbleTreeViewRowWidget::Construct(const FArguments& InArgs, const TSharedRef<STableViewBase>& InOwnerTableView, TWeakObjectPtr<UEzAbilityState> InState, const TSharedPtr<SScrollBox>& ViewBox)
+{
+	/*
+	ChildSlot
+	[
+		// Populate the widget
+	];
+	*/
+}
+END_SLATE_FUNCTION_BUILD_OPTIMIZATION

+ 20 - 5
Ability/Plugins/EzAbility/Source/EzAbilityEditor/Private/SEzAbleTreeViewWidget.cpp

@@ -5,6 +5,7 @@
 #include "SlateOptMacros.h"
 #include "SPositiveActionButton.h"
 #include "Widgets/Layout/SScrollBox.h"
+#include "SEzAbleTreeViewRowWidget.h"
 
 #define LOCTEXT_NAMESPACE "AbleStateTreeEditor"
 
@@ -19,6 +20,9 @@ void SEzAbleTreeViewWidget::Construct(const FArguments& InArgs)
 		.Orientation(Orient_Vertical)
 		.Thickness(FVector2D(12.0f, 12.0f));
 
+	TreeView = SNew(STreeView<TWeakObjectPtr<UEzAbilityState>>)
+		.OnGenerateRow(this, &SEzAbleTreeViewWidget::HandleGenerateRow);
+
 	ChildSlot
 		[
 			SNew(SVerticalBox)
@@ -43,7 +47,7 @@ void SEzAbleTreeViewWidget::Construct(const FArguments& InArgs)
 			.ToolTipText(LOCTEXT("AddStateToolTip", "Add New State"))
 		.Icon(FAppStyle::Get().GetBrush("Icons.Plus"))
 		.Text(LOCTEXT("AddState", "Add State"))
-		//.OnClicked(this, &SStateTreeView::HandleAddStateButton)
+		.OnClicked(this, &SEzAbleTreeViewWidget::HandleAddStateButton)
 		]
 		]
 		]
@@ -60,10 +64,10 @@ void SEzAbleTreeViewWidget::Construct(const FArguments& InArgs)
 			.Orientation(Orient_Horizontal)
 		.ExternalScrollbar(HorizontalScrollBar)
 		+ SScrollBox::Slot()
-// 		.FillSize(1.0f)
-// 		[
-// 			TreeView.ToSharedRef()
-// 		]
+		.FillSize(1.0f)
+		[
+			TreeView.ToSharedRef()
+		]
 		]
 
 	+ SHorizontalBox::Slot()
@@ -87,4 +91,15 @@ void SEzAbleTreeViewWidget::Construct(const FArguments& InArgs)
 }
 END_SLATE_FUNCTION_BUILD_OPTIMIZATION
 
+FReply SEzAbleTreeViewWidget::HandleAddStateButton()
+{
+	UE_LOG(LogTemp, Log, TEXT("SEzAbleTreeViewWidget::HandleAddStateButton"));
+	return FReply::Handled();
+}
+
+TSharedRef<ITableRow> SEzAbleTreeViewWidget::HandleGenerateRow(TWeakObjectPtr<UEzAbilityState> InState, const TSharedRef<STableViewBase>& InOwnerTableView)
+{
+	return SNew(SEzAbleTreeViewRowWidget, InOwnerTableView, InState, ViewBox);
+}
+
 #undef LOCTEXT_NAMESPACE

+ 22 - 0
Ability/Plugins/EzAbility/Source/EzAbilityEditor/Public/SEzAbleTreeViewRowWidget.h

@@ -0,0 +1,22 @@
+// Fill out your copyright notice in the Description page of Project Settings.
+
+#pragma once
+
+#include "CoreMinimal.h"
+#include "EzAbilityState.h"
+#include "Widgets/SCompoundWidget.h"
+#include "Widgets/Views/STableRow.h"
+
+/**
+ * 
+ */
+class EZABILITYEDITOR_API SEzAbleTreeViewRowWidget : public STableRow<TWeakObjectPtr<UEzAbilityState>> //public SCompoundWidget
+{
+public:
+	SLATE_BEGIN_ARGS(SEzAbleTreeViewRowWidget)
+	{}
+	SLATE_END_ARGS()
+
+	/** Constructs this widget with InArgs */
+	void Construct(const FArguments& InArgs, const TSharedRef<STableViewBase>& InOwnerTableView, TWeakObjectPtr<UEzAbilityState> InState, const TSharedPtr<SScrollBox>& ViewBox);
+};

+ 5 - 1
Ability/Plugins/EzAbility/Source/EzAbilityEditor/Public/SEzAbleTreeViewWidget.h

@@ -5,6 +5,7 @@
 #include "CoreMinimal.h"
 #include "Widgets/SCompoundWidget.h"
 #include "Widgets/Layout/SScrollBox.h"
+#include "EzAbilityState.h"
 
 /**
  * 
@@ -18,10 +19,13 @@ public:
 
 	/** Constructs this widget with InArgs */
 	void Construct(const FArguments& InArgs);
+	FReply HandleAddStateButton();
 
+	// Treeview handlers
+	TSharedRef<ITableRow> HandleGenerateRow(TWeakObjectPtr<UEzAbilityState> InState, const TSharedRef<STableViewBase>& InOwnerTableView);
 
 public:
 
-	//TSharedPtr<STreeView<TWeakObjectPtr<UStateTreeState>>> TreeView;
+	TSharedPtr<STreeView<TWeakObjectPtr<UEzAbilityState>>> TreeView;
 	TSharedPtr<SScrollBox> ViewBox;
 };