UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
InteractiveToolManager.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "UObject/Object.h"
7#include "InteractiveTool.h"
9#include "InputRouter.h"
12#include "InteractiveToolManager.generated.h"
13
16
18UENUM()
20{
22 Left = 1,
23 Mouse = 1,
25 Right = 2,
26};
27
28
34UENUM()
44
48UENUM()
50{
51 /* Accept if able, cancel if not (and complete if neither is possible) */
53 /* Cancel if able, complete if not */
55 /* Like AcceptIfAble, except a tool can change the shutdown type by implementing IInteractiveToolShutdownQueryAPI */
57 /* Like CancelIfAble, except a tool can change the shutdown type by implementing IInteractiveToolShutdownQueryAPI */
59};
60
61
77UCLASS(Transient, MinimalAPI)
79{
81
82protected:
83 friend class UInteractiveToolsContext; // to call Initialize/Shutdown
84
86
89
92
95
98
99public:
100
101
105 bool IsActive() const { return bIsActive; }
106
107
108 //
109 // Tool registration and Current Tool state
110 //
111
117 INTERACTIVETOOLSFRAMEWORK_API virtual void RegisterToolType(const FString& Identifier, UInteractiveToolBuilder* Builder);
118
124 INTERACTIVETOOLSFRAMEWORK_API virtual void UnregisterToolType(const FString& Identifier);
125
131 INTERACTIVETOOLSFRAMEWORK_API virtual bool SelectActiveToolType(EToolSide Side, const FString& Identifier);
132
137 INTERACTIVETOOLSFRAMEWORK_API virtual const FString& GetActiveToolType(EToolSide Side) const;
138
145 INTERACTIVETOOLSFRAMEWORK_API virtual bool CanActivateTool(EToolSide eSide, FString Identifier);
146
153 INTERACTIVETOOLSFRAMEWORK_API virtual bool ActivateTool(EToolSide Side);
154
161
166 virtual EToolManagerToolSwitchMode GetToolSwitchMode() const { return ToolSwitchMode; }
167
177
181 INTERACTIVETOOLSFRAMEWORK_API virtual bool HasAnyActiveTool() const;
182
183
189 INTERACTIVETOOLSFRAMEWORK_API virtual UInteractiveTool* GetActiveTool(EToolSide Side);
190
196 INTERACTIVETOOLSFRAMEWORK_API virtual UInteractiveToolBuilder* GetActiveToolBuilder(EToolSide Side);
197
204
211
218
224 INTERACTIVETOOLSFRAMEWORK_API virtual void DeactivateTool(EToolSide Side, EToolShutdownType ShutdownType);
225
229 INTERACTIVETOOLSFRAMEWORK_API EToolShutdownType GetPreferredShutdownType(EToolSide Side,
231
235 INTERACTIVETOOLSFRAMEWORK_API virtual void ConfigureChangeTrackingMode(EToolChangeTrackingMode ChangeMode);
236
240 INTERACTIVETOOLSFRAMEWORK_API virtual EToolChangeTrackingMode GetChangeTrackingMode() const;
241
242 //
243 // Functions that Tools can call to interact with Transactions API
244 //
245
247 INTERACTIVETOOLSFRAMEWORK_API virtual void DisplayMessage(const FText& Message, EToolMessageLevel Level);
248
250 INTERACTIVETOOLSFRAMEWORK_API virtual void PostInvalidation();
251
256 INTERACTIVETOOLSFRAMEWORK_API virtual void BeginUndoTransaction(const FText& Description);
257
259 INTERACTIVETOOLSFRAMEWORK_API virtual void EndUndoTransaction();
260
267 INTERACTIVETOOLSFRAMEWORK_API virtual void EmitObjectChange(UObject* TargetObject, TUniquePtr<FToolCommandChange> Change, const FText& Description );
268
269
273 INTERACTIVETOOLSFRAMEWORK_API virtual bool RequestSelectionChange(const FSelectedObjectsChangeList& SelectionChange);
274
275 //
276 // State control (@todo: have the Context call these? not safe for anyone to call)
277 //
278
280 INTERACTIVETOOLSFRAMEWORK_API virtual void Tick(float DeltaTime);
281
284
287
301 INTERACTIVETOOLSFRAMEWORK_API virtual bool PostActiveToolShutdownRequest(
303 EToolShutdownType ShutdownType,
306
314
316
322
323
324 //
325 // access to APIs, etc
326 //
327
329 virtual IToolsContextQueriesAPI* GetContextQueriesAPI() { return QueriesAPI; }
330
332 virtual IToolsContextTransactionsAPI* GetContextTransactionsAPI() final { return TransactionsAPI; }
333
335
339 INTERACTIVETOOLSFRAMEWORK_API UContextObjectStore* GetContextObjectStore() const;
340
341public:
343 UPROPERTY()
345
347 UPROPERTY()
348 TObjectPtr<UInteractiveTool> ActiveRightTool;
349
350
351
352
353public:
356
359
362
365
366 // Variant of OnToolEnded that also reports the EToolShutdownType
369
370
376
379
381 bool bIsActive = false;
382
383 // This bool is for handling the case where a Tool posts a shutdown request during it's Setup() call.
384 // In that case we will terminate the Tool immediately
385 bool bInToolSetup = false;
386 bool bToolRequestedTerminationDuringSetup = false;
387
388
390 UPROPERTY()
391 TMap<FString, TObjectPtr<UInteractiveToolBuilder>> ToolBuilders;
392
394 FString ActiveLeftBuilderName;
395 UInteractiveToolBuilder* ActiveLeftBuilder;
397 FString ActiveRightBuilderName;
398 UInteractiveToolBuilder* ActiveRightBuilder;
399
400 EToolChangeTrackingMode ActiveToolChangeTrackingMode;
402
403 FString ActiveLeftToolName;
404 FString ActiveRightToolName;
405 bool bInToolShutdown = false;
406
407 UE_DEPRECATED(5.5, "bActiveToolMadeSelectionStoreRequest is no longer used.")
408 bool bActiveToolMadeSelectionStoreRequest = false;
409
410 INTERACTIVETOOLSFRAMEWORK_API virtual bool ActivateToolInternal(EToolSide Side);
411 INTERACTIVETOOLSFRAMEWORK_API virtual void DeactivateToolInternal(EToolSide Side, EToolShutdownType ShutdownType);
412
415};
416
417
418
419
425{
426public:
427 INTERACTIVETOOLSFRAMEWORK_API virtual void Apply(UObject* Object) override;
428
429 INTERACTIVETOOLSFRAMEWORK_API virtual void Revert(UObject* Object) override;
430
431 INTERACTIVETOOLSFRAMEWORK_API virtual bool HasExpired(UObject* Object) const override;
432
433 INTERACTIVETOOLSFRAMEWORK_API virtual FString ToString() const override;
434};
435
458
459
460
461
462
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_MULTICAST_DELEGATE_TwoParams(DelegateName, Param1Type, Param2Type)
Definition DelegateCombinations.h:58
#define DECLARE_MULTICAST_DELEGATE_FiveParams(DelegateName, Param1Type, Param2Type, Param3Type, Param4Type, Param5Type)
Definition DelegateCombinations.h:85
#define DECLARE_MULTICAST_DELEGATE_ThreeParams(DelegateName, Param1Type, Param2Type, Param3Type)
Definition DelegateCombinations.h:67
return true
Definition ExternalRpcRegistry.cpp:601
EToolChangeTrackingMode
Definition InteractiveToolManager.h:36
EToolSide
Definition InteractiveToolManager.h:20
EToolManagerToolSwitchMode
Definition InteractiveToolManager.h:50
EToolShutdownType
Definition InteractiveTool.h:45
EToolShutdownReason
Definition InteractiveTool.h:56
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
#define UENUM(...)
Definition ObjectMacros.h:749
EToolMessageLevel
Definition ToolContextInterfaces.h:314
Definition InteractiveToolManager.h:441
virtual INTERACTIVETOOLSFRAMEWORK_API void Revert(UObject *Object) override
Definition InteractiveToolManager.cpp:607
FString ToolType
Definition InteractiveToolManager.h:444
FActivateToolChange(EToolSide SideIn, FString ToolTypeIn)
Definition InteractiveToolManager.h:448
FActivateToolChange(EToolSide SideIn, FString ToolTypeIn, EToolShutdownType ShutdownTypeIn)
Definition InteractiveToolManager.h:450
virtual INTERACTIVETOOLSFRAMEWORK_API void Apply(UObject *Object) override
Definition InteractiveToolManager.cpp:590
EToolSide Side
Definition InteractiveToolManager.h:443
EToolShutdownType ShutdownType
Definition InteractiveToolManager.h:446
virtual INTERACTIVETOOLSFRAMEWORK_API bool HasExpired(UObject *Object) const override
Definition InteractiveToolManager.cpp:624
bool bIsDeactivate
Definition InteractiveToolManager.h:445
virtual INTERACTIVETOOLSFRAMEWORK_API FString ToString() const override
Definition InteractiveToolManager.cpp:630
Definition InteractiveToolManager.h:425
Definition CanvasTypes.h:211
Definition Text.h:385
Definition InteractiveToolManager.h:468
virtual INTERACTIVETOOLSFRAMEWORK_API bool HasExpired(UObject *Object) const override
Definition InteractiveToolManager.cpp:657
virtual INTERACTIVETOOLSFRAMEWORK_API FString ToString() const override
Definition InteractiveToolManager.cpp:673
TWeakObjectPtr< UInteractiveTool > ActiveTool
Definition InteractiveToolManager.h:471
TUniquePtr< FToolCommandChange > ToolChange
Definition InteractiveToolManager.h:472
virtual INTERACTIVETOOLSFRAMEWORK_API void Apply(UObject *Object) override
Definition InteractiveToolManager.cpp:641
TWeakObjectPtr< UInteractiveToolManager > ToolManager
Definition InteractiveToolManager.h:470
virtual INTERACTIVETOOLSFRAMEWORK_API void Revert(UObject *Object) override
Definition InteractiveToolManager.cpp:649
Definition InteractiveToolChange.h:18
Definition InteractiveToolChange.h:39
Definition ToolContextInterfaces.h:254
Definition ToolContextInterfaces.h:427
Definition ToolContextInterfaces.h:360
Definition UnrealString.h.inl:34
Definition UniquePtr.h:107
Definition ContextObjectStore.h:25
Definition InputRouter.h:39
Definition InteractiveGizmoManager.h:40
Definition InteractiveToolBuilder.h:28
Definition InteractiveToolManager.h:79
virtual IToolsContextTransactionsAPI * GetContextTransactionsAPI() final
Definition InteractiveToolManager.h:332
virtual EToolManagerToolSwitchMode GetToolSwitchMode() const
Definition InteractiveToolManager.h:166
bool IsActive() const
Definition InteractiveToolManager.h:105
DECLARE_DELEGATE_RetVal_ThreeParams(bool, FOnToolShutdownRequest, UInteractiveToolManager *, UInteractiveTool *, EToolShutdownType)
FOnToolShutdownRequest OnToolShutdownRequest
Definition InteractiveToolManager.h:313
DECLARE_MULTICAST_DELEGATE_FourParams(FOnToolUnexpectedShutdownMessage, UInteractiveToolManager *, UInteractiveTool *, const FText &Message, bool bWasDuringToolSetup)
virtual IToolsContextQueriesAPI * GetContextQueriesAPI()
Definition InteractiveToolManager.h:329
FOnToolUnexpectedShutdownMessage OnToolUnexpectedShutdownMessage
Definition InteractiveToolManager.h:321
virtual void SetToolSwitchMode(EToolManagerToolSwitchMode ToolSwitchModeIn)
Definition InteractiveToolManager.h:176
Definition InteractiveTool.h:364
Definition InteractiveToolsContext.h:39
INTERACTIVETOOLSFRAMEWORK_API bool CanAcceptActiveTool(EToolSide WhichSide) const
Definition InteractiveToolsContext.cpp:224
INTERACTIVETOOLSFRAMEWORK_API bool HasActiveTool(EToolSide WhichSide) const
Definition InteractiveToolsContext.cpp:208
INTERACTIVETOOLSFRAMEWORK_API bool CanCancelActiveTool(EToolSide WhichSide) const
Definition InteractiveToolsContext.cpp:229
TObjectPtr< UInputRouter > InputRouter
Definition InteractiveToolsContext.h:109
INTERACTIVETOOLSFRAMEWORK_API FString GetActiveToolName(EToolSide WhichSide) const
Definition InteractiveToolsContext.cpp:213
Definition Object.h:95
@ false
Definition radaudio_common.h:23
Definition ToolContextInterfaces.h:341
Definition ToolContextInterfaces.h:50
Definition ObjectPtr.h:488
Definition WeakObjectPtrTemplates.h:25