Files
UnrealEngineUWP/Engine/Source/Editor/GraphEditor/Private/SNodePanel.cpp
Marc Audy d5628cd986 Copying //UE4/Dev-Framework to //UE4/Dev-Main (Source: //UE4/Dev-Framework @ 3967517)
#rb none
#lockdown Nick.Penwarden
#rnx

============================
  MAJOR FEATURES & CHANGES
============================

Change 3804281 by Fred.Kimberley

	Improve contrast on watches in blueprints.

Change 3804322 by Fred.Kimberley

	First pass at adding a watch window for blueprint debugging.

Change 3804737 by mason.seay

	Added some Descriptions to tests that didn't have any, and fixed some typos

Change 3806103 by mason.seay

	Moved and Renamed Timers test map and content appropriately

Change 3806164 by Fred.Kimberley

	Add missing property types to GetDebugInfoInternal.

	#jira UE-53355

Change 3806617 by Dan.Oconnor

	Function Terminator (and derived types) now use FMemberReference instead of a UClass/FName pair. This fixes various bugs when resolving the UFunction referenced by the function terminator

	#jira UE-31754, UE-42431, UE-53315, UE-53172

Change 3808541 by Fred.Kimberley

	Add support for redirecting user defined enums.
	This is in response to the following UDN thread: https://udn.unrealengine.com/questions/404141/is-is-possible-to-create-a-redirector-from-a-bluep.html

Change 3808565 by mason.seay

	Added a few more struct tests

Change 3809840 by mason.seay

	Renamed CharacterMovement.umap to CharacterCollision.  Fixed up content to reflect this change.

Change 3809847 by mason.seay

	Added Object Timer tests.  Fixed up existing timer test to remove delay dependency

Change 3811704 by Ben.Zeigler

	Fix issue where identical enum redirects registered to different initial names would throw an incorrect error, it's fine if the value change maps are identical

Change 3811946 by Ben.Zeigler

	#jira UE-53511 Fix it so it is possible to set a user defined struct value back to it's default. The UDS hack in PropertyValueToString is no longer needed, but this could affect some other user struct editor operations

Change 3812061 by Dan.Oconnor

	Stepping over or in to nodes that are expanded at compile time (e.g. event nodes, spawn actor nodes) no longer requires multiple 'steps'

	#jira UE-52854

Change 3812259 by Dan.Oconnor

	Fix asset broken by removal of an unkown enum

	#jira UE-51419

Change 3812904 by Ben.Zeigler

	Make ResolveRedirects on StreamableManager public as it can be used to validate things

Change 3812958 by Ben.Zeigler

	#jira UE-52977 Fix crashes when binding blueprint editor commands to keys and using from invalid contexts

Change 3812975 by Mieszko.Zielinski

	Added contraptions to catch a rare eidtor-time EQS crash #UE4

	#jira UE-53468

Change 3818530 by Phillip.Kavan

	Fix incorrect access to nested instanced subobjects in nativized Blueprint ctor codegen.

	Change summary:
	- Modified FEmitDefaultValueHelper::HandleInstancedSubobject() to properly reference the outer and check ptr validity when creating/obtaining nested default subobjects.
	- Modified FEmitDefaultValueHelper::HandleClassSubobject() to better guard against code generation based on an invalid local variable name.

	#jira UE-52167

Change 3819733 by Mieszko.Zielinski

	Marked UAISenseConfig_Blueprint and UAISense_Blueprint as hidedropdown #UE4

	#jira UE-15089

Change 3821776 by Marc.Audy

	Remove redundent code in SpawnActorFromClass that already exists in ConstructObjectFromClass parent class

Change 3823851 by mason.seay

	Moved and renamed blueprints used for Object Reference testing

Change 3824165 by Phillip.Kavan

	Ensure that subobject class types are constructed prior to accessing a subobject CDO in a nativized Blueprint class's generated ctor at runtime.

	Change summary:
	- Modified FFakeImportTableHelper to tag subobject class types as a preload dependency of the outer converted Blueprint class type and not of the CDO.

	#jira UE-53111

Change 3830309 by mason.seay

	Created Literal Gameplay Tag Container test

Change 3830562 by Phillip.Kavan

	Blueprint nativization bug fixes (reviewed/taken from PR).

	Change summary:
	- Modified FSafeContextScopedEmitter::ValidationChain() to ensure that generated code calls the global IsValid() utility function on objects.
	- Modified FBlueprintCompilerCppBackend::EmitCreateArrayStatement() to generate a proper cast on MakeArray node inputs for enum class types.
	- Modified FBlueprintCompilerCppBackend::EnimCallStatementInner() to more correctly identify an interface function call site.
	- Modified FEmitHelper::GenerateAutomaticCast() to properly handle automatic casts of enum arrays.
	- (Modified from PR source) Added new FComponentDataUtils statics to consolidate custom init code generation for converted special-case component types (e.g. BodyInstance). Ties native component DSOs to the same pre/post as converted non-native component templates around the OuterGenerate() loop.
	- Modified FExposeOnSpawnValidator::IsSupported() to include CPT_SoftObjectReference property types.
	- Modified UBlueprintGeneratedClass::CheckAndApplyComponentTemplateOverrides() to no longer break out of the loop before finding additional ICH override record matches.

	#4202

	#jira UE-52188

Change 3830579 by Fred.Kimberley

	Add support for turning off multiple watches at once in the watch window.

	#jira UE-53852

Change 3836047 by Zak.Middleton

	#ue4 - Dev test maps for overlaps perf tests.

Change 3836768 by Phillip.Kavan

	Fix for a build failure that could occur with Blueprint nativization enabled and EDL disabled. This was a regression introduced in 4.18.

	Change summary:
	- Modified FEmitDefaultValueHelper::AddStaticFunctionsForDependencies() to emit the correct signature for constructing FBlueprintDependencyData elements when the EDL boot time optimization is disabled.

	#jira UE-53908

Change 3838085 by mason.seay

	Functional tests around basic blueprint functions

Change 3840489 by Ben.Zeigler

	#jira UE-31662 Fix regression with renaming parent inherited function. It was not correctly searching the parent's skeleton class during the child's recompile so it was erroneously detecting the parent function as missing

Change 3840648 by mason.seay

	Updated Descriptions on tests

Change 3842914 by Ben.Zeigler

	Improve comments around stremable handle cancel/release

Change 3850413 by Ben.Zeigler

	Fix asset registry memory reporting, track some newer fields and correctly report the state size instead of static size twice
	Copy of CL #3849610

Change 3850426 by Ben.Zeigler

	Reduce asset registry memory in cooked build by stripping out searchable names and empty dependency nodes by default
	Add option to strip dependency data for asset data with no tags, this was always true before but isn't necessarily safe
	Copy of CL #3850389

Change 3853449 by Phillip.Kavan

	Fix a scoping issue for local instanced subobject references in nativized Blueprint C++ code. Also, don't emit redundant assignment statements for instanced subobject reference properties.

	Change summary:
	- Consolidated FComponentDataUtils into FDefaultSubobjectData and extended FNonativeComponentData from it in order to handle both native & non-native DSO initialization codegen through a more common interface.
	- Exposed FEmitDefaultValueHelper::HandleInstancedSubobject() as a public API and added a 'SubobjectData' parameter to allow initialization codegen to be deferred until after all default subobjects have been mapped to local variables within the current scope.
	- Modified FEmitDefaultValueHelper::GenerateConstructor() to first map all default subobjects to local variables and then emit any delta initialization code for property values.
	- Modified FEmitDefaultValueHelper::HandleSpecialTypes() to return an empty string for an instanced reference to a default subobject. This allows us to avoid emitting initialization statements to unnecessarily reassign instances back to the same property.
	- Modified FEmitDefaultValueHelper::InnerGenerate() to better handle instanced references to default subobjects, ensuring that we don't emit unnecessary assignment statements and array initialization code to the converted class constructor in C++.
	- Fixed a few typos.

	#jira UE-53960

Change 3853465 by Phillip.Kavan

	Fix plugin module C++ source template to conform to recent public include path changes.

Change 3857599 by Marc.Audy

	PR #4438: UE-54281: Make None a valid default value to select (Contributed by projectgheist)
	#jira UE-54281
	#jira UE-54399

Change 3863259 by Zak.Middleton

	#ue4 - Save bandwidth for replicated characters by only replicating 4 byte timestamp value to clients if it's actually needed for Linear smoothing. Added option to always replicate the timestamp ("bNetworkAlwaysReplicateTransformUpdateTimestamp", default off), in case users still want this timestamp for some reason, or if smoothing mode changes dynamically and the server won't know.

	#jira UE-46293

Change 3863491 by Zak.Middleton

	#ue4 - Reduce network RPC overhead for players that are not moving. Added ClientNetSendMoveDeltaTimeStationary (default 12Hz) to supplement existing ClientNetSendMoveDeltaTime and ClientNetSendMoveDeltaTimeThrottled. UCharacterMovementComponent::GetClientNetSendDeltaTime() now uses this time if Acceleration and Velocity are zero, and the control rotation matches the last ack'd control rotation from the server.

	Also fixed up code default for ClientNetSendMoveDeltaTime to match default INI value.

	#jira UE-21264

Change 3865325 by Zak.Middleton

	#ue4 - Fix static analysis warning about possible null PC pointer.

	#jira none

Change 3869828 by Ben.Zeigler

	#jira UE-54786 Fix it so -cookonthefly cooperates with -iterate by writing out a development asset registry

Change 3869969 by mason.seay

	Character Movement Functional Tests

Change 3870099 by Mason.Seay

	Submitted asset deletes

Change 3870105 by mason.seay

	Removed link to anim blueprint to fix errors

Change 3870238 by mason.seay

	Test map for Async Loading in a Loop

Change 3870479 by Ben.Zeigler

	Add code to check CoreRedirects for SoftObjectPaths when saving or resolving in the editor. This is a bit slow so we don't want to do it on load
	We don't have any good way to know the type of a path so I check both Object and Class redirectors, which will also pickup Module renames

Change 3875224 by mason.seay

	Functional tests for Event BeginPlay execution order

Change 3875409 by mason.seay

	Optimized and fixed up character movement tests (because a potential bug in FunctionalTestActor is always passing a test when it can fail)

Change 3878947 by Mieszko.Zielinski

	CIS fixes #UE4

Change 3879000 by Mieszko.Zielinski

	More CIS fixes #UE4

Change 3879139 by Mieszko.Zielinski

	Even moar CIS fixes #UE4

Change 3879742 by mason.seay

	Added animation to Nativization Widget asset

Change 3880198 by Zak.Middleton

	#ue4 - CanCrouchInCurrentState() returns false when character capsule is simulating physics.

	#jira UE-54875
	github #4479

Change 3880266 by Zak.Middleton

	#ue4 - Optimize UpdateCharacterStateBeforeMovement() to do cheaper tests earlier (avoid CanCrouchInCurrentState() unless necessary, now that it tests IsSimulatingPhysics() which is not trivial).

	#jira UE-54875

Change 3881546 by Mieszko.Zielinski

	*.Build.cs files clean up - removed redundant dependencies from NavigationSystem and AIModule #UE4

Change 3881547 by Mieszko.Zielinski

	Removed a bunch of DEPRECATED functions from the new NavigationSystem module #UE4

	Removed all deprecates prior 4.15 (picked this one because I do know some licencees are still using it).

Change 3881742 by mason.seay

	Additional crouch test to cover UE-54875

Change 3881794 by Mieszko.Zielinski

	Fixed a bug in FVisualLoggerHelpers::GetCategories resulting in losing verbosity information #UE4

Change 3884503 by Mieszko.Zielinski

	Fixed TopDown code template to make it compile after navsys refactor #UE4

	#jira UE-55039

Change 3884507 by Mieszko.Zielinski

	Switched ensures in UNavigationSystemV1:SimpleMoveToX to error-level logs #UE4

	It's an error rather than a warning because the functions no longer do anything. Making it work would require a cyclic dependency between NavigationSystem and AIModule.

	#jira UE-55033

Change 3884594 by Mieszko.Zielinski

	Added a const FNavigationSystem::GetCurrent version #UE4

	lack of it was causing KiteDemo to not compile.

Change 3884602 by Mieszko.Zielinski

	Mac editor compilation fix #UE4

Change 3884615 by Mieszko.Zielinski

	Fixed FAIDataProviderValue::GetRawValuePtr not being accessible from outside of AIModule #UE4

Change 3885254 by Mieszko.Zielinski

	Guessfix for UE-55030 #UE4

	The name of NavigationSystem module was put in wrong in the IMPLEMENT_MODULE macro

	#jira 55030

Change 3885286 by Mieszko.Zielinski

	Changed how NavigationSystem module includes DerivedDataCache module #UE4

	#jira UE-55035

Change 3885492 by mason.seay

	Minor tweaks to animation

Change 3885773 by mason.seay

	Resaving assets to clear out warning

Change 3886433 by Mieszko.Zielinski

	Fixed TP_TopDownBP's player controller BP to not use deprecated nav functions #UE4

	#jira UE-55108

Change 3886783 by Mieszko.Zielinski

	Removed silly inclusion of NavigationSystemTypes.h from NavigationSystemTypes.h #UE4

Change 3887019 by Mieszko.Zielinski

	Fixed accessing unchecked pointer in ANavigationData::OnNavAreaAdded #UE4

Change 3891031 by Mieszko.Zielinski

	Fixed missing includes in NavigationSystem.cpp #UE4

Change 3891037 by Mieszko.Zielinski

	ContentEample's navigation fix #UE4

	#jira UE-55109

Change 3891044 by Mieszko.Zielinski

	PR #4456: Fix bug in UAISense_Sight::OnListenerForgetsActor (Contributed by maxtunel)

	#UE4

Change 3891598 by mason.seay

	Resaving assets to clear out "empty engine version" spam

Change 3891612 by mason.seay

	Fixed deprecated Set Text warnings

Change 3893334 by Mieszko.Zielinski

	Fixed a bug in navmesh generation resulting in not removing layers that ended up empty after rebuilding #UE4

	#jira UE-55041

Change 3893394 by Mieszko.Zielinski

	Fixed navmesh debug drawing to properly display octree elements with "per instance transforms" (like instanced SMs) #UE4

	Also, added a more detailed debug drawing of navoctree contents (optional, but on by default).

Change 3893395 by Mieszko.Zielinski

	Added a bit of code to navigation system's initialization that checks the enegine ini for sections refering to the moved navigation classes, and complain about it #UE4

	The message is printed as an error-level log line and it says what should the offending section be renamed to.

Change 3895563 by Dan.Oconnor

	Mirror 3895535
	Append history from previous branches in source control history view

	#jira none

Change 3896930 by Mieszko.Zielinski

	Added an option to tick navigation system while the game is paused #UE4

	Controlled via NavigationSystemV1.bTickWhilePaused, ini- and ProjectSettings-configurable.

	#jira UE-39275

Change 3897554 by Mieszko.Zielinski

	Unified how NavMeshRenderingComponent draws navmesh and octree collision's polys #UE4

Change 3897556 by Mieszko.Zielinski

	Fixed what kind of nav tile bounds we're sending to nav-colliding elements when calling 'per-instance transform' delegate #UE4

	#jira UE-45261

Change 3898064 by Mieszko.Zielinski

	Made SM Editor display AI-navigation-related whenever bHasNavigationData is set to true #UE4

	#jira UE-50436

Change 3899004 by Mieszko.Zielinski

	Fixed UEnvQueryItemType_Actor::GetItemLocation and UEnvQueryItemType_Actor::GetItemRotation to return FAISystem::InvalidLocation and FAISystem::InvalidRotation respectively instead of '0' when hosted Actor ptr is null #UE4

	Note for programmers: this changes the default behavior of this edge case. You might want to go through your code and check if you're comparing UEnvQueryItemType_Actor::GetItem*'s results to 0.

Change 3901733 by Mieszko.Zielinski

	Made FEnvQueryInstance::PrepareContext implementations returning vectors and rotators ignore InvalidLocation and InvalidRotation (respectively) #UE4

Change 3901925 by Ben.Zeigler

	#jira UE-55395 Fix issue where the cooker could load asset registry caches made in -game that do not have dependency data, leading to broken cooks

Change 3902166 by Marc.Audy

	Make ULevel::GetWorld final

Change 3902749 by Ben.Zeigler

	Fix it so pressing refresh button in asset audit window actually refreshes the asset management database

Change 3902763 by Ben.Zeigler

	#jira UE-55407 Fix it so editor tutorials are not cooked unless referenced, by correctly marking soft object paths imported from editor project settings as editor-only

Change 3905578 by Phillip.Kavan

	The UX to add a new parameter on a Blueprint delegate is now at parity with Blueprint functions.

	#4392

	#jira UE-53779

Change 3905848 by Phillip.Kavan

	First pass of the experimental Blueprint graph bookmarks feature.

	#jira UE-10052

Change 3906025 by Phillip.Kavan

	CIS fix.

Change 3906195 by Phillip.Kavan

	Add missing icon file.

Change 3906356 by Phillip.Kavan

	Moved Blueprint bookmarks enable flag into EditorExperimentalSettings for consistency with other options.

Change 3910628 by Ben.Zeigler

	Partial fix for UE-55363, this allows references to ObjectRedirectors to be switched from parent class to a child class on load as this should always be safe
	This does not actually fix UE-55363 because that case is changing from UMaterial to UMaterialInstanceConstant, and those are siblings instead of parent/child

Change 3912470 by Ben.Zeigler

	#jira UE-55586 Fix issue with saving redirected soft object paths where the export sort could accidentally cause the parent CDO to get modified between name tagging and writing exports, which is unsafe because due to delta serialization it would try to write names that were not previously tagged

Change 3913045 by Marc.Audy

	Fix issues where recursion in to child actors wasn't being handled correctly

Change 3913398 by Fred.Kimberley

	Fixes a misspelled name for one of the classes in the ability system.

	PR #4430: Fixed spelling of FGameplayAbilityInputBinds. (Contributed by IntegralLee)
	#github

	#jira UE-54327

Change 3918016 by Fred.Kimberley

	Ensure AllocGameplayEffectContext is being used in all cases where FGameplayeEffectContext is being created.

	#jira UE-52668

	PR #4250: Only create FGameplayEffectContext via AbilitySystemGlobals::.AllocGameplayEffectContext (Contributed by slonopotamus)
	#github

Change 3924653 by Mieszko.Zielinski

	Fixed LoadEngineClass local to UnrealEngine.cpp to check class redirects before falling back to default class instance #UE4

	#jira UE-55378

Change 3925614 by Phillip.Kavan

	Fix ForEachEnum node to skip over hidden enum values in new placements by default.

	Change summary:
	- Added FKismetNodeHelperLibrary::ShouldHideEnumeratorIndex() as an internal-only Blueprint node support API.
	- Modified FForExpandNodeHelper::AllocateDefaultPins() to add a "Skip Hidden" input pin (advanced). Pin default value is false.
	- Added a UK2Node_ForEachElementInEnum::PostPlacedNewNode() override to set the default value of the "Skip Hidden" input pin to 'true' for all new node placements.
	- Modified UK2Node_ForEachElementInEnum::ExpandNode() to include additional expansion logic based on the "Skip Hidden" input pin. For new placements (i.e. when the pin defaults to 'true'), an intermediate branch node will now be inserted into the compiled execution sequence to test for "hidden" metadata on the value before executing the loop body. If the input pin is linked, another intermediate branch will be inserted into the execution sequence prior to the "hidden" metadata test. All existing placements of the node will remain as-is after compilation (i.e. no additional intermediate branch nodes will be included in the expansion).

	#jira UE-34563

Change 3925649 by Marc.Audy

	Fix up issue post merge from Main with navigation system refactor

Change 3926293 by Phillip.Kavan

	Temp fix to unblock CIS.

	#jira UE-34563

Change 3926523 by Marc.Audy

	Ensure that a renamed Actor is in the correct Actors array

	#jira UE-46718

Change 3928732 by Fred.Kimberley

	Unshelved from pending changelist '3793298':

	#jira UE-53136

	PR #4287: virtual additions for AttributeSet extendability (Contributed by TWIDan)
	#github

Change 3928780 by Marc.Audy

	PR #4309: The display names of the functions. (Contributed by SertacOgan)
	#jira UE-53334

Change 3929730 by Joseph.Wysosky

	Submitting test assets for the new Blueprint Structure test cases

Change 3931919 by Joseph.Wysosky

	Deleting BasicStructure asset to rest MemberVariables back to default settings

Change 3931922 by Joseph.Wysosky

	Adding BasicStructure test asset back with default members

Change 3932083 by Phillip.Kavan

	Fix Compositing plugin source files to conform to updated relative include path specifications.

	- Encountered while testing Blueprint nativization of assets with dependencies on Composure/LensDistortion APIs.

Change 3932196 by Dan.Oconnor

	Resetting a property to default now uses the same codepath as assigning the value from the slate control

	#jira UE-55909

Change 3932408 by Lukasz.Furman

	fixed behavior tree services attached to task nodes being sometimes recognized as root level
	#jira nope

Change 3932808 by Marc.Audy

	PR #4083: Change to UK2Node_BaseAsyncTask to have pin tooltips on latent nodes (Contributed by dwrpayne)
	#jira UE-50871

Change 3934101 by Phillip.Kavan

	Revise ForEachEnum node expansion logic to exclude hidden values at compile time.

	Change summary:
	- Removed UKismetNodeHelperLibrary::ShouldHideEnumeratorIndex() (no longer in use).
	- Modified UK2Node_ForEachElementInEnum::ExpandNode() to include an enum switch node in the expansion, which will exclude hidden values when constructed. The additional expansion will occur if the enum type contains at least one hidden value.

	#jira UE-34563

Change 3934106 by Phillip.Kavan

	Mirrored 4.19 fixes to allow for EngineTest iteration w/ nativization enabled.

	Change summary:
	- Mirrored CLs 3876918, 3878968, 3883257, 3885566, 3912161 and 3920519.

Change 3934116 by Phillip.Kavan

	UBT: Explicitly define the DEPRECATED_FORGAME macro only for non-engine modules.

	Change summary:
	- Modified UEBuildModule.SetupPrivateCompileEnvironment() to check the 'bTreatAsEngineModule' flag from the rules assembly rather than testing the module's build type.

Change 3934382 by Phillip.Kavan

	Avoid inclusion of monolothic engine header files in nativized Blueprint codegen.

Change 3936387 by Mieszko.Zielinski

	Added a flag to NavModifierComponent to control whether agent's height is being used while expadning modifier's bounds during navmesh generation #UE4

Change 3936905 by Ben.Marsh

	Disable IncludeTool warning for DEPRECATED_FORGAME macro; we expect this to be different for game modules.

Change 3940537 by Marc.Audy

	Don't allow maps, sets, or arrays with an actor inner type in user defined structs to select an actor from the currently open level as default value.
	#jira UE-55938

Change 3940901 by Marc.Audy

	Properly name CVar global to reflect what it is for

Change 3943043 by Marc.Audy

	Fix world context functions not being able to be used in CheatManager derived blueprints
	#jira UE-55787

Change 3943075 by Mieszko.Zielinski

	Moved path-following related delegats' interface from NavigationSystemBase over to a new IPathFollowingManagerInterface #UE4

Change 3943089 by Mieszko.Zielinski

	Fixed how WorldSettings.NavigationSystemConfig gets created #UE4

	Made it so that there's always a NavigationSystemConfig instance present, but added a 'Null' config - this was required due to issues with creation/serialization of instanced subobjects.
	The change required adding copying constructors to FNavAgentProperties and FNavDataConfig.
	Also, fixed FNavAgentProperties.IsEquivalent to be symetrical.

Change 3943225 by Marc.Audy

	Fix spelling of Implements

Change 3950813 by Marc.Audy

	Include owner in attachment mismatch ensure
	#jira UE-56148

Change 3950996 by Marc.Audy

	Fix cases where bit packed properties used the entire byte not just the bit when interacting with boolean arrays

	#jira UE-55482

Change 3952086 by Marc.Audy

	PR #4483: Add Missing Radial Damage Multicast Delegate (Contributed by error454)
	#jira UE-54974

Change 3952720 by Marc.Audy

	PR #4575: Check if *Pawn* is a null Pointer (Contributed by dani9bma)
	#jira UE-56248

Change 3952804 by Richard.Hinckley

	Changes to BP API export commandlet to support better plugin exporting. Contributed by Harry Wang of Google.

Change 3952962 by Marc.Audy

	UHT now validates that ExpandEnumAsExecs references a valid parameter to the function.
	#jira UE-49610

Change 3952977 by Phillip.Kavan

	Fix EDL cycle at load time in nativized cooked builds when a circular dependency exists between converted and unconverted assets.

	Change summary:
	- Added FGatherConvertedClassDependencies::MarkUnconvertedClassAsNecessary().
	- Modified FFindAssetsToInclude::MaybeIncludeObjectAsDependency() to mark unconverted BPGCs (e.g. DOBPs) as necessary for conversion when the potential for a circular dependency exists so that we generate stub wrappers rather than depend on them directly.
	- Fixed a few typos in existing API names.

	#jira UE-48233

Change 3953658 by Marc.Audy

	(4.19.1) Fix inserting a reroute node causing connections to break on a GetClassDefaults node
	#jira UE-56270

Change 3954727 by Marc.Audy

	Add friendly name to custom version mismatch message

Change 3954906 by Marc.Audy

	(4.19.1) Fix crash when undoing changes related to reroute nodes connected to a GetClassDefaults node
	#jira UE-56313

Change 3954997 by Marc.Audy

	Ensure and return null if GetOuter<WithinClass> is called on a CDO for uclasses declared as within another so we don't get a UPackage c-style cast to the expected outer type

Change 3955091 by Marc.Audy

	Do not register subcomponents that are not auto register
	#jira UE-52878

Change 3955943 by Marc.Audy

	Make AbilitySystemComponent pass parameters by const& instead of ref as no state is being changed

Change 3956185 by Zak.Middleton

	#ue4 - Fix Characters using scoped movement updates (the default) not visually rotating when rotated at small rates at high framerate.

	This was caused by FScopedMovementUpdate::IsTransformDirty() using a larger FTransform comparison tolerance than USceneComponent::UpdateComponentToWorldWithParent().

	#jira none

Change 3958102 by Marc.Audy

	Clean out dead code path from k2node_select
	Select node now resets pins to wildcard if none of the pins are in use

Change 3958113 by Lukasz.Furman

	added OnSearchStart call to root level behavior tree services
	#jira UE-56257

Change 3958361 by Marc.Audy

	Fix literal input pins on select being set to wildcard during compilation

Change 3961148 by Dan.Oconnor

	Mirror 3961139 from Release 4.19
	Fix for placeholder objects being left behind when loading certain UMG assets - this could causea crash when loading UMG assets
	#jira UE-55742

Change 3961640 by Marc.Audy

	Select node now displays Add Pin button
	Undo of changing select node index type now works correctly.
	Connections to option pins now maintained across change of index pin type
	#jira UE-20742

Change 3962262 by Marc.Audy

	Display "Object Reference" instead of "Object Object Reference" and "Soft Object Reference" instead of "Object Soft Object Reference"

Change 3962795 by Phillip.Kavan

	Fix for a crash when cooking with Blueprint nativization enabled after encountering a nested instanced editor-only default subobject inherited from a native C++ base class.

	- Mirrored from //UE4/Release-4.19 (3962782)

	#jira UE-56316

Change 3962991 by Marc.Audy

	Modify Negate/Increment/Decrement Int/Float so that the output is always the desired result even if a non-mutable pin is passed in.
	Note that this can mean the result being returned and the value of the pin passed in if queried again will not be the same (in the case of pure nodes).
	#jira UE-54807

Change 3963114 by Marc.Audy

	Fix ensures/crash as a result of UClass expecting to be able to access the UPackage of CDOs via the GetOuterUPackage call.

Change 3963427 by Marc.Audy

	Fix initialization order
	Initialize bUseBackwardsCompatForEmptyAutogeneratedValue

Change 3963781 by Marc.Audy

	Fix without editor compiles

Change 3964576 by Marc.Audy

	PR #4599: : Working category for timelines (Contributed by projectgheist)
	#jira UE-56460
	#jira UE-26053

Change 3964782 by Dan.Oconnor

	Mirror 3964772 from Release 4.19

	Fix crash when force deleting certain blueprints, we can only check for authoritativeness while reinstancing

	#jira UE-56447

Change 3965156 by Mieszko.Zielinski

	PR #4592: Visual Logger optimization to fix rapid FPS drop when many items are hidden (Contributed by tstaples)

	#jira UE-56435

Change 3965173 by Marc.Audy

	(4.19.1) Fix incorrectly switching a cooling down tick to be an enabled tick when marking it enabled.
	#jira UE-56431

Change 3966117 by Marc.Audy

	Fix select nodes inside macros using wildcard array inputs having issues resolving type.
	#jira UE-56484

Change 3878901 by Mieszko.Zielinski

	NavigationSystem's code refactored out of the engine and into a new separate module #UE4

	The CL contains required changes to all of our internal projects. Fortnite and Paragon have been tested, while the rest have been only compiled.

Change 3879409 by Mieszko.Zielinski

	Further fallout fixes after ripping out NavigationSystem out of the engine #UE4

	- Fixed bad ini redirects (had NavigationSystem.NavigationSystem instead of NavigationSystem.NavigationSystemV1)
	- Added missing FNavigationSystem::GetDefaultNavDataClass binding (resulting in QAGame's func tests failing)

Change 3897655 by Ben.Zeigler

	#jira UE-55211 Fix it so literal soft object pins on blueprint nodes get correctly cooked/referenced
	It now sets the thread context to skip internal serialize and calls the archive's serialize function instead of bypassing it, which allows it to pick up references

	Change 3962780 by Marc.Audy

	When preventing a split pin from being orphaned, all sub pins must also be prevented.
	#jira UE-56328
	Repack members of UEdGraphPin to avoid wasted space (saves 16bytes)

[CL 3967553 by Marc Audy in Main branch]
2018-03-27 14:27:07 -04:00

1716 lines
56 KiB
C++

// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
#include "SNodePanel.h"
#include "Rendering/DrawElements.h"
#include "Fonts/FontMeasure.h"
#include "Framework/Application/SlateApplication.h"
#include "Classes/EditorStyleSettings.h"
#include "Settings/LevelEditorViewportSettings.h"
#include "ScopedTransaction.h"
#include "GraphEditorSettings.h"
struct FZoomLevelEntry
{
public:
FZoomLevelEntry(float InZoomAmount, const FText& InDisplayText, EGraphRenderingLOD::Type InLOD)
: DisplayText(FText::Format(NSLOCTEXT("GraphEditor", "Zoom", "Zoom {0}"), InDisplayText))
, ZoomAmount(InZoomAmount)
, LOD(InLOD)
{
}
public:
FText DisplayText;
float ZoomAmount;
EGraphRenderingLOD::Type LOD;
};
struct FFixedZoomLevelsContainer : public FZoomLevelsContainer
{
FFixedZoomLevelsContainer()
{
ZoomLevels.Reserve(20);
ZoomLevels.Add(FZoomLevelEntry(0.100f, FText::FromString(TEXT("-12")), EGraphRenderingLOD::LowestDetail));
ZoomLevels.Add(FZoomLevelEntry(0.125f, FText::FromString(TEXT("-11")), EGraphRenderingLOD::LowestDetail));
ZoomLevels.Add(FZoomLevelEntry(0.150f, FText::FromString(TEXT("-10")), EGraphRenderingLOD::LowestDetail));
ZoomLevels.Add(FZoomLevelEntry(0.175f, FText::FromString(TEXT("-9")), EGraphRenderingLOD::LowestDetail));
ZoomLevels.Add(FZoomLevelEntry(0.200f, FText::FromString(TEXT("-8")), EGraphRenderingLOD::LowestDetail));
ZoomLevels.Add(FZoomLevelEntry(0.225f, FText::FromString(TEXT("-7")), EGraphRenderingLOD::LowDetail));
ZoomLevels.Add(FZoomLevelEntry(0.250f, FText::FromString(TEXT("-6")), EGraphRenderingLOD::LowDetail));
ZoomLevels.Add(FZoomLevelEntry(0.375f, FText::FromString(TEXT("-5")), EGraphRenderingLOD::MediumDetail));
ZoomLevels.Add(FZoomLevelEntry(0.500f, FText::FromString(TEXT("-4")), EGraphRenderingLOD::MediumDetail));
ZoomLevels.Add(FZoomLevelEntry(0.675f, FText::FromString(TEXT("-3")), EGraphRenderingLOD::MediumDetail));
ZoomLevels.Add(FZoomLevelEntry(0.750f, FText::FromString(TEXT("-2")), EGraphRenderingLOD::DefaultDetail));
ZoomLevels.Add(FZoomLevelEntry(0.875f, FText::FromString(TEXT("-1")), EGraphRenderingLOD::DefaultDetail));
ZoomLevels.Add(FZoomLevelEntry(1.000f, FText::FromString(TEXT("1:1")), EGraphRenderingLOD::DefaultDetail));
ZoomLevels.Add(FZoomLevelEntry(1.250f, FText::FromString(TEXT("+1")), EGraphRenderingLOD::DefaultDetail));
ZoomLevels.Add(FZoomLevelEntry(1.375f, FText::FromString(TEXT("+2")), EGraphRenderingLOD::DefaultDetail));
ZoomLevels.Add(FZoomLevelEntry(1.500f, FText::FromString(TEXT("+3")), EGraphRenderingLOD::FullyZoomedIn));
ZoomLevels.Add(FZoomLevelEntry(1.675f, FText::FromString(TEXT("+4")), EGraphRenderingLOD::FullyZoomedIn));
ZoomLevels.Add(FZoomLevelEntry(1.750f, FText::FromString(TEXT("+5")), EGraphRenderingLOD::FullyZoomedIn));
ZoomLevels.Add(FZoomLevelEntry(1.875f, FText::FromString(TEXT("+6")), EGraphRenderingLOD::FullyZoomedIn));
ZoomLevels.Add(FZoomLevelEntry(2.000f, FText::FromString(TEXT("+7")), EGraphRenderingLOD::FullyZoomedIn));
}
float GetZoomAmount(int32 InZoomLevel) const override
{
checkSlow(ZoomLevels.IsValidIndex(InZoomLevel));
return ZoomLevels[InZoomLevel].ZoomAmount;
}
int32 GetNearestZoomLevel(float InZoomAmount) const override
{
for (int32 ZoomLevelIndex=0; ZoomLevelIndex < GetNumZoomLevels(); ++ZoomLevelIndex)
{
if (InZoomAmount <= GetZoomAmount(ZoomLevelIndex))
{
return ZoomLevelIndex;
}
}
return GetDefaultZoomLevel();
}
FText GetZoomText(int32 InZoomLevel) const override
{
checkSlow(ZoomLevels.IsValidIndex(InZoomLevel));
return ZoomLevels[InZoomLevel].DisplayText;
}
int32 GetNumZoomLevels() const override
{
return ZoomLevels.Num();
}
int32 GetDefaultZoomLevel() const override
{
return 12;
}
EGraphRenderingLOD::Type GetLOD(int32 InZoomLevel) const override
{
checkSlow(ZoomLevels.IsValidIndex(InZoomLevel));
return ZoomLevels[InZoomLevel].LOD;
}
TArray<FZoomLevelEntry> ZoomLevels;
};
const TCHAR* XSymbol=TEXT("\xD7");
//////////////////////////////////////////////////////////////////////////
// FGraphSelectionManager
const FGraphPanelSelectionSet& FGraphSelectionManager::GetSelectedNodes() const
{
return SelectedNodes;
}
void FGraphSelectionManager::SelectSingleNode(SelectedItemType Node)
{
SelectedNodes.Empty();
SetNodeSelection(Node, true);
}
// Reset the selection state of all nodes
void FGraphSelectionManager::ClearSelectionSet()
{
if (SelectedNodes.Num())
{
SelectedNodes.Empty();
OnSelectionChanged.ExecuteIfBound(SelectedNodes);
}
}
// Changes the selection set to contain exactly all of the passed in nodes
void FGraphSelectionManager::SetSelectionSet(FGraphPanelSelectionSet& NewSet)
{
SelectedNodes = NewSet;
OnSelectionChanged.ExecuteIfBound(SelectedNodes);
}
void FGraphSelectionManager::SetNodeSelection(SelectedItemType Node, bool bSelect)
{
ensureMsgf(Node != nullptr, TEXT("Node is invalid"));
if (bSelect)
{
SelectedNodes.Add(Node);
OnSelectionChanged.ExecuteIfBound(SelectedNodes);
}
else
{
SelectedNodes.Remove(Node);
OnSelectionChanged.ExecuteIfBound(SelectedNodes);
}
}
bool FGraphSelectionManager::IsNodeSelected(SelectedItemType Node) const
{
return SelectedNodes.Contains(Node);
}
void FGraphSelectionManager::StartDraggingNode(SelectedItemType NodeBeingDragged, const FPointerEvent& MouseEvent)
{
if (!IsNodeSelected(NodeBeingDragged))
{
if (MouseEvent.IsControlDown() || MouseEvent.IsShiftDown())
{
// Control and shift do not clear existing selection.
SetNodeSelection(NodeBeingDragged, true);
}
else
{
SelectSingleNode(NodeBeingDragged);
}
}
}
void FGraphSelectionManager::ClickedOnNode(SelectedItemType Node, const FPointerEvent& MouseEvent)
{
if (MouseEvent.IsShiftDown())
{
// Shift always adds to selection
SetNodeSelection(Node, true);
}
else if (MouseEvent.IsControlDown())
{
// Control toggles selection
SetNodeSelection(Node, !IsNodeSelected(Node));
}
else
{
// No modifiers sets selection
SelectSingleNode(Node);
}
}
//////////////////////////////////////////////////////////////////////////
// SNodePanel
namespace NodePanelDefs
{
// Default Zoom Padding Value
static const float DefaultZoomPadding = 25.f;
// Node Culling Guardband Area
static const float GuardBandArea = 0.25f;
// Scaling factor to reduce speed of mouse zooming
static const float MouseZoomScaling = 0.05f;
};
SNodePanel::SNodePanel()
: Children(this)
, VisibleChildren(this)
{
}
void SNodePanel::OnArrangeChildren(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const
{
ArrangeChildNodes(AllottedGeometry, ArrangedChildren);
}
void SNodePanel::ArrangeChildNodes(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const
{
const TSlotlessChildren<SNode>& ChildrenToArrange = ArrangedChildren.Accepts(EVisibility::Hidden) ? Children : VisibleChildren;
// First pass nodes
for (int32 ChildIndex = 0; ChildIndex < ChildrenToArrange.Num(); ++ChildIndex)
{
const TSharedRef<SNode>& SomeChild = ChildrenToArrange[ChildIndex];
if (!SomeChild->RequiresSecondPassLayout())
{
ArrangedChildren.AddWidget(AllottedGeometry.MakeChild(SomeChild, SomeChild->GetPosition() - ViewOffset, SomeChild->GetDesiredSize(), GetZoomAmount()));
}
}
// Second pass nodes
for (int32 ChildIndex = 0; ChildIndex < ChildrenToArrange.Num(); ++ChildIndex)
{
const TSharedRef<SNode>& SomeChild = ChildrenToArrange[ChildIndex];
if (SomeChild->RequiresSecondPassLayout())
{
SomeChild->PerformSecondPassLayout(NodeToWidgetLookup);
ArrangedChildren.AddWidget(AllottedGeometry.MakeChild(SomeChild, SomeChild->GetPosition() - ViewOffset, SomeChild->GetDesiredSize(), GetZoomAmount()));
}
}
}
FVector2D SNodePanel::ComputeDesiredSize( float ) const
{
// In this case, it would be an expensive computation that is not worth performing.
// Users prefer to explicitly size canvases just like they do with text documents, browser pages, etc.
return FVector2D(160.0f, 120.0f);
}
FChildren* SNodePanel::GetChildren()
{
return &VisibleChildren;
}
FChildren* SNodePanel::GetAllChildren()
{
return &Children;
}
float SNodePanel::GetZoomAmount() const
{
if (bAllowContinousZoomInterpolation)
{
return FMath::Lerp(ZoomLevels->GetZoomAmount(PreviousZoomLevel), ZoomLevels->GetZoomAmount(ZoomLevel), ZoomLevelGraphFade.GetLerp());
}
else
{
return ZoomLevels->GetZoomAmount(ZoomLevel);
}
}
FText SNodePanel::GetZoomText() const
{
return ZoomLevels->GetZoomText(ZoomLevel);
}
FSlateColor SNodePanel::GetZoomTextColorAndOpacity() const
{
return FLinearColor( 1, 1, 1, 1.25f - ZoomLevelFade.GetLerp() );
}
FVector2D SNodePanel::GetViewOffset() const
{
return ViewOffset;
}
void SNodePanel::Construct()
{
if (!ZoomLevels)
{
ZoomLevels = MakeUnique<FFixedZoomLevelsContainer>();
}
ZoomLevel = ZoomLevels->GetDefaultZoomLevel();
PreviousZoomLevel = ZoomLevels->GetDefaultZoomLevel();
PostChangedZoom();
ViewOffset = FVector2D::ZeroVector;
TotalMouseDelta = 0;
TotalMouseDeltaY = 0;
bDeferredZoomToSelection = false;
bDeferredZoomToNodeExtents = false;
ZoomTargetTopLeft = FVector2D::ZeroVector;
ZoomTargetBottomRight = FVector2D::ZeroVector;
ZoomPadding = NodePanelDefs::DefaultZoomPadding;
bAllowContinousZoomInterpolation = false;
bTeleportInsteadOfScrollingWhenZoomingToFit = false;
DeferredSelectionTargetObjects.Empty();
DeferredMovementTargetObject = nullptr;
bIsPanning = false;
bIsZoomingWithTrackpad = false;
IsEditable.Set(true);
ZoomLevelFade = FCurveSequence( 0.0f, 1.0f );
ZoomLevelFade.Play( this->AsShared() );
ZoomLevelGraphFade = FCurveSequence( 0.0f, 0.5f );
ZoomLevelGraphFade.Play( this->AsShared() );
PastePosition = FVector2D::ZeroVector;
DeferredPanPosition = FVector2D::ZeroVector;
bRequestDeferredPan = false;
OldViewOffset = ViewOffset;
OldZoomAmount = GetZoomAmount();
ZoomStartOffset = FVector2D::ZeroVector;
TotalGestureMagnify = 0.0f;
ScopedTransactionPtr.Reset();
}
FVector2D SNodePanel::ComputeEdgePanAmount(const FGeometry& MyGeometry, const FVector2D& TargetPosition)
{
// How quickly to ramp up the pan speed as the user moves the mouse further past the edge of the graph panel.
static const float EdgePanSpeedCoefficient = 2.f, EdgePanSpeedPower = 0.6f;
// Never pan faster than this - probably not really required since we raise to a power of 0.6
static const float MaxPanSpeed = 200.0f;
// Start panning before we reach the edge of the graph panel.
static const float EdgePanForgivenessZone = 30.0f;
const FVector2D LocalCursorPos = MyGeometry.AbsoluteToLocal( TargetPosition );
// If the mouse is outside of the graph area, then we want to pan in that direction.
// The farther out the mouse is, the more we want to pan.
FVector2D EdgePanThisTick(0,0);
if ( LocalCursorPos.X <= EdgePanForgivenessZone )
{
EdgePanThisTick.X += FMath::Max( -MaxPanSpeed, EdgePanSpeedCoefficient * -FMath::Pow(EdgePanForgivenessZone - LocalCursorPos.X, EdgePanSpeedPower) );
}
else if( LocalCursorPos.X >= MyGeometry.GetLocalSize().X - EdgePanForgivenessZone )
{
EdgePanThisTick.X = FMath::Min( MaxPanSpeed, EdgePanSpeedCoefficient * FMath::Pow(LocalCursorPos.X - MyGeometry.GetLocalSize().X + EdgePanForgivenessZone, EdgePanSpeedPower) );
}
if ( LocalCursorPos.Y <= EdgePanForgivenessZone )
{
EdgePanThisTick.Y += FMath::Max( -MaxPanSpeed, EdgePanSpeedCoefficient * -FMath::Pow(EdgePanForgivenessZone - LocalCursorPos.Y, EdgePanSpeedPower) );
}
else if( LocalCursorPos.Y >= MyGeometry.GetLocalSize().Y - EdgePanForgivenessZone )
{
EdgePanThisTick.Y = FMath::Min( MaxPanSpeed, EdgePanSpeedCoefficient * FMath::Pow(LocalCursorPos.Y - MyGeometry.GetLocalSize().Y + EdgePanForgivenessZone, EdgePanSpeedPower) );
}
return EdgePanThisTick;
}
void SNodePanel::UpdateViewOffset (const FGeometry& MyGeometry, const FVector2D& TargetPosition)
{
const FVector2D PanAmount = ComputeEdgePanAmount( MyGeometry, TargetPosition ) / GetZoomAmount();
ViewOffset += PanAmount;
}
void SNodePanel::RequestDeferredPan(const FVector2D& UpdatePosition)
{
bRequestDeferredPan = true;
DeferredPanPosition = UpdatePosition;
}
FVector2D SNodePanel::GraphCoordToPanelCoord( const FVector2D& GraphSpaceCoordinate ) const
{
return (GraphSpaceCoordinate - GetViewOffset()) * GetZoomAmount();
}
FVector2D SNodePanel::PanelCoordToGraphCoord( const FVector2D& PanelSpaceCoordinate ) const
{
return PanelSpaceCoordinate / GetZoomAmount() + GetViewOffset();
}
FSlateRect SNodePanel::PanelRectToGraphRect( const FSlateRect& PanelSpaceRect ) const
{
FVector2D UpperLeft = PanelCoordToGraphCoord( FVector2D(PanelSpaceRect.Left, PanelSpaceRect.Top) );
FVector2D LowerRight = PanelCoordToGraphCoord( FVector2D(PanelSpaceRect.Right, PanelSpaceRect.Bottom) );
return FSlateRect(
UpperLeft.X, UpperLeft.Y,
LowerRight.X, LowerRight.Y );
}
void SNodePanel::OnBeginNodeInteraction(const TSharedRef<SNode>& InNodeToDrag, const FVector2D& GrabOffset)
{
NodeUnderMousePtr = InNodeToDrag;
NodeGrabOffset = GrabOffset;
}
void SNodePanel::OnEndNodeInteraction(const TSharedRef<SNode>& InNodeToDrag)
{
InNodeToDrag->EndUserInteraction();
}
EActiveTimerReturnType SNodePanel::HandleZoomToFit(double InCurrentTime, float InDeltaTime)
{
const FVector2D DesiredViewCenter = ( ZoomTargetTopLeft + ZoomTargetBottomRight ) * 0.5f;
const bool bDoneScrolling = ScrollToLocation(CachedGeometry, DesiredViewCenter, bTeleportInsteadOfScrollingWhenZoomingToFit ? 1000.0f : InDeltaTime);
bool bDoneZooming = ZoomToLocation(CachedGeometry.GetLocalSize(), ZoomTargetBottomRight - ZoomTargetTopLeft, bDoneScrolling);
if (bDoneZooming && bDoneScrolling)
{
// One final push to make sure we centered in the end
ViewOffset = DesiredViewCenter - ( 0.5f * CachedGeometry.GetLocalSize() / GetZoomAmount() );
// Reset ZoomPadding
ZoomPadding = NodePanelDefs::DefaultZoomPadding;
ZoomTargetTopLeft = FVector2D::ZeroVector;
ZoomTargetBottomRight = FVector2D::ZeroVector;
DeferredMovementTargetObject = nullptr;
return EActiveTimerReturnType::Stop;
}
return EActiveTimerReturnType::Continue;
}
void SNodePanel::Tick( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime )
{
CachedGeometry = AllottedGeometry;
bool bCanMoveToTargetObjectThisFrame = true;
if(DeferredSelectionTargetObjects.Num() > 0)
{
FGraphPanelSelectionSet NewSelectionSet;
for (const UObject* SelectionTarget : DeferredSelectionTargetObjects)
{
if (TSharedRef<SNode>* pWidget = NodeToWidgetLookup.Find(SelectionTarget))
{
NewSelectionSet.Add(const_cast<SelectedItemType>(SelectionTarget));
}
}
if (NewSelectionSet.Num() > 0)
{
SelectionManager.SetSelectionSet(NewSelectionSet);
}
DeferredSelectionTargetObjects.Empty();
// Do not allow movement to happen this Tick as the selected nodes may not yet have a size set (if they're newly added)
bCanMoveToTargetObjectThisFrame = false;
}
if(DeferredMovementTargetObject)
{
// Since we want to move to a target object, do not zoom to extent
bDeferredZoomToNodeExtents = false;
if (bCanMoveToTargetObjectThisFrame && GetBoundsForNode(DeferredMovementTargetObject, ZoomTargetTopLeft, ZoomTargetBottomRight, ZoomPadding))
{
DeferredMovementTargetObject = nullptr;
RequestZoomToFit();
}
}
// Zoom to node extents
if( bDeferredZoomToNodeExtents )
{
bDeferredZoomToNodeExtents = false;
ZoomPadding = NodePanelDefs::DefaultZoomPadding;
if( GetBoundsForNodes(bDeferredZoomToSelection, ZoomTargetTopLeft, ZoomTargetBottomRight, ZoomPadding))
{
bDeferredZoomToSelection = false;
RequestZoomToFit();
}
}
// Handle any deferred panning
if (bRequestDeferredPan)
{
bRequestDeferredPan = false;
UpdateViewOffset(AllottedGeometry, DeferredPanPosition);
}
if ( !HasMouseCapture() )
{
bShowSoftwareCursor = false;
bIsPanning = false;
}
PopulateVisibleChildren(AllottedGeometry);
// Reset the current bookmark if the location and/or zoom level has been changed.
const float CurZoomAmount = GetZoomAmount();
if (CurrentBookmarkGuid.IsValid() && (OldViewOffset != ViewOffset || OldZoomAmount != CurZoomAmount))
{
CurrentBookmarkGuid.Invalidate();
}
OldZoomAmount = CurZoomAmount;
OldViewOffset = ViewOffset;
SPanel::Tick( AllottedGeometry, InCurrentTime, InDeltaTime );
}
// The system calls this method to notify the widget that a mouse button was pressed within it. This event is bubbled.
FReply SNodePanel::OnMouseButtonDown( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent )
{
const bool bIsLeftMouseButtonEffecting = MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton;
const bool bIsRightMouseButtonEffecting = MouseEvent.GetEffectingButton() == EKeys::RightMouseButton;
const bool bIsMiddleMouseButtonEffecting = MouseEvent.GetEffectingButton() == EKeys::MiddleMouseButton;
const bool bIsRightMouseButtonDown = MouseEvent.IsMouseButtonDown( EKeys::RightMouseButton );
const bool bIsLeftMouseButtonDown = MouseEvent.IsMouseButtonDown( EKeys::LeftMouseButton );
const bool bIsMiddleMouseButtonDown = MouseEvent.IsMouseButtonDown(EKeys::MiddleMouseButton);
TotalMouseDelta = 0;
if ((bIsLeftMouseButtonEffecting && bIsRightMouseButtonDown)
|| (bIsRightMouseButtonEffecting && (bIsLeftMouseButtonDown || FSlateApplication::Get().IsUsingTrackpad())))
{
// Starting zoom by holding LMB+RMB
FReply ReplyState = FReply::Handled();
ReplyState.CaptureMouse( SharedThis(this) );
ReplyState.UseHighPrecisionMouseMovement( SharedThis(this) );
DeferredMovementTargetObject = nullptr; // clear any interpolation when you manually zoom
CancelZoomToFit();
TotalMouseDeltaY = 0;
if (!FSlateApplication::Get().IsUsingTrackpad()) // on trackpad we don't know yet if user wants to zoom or bring up the context menu
{
bShowSoftwareCursor = true;
}
if (bIsLeftMouseButtonEffecting)
{
// Got here from panning mode (with RMB held) - clear panning mode, but use cached software cursor position
const FVector2D WidgetSpaceCursorPos = GraphCoordToPanelCoord( SoftwareCursorPosition );
ZoomStartOffset = WidgetSpaceCursorPos;
this->bIsPanning = false;
}
else
{
// Cache current cursor position as zoom origin and software cursor position
ZoomStartOffset = MyGeometry.AbsoluteToLocal( MouseEvent.GetLastScreenSpacePosition() );
SoftwareCursorPosition = PanelCoordToGraphCoord( ZoomStartOffset );
if (bIsRightMouseButtonEffecting)
{
// Clear things that may be set when left clicking
if (NodeUnderMousePtr.IsValid())
{
OnEndNodeInteraction(NodeUnderMousePtr.Pin().ToSharedRef());
}
if ( Marquee.IsValid() )
{
auto PreviouslySelectedNodes = SelectionManager.SelectedNodes;
ApplyMarqueeSelection(Marquee, PreviouslySelectedNodes, SelectionManager.SelectedNodes);
if (SelectionManager.SelectedNodes.Num() > 0 || PreviouslySelectedNodes.Num() > 0)
{
SelectionManager.OnSelectionChanged.ExecuteIfBound(SelectionManager.SelectedNodes);
}
}
Marquee = FMarqueeOperation();
}
}
return ReplyState;
}
else if (bIsRightMouseButtonEffecting && ( GetDefault<UGraphEditorSettings>()->PanningMouseButton == EGraphPanningMouseButton::Right || GetDefault<UGraphEditorSettings>()->PanningMouseButton == EGraphPanningMouseButton::Both ) )
{
// Cache current cursor position as zoom origin and software cursor position
ZoomStartOffset = MyGeometry.AbsoluteToLocal( MouseEvent.GetLastScreenSpacePosition() );
SoftwareCursorPosition = PanelCoordToGraphCoord( ZoomStartOffset );
FReply ReplyState = FReply::Handled();
ReplyState.CaptureMouse( SharedThis(this) );
ReplyState.UseHighPrecisionMouseMovement( SharedThis(this) );
SoftwareCursorPosition = PanelCoordToGraphCoord( MyGeometry.AbsoluteToLocal( MouseEvent.GetScreenSpacePosition() ) );
DeferredMovementTargetObject = nullptr; // clear any interpolation when you manually pan
CancelZoomToFit();
// RIGHT BUTTON is for dragging and Context Menu.
return ReplyState;
}
else if (bIsMiddleMouseButtonEffecting && (GetDefault<UGraphEditorSettings>()->PanningMouseButton == EGraphPanningMouseButton::Middle || GetDefault<UGraphEditorSettings>()->PanningMouseButton == EGraphPanningMouseButton::Both))
{
// Cache current cursor position as zoom origin and software cursor position
ZoomStartOffset = MyGeometry.AbsoluteToLocal(MouseEvent.GetLastScreenSpacePosition());
SoftwareCursorPosition = PanelCoordToGraphCoord(ZoomStartOffset);
FReply ReplyState = FReply::Handled();
ReplyState.CaptureMouse(SharedThis(this));
ReplyState.UseHighPrecisionMouseMovement(SharedThis(this));
SoftwareCursorPosition = PanelCoordToGraphCoord(MyGeometry.AbsoluteToLocal(MouseEvent.GetScreenSpacePosition()));
DeferredMovementTargetObject = nullptr; // clear any interpolation when you manually pan
// MIDDLE BUTTON is for dragging only.
return ReplyState;
}
else if ( bIsLeftMouseButtonEffecting )
{
// LEFT BUTTON is for selecting nodes and manipulating pins.
FArrangedChildren ArrangedChildren(EVisibility::Visible);
ArrangeChildNodes(MyGeometry, ArrangedChildren);
const int32 NodeUnderMouseIndex = SWidget::FindChildUnderMouse( ArrangedChildren, MouseEvent );
if ( NodeUnderMouseIndex != INDEX_NONE )
{
// PRESSING ON A NODE!
// This changes selection and starts dragging it.
const FArrangedWidget& NodeGeometry = ArrangedChildren[NodeUnderMouseIndex];
const FVector2D MousePositionInNode = NodeGeometry.Geometry.AbsoluteToLocal(MouseEvent.GetScreenSpacePosition());
TSharedRef<SNode> NodeWidgetUnderMouse = StaticCastSharedRef<SNode>( NodeGeometry.Widget );
if( NodeWidgetUnderMouse->CanBeSelected(MousePositionInNode) )
{
// Track the node that we're dragging; we will move it in OnMouseMove.
this->OnBeginNodeInteraction(NodeWidgetUnderMouse, MousePositionInNode);
return FReply::Handled().CaptureMouse( SharedThis(this) );
}
}
// START MARQUEE SELECTION.
const FVector2D GraphMousePos = PanelCoordToGraphCoord( MyGeometry.AbsoluteToLocal( MouseEvent.GetScreenSpacePosition() ) );
Marquee.Start( GraphMousePos, FMarqueeOperation::OperationTypeFromMouseEvent(MouseEvent) );
// If we're marquee selecting, then we're not clicking on a node!
NodeUnderMousePtr.Reset();
return FReply::Handled().CaptureMouse( SharedThis(this) );
}
else
{
return FReply::Unhandled();
}
}
// The system calls this method to notify the widget that a mouse moved within it. This event is bubbled.
FReply SNodePanel::OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
const bool bIsRightMouseButtonDown = MouseEvent.IsMouseButtonDown( EKeys::RightMouseButton );
const bool bIsLeftMouseButtonDown = MouseEvent.IsMouseButtonDown( EKeys::LeftMouseButton );
const bool bIsMiddleMouseButtonDown = MouseEvent.IsMouseButtonDown(EKeys::MiddleMouseButton);
const FModifierKeysState ModifierKeysState = FSlateApplication::Get().GetModifierKeys();
PastePosition = PanelCoordToGraphCoord( MyGeometry.AbsoluteToLocal( MouseEvent.GetScreenSpacePosition() ) );
if ( this->HasMouseCapture() )
{
const FVector2D CursorDelta = MouseEvent.GetCursorDelta();
// Track how much the mouse moved since the mouse down.
TotalMouseDelta += CursorDelta.Size();
const bool bShouldZoom = bIsRightMouseButtonDown && (bIsLeftMouseButtonDown || bIsMiddleMouseButtonDown || ModifierKeysState.IsAltDown() || FSlateApplication::Get().IsUsingTrackpad());
if (bShouldZoom)
{
FReply ReplyState = FReply::Handled();
TotalMouseDeltaY += CursorDelta.Y;
const int32 ZoomLevelDelta = FMath::FloorToInt(TotalMouseDeltaY * NodePanelDefs::MouseZoomScaling);
// Get rid of mouse movement that's been 'used up' by zooming
if (ZoomLevelDelta != 0)
{
TotalMouseDeltaY -= (ZoomLevelDelta / NodePanelDefs::MouseZoomScaling);
}
// Perform zoom centered on the cached start offset
ChangeZoomLevel(ZoomLevelDelta, ZoomStartOffset, MouseEvent.IsControlDown());
this->bIsPanning = false;
if (FSlateApplication::Get().IsUsingTrackpad() && ZoomLevelDelta != 0)
{
this->bIsZoomingWithTrackpad = true;
bShowSoftwareCursor = true;
}
// Stop the zoom-to-fit in favor of user control
CancelZoomToFit();
return ReplyState;
}
else if (bIsRightMouseButtonDown)
{
FReply ReplyState = FReply::Handled();
if( !CursorDelta.IsZero() )
{
bShowSoftwareCursor = true;
}
// Panning and mouse is outside of panel? Pasting should just go to the screen center.
PastePosition = PanelCoordToGraphCoord( 0.5f * MyGeometry.GetLocalSize() );
this->bIsPanning = true;
ViewOffset -= CursorDelta / GetZoomAmount();
// Stop the zoom-to-fit in favor of user control
CancelZoomToFit();
return ReplyState;
}
else if (bIsMiddleMouseButtonDown)
{
FReply ReplyState = FReply::Handled();
if (!CursorDelta.IsZero())
{
bShowSoftwareCursor = true;
}
// Panning and mouse is outside of panel? Pasting should just go to the screen center.
PastePosition = PanelCoordToGraphCoord(0.5f * MyGeometry.Size);
this->bIsPanning = true;
ViewOffset -= CursorDelta / GetZoomAmount();
return ReplyState;
}
else if (bIsLeftMouseButtonDown)
{
TSharedPtr<SNode> NodeBeingDragged = NodeUnderMousePtr.Pin();
if ( IsEditable.Get() )
{
// Update the amount to pan panel
UpdateViewOffset(MyGeometry, MouseEvent.GetScreenSpacePosition());
const bool bCursorInDeadZone = TotalMouseDelta <= FSlateApplication::Get().GetDragTriggerDistance();
if ( NodeBeingDragged.IsValid() )
{
if ( !bCursorInDeadZone )
{
// Note, NodeGrabOffset() comes from the node itself, so it's already scaled correctly.
FVector2D AnchorNodeNewPos = PanelCoordToGraphCoord( MyGeometry.AbsoluteToLocal( MouseEvent.GetScreenSpacePosition() ) ) - NodeGrabOffset;
// Snap to grid
const float SnapSize = GetSnapGridSize();
AnchorNodeNewPos.X = SnapSize * FMath::RoundToFloat( AnchorNodeNewPos.X / SnapSize );
AnchorNodeNewPos.Y = SnapSize * FMath::RoundToFloat( AnchorNodeNewPos.Y / SnapSize );
// Dragging an unselected node automatically selects it.
SelectionManager.StartDraggingNode(NodeBeingDragged->GetObjectBeingDisplayed(), MouseEvent);
// Move all the selected nodes.
{
const FVector2D AnchorNodeOldPos = NodeBeingDragged->GetPosition();
const FVector2D DeltaPos = AnchorNodeNewPos - AnchorNodeOldPos;
// Perform movement in 2 passes:
// 1. Gather all selected nodes positions and calculate new positions
struct FDefferedNodePosition
{
SNode* Node;
FVector2D NewPosition;
};
TArray<FDefferedNodePosition> DefferedNodesToMove;
for (FGraphPanelSelectionSet::TIterator NodeIt(SelectionManager.SelectedNodes); NodeIt; ++NodeIt)
{
TSharedRef<SNode>* pWidget = NodeToWidgetLookup.Find(*NodeIt);
if (pWidget != nullptr)
{
SNode& Widget = pWidget->Get();
FDefferedNodePosition NodePosition = { &Widget, Widget.GetPosition() + DeltaPos };
DefferedNodesToMove.Add(NodePosition);
}
}
// Create a new transaction record
if(!ScopedTransactionPtr.IsValid())
{
if(DefferedNodesToMove.Num() > 1)
{
ScopedTransactionPtr = MakeShareable(new FScopedTransaction(NSLOCTEXT("GraphEditor", "MoveNodesAction", "Move Nodes")));
}
else if(DefferedNodesToMove.Num() > 0)
{
ScopedTransactionPtr = MakeShareable(new FScopedTransaction(NSLOCTEXT("GraphEditor", "MoveNodeAction", "Move Node")));
}
}
// 2. Move selected nodes to new positions
SNode::FNodeSet NodeFilter;
for (int32 NodeIdx = 0; NodeIdx < DefferedNodesToMove.Num(); ++NodeIdx)
{
DefferedNodesToMove[NodeIdx].Node->MoveTo( DefferedNodesToMove[NodeIdx].NewPosition, NodeFilter );
}
}
}
return FReply::Handled();
}
}
if ( !NodeBeingDragged.IsValid() )
{
// We are marquee selecting
const FVector2D GraphMousePos = PanelCoordToGraphCoord( MyGeometry.AbsoluteToLocal( MouseEvent.GetScreenSpacePosition() ) );
Marquee.Rect.UpdateEndPoint(GraphMousePos);
FindNodesAffectedByMarquee( /*out*/ Marquee.AffectedNodes );
return FReply::Handled();
}
// Stop the zoom-to-fit in favor of user control
CancelZoomToFit();
}
}
return FReply::Unhandled();
}
// The system calls this method to notify the widget that a mouse button was release within it. This event is bubbled.
FReply SNodePanel::OnMouseButtonUp( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent )
{
FReply ReplyState = FReply::Unhandled();
const bool bIsLeftMouseButtonEffecting = MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton;
const bool bIsRightMouseButtonEffecting = MouseEvent.GetEffectingButton() == EKeys::RightMouseButton;
const bool bIsMiddleMouseButtonEffecting = MouseEvent.GetEffectingButton() == EKeys::MiddleMouseButton;
const bool bIsRightMouseButtonDown = MouseEvent.IsMouseButtonDown( EKeys::RightMouseButton );
const bool bIsLeftMouseButtonDown = MouseEvent.IsMouseButtonDown( EKeys::LeftMouseButton );
const bool bIsMiddleMouseButtonDown = MouseEvent.IsMouseButtonDown(EKeys::MiddleMouseButton);
// Did the user move the cursor sufficiently far, or is it in a dead zone?
// In Dead zone - implies actions like summoning context menus and general clicking.
// Out of Dead Zone - implies dragging actions like moving nodes and marquee selection.
const bool bCursorInDeadZone = TotalMouseDelta <= FSlateApplication::Get().GetDragTriggerDistance();
// Set to true later if we need to finish with the software cursor
bool bRemoveSoftwareCursor = false;
if ((bIsLeftMouseButtonEffecting && bIsRightMouseButtonDown)
|| (bIsRightMouseButtonEffecting && (bIsLeftMouseButtonDown || (FSlateApplication::Get().IsUsingTrackpad() && bIsZoomingWithTrackpad)))
|| (bIsMiddleMouseButtonEffecting && bIsRightMouseButtonDown))
{
// Ending zoom by releasing LMB or RMB
ReplyState = FReply::Handled();
if (bIsLeftMouseButtonDown || FSlateApplication::Get().IsUsingTrackpad())
{
// If we released the right mouse button first, we need to cancel the software cursor display
bRemoveSoftwareCursor = true;
bIsZoomingWithTrackpad = false;
ReplyState.ReleaseMouseCapture();
}
}
else if ( bIsRightMouseButtonEffecting )
{
ReplyState = FReply::Handled().ReleaseMouseCapture();
bRemoveSoftwareCursor = true;
TSharedPtr<SWidget> WidgetToFocus;
if (bCursorInDeadZone)
{
WidgetToFocus = OnSummonContextMenu(MyGeometry, MouseEvent);
}
this->bIsPanning = false;
if (WidgetToFocus.IsValid())
{
ReplyState.SetUserFocus(WidgetToFocus.ToSharedRef(), EFocusCause::SetDirectly);
}
}
else if ( bIsMiddleMouseButtonEffecting )
{
ReplyState = FReply::Handled().ReleaseMouseCapture();
bRemoveSoftwareCursor = true;
this->bIsPanning = false;
}
else if ( bIsLeftMouseButtonEffecting )
{
if (NodeUnderMousePtr.IsValid())
{
OnEndNodeInteraction(NodeUnderMousePtr.Pin().ToSharedRef());
ScopedTransactionPtr.Reset();
}
if (OnHandleLeftMouseRelease(MyGeometry, MouseEvent))
{
}
else if ( bCursorInDeadZone )
{
//@TODO: Move to selection manager
if ( NodeUnderMousePtr.IsValid() )
{
// We clicked on a node!
TSharedRef<SNode> NodeWidgetUnderMouse = NodeUnderMousePtr.Pin().ToSharedRef();
SelectionManager.ClickedOnNode(NodeWidgetUnderMouse->GetObjectBeingDisplayed(), MouseEvent);
// We're done interacting with this node.
NodeUnderMousePtr.Reset();
}
else if (this->HasMouseCapture())
{
// We clicked on the panel background
this->SelectionManager.ClearSelectionSet();
if(OnSpawnNodeByShortcut.IsBound())
{
OnSpawnNodeByShortcut.Execute(LastKeyChordDetected, PanelCoordToGraphCoord( MyGeometry.AbsoluteToLocal( MouseEvent.GetScreenSpacePosition() ) ));
}
LastKeyChordDetected = FInputChord();
}
}
else if ( Marquee.IsValid() )
{
auto PreviouslySelectedNodes = SelectionManager.SelectedNodes;
ApplyMarqueeSelection(Marquee, PreviouslySelectedNodes, SelectionManager.SelectedNodes);
if (SelectionManager.SelectedNodes.Num() > 0 || PreviouslySelectedNodes.Num() > 0)
{
SelectionManager.OnSelectionChanged.ExecuteIfBound(SelectionManager.SelectedNodes);
}
}
// The existing marquee operation ended; reset it.
Marquee = FMarqueeOperation();
ReplyState = FReply::Handled().ReleaseMouseCapture();
}
if (bRemoveSoftwareCursor)
{
// If we released the right mouse button first, we need to cancel the software cursor display
if ( this->HasMouseCapture() )
{
FSlateRect ThisPanelScreenSpaceRect = MyGeometry.GetLayoutBoundingRect();
const FVector2D ScreenSpaceCursorPos = MyGeometry.LocalToAbsolute( GraphCoordToPanelCoord( SoftwareCursorPosition ) );
FIntPoint BestPositionInViewport(
FMath::RoundToInt( FMath::Clamp( ScreenSpaceCursorPos.X, ThisPanelScreenSpaceRect.Left, ThisPanelScreenSpaceRect.Right ) ),
FMath::RoundToInt( FMath::Clamp( ScreenSpaceCursorPos.Y, ThisPanelScreenSpaceRect.Top, ThisPanelScreenSpaceRect.Bottom ) )
);
if (!bCursorInDeadZone)
{
ReplyState.SetMousePos(BestPositionInViewport);
}
}
bShowSoftwareCursor = false;
}
return ReplyState;
}
FReply SNodePanel::OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
// We want to zoom into this point; i.e. keep it the same fraction offset into the panel
const FVector2D WidgetSpaceCursorPos = MyGeometry.AbsoluteToLocal( MouseEvent.GetScreenSpacePosition() );
const int32 ZoomLevelDelta = FMath::FloorToInt( MouseEvent.GetWheelDelta() );
ChangeZoomLevel(ZoomLevelDelta, WidgetSpaceCursorPos, MouseEvent.IsControlDown());
// Stop the zoom-to-fit in favor of user control
CancelZoomToFit();
return FReply::Handled();
}
FCursorReply SNodePanel::OnCursorQuery( const FGeometry& MyGeometry, const FPointerEvent& CursorEvent ) const
{
return bShowSoftwareCursor ?
FCursorReply::Cursor( EMouseCursor::None ) :
FCursorReply::Cursor( EMouseCursor::Default );
}
FReply SNodePanel::OnKeyDown( const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent )
{
if( IsEditable.Get() )
{
LastKeyChordDetected = FInputChord(InKeyEvent.GetKey(), EModifierKey::FromBools(InKeyEvent.IsControlDown(), InKeyEvent.IsAltDown(), InKeyEvent.IsShiftDown(), InKeyEvent.IsCommandDown()));
}
return FReply::Unhandled();
}
FReply SNodePanel::OnKeyUp( const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent )
{
if(LastKeyChordDetected.Key == InKeyEvent.GetKey())
{
LastKeyChordDetected = FInputChord();
}
return FReply::Unhandled();
}
void SNodePanel::OnFocusLost( const FFocusEvent& InFocusEvent )
{
LastKeyChordDetected = FInputChord();
}
FReply SNodePanel::OnTouchGesture( const FGeometry& MyGeometry, const FPointerEvent& GestureEvent )
{
const EGestureEvent GestureType = GestureEvent.GetGestureType();
const FVector2D& GestureDelta = GestureEvent.GetGestureDelta();
if (GestureType == EGestureEvent::Magnify)
{
TotalGestureMagnify += GestureDelta.X;
if (FMath::Abs(TotalGestureMagnify) > 0.07f)
{
// We want to zoom into this point; i.e. keep it the same fraction offset into the panel
const FVector2D WidgetSpaceCursorPos = MyGeometry.AbsoluteToLocal(GestureEvent.GetScreenSpacePosition());
const int32 ZoomLevelDelta = TotalGestureMagnify > 0.0f ? 1 : -1;
ChangeZoomLevel(ZoomLevelDelta, WidgetSpaceCursorPos, GestureEvent.IsControlDown());
TotalGestureMagnify = 0.0f;
}
// Stop the zoom-to-fit in favor of user control
CancelZoomToFit();
return FReply::Handled();
}
else if (GestureType == EGestureEvent::Scroll)
{
const EScrollGestureDirection DirectionSetting = GetDefault<ULevelEditorViewportSettings>()->ScrollGestureDirectionForOrthoViewports;
const bool bUseDirectionInvertedFromDevice = DirectionSetting == EScrollGestureDirection::Natural || (DirectionSetting == EScrollGestureDirection::UseSystemSetting && GestureEvent.IsDirectionInvertedFromDevice());
this->bIsPanning = true;
ViewOffset -= (bUseDirectionInvertedFromDevice == GestureEvent.IsDirectionInvertedFromDevice() ? GestureDelta : -GestureDelta) / GetZoomAmount();
// Stop the zoom-to-fit in favor of user control
CancelZoomToFit();
return FReply::Handled();
}
return FReply::Unhandled();
}
FReply SNodePanel::OnTouchEnded( const FGeometry& MyGeometry, const FPointerEvent& InTouchEvent )
{
TotalGestureMagnify = 0.0f;
return FReply::Unhandled();
}
float SNodePanel::GetRelativeLayoutScale(const FSlotBase& Child, float LayoutScaleMultiplier) const
{
return GetZoomAmount();
}
void SNodePanel::FindNodesAffectedByMarquee( FGraphPanelSelectionSet& OutAffectedNodes ) const
{
OutAffectedNodes.Empty();
FSlateRect MarqueeSlateRect = Marquee.Rect.ToSlateRect();
for ( int32 NodeIndex=0; NodeIndex < Children.Num(); ++NodeIndex )
{
const TSharedRef<SNode>& SomeNodeWidget = Children[NodeIndex];
const FVector2D NodePosition = SomeNodeWidget->GetPosition();
const FVector2D NodeSize = SomeNodeWidget->GetDesiredSizeForMarquee();
if (NodeSize.X > 0.f && NodeSize.Y > 0.f)
{
const FSlateRect NodeGeometryGraphSpace( NodePosition.X, NodePosition.Y, NodePosition.X + NodeSize.X, NodePosition.Y + NodeSize.Y );
const bool bIsInMarqueeRect = FSlateRect::DoRectanglesIntersect( MarqueeSlateRect, NodeGeometryGraphSpace );
if (bIsInMarqueeRect)
{
// This node is affected by the marquee rect
OutAffectedNodes.Add(SomeNodeWidget->GetObjectBeingDisplayed());
}
}
}
}
void SNodePanel::ApplyMarqueeSelection( const FMarqueeOperation& InMarquee, const FGraphPanelSelectionSet& CurrentSelection, FGraphPanelSelectionSet& OutNewSelection )
{
switch (InMarquee.Operation )
{
default:
case FMarqueeOperation::Replace:
{
OutNewSelection = InMarquee.AffectedNodes;
}
break;
case FMarqueeOperation::Remove:
{
OutNewSelection = CurrentSelection.Difference(InMarquee.AffectedNodes);
}
break;
case FMarqueeOperation::Add:
{
OutNewSelection = CurrentSelection.Union(InMarquee.AffectedNodes);
}
break;
case FMarqueeOperation::Invert:
{
// ToAdd = items in AffectedNodes that aren't in CurrentSelection (new selections)
FGraphPanelSelectionSet ToAdd = InMarquee.AffectedNodes.Difference(CurrentSelection);
// remove AffectedNodes that were already selected
OutNewSelection = CurrentSelection.Difference(InMarquee.AffectedNodes);
OutNewSelection.Append(ToAdd);
}
break;
}
}
void SNodePanel::SelectAndCenterObject(const UObject* ObjectToSelect, bool bCenter)
{
DeferredSelectionTargetObjects.Empty();
DeferredSelectionTargetObjects.Add(ObjectToSelect);
if( bCenter )
{
DeferredMovementTargetObject = ObjectToSelect;
}
CancelZoomToFit();
}
void SNodePanel::CenterObject(const UObject* ObjectToCenter)
{
DeferredMovementTargetObject = ObjectToCenter;
CancelZoomToFit();
}
/** Add a slot to the CanvasPanel dynamically */
void SNodePanel::AddGraphNode( const TSharedRef<SNodePanel::SNode>& NodeToAdd )
{
Children.Add( NodeToAdd );
NodeToWidgetLookup.Add( NodeToAdd->GetObjectBeingDisplayed(), NodeToAdd );
}
/** Remove all nodes from the panel */
void SNodePanel::RemoveAllNodes()
{
Children.Empty();
NodeToWidgetLookup.Empty();
VisibleChildren.Empty();
}
void SNodePanel::PopulateVisibleChildren(const FGeometry& AllottedGeometry)
{
VisibleChildren.Empty();
for (int32 ChildIndex = 0; ChildIndex < Children.Num(); ++ChildIndex)
{
const TSharedRef<SNode>& SomeChild = Children[ChildIndex];
if ( !IsNodeCulled(SomeChild, AllottedGeometry) )
{
VisibleChildren.Add(SomeChild);
}
}
// Depth Sort Nodes
if( VisibleChildren.Num() > 0 )
{
struct SNodeLessThanSort
{
FORCEINLINE bool operator()(const TSharedRef<SNodePanel::SNode>& A, const TSharedRef<SNodePanel::SNode>& B) const { return A.Get() < B.Get(); }
};
VisibleChildren.Sort( SNodeLessThanSort() );
}
}
// Is the given node being observed by a widget in this panel?
bool SNodePanel::Contains(UObject* Node) const
{
return NodeToWidgetLookup.Find(Node) != nullptr;
}
void SNodePanel::RestoreViewSettings(const FVector2D& InViewOffset, float InZoomAmount, const FGuid& InBookmarkGuid)
{
ViewOffset = InViewOffset;
if (InZoomAmount <= 0.0f)
{
// Zoom into the graph; it's the first time it's ever been displayed
ZoomLevel = ZoomLevels->GetDefaultZoomLevel();
bDeferredZoomToNodeExtents = true;
}
else
{
ZoomLevel = ZoomLevels->GetNearestZoomLevel(InZoomAmount);
bDeferredZoomToNodeExtents = false;
CancelZoomToFit();
}
PostChangedZoom();
// If we have been forced to a specific position, set the old values equal to the new ones.
// This is so our locked window isn't forced to update according to this movement.
OldViewOffset = ViewOffset;
OldZoomAmount = GetZoomAmount();
// Update the current bookmark ID.
CurrentBookmarkGuid = InBookmarkGuid;
}
float SNodePanel::GetSnapGridSize()
{
return GetDefault<UEditorStyleSettings>()->GridSnapSize;
}
inline float FancyMod(float Value, float Size)
{
return ((Value >= 0) ? 0.0f : Size) + FMath::Fmod(Value, Size);
}
void SNodePanel::PaintBackgroundAsLines(const FSlateBrush* BackgroundImage, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32& DrawLayerId) const
{
const bool bAntialias = false;
const int32 RulePeriod = (int32)FEditorStyle::GetFloat("Graph.Panel.GridRulePeriod");
check(RulePeriod > 0);
const FLinearColor RegularColor(GetDefault<UEditorStyleSettings>()->RegularColor);
const FLinearColor RuleColor(GetDefault<UEditorStyleSettings>()->RuleColor);
const FLinearColor CenterColor(GetDefault<UEditorStyleSettings>()->CenterColor);
const float GraphSmallestGridSize = 8.0f;
const float RawZoomFactor = GetZoomAmount();
const float NominalGridSize = GetSnapGridSize();
float ZoomFactor = RawZoomFactor;
float Inflation = 1.0f;
while (ZoomFactor*Inflation*NominalGridSize <= GraphSmallestGridSize)
{
Inflation *= 2.0f;
}
const float GridCellSize = NominalGridSize * ZoomFactor * Inflation;
const float GraphSpaceGridX0 = FancyMod(ViewOffset.X, Inflation * NominalGridSize * RulePeriod);
const float GraphSpaceGridY0 = FancyMod(ViewOffset.Y, Inflation * NominalGridSize * RulePeriod);
float ImageOffsetX = GraphSpaceGridX0 * -ZoomFactor;
float ImageOffsetY = GraphSpaceGridY0 * -ZoomFactor;
const FVector2D ZeroSpace = GraphCoordToPanelCoord(FVector2D::ZeroVector);
// Fill the background
FSlateDrawElement::MakeBox(
OutDrawElements,
DrawLayerId,
AllottedGeometry.ToPaintGeometry(),
BackgroundImage
);
TArray<FVector2D> LinePoints;
new (LinePoints) FVector2D(0.0f, 0.0f);
new (LinePoints) FVector2D(0.0f, 0.0f);
//If we want to use grid then show grid, otherwise don't render the grid
if (GetDefault<UEditorStyleSettings>()->bUseGrid == true){
// Horizontal bars
for (int32 GridIndex = 0; ImageOffsetY < AllottedGeometry.GetLocalSize().Y; ImageOffsetY += GridCellSize, ++GridIndex)
{
if (ImageOffsetY >= 0.0f)
{
const bool bIsRuleLine = (GridIndex % RulePeriod) == 0;
const int32 Layer = bIsRuleLine ? (DrawLayerId + 1) : DrawLayerId;
const FLinearColor* Color = bIsRuleLine ? &RuleColor : &RegularColor;
if (FMath::IsNearlyEqual(ZeroSpace.Y, ImageOffsetY, 1.0f))
{
Color = &CenterColor;
}
LinePoints[0] = FVector2D(0.0f, ImageOffsetY);
LinePoints[1] = FVector2D(AllottedGeometry.GetLocalSize().X, ImageOffsetY);
FSlateDrawElement::MakeLines(
OutDrawElements,
Layer,
AllottedGeometry.ToPaintGeometry(),
LinePoints,
ESlateDrawEffect::None,
*Color,
bAntialias);
}
}
// Vertical bars
for (int32 GridIndex = 0; ImageOffsetX < AllottedGeometry.GetLocalSize().X; ImageOffsetX += GridCellSize, ++GridIndex)
{
if (ImageOffsetX >= 0.0f)
{
const bool bIsRuleLine = (GridIndex % RulePeriod) == 0;
const int32 Layer = bIsRuleLine ? (DrawLayerId + 1) : DrawLayerId;
const FLinearColor* Color = bIsRuleLine ? &RuleColor : &RegularColor;
if (FMath::IsNearlyEqual(ZeroSpace.X, ImageOffsetX, 1.0f))
{
Color = &CenterColor;
}
LinePoints[0] = FVector2D(ImageOffsetX, 0.0f);
LinePoints[1] = FVector2D(ImageOffsetX, AllottedGeometry.GetLocalSize().Y);
FSlateDrawElement::MakeLines(
OutDrawElements,
Layer,
AllottedGeometry.ToPaintGeometry(),
LinePoints,
ESlateDrawEffect::None,
*Color,
bAntialias);
}
}
}
DrawLayerId += 2;
}
void SNodePanel::PaintSurroundSunkenShadow(const FSlateBrush* ShadowImage, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 DrawLayerId) const
{
FSlateDrawElement::MakeBox(
OutDrawElements,
DrawLayerId,
AllottedGeometry.ToPaintGeometry(),
ShadowImage
);
}
void SNodePanel::PaintMarquee(const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 DrawLayerId) const
{
if (Marquee.IsValid())
{
FSlateDrawElement::MakeBox(
OutDrawElements,
DrawLayerId,
AllottedGeometry.ToPaintGeometry( GraphCoordToPanelCoord(Marquee.Rect.GetUpperLeft()), Marquee.Rect.GetSize()*GetZoomAmount() ),
FEditorStyle::GetBrush(TEXT("MarqueeSelection"))
);
}
}
void SNodePanel::PaintSoftwareCursor(const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 DrawLayerId) const
{
if( !bShowSoftwareCursor )
{
return;
}
// Get appropriate software cursor, depending on whether we're panning or zooming
const FSlateBrush* Brush = FEditorStyle::GetBrush(bIsPanning ? TEXT("SoftwareCursor_Grab") : TEXT("SoftwareCursor_UpDown"));
FSlateDrawElement::MakeBox(
OutDrawElements,
DrawLayerId,
AllottedGeometry.ToPaintGeometry( GraphCoordToPanelCoord( SoftwareCursorPosition ) - ( Brush->ImageSize / 2 ), Brush->ImageSize ),
Brush
);
}
void SNodePanel::PaintComment(const FString& CommentText, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 DrawLayerId, const FLinearColor& CommentTinting, float& HeightAboveNode, const FWidgetStyle& InWidgetStyle) const
{
//@TODO: Ideally we don't need to grab these resources for every comment being drawn
// Get resources/settings for drawing comment bubbles
const FSlateBrush* CommentCalloutArrow = FEditorStyle::GetBrush(TEXT("Graph.Node.CommentArrow"));
const FSlateBrush* CommentCalloutBubble = FEditorStyle::GetBrush(TEXT("Graph.Node.CommentBubble"));
const FSlateFontInfo CommentFont = FEditorStyle::GetFontStyle( TEXT("Graph.Node.CommentFont") );
const FSlateColor CommentTextColor = FEditorStyle::GetColor( TEXT("Graph.Node.Comment.TextColor") );
const FVector2D CommentBubblePadding = FEditorStyle::GetVector( TEXT("Graph.Node.Comment.BubblePadding") );
const TSharedRef< FSlateFontMeasure > FontMeasureService = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();
FVector2D CommentTextSize = FontMeasureService->Measure( CommentText, CommentFont ) + (CommentBubblePadding * 2);
const float PositionBias = HeightAboveNode;
HeightAboveNode += CommentTextSize.Y + 8.0f;
const FVector2D CommentBubbleOffset = FVector2D(0, -(CommentTextSize.Y + CommentCalloutArrow->ImageSize.Y) - PositionBias);
const FVector2D CommentBubbleArrowOffset = FVector2D( CommentCalloutArrow->ImageSize.X, -CommentCalloutArrow->ImageSize.Y - PositionBias);
// Draw a comment bubble
FSlateDrawElement::MakeBox(
OutDrawElements,
DrawLayerId-1,
AllottedGeometry.ToPaintGeometry(CommentBubbleOffset, CommentTextSize),
CommentCalloutBubble,
ESlateDrawEffect::None,
CommentTinting
);
FSlateDrawElement::MakeBox(
OutDrawElements,
DrawLayerId-1,
AllottedGeometry.ToPaintGeometry( CommentBubbleArrowOffset, CommentCalloutArrow->ImageSize ),
CommentCalloutArrow,
ESlateDrawEffect::None,
CommentTinting
);
// Draw the comment text itself
FSlateDrawElement::MakeText(
OutDrawElements,
DrawLayerId,
AllottedGeometry.ToPaintGeometry( CommentBubbleOffset + CommentBubblePadding, CommentTextSize ),
CommentText,
CommentFont,
ESlateDrawEffect::None,
CommentTextColor.GetColor( InWidgetStyle )
);
}
bool SNodePanel::IsNodeCulled(const TSharedRef<SNode>& Node, const FGeometry& AllottedGeometry) const
{
if ( Node->ShouldAllowCulling() )
{
const FVector2D MinClipArea = AllottedGeometry.GetDrawSize() * -NodePanelDefs::GuardBandArea;
const FVector2D MaxClipArea = AllottedGeometry.GetDrawSize() * ( 1.f + NodePanelDefs::GuardBandArea );
const FVector2D NodeTopLeft = GraphCoordToPanelCoord( Node->GetPosition() );
const FVector2D NodeBottomRight = GraphCoordToPanelCoord( Node->GetPosition() + Node->GetDesiredSize() );
return
NodeBottomRight.X < MinClipArea.X ||
NodeBottomRight.Y < MinClipArea.Y ||
NodeTopLeft.X > MaxClipArea.X ||
NodeTopLeft.Y > MaxClipArea.Y;
}
else
{
return false;
}
}
bool SNodePanel::GetBoundsForNode(const UObject* InNode, /*out*/ FVector2D& MinCorner, /*out*/ FVector2D& MaxCorner, float Padding) const
{
MinCorner = FVector2D(MAX_FLT, MAX_FLT);
MaxCorner = FVector2D(-MAX_FLT, -MAX_FLT);
bool bValid = false;
const TSharedRef<SNode>* pWidget = (InNode) ? NodeToWidgetLookup.Find(InNode) : nullptr;
if (pWidget)
{
const SNode& Widget = pWidget->Get();
const FVector2D Lower = Widget.GetPosition();
const FVector2D Upper = Lower + Widget.GetDesiredSize();
MinCorner.X = FMath::Min(MinCorner.X, Lower.X);
MinCorner.Y = FMath::Min(MinCorner.Y, Lower.Y);
MaxCorner.X = FMath::Max(MaxCorner.X, Upper.X);
MaxCorner.Y = FMath::Max(MaxCorner.Y, Upper.Y);
bValid = true;
}
if (bValid)
{
MinCorner.X -= Padding;
MinCorner.Y -= Padding;
MaxCorner.X += Padding;
MaxCorner.Y += Padding;
}
return bValid;
}
bool SNodePanel::GetBoundsForNodes(bool bSelectionSetOnly, FVector2D& MinCorner, FVector2D& MaxCorner, float Padding)
{
MinCorner = FVector2D(MAX_FLT, MAX_FLT);
MaxCorner = FVector2D(-MAX_FLT, -MAX_FLT);
bool bValid = false;
if (bSelectionSetOnly && (SelectionManager.GetSelectedNodes().Num() > 0))
{
for (FGraphPanelSelectionSet::TConstIterator NodeIt(SelectionManager.GetSelectedNodes()); NodeIt; ++NodeIt)
{
TSharedRef<SNode>* pWidget = NodeToWidgetLookup.Find(*NodeIt);
if (pWidget != nullptr)
{
SNode& Widget = pWidget->Get();
const FVector2D Lower = Widget.GetPosition();
const FVector2D Upper = Lower + Widget.GetDesiredSize();
MinCorner.X = FMath::Min(MinCorner.X, Lower.X);
MinCorner.Y = FMath::Min(MinCorner.Y, Lower.Y);
MaxCorner.X = FMath::Max(MaxCorner.X, Upper.X);
MaxCorner.Y = FMath::Max(MaxCorner.Y, Upper.Y);
bValid = true;
}
}
}
else
{
bValid = NodeToWidgetLookup.Num() > 0;
for (auto NodeIt = NodeToWidgetLookup.CreateConstIterator(); NodeIt; ++NodeIt)
{
SNode& Widget = NodeIt.Value().Get();
const FVector2D Lower = Widget.GetPosition();
const FVector2D Upper = Lower + Widget.GetDesiredSize();
MinCorner.X = FMath::Min(MinCorner.X, Lower.X);
MinCorner.Y = FMath::Min(MinCorner.Y, Lower.Y);
MaxCorner.X = FMath::Max(MaxCorner.X, Upper.X);
MaxCorner.Y = FMath::Max(MaxCorner.Y, Upper.Y);
}
}
if (bValid)
{
MinCorner.X -= Padding;
MinCorner.Y -= Padding;
MaxCorner.X += Padding;
MaxCorner.Y += Padding;
}
return bValid;
}
bool SNodePanel::ScrollToLocation(const FGeometry& MyGeometry, FVector2D DesiredCenterPosition, const float InDeltaTime)
{
const FVector2D HalfOFScreenInGraphSpace = 0.5f * MyGeometry.GetLocalSize() / GetZoomAmount();
FVector2D CurrentPosition = ViewOffset + HalfOFScreenInGraphSpace;
FVector2D NewPosition = FMath::Vector2DInterpTo(CurrentPosition, DesiredCenterPosition, InDeltaTime, 10.f);
ViewOffset = NewPosition - HalfOFScreenInGraphSpace;
// If within 1 pixel of target, stop interpolating
return ((NewPosition - DesiredCenterPosition).SizeSquared() < 1.f);
}
bool SNodePanel::ZoomToLocation(const FVector2D& CurrentSizeWithoutZoom, const FVector2D& InDesiredSize, bool bDoneScrolling)
{
if (bAllowContinousZoomInterpolation && ZoomLevelGraphFade.IsPlaying())
{
return false;
}
const int32 DefaultZoomLevel = ZoomLevels->GetDefaultZoomLevel();
const int32 NumZoomLevels = ZoomLevels->GetNumZoomLevels();
int32 DesiredZoom = DefaultZoomLevel;
// Find lowest zoom level that will display all nodes
for (int32 Zoom = 0; Zoom < DefaultZoomLevel; ++Zoom)
{
const FVector2D SizeWithZoom = CurrentSizeWithoutZoom / ZoomLevels->GetZoomAmount(Zoom);
const FVector2D LeftOverSize = SizeWithZoom - InDesiredSize;
if ((InDesiredSize.X > SizeWithZoom.X) || (InDesiredSize.Y > SizeWithZoom.Y))
{
// Use the previous zoom level, this one is too tight
DesiredZoom = FMath::Max<int32>(0, Zoom - 1);
break;
}
}
if (DesiredZoom != ZoomLevel)
{
if (bAllowContinousZoomInterpolation)
{
// Animate to it
PreviousZoomLevel = ZoomLevel;
ZoomLevel = FMath::Clamp(DesiredZoom, 0, NumZoomLevels-1);
ZoomLevelGraphFade.Play( this->AsShared() );
return false;
}
else
{
// Do it instantly, either first or last
if (DesiredZoom < ZoomLevel)
{
// Zooming out; do it instantly
ZoomLevel = PreviousZoomLevel = DesiredZoom;
ZoomLevelFade.Play( this->AsShared() );
}
else
{
// Zooming in; do it last
if (bDoneScrolling)
{
ZoomLevel = PreviousZoomLevel = DesiredZoom;
ZoomLevelFade.Play( this->AsShared() );
}
}
}
PostChangedZoom();
}
return true;
}
void SNodePanel::ZoomToFit(bool bOnlySelection)
{
bDeferredZoomToNodeExtents = true;
bDeferredZoomToSelection = bOnlySelection;
ZoomPadding = NodePanelDefs::DefaultZoomPadding;
}
void SNodePanel::ZoomToTarget(const FVector2D& TopLeft, const FVector2D& BottomRight)
{
bDeferredZoomToNodeExtents = false;
ZoomTargetTopLeft = TopLeft;
ZoomTargetBottomRight = BottomRight;
RequestZoomToFit();
}
void SNodePanel::ChangeZoomLevel(int32 ZoomLevelDelta, const FVector2D& WidgetSpaceZoomOrigin, bool bOverrideZoomLimiting)
{
// We want to zoom into this point; i.e. keep it the same fraction offset into the panel
const FVector2D PointToMaintainGraphSpace = PanelCoordToGraphCoord( WidgetSpaceZoomOrigin );
const int32 DefaultZoomLevel = ZoomLevels->GetDefaultZoomLevel();
const int32 NumZoomLevels = ZoomLevels->GetNumZoomLevels();
const bool bAllowFullZoomRange =
// To zoom in past 1:1 the user must press control
(ZoomLevel == DefaultZoomLevel && ZoomLevelDelta > 0 && bOverrideZoomLimiting) ||
// If they are already zoomed in past 1:1, user may zoom freely
(ZoomLevel > DefaultZoomLevel);
const float OldZoomLevel = ZoomLevel;
if ( bAllowFullZoomRange )
{
ZoomLevel = FMath::Clamp( ZoomLevel + ZoomLevelDelta, 0, NumZoomLevels-1 );
}
else
{
// Without control, we do not allow zooming in past 1:1.
ZoomLevel = FMath::Clamp( ZoomLevel + ZoomLevelDelta, 0, DefaultZoomLevel );
}
if (OldZoomLevel != ZoomLevel)
{
PostChangedZoom();
}
// Note: This happens even when maxed out at a stop; so the user sees the animation and knows that they're at max zoom in/out
ZoomLevelFade.Play( this->AsShared() );
// Re-center the screen so that it feels like zooming around the cursor.
this->ViewOffset = PointToMaintainGraphSpace - WidgetSpaceZoomOrigin / GetZoomAmount();
}
bool SNodePanel::GetBoundsForSelectedNodes( class FSlateRect& Rect, float Padding )
{
bool Result = false;
if(SelectionManager.GetSelectedNodes().Num() > 0)
{
FVector2D MinCorner, MaxCorner;
Result = GetBoundsForNodes(true, MinCorner, MaxCorner,Padding);
Rect = FSlateRect(MinCorner.X, MinCorner.Y, MaxCorner.X, MaxCorner.Y);
}
return Result;
}
FVector2D SNodePanel::GetPastePosition() const
{
return PastePosition;
}
bool SNodePanel::HasDeferredObjectFocus() const
{
return DeferredMovementTargetObject != nullptr;
}
void SNodePanel::PostChangedZoom()
{
CurrentLOD = ZoomLevels->GetLOD(ZoomLevel);
// Invalidate the current bookmark.
CurrentBookmarkGuid.Invalidate();
}
void SNodePanel::RequestZoomToFit()
{
if (!ActiveTimerHandle.IsValid())
{
ActiveTimerHandle = RegisterActiveTimer(0.f, FWidgetActiveTimerDelegate::CreateSP(this, &SNodePanel::HandleZoomToFit));
}
}
void SNodePanel::CancelZoomToFit()
{
if (ActiveTimerHandle.IsValid())
{
UnRegisterActiveTimer(ActiveTimerHandle.Pin().ToSharedRef());
}
}
bool SNodePanel::HasMoved() const
{
return (!FMath::IsNearlyEqual(GetZoomAmount(), OldZoomAmount) || !ViewOffset.Equals(OldViewOffset, SMALL_NUMBER));
}