ArticyXImporter
ArticyXImporter for Unreal Engine
Loading...
Searching...
No Matches
SArticyObjectAssetPicker.h
1//
2// Copyright (c) 2023 articy Software GmbH & Co. KG. All rights reserved.
3//
4
5#pragma once
6
7#include "CoreMinimal.h"
8#include "ContentBrowserDelegates.h"
9#include "ArticyObject.h"
10#include <Widgets/SCompoundWidget.h>
11#include <Widgets/Views/STableViewBase.h>
12#include <Widgets/Views/STableRow.h>
13#include <IContentBrowserSingleton.h>
14#include <SAssetSearchBox.h>
15#include <Types/SlateEnums.h>
16#include <Misc/TextFilterExpressionEvaluator.h>
17#include "Widgets/Input/SComboButton.h"
18#include "Slate/ArticyFilterHelpers.h"
19#include "ClassViewerModule.h"
20
21#define LOCTEXT_NAMESPACE "ArticyObjectAssetPicker"
22
23namespace FArticyObjectAssetPicketConstants {
24
28 const FVector2D TileSize(96.f, 96.f);
29 const int32 ThumbnailPadding = 2;
30
31}
32
38class ARTICYEDITOR_API SArticyObjectAssetPicker : public SCompoundWidget
39{
40public:
41 SLATE_BEGIN_ARGS(SArticyObjectAssetPicker) :
42 _CurrentClassRestriction(UArticyObject::StaticClass()),
43 _TopLevelClassRestriction(UArticyObject::StaticClass()),
44 _bExactClass(false),
45 _bExactClassEditable(true),
46 _bClassFilterEditable(true)
47 {}
48 SLATE_EVENT(FOnAssetSelected, OnArticyObjectSelected)
49 SLATE_ARGUMENT(UClass*, CurrentClassRestriction)
50 SLATE_ATTRIBUTE(UClass*, TopLevelClassRestriction)
51 SLATE_ATTRIBUTE(bool, bExactClass)
52 SLATE_ATTRIBUTE(bool, bExactClassEditable)
53 SLATE_ATTRIBUTE(bool, bClassFilterEditable)
54 SLATE_EVENT(FOnClassPicked, OnClassPicked)
55 SLATE_END_ARGS()
56
58
64 void Construct(const FArguments& InArgs);
65
73 virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override;
74
79
86 void SelectAsset(TWeakObjectPtr<UArticyObject> AssetItem, ESelectInfo::Type SelectInfo) const;
87
88private:
92 void CreateInternalWidgets();
93
99 void OnCopyProperty(FArticyId Id) const;
100
106 TSharedRef<SWidget> CreateClassPicker();
107
113 void OnExactClassCheckBoxChanged(ECheckBoxState NewState);
114
120 void OnClassPicked_Func(UClass* InChosenClass);
121
127 FText GetChosenClassName() const;
128
136 TSharedRef<class ITableRow> MakeTileViewWidget(TWeakObjectPtr<UArticyObject> Entity, const TSharedRef<STableViewBase>& OwnerTable) const;
137
143 float GetTileViewHeight() const;
144
150 float GetTileViewWidth() const;
151
155 void OnClear() const;
156
162 void OnSearchBoxChanged(const FText& InSearchText) const;
163
170 void OnSearchBoxCommitted(const FText& InSearchText, ETextCommit::Type CommitInfo) const;
171
175 void RefreshSourceItems();
176
182 void SetSearchBoxText(const FText& InSearchText) const;
183
187 void OnFrontendFiltersChanged();
188
195 bool TestAgainstFrontendFilters(const FAssetData& Item) const;
196
204 EActiveTimerReturnType FocusSearchField(double InCurrentTime, float InDeltaTime) const;
205
206private: // Slate Attributes
207 FOnAssetSelected OnAssetSelected;
208 FOnClassPicked OnClassPicked;
209 TAttribute<UClass*> TopLevelClassRestriction;
210 UClass* CurrentClassRestriction = nullptr;
211 TAttribute<bool> bExactClass;
212 TAttribute<bool> bExactClassEditable;
213 TAttribute<bool> bClassFilterEditable;
214
215private: // Widgets
216 TSharedPtr<SAssetSearchBox> SearchField;
217 TSharedPtr<SWidget> AssetViewContainer;
218 TSharedPtr<SListView<TWeakObjectPtr<UArticyObject>>> AssetView;
219 TSharedPtr<SHorizontalBox> FilterBox;
220 TSharedPtr<SComboButton> ClassFilterButton;
221
222private: // Internal Data
223 TSharedPtr<FArticyObjectFilterCollectionType> FrontendFilters;
224 TSharedPtr<FArticyClassRestrictionFilter> ClassFilter;
225 TSharedPtr<FFrontendFilter_ArticyObject> ArticyObjectFilter;
226
227 TArray<FAssetData> ArticyPackageDataAssets;
228 TArray<TWeakObjectPtr<UArticyObject>> FilteredObjects;
229 bool bSlowFullListRefreshRequested = false;
230};
231
232#undef LOCTEXT_NAMESPACE
A widget for picking Articy object assets.
Definition SArticyObjectAssetPicker.h:39
void Construct(const FArguments &InArgs)
Constructs the Articy Object Asset Picker widget.
Definition SArticyObjectAssetPicker.cpp:41
virtual void Tick(const FGeometry &AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override
Ticks the widget for updates.
Definition SArticyObjectAssetPicker.cpp:117
void RequestSlowFullListRefresh()
Requests a slow full list refresh.
Definition SArticyObjectAssetPicker.cpp:460
void SelectAsset(TWeakObjectPtr< UArticyObject > AssetItem, ESelectInfo::Type SelectInfo) const
Selects an asset in the asset picker.
Definition SArticyObjectAssetPicker.cpp:471
Definition ArticyBaseTypes.h:18