You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden #rb none #rnx ============================ MAJOR FEATURES & CHANGES ============================ Change 3431439 by Marc.Audy Editor only subobjects shouldn't exist in PIE world #jira UE-43186 Change 3457323 by Marc.Audy Undo CL# 3431439 and once again allow (incorrectly) for editor only objects to exist in a PIE world #jira UE-45087 Change 3499927 by Dan.Oconnor UField::Serialize no longer serialize's its next ptr, UStruct::Serialize serializes all Children properties instead. This resolves a hard circular dependency between function libraries that EDL detected. It was resolved in an ad hoc way by the old linker #jira UE-43458 Change 3502939 by Michael.Noland Back out changelist 3499927 Change 3522783 by Zak.Middleton #ue4 - Imported new simple collision for Engine/Content/BasicShaps/Cylinder.uasset which is a single convex shape (rather than being 4 shapes as before). Change 3544641 by Dan.Oconnor Remove conditional that is no longer needed, replace with ensure. It is unsafe to change CDO names #jira OR-38176 Change 3544645 by Dan.Oconnor In addition to marking nodes as not transient, FBlueprintEditor::ExpandNode needs to mark them as transactional #jira UE-45248 Change 3545023 by Marc.Audy Properly encapsulate FPinDeletionQueue Fix ensure during deletion of split pins when not clearing links Fix split pins able to end up in delete queue twice during undo/redo Change 3545025 by Marc.Audy Properly allow changing the pin type from a struct that is split on the node #jira UE-47328 Change 3545455 by Ben.Zeigler Fix issue where combined streamable handles could be freed before their complete callback is called if nothing external referenced them Copy of CL#3544474 Change 3545456 by Ben.Zeigler Allow PrimaryAssets to update their AssetData based on in-memory changes when launching 'Standalone Game' and 'Mobile Preview' from the editor. As it was, changes could be detected and propagated through UPrimaryDataAsset::PostLoad, but the changes would always reapply whatever already exists in the AssetRegistry. The primary use-case for this: making AssetBundle tag changes and allowing them to propagate without resaving/recooking all affected assets. Copy of CL #3544374 Change 3545547 by Ben.Zeigler CIS Fix Change 3545568 by Michael.Noland PR #3758: Fixing a comment typo from Transistion to Transition (Contributed by gsfreema) #jira UE-46845 Change 3545582 by Michael.Noland Blueprints: Prevent duplicate messages from being added to the compiler results log (fixes a crash when resizing the results log while a math expression node has an error) Blueprints: Fixed the tooltip of math expression nodes not showing up, and error messages getting cleared on subsequent compiles [Duplicating fixes for UE-47491 and UE-47512 from 4.17 to Dev-Framework] Change 3546528 by Ben.Zeigler #jira UE-47548 Fix crash when a map's key type has changed but value has not, it was passing the UStruct defaults in when serialize was expecting the default instance, so pass null instead as we don't have the instance Change 3546544 by Marc.Audy Fix split pin restoration logic to deal with wildcards and variations in const/refness Change 3546551 by Marc.Audy Don't crash if the struct type is missing for whatever reason Change 3547152 by Marc.Audy Fix array exporting so you don't end up getting none instead of defaults #jira UE-47320 Change 3547438 by Marc.Audy Fix split pins on class defaults Don't cause a structural change when reapplying a split pin as part of node reconstruction #jira UE-46935 Change 3547501 by Ben.Zeigler Fix ensure, it's valid to pass a null path for a dynamic asset Change 3551185 by Ben.Zeigler #jira UE-42835 Fix it so SoftObjectPaths work correctly when inside levels loaded for the first time from PIE. Added code to do in-place PIE fixup for levels that are loaded instead of duplicated, and changed the fixup logic to fix all level references, not just ones being explicitly duplicated Change 3551723 by Ben.Zeigler Improve UI for displaying actor soft references. Add an error/warning icon if the cross level reference is broken or unloaded, and fix various display and copy/paste behaviors Change 3553216 by Phillip.Kavan #jira UE-39303, UE-46268, UE-47519 - Nativized UDS now support external asset dependencies and will construct their own linker import tables on load. Change summary: - Modified FCompactBlueprintDependencyData and FFakeImportTableHelper to be more relevant to UStruct and not just UClass-derivative types. - Modified FBlueprintDependencyData to accept a single FCompactBlueprintDependencyData struct rather than its individual fields. - Modified FBlueprintCompilerCppBackendBase::GenerateCodeFromStruct() to emit dependency assignment and static type registration functions for nativized UStruct types. - Modified FBlueprintNativeCodeGenModule::FStatePerPlatform to include an array for tracking UDS assets that need to be converted during the nativization pass at cook time. - Modified FBlueprintNativeCodeGenModule::GenerateFullyConvertedClasses() to generate nativized code for UDS assets. This ensures that UDS conversion falls under the same scope as BPGC conversion, so that they both feed into the same NativizationSummary context for asset dependency tracking (i.e. since we only have a single global dependency table in the codegen). Also modified InitializeForRerunDebugOnly() to do the same. - Modified FBlueprintNativeCodeGenModule::Convert() to defer UDS conversion so that it's done at the same time as BPGC conversion (see note above). - Modified FEmitDefaultValueHelper::AddStaticFunctionsForDependencies() to include support for UStruct types and to conform to changes made to FCompactBlueprintDependencyData. - Modified FEmitDefaultValueHelper::AddRegisterHelper() to include support for UStruct types. - Modified FBlueprintNativeCodeGenModule::FindReplacedClassForObject() to ensure that converted User-Defined Enum types are switched to a UEnumProperty at package save time so that any import tables contain the proper class. This is necessary because we nativize User-Defined Enum types as 'enum class' types, and UHT will generate code for those as a UEnumProperty with an "underlying" property. However, non-nativized User-Defined Enum types are referenced as a UByteProperty with a UEnum reference, so we have to fix up all the import tables before saving. Otherwise, EDL will assert on load (see UE-47519). Change 3553301 by Ben.Zeigler Fix ensure when passing literal None to SoftObjectPath, it now treats them as empty instead Change 3553631 by Dan.Oconnor UField::Serialize no longer serialize's its next ptr, UStruct::Serialize serializes all Children properties instead. This resolves a hard circular dependency between function libraries that EDL detected. It was resolved in an ad hoc way by the old linker. This change was originally submitted in 3499927, but it was incorrectly clearing the UField::Next pointer in UField::Serialize. #jira UE-43458 Change 3553799 by Ben.Zeigler Fix issue where calling WaitUntilComplete on a combined handle with Stalled children wouldn't work properly. It now forces all stalled children to start immediately. I also added a warning log when this happens and an ensure if somehow the force didn't work Copy of CL #3553781 Change 3553896 by Michael.Noland Blueprints: Allow the autowiring logic to better break and replace existing connections when made (e.g., when dragging a variable onto a compatible pin with an existing connection, break the old connection to allow the new connection to be made) #jira UE-31031 Change 3553897 by Michael.Noland Blueprints: Adjust search query when doing 'Find References' on variables from My Blueprints so that bound event nodes show up for components and widgets #jira UE-37862 Change3553898by Michael.Noland Blueprints: Add the name of the variable directly in the get/set menu options (when dragging from My Blueprints into the graph) Change 3553909 by Michael.Noland Blueprints: Added the full name of the type, container type (and value type for maps) to the tooltips for the type picker elements, so long names can be read in full #jira UE-19710 Change 3554517 by Michael.Noland Blueprints: Added an option to disable the comment bubble on comment boxes that appears when zoomed out #jira UE-21810 Change 3554664 by Michael.Noland Editor: Renamed "Find in CB" command to "Browse" and renamed "Search" (in BP) to "Find", so terminology is consistent and keyboard shortcuts make sense (Ctrl+B for Browse, Ctrl+F for find, not using the term Search anywhere) #jira UE-27121 Change 3554831 by Dan.Oconnor Non editor build fix Change 3554834 by Dan.Oconnor Actor bound event related warnings now show up in blueprint status when opening level blueprint for first time, improved warning message. Removed unused delegate and return value from FixLevelScriptActorBindings. Can now pass raw strings to blueprint results log (no need for Printf, although padding is not great), UClasses in compiler results log will open the generated blueprint when clicked on #jira UE-40438 Change 3556157 by Ben.Zeigler Convert LevelSequenceBindingReference to use FSoftObjectPath so it works properly with redirectors and fixups Change 3557775 by Michael.Noland Blueprints: Fixed swapped transaction messages when converting a cast node between pure and impure #jira UE-36090 Change 3557777 by Michael.Noland Blueprints: Allow 'Goto Definition' and 'Find References' to be used while stopped at a breakpoint PR #3774: Expose GotoFunctionDefinition during BP debugging (Contributed by projectgheist) #jira UE-47024 Change 3560510 by Michael.Noland Blueprints: Add support for 'goto definition' on Create Event nodes when the Object pin is not hooked up #jira UE-38912 Change 3560563 by Michael.Noland Blueprints: Disallow converting a variable get node to impure/back when debugging (no graph mutating operations should be allowed) Change 3561443 by Ben.Zeigler Restore code to support gc.DumpPoolStats, was accidentally removed when FGCArrayPool was moved to a header. Clean up comments around Cleanup function, the functionality to trim the memory pools was integrated into ClearWeakReferences on a prior change Change 3561658 by Michael.Noland Blueprints: Refactored 'Goto Definition' so there is no per-class logic in the Blueprint editor or schema any more; any node can opt in individually - Added a key binding for Goto Definition (Alt+G) - Added a key binding for Find References (Shift+Alt+F) - Collapsed 'Goto Code Definition' for variables and functions into the same path, so there aren't separate menu items and commands - Added new methods CanJumpToDefinition and JumpToDefinition to UEdGraphNode, the default behavior for UK2Node subclasses is to call GetJumpTargetForDoubleClick and call into FKismetEditorUtilities::BringKismetToFocusAttentionOnObject - Going to a native function now goes thru a better code path that will actually put the source code editor on the function definition, rather than just opening the file containing the definition Change 3562291 by Ben.Zeigler Fix issue where calling FSoftObjectPtr::Get during a package save would result in that ptr being forever marked broken, because the ResolveObject fails during save. It's too risky to change that behavior, so change it so the TagAtLastTest doesn't get updated in that case Change 3562292 by Ben.Zeigler #jira UE-39042 When renaming or moving actors between levels it now attempts to fix any soft object references from blueprints or sequencer When deleting actors that are soft referenced by actor/sequencer it will now warn the same way it does for level script. Added IAssetTools::FindSoftReferencesToObject to perform this search Change it so saving a non-primary world does not result it being dirtied due to the temporary physics scene fixup Fix issue where the actor name was shown incorrectly in the SSCS tree for actor instances, which meant that if you renamed it you would end up renaming it to the BP's name Change 3564814 by Ben.Zeigler #jira UE-47843 Don't set InputKey output pins to AnyKey if empty, this was causing blueprints with key events to constantly dirty themselves Change 3566707 by Dan.Oconnor Remove unused code, UClassGenerateCDODuplicatesForHotReload was attempting to create a CDO with a special name, which triggered an ensure. The Duplicated CDO was never used (callign code removed in 3289276 as it was a waste of cycles) #jira None Change 3566717 by Michael.Noland Core: Remove all defintions that contain "_API" from the command line when compiling .rc files (they do not support repsonse files and a too-long command line will fail the compile) Change 3566771 by Michael.Noland Editor: Fixing deprecation warning #jira UE-47922 Change 3567023 by Michael.Noland Blueprints: Change various TArray<> uses to TSet<> throughout name validation and related code to enable it to scale better to high component or variable counts Adapted from PR #3708: Fast construction of bp (Contributed by gildor2) #jira UE-46473 Change 3567304 by Ben.Zeigler Add bCheckRecursive option to IsEditorOnlyObject that is enabled by default and will check outer/archetype/class. This is needed for places that call this function from outside of SavePackage.cpp when the editor only mark is set, such as the automation test code Change 3567398 by Ben.Zeigler Fix crash when spawning a widget that has no editor WidgetTree, but does have a cooked widget tree template due to tree inheritance Change 3567729 by Michael.Noland Blueprints: Clarified message about "{VariableName} is not blueprint visible" to define what that means "(BlueprintReadOnly or BlueprintReadWrite)" Change 3567739 by Ben.Zeigler Don't crash if PropertyStruct cannot find it's struct. The function half handled this before, but Preload crashes with a null parameter Change 3567741 by Ben.Zeigler Disable optimization for a path test that was crashing in VC2015 in a monolithic build Change 3568332 by Mieszko.Zielinski Prevented UAIPerceptionSystem::GetCurrent causing a BP error when WorldContextObject is null #UE4 #jira UE-47948 Change 3568676 by Michael.Noland Blueprints: Allow editing the tooltip of each enum value in a user defined enum #jira UE-20036 Known issue: Undo/redo is not currently possible on the tooltip as it is directly stored in package metadata Change 3569128 by Michael.Noland Blueprints: Removing the experimental profiler as we won't be returning to it any time soon #jira UE-46852 Change 3569207 by Michael.Noland Blueprints: Allow drag-dropping component Blueprint assets into the graph to create Add Component nodes and improved the error message when dragging something that cannot be dropped into an actor Blueprint #jira UE-8708 Change 3569208 by Michael.Noland Blueprints: Allow specifying a description for user defined enums (shown in the content browser) #jira UE-20036 Change 3569209 by Michael.Noland Editor: Allow adjusting the font size for each individual comment box node in Blueprints and Materials #jira UE-16085 Change 3570177 by Michael.Noland Blueprints: Fixed discrepancy between the Structure tab name and the menu option for the tab in the user defined structure editor (now both say Structure Editor) #jira UE-47962 Change 3570179 by Michael.Noland Blueprints: Fixed the tooltip of a user defined structure not updating immediately in the content browser after being edited Change 3570192 by Michael.Noland Blueprints: Added "(selected)" after the label (in the 'debug filter' dropdown in the Blueprint editor) for actors that are selected in the level editor, which should make it easier to choose the specific actor you want to debug #jira UE-20709 Change 3571203 by Michael.Noland Blueprints: Cleanup and refactoring to prepare for turning commented out nodes into an official feature - Made EnabledState and bUserSetEnabledState private on UEdGraphNode and added new getters/setters - Introduced IsAutomaticallyPlacedGhostNode() and MakeAutomaticallyPlacedGhostNode() to start decoupling the concept from commented out nodes - Updated a couple of places that used a hardcoded UberGraphPages[0] into instead editing the most recently interacted with event graph if possible - Updated 'is data only blueprint' logic to allow multiple ubergraph pages, as long as they're all empty of non-disabled nodes Change 3571224 by Michael.Noland Blueprints: Draw banners on development-only and user disabled nodes (excluding 'ghost' nodes like autogenerated event entries in new BPs) Adapted from PR #2701: Differentiate development nodes in BP (Contributed by projectgheist) #jira UE-29848 #jira UE-34698 Change 3571279 by Michael.Noland Blueprints: Changed UK2Node::GetPassThroughPin so that only the execution wire on nodes with exactly one input and one output exec wire will have a corresponding pass-through pin (when there is ambiguity in which exec would be used, e.g., with a branch or sequence or timeline node, the subsequent nodes are now effectively disabled as well) Change 3571282 by Michael.Noland Blueprints: Fixed the tooltip for dragging a variable onto an inherited category not showing the 'move to category' hint Change 3571284 by Michael.Noland Blueprints: Made wires into/out of a user-disabled node draw verly dimly (other than the passthrough exec if it exists) Change 3571311 by Ben.Zeigler Add ActorIteratorFlags which allows overriding which types of actors/levels are iterated by ActorIterator, to allow iterating levels that are not visible. All of the iteration logic is now in the base and the children just set different flags, which fixes it so TActorIterator does the same level collection check as FActorIterator Change 3571313 by Ben.Zeigler Several fixes to automation framework to allow it to work better with Cooked builds. Change it so the automation test list is a single message. There is no guarantee on order of message packets, so several tests were being missed each time. Change 3571485 by mason.seay Test map for Make Set bug Change 3571501 by Ben.Zeigler Accidentally undid the UHT fixup for TAssetPtr during my bulk rename Change 3571531 by Ben.Zeigler Fix warning messages Change 3571591 by Michael.Noland Blueprints: Made drag-dropping assets into a graph to create a component transactional (allowing the action to be undone) #jira UE-48024 Change 3572938 by Michael.Noland Blueprints: Fixed a typo in a set function comment #jira UE-48036 Change 3572941 by Michael.Noland Blueprints: Made the compact node title for cross and dot product the words cross and dot rather than hard to see . and x symbols #jira UE-38624 Change 3574816 by mason.seay Renamed asset to better reflect name of object reference Change 3574985 by mason.seay Updated comments and string outputs to list Soft Object Reference Change 3575740 by Ben.Zeigler #jira UE-48061 Change it so Editor builds work like cooked builds and always try to reuse existing packages when loading them instead of recreating them in place. Recreating in place does not work well for levels and blueprints, and blueprints already had a hack that was causing this behavior to not activate Change 3575795 by Ben.Zeigler #jira UE-48118 Call into the AssetManager as part of the DistillPackages commandlet. This makes sure that ShooterGame and EngineTest end up with the correct content in launcher builds Change 3576374 by mason.seay Forgot to submit the deleting of a redirector Change 3576966 by Ben.Zeigler #jira UE-48153 Fix issue where actors in streaming levels weren't properly replicating in PIE. It now does the remap path on both send and receive for the manual PC level streaming commands Change 3577002 by Marc.Audy Prevent wildcard pins from being connected to exec pins #jira UE-48148 Change 3577232 by Phillip.Kavan #jira UE-48034 - Fix EDL assert on load caused by a native reference to a nativized BP class that also references a nativized UDS asset. Change summary: - Modified FNativeClassHeaderGenerator::ExportGeneratedStructBodyMacros() to emit the 'ReplaceConverted' package name for the FCompiledInDeferStruct global associated with the nativized UDS asset in the UHT codegen. This brings nativized UDS to parity with nativized BP class assets (it was likely just an oversight initially). Change 3577710 by Dan.Oconnor Mirror of 3576977: Fix for crash when loading cooked uassets that reference functions that are not present #jira UE-47644 Change 3577723 by Dan.Oconnor Prevent deferring of classes that are needed to load subobjects #jira UE-47726 Change 3577741 by Dan.Oconnor Back out changelist 3577723 - causes crash when starting QAGame in Dev-Framework - not in Release-4.17 Change 3578938 by Ben.Zeigler #jira UE-27124 Fix issue where renaming a map with legacy map build data would end up with a half-loaded redirector package, becuase the old map build data was still in use. It's possible the call to HandleLegacyMapBuildData should just be in World PostLoad instead of piecemeal in several other places but I am unsure. Fix it so the redirector cleanup code on map change will not be stopped by non-standalone top level objects, which could be left behind by issues in other systems Change 3578947 by Marc.Audy (4.17) Properly expose members of DialogueContext to blueprints #jira UE-48175 Change 3578952 by Ben.Zeigler Fix ensure where ParentHandles on a StreamableHandle could be modified while iterating Change 3579315 by mason.seay Test map for Make Container nodes Change 3579600 by Ben.Zeigler Disable window test on non-desktop platforms as they cannot be resized post launch Change 3579601 by Ben.Zeigler #jira UE-48236 Disable optimizations on PS4 for certain math tests pending fixing of platform issue Change 3579713 by Dan.Oconnor Prevent crashes when bluepints implement an interface that was deleted #jira UE-48223 Change 3579719 by Dan.Oconnor Fix two compilation manager issues: Make sure CDOs are not renamed under a UClass, because they will be considered as possible subobjects, which has bad side effects and make sure that we update references even on empty functions, so that empty UFunctions are not left with references to REINST data #jira UE-48240 Change 3579745 by Michael.Noland Blueprints: Improve categorization and reordering support in 'My Blueprints' - Allow drag-dropping functions, macros, delegates, etc... to reorder them within a category or to change categories (bringing them to parity with variables) - Make category ordering on all categories sticky so you can reorder categories (the relative ordering will be the same within different sections like variables and functions) - Added hover cues when drag dropping some items that were missing them (e.g., event dispatchers) - Added support for renaming categories using F2 Known issues (none are regressions): - Timelines cannot be moved to other categories or reordered - Renaming a nested category will result in it becoming a top level category (discarding the parent category chain) - Some actions do not support undo #jira UE-31557 Change 3579795 by Michael.Noland PR #3867: Fix for not releasing Local Notification Delegate. (Contributed by enginevividgames) #jira UE-48105 Change 3580463 by Marc.Audy (4.17) Don't crash if calling PostEditUndo on an Actor in the transient package #jira UE-47523 Change 3581073 by Marc.Audy Make UK2Node_SpawnActorFromClass inherit from K2Node_ConstructObjectFromClass and eliminate duplicate code. Correctly reconnect split pins when changing class on create widget, construct object, and spawn actor nodes Change 3581156 by Ben.Zeigler #jira UE-48161 Fix issue where split pins would not be restored if a Struct type was changed due to refactoring of parent variables/functions. For structs we want to copy the pins, if they're invalid due to other changes they will be individual orphaned Also fix bug where the category of parent pins was being set incorrectly while changing variable type, we only want to override type for wildcard pins Change3581473by Ben.Zeigler Properly turn off optimization for PS4 test Change 3582094 by Marc.Audy Fix anim nodes not navigating to their graph on double click #jira UE-48333 Change 3582157 by Marc.Audy Fix double-clicking on animation asset nodes not opening the asset editors Change 3582289 by Marc.Audy (4.17) Don't crash when adding a streaming level that's already in the level #jira UE-48928 Change 3545435 by Ben.Zeigler #jira UE-47509 Rename and refactor internals StringAssetReferences and AssetPtrs to become SoftObjectPath/Ptr. This is to prepare them for use for subobjects like actors. Here is the rename table: FStringAssetReference -> FSoftObjectPath FStringClassReference -> FSoftClassPath TAssetPtr -> TSoftObjectPtr TAssetSubclassOf -> TSoftClassPtr The old headers are deprecated, and FSoftClassPath is now in the same header has FSoftObjectPath. This change increments the UE4 version because FSoftObjectPaths are now stored as a name + substring instead of one giant name, which in practice will improve performance and memory while manipulating them. Also the package table of soft referenced packages is now stored as FNames instead of FStrings as these packages names will already be in the name table due to the AssetRegistry Remove automatic support for loading Objectpaths starting with engine-ini:, as it was only partially supported and is very outdated. ResolveIniObjectsReference can still be called manually Changed TPersistentObjectPtr and TLazyObjectPtr to be structs instead of classes Change UnrealHeaderTool to read configuration such as StructsWithNoPrefix out of inis instead of using a hardcoded list. Add support for TypeRedirects, which is used to make the old type names automatically remap to the new ones Clean up FRedirectCollector to remove some of the functionality that is no longer used by the cooker, and disable tracking of redirects in standalone -game builds Change 3567760 by Ben.Zeigler Fix it so EngineTest can be cooked by moving some utility functions to EditorTestsUtilityLibrary and adding an EditorFunctionalTest. The core EngineTest module is safely runtime-only now and can run it's tests locally in windows cooked Merge FuncTestManager into FunctionalTestModule to avoid confusion with FunctionalTestingManager UObject Add EngineTestAssetManager and override the cook function to cook all maps with runtime functional tests Change actor merging tests to be editor only, this stops them from cooking Several individual tests crash on cooked builds, I started threads with the owners of those Change 3575737 by Ben.Zeigler #jira UE-48042 Change it so playing via PIE Standalone, multiprocess networked PIE and external cook launch on does not save temporary levels to UEDPC and instead prompts the user to save. This is how launch on works by default already, and this fixes cross level references/sequencer. The UEDPC code has been removed entirely. As part of this change, connecting a -game client to a PIE server and vice versa is much more likely to work. You may still have game-side problems, look at UEditorEngine::NetworkRemapPath for an example of how to do the PIE prefix conversion Remove advanced CreateTemporaryCopiesOfLevels option from sequencer capture, it has not been tested in multiple years and does not work with newer sequencer features #jira UE-27124 Fix several possible crashes with changing levels while in PIE Change 3578806 by Marc.Audy Fix Construct Object not working correctly with split pins. Add Construct Object test cases to functional tests. Added split pin expose on spawn test cases. #jira UE-33924 [CL 3582334 by Marc Audy in Main branch]
1683 lines
55 KiB
C++
1683 lines
55 KiB
C++
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
#include "SGraphPanel.h"
|
|
#include "Rendering/DrawElements.h"
|
|
#include "EdGraph/EdGraph.h"
|
|
#include "Layout/WidgetPath.h"
|
|
#include "Framework/Application/MenuStack.h"
|
|
#include "Framework/Application/SlateApplication.h"
|
|
#include "EdGraphNode_Comment.h"
|
|
#include "Settings/EditorExperimentalSettings.h"
|
|
#include "Editor.h"
|
|
#include "GraphEditorSettings.h"
|
|
#include "GraphEditorDragDropAction.h"
|
|
#include "NodeFactory.h"
|
|
|
|
#include "DragAndDrop/DecoratedDragDropOp.h"
|
|
#include "DragAndDrop/ActorDragDropGraphEdOp.h"
|
|
#include "DragAndDrop/AssetDragDropOp.h"
|
|
#include "DragAndDrop/LevelDragDropOp.h"
|
|
|
|
#include "GraphEditorActions.h"
|
|
|
|
#include "ConnectionDrawingPolicy.h"
|
|
|
|
#include "AssetSelection.h"
|
|
|
|
#include "KismetNodes/KismetNodeInfoContext.h"
|
|
#include "GraphDiffControl.h"
|
|
|
|
DEFINE_LOG_CATEGORY_STATIC(LogGraphPanel, Log, All);
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// SGraphPanel
|
|
|
|
void SGraphPanel::Construct( const SGraphPanel::FArguments& InArgs )
|
|
{
|
|
SNodePanel::Construct();
|
|
|
|
this->OnGetContextMenuFor = InArgs._OnGetContextMenuFor;
|
|
this->GraphObj = InArgs._GraphObj;
|
|
this->GraphObjToDiff = InArgs._GraphObjToDiff;
|
|
this->SelectionManager.OnSelectionChanged = InArgs._OnSelectionChanged;
|
|
this->IsEditable = InArgs._IsEditable;
|
|
this->DisplayAsReadOnly = InArgs._DisplayAsReadOnly;
|
|
this->OnNodeDoubleClicked = InArgs._OnNodeDoubleClicked;
|
|
this->OnDropActor = InArgs._OnDropActor;
|
|
this->OnDropStreamingLevel = InArgs._OnDropStreamingLevel;
|
|
this->OnVerifyTextCommit = InArgs._OnVerifyTextCommit;
|
|
this->OnTextCommitted = InArgs._OnTextCommitted;
|
|
this->OnSpawnNodeByShortcut = InArgs._OnSpawnNodeByShortcut;
|
|
this->OnUpdateGraphPanel = InArgs._OnUpdateGraphPanel;
|
|
this->OnDisallowedPinConnection = InArgs._OnDisallowedPinConnection;
|
|
|
|
this->bPreservePinPreviewConnection = false;
|
|
this->PinVisibility = SGraphEditor::Pin_Show;
|
|
|
|
CachedAllottedGeometryScaledSize = FVector2D(160, 120);
|
|
if (InArgs._InitialZoomToFit)
|
|
{
|
|
ZoomToFit(/*bOnlySelection=*/ false);
|
|
bTeleportInsteadOfScrollingWhenZoomingToFit = true;
|
|
}
|
|
|
|
BounceCurve.AddCurve(0.0f, 1.0f);
|
|
|
|
FEditorDelegates::BeginPIE.AddRaw( this, &SGraphPanel::OnBeginPIE );
|
|
FEditorDelegates::EndPIE.AddRaw( this, &SGraphPanel::OnEndPIE );
|
|
|
|
// Register for notifications
|
|
MyRegisteredGraphChangedDelegate = FOnGraphChanged::FDelegate::CreateSP(this, &SGraphPanel::OnGraphChanged);
|
|
MyRegisteredGraphChangedDelegateHandle = this->GraphObj->AddOnGraphChangedHandler(MyRegisteredGraphChangedDelegate);
|
|
|
|
ShowGraphStateOverlay = InArgs._ShowGraphStateOverlay;
|
|
|
|
SavedMousePosForOnPaintEventLocalSpace = FVector2D::ZeroVector;
|
|
PreviousFrameSavedMousePosForSplineOverlap = FVector2D::ZeroVector;
|
|
|
|
TimeLeftToInvalidatePerTick = 0.0f;
|
|
}
|
|
|
|
SGraphPanel::~SGraphPanel()
|
|
{
|
|
FEditorDelegates::BeginPIE.RemoveAll( this );
|
|
FEditorDelegates::EndPIE.RemoveAll( this );
|
|
|
|
this->GraphObj->RemoveOnGraphChangedHandler(MyRegisteredGraphChangedDelegateHandle);
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
int32 SGraphPanel::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const
|
|
{
|
|
CachedAllottedGeometryScaledSize = AllottedGeometry.GetLocalSize() * AllottedGeometry.Scale;
|
|
|
|
//Style used for objects that are the same between revisions
|
|
FWidgetStyle FadedStyle = InWidgetStyle;
|
|
FadedStyle.BlendColorAndOpacityTint(FLinearColor(0.45f,0.45f,0.45f,0.45f));
|
|
|
|
// First paint the background
|
|
const UEditorExperimentalSettings& Options = *GetDefault<UEditorExperimentalSettings>();
|
|
|
|
const FSlateBrush* BackgroundImage = FEditorStyle::GetBrush(TEXT("Graph.Panel.SolidBackground"));
|
|
PaintBackgroundAsLines(BackgroundImage, AllottedGeometry, MyCullingRect, OutDrawElements, LayerId);
|
|
|
|
const float ZoomFactor = AllottedGeometry.Scale * GetZoomAmount();
|
|
|
|
FArrangedChildren ArrangedChildren(EVisibility::Visible);
|
|
ArrangeChildNodes(AllottedGeometry, ArrangedChildren);
|
|
|
|
// Determine some 'global' settings based on current LOD
|
|
const bool bDrawShadowsThisFrame = GetCurrentLOD() > EGraphRenderingLOD::LowestDetail;
|
|
|
|
// Because we paint multiple children, we must track the maximum layer id that they produced in case one of our parents
|
|
// wants to an overlay for all of its contents.
|
|
|
|
// Save LayerId for comment boxes to ensure they always appear below nodes & wires
|
|
const int32 CommentNodeShadowLayerId = LayerId++;
|
|
const int32 CommentNodeLayerId = LayerId++;
|
|
|
|
// Save a LayerId for wires, which appear below nodes but above comments
|
|
// We will draw them later, along with the arrows which appear above nodes.
|
|
const int32 WireLayerId = LayerId++;
|
|
|
|
const int32 NodeShadowsLayerId = LayerId;
|
|
const int32 NodeLayerId = NodeShadowsLayerId + 1;
|
|
int32 MaxLayerId = NodeLayerId;
|
|
|
|
const FPaintArgs NewArgs = Args.WithNewParent(this);
|
|
|
|
const FVector2D NodeShadowSize = GetDefault<UGraphEditorSettings>()->GetShadowDeltaSize();
|
|
const UEdGraphSchema* Schema = GraphObj->GetSchema();
|
|
|
|
// Draw the child nodes
|
|
{
|
|
// When drawing a marquee, need a preview of what the selection will be.
|
|
const FGraphPanelSelectionSet* SelectionToVisualize = &(SelectionManager.SelectedNodes);
|
|
FGraphPanelSelectionSet SelectionPreview;
|
|
if ( Marquee.IsValid() )
|
|
{
|
|
ApplyMarqueeSelection(Marquee, SelectionManager.SelectedNodes, SelectionPreview);
|
|
SelectionToVisualize = &SelectionPreview;
|
|
}
|
|
|
|
// Context for rendering node infos
|
|
FKismetNodeInfoContext Context(GraphObj);
|
|
|
|
TArray<FGraphDiffControl::FNodeMatch> NodeMatches;
|
|
for (int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex)
|
|
{
|
|
FArrangedWidget& CurWidget = ArrangedChildren[ChildIndex];
|
|
TSharedRef<SGraphNode> ChildNode = StaticCastSharedRef<SGraphNode>(CurWidget.Widget);
|
|
|
|
// Examine node to see what layers we should be drawing in
|
|
int32 ShadowLayerId = NodeShadowsLayerId;
|
|
int32 ChildLayerId = NodeLayerId;
|
|
|
|
// If a comment node, draw in the dedicated comment slots
|
|
{
|
|
UObject* NodeObj = ChildNode->GetObjectBeingDisplayed();
|
|
if (NodeObj && NodeObj->IsA(UEdGraphNode_Comment::StaticClass()))
|
|
{
|
|
ShadowLayerId = CommentNodeShadowLayerId;
|
|
ChildLayerId = CommentNodeLayerId;
|
|
}
|
|
}
|
|
|
|
|
|
const bool bNodeIsVisible = FSlateRect::DoRectanglesIntersect( CurWidget.Geometry.GetLayoutBoundingRect(), MyCullingRect );
|
|
|
|
if (bNodeIsVisible)
|
|
{
|
|
const bool bSelected = SelectionToVisualize->Contains( StaticCastSharedRef<SNodePanel::SNode>(CurWidget.Widget)->GetObjectBeingDisplayed() );
|
|
|
|
// Handle Node renaming once the node is visible
|
|
if( bSelected && ChildNode->IsRenamePending() )
|
|
{
|
|
// Only open a rename when the window has focus
|
|
TSharedPtr<SWindow> OwnerWindow = FSlateApplication::Get().FindWidgetWindow(AsShared());
|
|
if (!OwnerWindow.IsValid() || FSlateApplication::Get().HasFocusedDescendants(OwnerWindow.ToSharedRef()))
|
|
{
|
|
ChildNode->ApplyRename();
|
|
}
|
|
}
|
|
|
|
// Draw the node's shadow.
|
|
if (bDrawShadowsThisFrame || bSelected)
|
|
{
|
|
const FSlateBrush* ShadowBrush = ChildNode->GetShadowBrush(bSelected);
|
|
FSlateDrawElement::MakeBox(
|
|
OutDrawElements,
|
|
ShadowLayerId,
|
|
CurWidget.Geometry.ToInflatedPaintGeometry(NodeShadowSize),
|
|
ShadowBrush
|
|
);
|
|
}
|
|
|
|
// Draw the comments and information popups for this node, if it has any.
|
|
{
|
|
const SNodePanel::SNode::FNodeSlot* CommentSlot = ChildNode->GetSlot( ENodeZone::TopCenter );
|
|
float CommentBubbleY = CommentSlot ? -CommentSlot->Offset.Get().Y : 0.f;
|
|
Context.bSelected = bSelected;
|
|
TArray<FGraphInformationPopupInfo> Popups;
|
|
|
|
{
|
|
ChildNode->GetNodeInfoPopups(&Context, /*out*/ Popups);
|
|
}
|
|
|
|
for (int32 PopupIndex = 0; PopupIndex < Popups.Num(); ++PopupIndex)
|
|
{
|
|
FGraphInformationPopupInfo& Popup = Popups[PopupIndex];
|
|
PaintComment(Popup.Message, CurWidget.Geometry, MyCullingRect, OutDrawElements, ChildLayerId, Popup.BackgroundColor, /*inout*/ CommentBubbleY, InWidgetStyle);
|
|
}
|
|
}
|
|
|
|
int32 CurWidgetsMaxLayerId;
|
|
{
|
|
UEdGraphNode* NodeObj = Cast<UEdGraphNode>(ChildNode->GetObjectBeingDisplayed());
|
|
|
|
/** When diffing nodes, nodes that are different between revisions are opaque, nodes that have not changed are faded */
|
|
FGraphDiffControl::FNodeMatch NodeMatch = FGraphDiffControl::FindNodeMatch(GraphObjToDiff, NodeObj, NodeMatches);
|
|
if (NodeMatch.IsValid())
|
|
{
|
|
NodeMatches.Add(NodeMatch);
|
|
}
|
|
const bool bNodeIsDifferent = (!GraphObjToDiff || NodeMatch.Diff(FGraphDiffControl::FNodeDiffContext()));
|
|
|
|
/* When dragging off a pin, we want to duck the alpha of some nodes */
|
|
TSharedPtr< SGraphPin > OnlyStartPin = (1 == PreviewConnectorFromPins.Num()) ? PreviewConnectorFromPins[0].FindInGraphPanel(*this) : TSharedPtr< SGraphPin >();
|
|
const bool bNodeIsNotUsableInCurrentContext = Schema->FadeNodeWhenDraggingOffPin(NodeObj, OnlyStartPin.IsValid() ? OnlyStartPin.Get()->GetPinObj() : nullptr);
|
|
const FWidgetStyle& NodeStyleToUse = (bNodeIsDifferent && !bNodeIsNotUsableInCurrentContext)? InWidgetStyle : FadedStyle;
|
|
|
|
// Draw the node.O
|
|
CurWidgetsMaxLayerId = CurWidget.Widget->Paint(NewArgs, CurWidget.Geometry, MyCullingRect, OutDrawElements, ChildLayerId, NodeStyleToUse, !DisplayAsReadOnly.Get() && ShouldBeEnabled( bParentEnabled ) );
|
|
}
|
|
|
|
// Draw the node's overlay, if it has one.
|
|
{
|
|
// Get its size
|
|
const FVector2D WidgetSize = CurWidget.Geometry.Size;
|
|
|
|
{
|
|
TArray<FOverlayBrushInfo> OverlayBrushes;
|
|
ChildNode->GetOverlayBrushes(bSelected, WidgetSize, /*out*/ OverlayBrushes);
|
|
|
|
for (int32 BrushIndex = 0; BrushIndex < OverlayBrushes.Num(); ++BrushIndex)
|
|
{
|
|
FOverlayBrushInfo& OverlayInfo = OverlayBrushes[BrushIndex];
|
|
const FSlateBrush* OverlayBrush = OverlayInfo.Brush;
|
|
if (OverlayBrush != nullptr)
|
|
{
|
|
FPaintGeometry BouncedGeometry = CurWidget.Geometry.ToPaintGeometry(OverlayInfo.OverlayOffset, OverlayBrush->ImageSize, 1.f);
|
|
|
|
// Handle bouncing during PIE
|
|
const float BounceValue = FMath::Sin(2.0f * PI * BounceCurve.GetLerp());
|
|
BouncedGeometry.DrawPosition += (OverlayInfo.AnimationEnvelope * BounceValue * ZoomFactor);
|
|
|
|
CurWidgetsMaxLayerId++;
|
|
FSlateDrawElement::MakeBox(
|
|
OutDrawElements,
|
|
CurWidgetsMaxLayerId,
|
|
BouncedGeometry,
|
|
OverlayBrush
|
|
);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
{
|
|
TArray<FOverlayWidgetInfo> OverlayWidgets = ChildNode->GetOverlayWidgets(bSelected, WidgetSize);
|
|
|
|
for (int32 WidgetIndex = 0; WidgetIndex < OverlayWidgets.Num(); ++WidgetIndex)
|
|
{
|
|
FOverlayWidgetInfo& OverlayInfo = OverlayWidgets[WidgetIndex];
|
|
if(OverlayInfo.Widget->GetVisibility() == EVisibility::Visible)
|
|
{
|
|
// call SlatePrepass as these widgets are not in the 'normal' child hierarchy
|
|
OverlayInfo.Widget->SlatePrepass(AllottedGeometry.GetAccumulatedLayoutTransform().GetScale());
|
|
|
|
const FGeometry WidgetGeometry = CurWidget.Geometry.MakeChild(OverlayInfo.OverlayOffset, OverlayInfo.Widget->GetDesiredSize());
|
|
|
|
OverlayInfo.Widget->Paint(NewArgs, WidgetGeometry, MyCullingRect, OutDrawElements, CurWidgetsMaxLayerId, InWidgetStyle, bParentEnabled);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
MaxLayerId = FMath::Max( MaxLayerId, CurWidgetsMaxLayerId + 1 );
|
|
}
|
|
}
|
|
}
|
|
|
|
MaxLayerId += 1;
|
|
|
|
|
|
// Draw connections between pins
|
|
if (Children.Num() > 0 )
|
|
{
|
|
FConnectionDrawingPolicy* ConnectionDrawingPolicy = FNodeFactory::CreateConnectionPolicy(Schema, WireLayerId, MaxLayerId, ZoomFactor, MyCullingRect, OutDrawElements, GraphObj);
|
|
|
|
TArray<TSharedPtr<SGraphPin>> OverridePins;
|
|
for (const FGraphPinHandle& Handle : PreviewConnectorFromPins)
|
|
{
|
|
TSharedPtr<SGraphPin> Pin = Handle.FindInGraphPanel(*this);
|
|
if (Pin.IsValid())
|
|
{
|
|
OverridePins.Add(Pin);
|
|
}
|
|
}
|
|
ConnectionDrawingPolicy->SetHoveredPins(CurrentHoveredPins, OverridePins, TimeWhenMouseEnteredPin);
|
|
ConnectionDrawingPolicy->SetMarkedPin(MarkedPin);
|
|
ConnectionDrawingPolicy->SetMousePosition(AllottedGeometry.LocalToAbsolute(SavedMousePosForOnPaintEventLocalSpace));
|
|
|
|
// Get the set of pins for all children and synthesize geometry for culled out pins so lines can be drawn to them.
|
|
TMap<TSharedRef<SWidget>, FArrangedWidget> PinGeometries;
|
|
TSet< TSharedRef<SWidget> > VisiblePins;
|
|
for (int32 ChildIndex = 0; ChildIndex < Children.Num(); ++ChildIndex)
|
|
{
|
|
TSharedRef<SGraphNode> ChildNode = StaticCastSharedRef<SGraphNode>(Children[ChildIndex]);
|
|
|
|
// If this is a culled node, approximate the pin geometry to the corner of the node it is within
|
|
if (IsNodeCulled(ChildNode, AllottedGeometry))
|
|
{
|
|
TArray< TSharedRef<SWidget> > NodePins;
|
|
ChildNode->GetPins(NodePins);
|
|
|
|
const FVector2D NodeLoc = ChildNode->GetPosition();
|
|
const FGeometry SynthesizedNodeGeometry(GraphCoordToPanelCoord(NodeLoc), AllottedGeometry.AbsolutePosition, FVector2D::ZeroVector, 1.f);
|
|
|
|
for (TArray< TSharedRef<SWidget> >::TConstIterator NodePinIterator(NodePins); NodePinIterator; ++NodePinIterator)
|
|
{
|
|
const SGraphPin& PinWidget = static_cast<const SGraphPin&>((*NodePinIterator).Get());
|
|
FVector2D PinLoc = NodeLoc + PinWidget.GetNodeOffset();
|
|
|
|
const FGeometry SynthesizedPinGeometry(GraphCoordToPanelCoord(PinLoc), AllottedGeometry.AbsolutePosition, FVector2D::ZeroVector, 1.f);
|
|
PinGeometries.Add(*NodePinIterator, FArrangedWidget(*NodePinIterator, SynthesizedPinGeometry));
|
|
}
|
|
|
|
// Also add synthesized geometries for culled nodes
|
|
ArrangedChildren.AddWidget( FArrangedWidget(ChildNode, SynthesizedNodeGeometry) );
|
|
}
|
|
else
|
|
{
|
|
ChildNode->GetPins(VisiblePins);
|
|
}
|
|
}
|
|
|
|
// Now get the pin geometry for all visible children and append it to the PinGeometries map
|
|
TMap<TSharedRef<SWidget>, FArrangedWidget> VisiblePinGeometries;
|
|
{
|
|
this->FindChildGeometries(AllottedGeometry, VisiblePins, VisiblePinGeometries);
|
|
PinGeometries.Append(VisiblePinGeometries);
|
|
}
|
|
|
|
// Draw preview connections (only connected on one end)
|
|
if (PreviewConnectorFromPins.Num() > 0)
|
|
{
|
|
for (const FGraphPinHandle& Handle : PreviewConnectorFromPins)
|
|
{
|
|
TSharedPtr< SGraphPin > CurrentStartPin = Handle.FindInGraphPanel(*this);
|
|
if (!CurrentStartPin.IsValid())
|
|
{
|
|
continue;
|
|
}
|
|
const FArrangedWidget* PinGeometry = PinGeometries.Find( CurrentStartPin.ToSharedRef() );
|
|
|
|
if (PinGeometry != nullptr)
|
|
{
|
|
FVector2D StartPoint;
|
|
FVector2D EndPoint;
|
|
|
|
if (CurrentStartPin->GetDirection() == EGPD_Input)
|
|
{
|
|
StartPoint = AllottedGeometry.LocalToAbsolute(PreviewConnectorEndpoint);
|
|
EndPoint = FGeometryHelper::VerticalMiddleLeftOf( PinGeometry->Geometry ) - FVector2D(ConnectionDrawingPolicy->ArrowRadius.X, 0);
|
|
}
|
|
else
|
|
{
|
|
StartPoint = FGeometryHelper::VerticalMiddleRightOf( PinGeometry->Geometry );
|
|
EndPoint = AllottedGeometry.LocalToAbsolute(PreviewConnectorEndpoint);
|
|
}
|
|
|
|
ConnectionDrawingPolicy->DrawPreviewConnector(PinGeometry->Geometry, StartPoint, EndPoint, CurrentStartPin.Get()->GetPinObj());
|
|
}
|
|
|
|
//@TODO: Re-evaluate this incompatible mojo; it's mutating every pin state every frame to accomplish a visual effect
|
|
ConnectionDrawingPolicy->SetIncompatiblePinDrawState(CurrentStartPin, VisiblePins);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//@TODO: Re-evaluate this incompatible mojo; it's mutating every pin state every frame to accomplish a visual effect
|
|
ConnectionDrawingPolicy->ResetIncompatiblePinDrawState(VisiblePins);
|
|
}
|
|
|
|
// Draw all regular connections
|
|
ConnectionDrawingPolicy->Draw(PinGeometries, ArrangedChildren);
|
|
|
|
// Pull back data from the drawing policy
|
|
{
|
|
FGraphSplineOverlapResult OverlapData = ConnectionDrawingPolicy->SplineOverlapResult;
|
|
|
|
if (OverlapData.IsValid())
|
|
{
|
|
OverlapData.ComputeBestPin();
|
|
|
|
// Only allow spline overlaps when there is no node under the cursor (unless it is a comment box)
|
|
const FVector2D PaintAbsoluteSpaceMousePos = AllottedGeometry.LocalToAbsolute(SavedMousePosForOnPaintEventLocalSpace);
|
|
const int32 HoveredNodeIndex = SWidget::FindChildUnderPosition(ArrangedChildren, PaintAbsoluteSpaceMousePos);
|
|
if (HoveredNodeIndex != INDEX_NONE)
|
|
{
|
|
TSharedRef<SGraphNode> HoveredNode = StaticCastSharedRef<SGraphNode>(ArrangedChildren[HoveredNodeIndex].Widget);
|
|
UEdGraphNode_Comment* CommentNode = Cast<UEdGraphNode_Comment>(HoveredNode->GetObjectBeingDisplayed());
|
|
if (CommentNode == nullptr)
|
|
{
|
|
// Wasn't a comment node, disallow the spline interaction
|
|
OverlapData = FGraphSplineOverlapResult();
|
|
}
|
|
}
|
|
}
|
|
|
|
// Update the spline hover state
|
|
const_cast<SGraphPanel*>(this)->OnSplineHoverStateChanged(OverlapData);
|
|
}
|
|
|
|
delete ConnectionDrawingPolicy;
|
|
}
|
|
|
|
// Draw a shadow overlay around the edges of the graph
|
|
++MaxLayerId;
|
|
PaintSurroundSunkenShadow(FEditorStyle::GetBrush(TEXT("Graph.Shadow")), AllottedGeometry, MyCullingRect, OutDrawElements, MaxLayerId);
|
|
|
|
if (ShowGraphStateOverlay.Get())
|
|
{
|
|
const FSlateBrush* BorderBrush = nullptr;
|
|
if ((GEditor->bIsSimulatingInEditor || GEditor->PlayWorld != nullptr))
|
|
{
|
|
// Draw a surrounding indicator when PIE is active, to make it clear that the graph is read-only, etc...
|
|
BorderBrush = FEditorStyle::GetBrush(TEXT("Graph.PlayInEditor"));
|
|
}
|
|
else if (!IsEditable.Get())
|
|
{
|
|
// Draw a different border when we're not simulating but the graph is read-only
|
|
BorderBrush = FEditorStyle::GetBrush(TEXT("Graph.ReadOnlyBorder"));
|
|
}
|
|
|
|
if (BorderBrush != nullptr)
|
|
{
|
|
// Actually draw the border
|
|
FSlateDrawElement::MakeBox(
|
|
OutDrawElements,
|
|
MaxLayerId,
|
|
AllottedGeometry.ToPaintGeometry(),
|
|
BorderBrush
|
|
);
|
|
}
|
|
}
|
|
|
|
// Draw the marquee selection rectangle
|
|
PaintMarquee(AllottedGeometry, MyCullingRect, OutDrawElements, MaxLayerId);
|
|
|
|
// Draw the software cursor
|
|
++MaxLayerId;
|
|
PaintSoftwareCursor(AllottedGeometry, MyCullingRect, OutDrawElements, MaxLayerId);
|
|
|
|
return MaxLayerId;
|
|
}
|
|
|
|
void SGraphPanel::OnSplineHoverStateChanged(const FGraphSplineOverlapResult& NewSplineHoverState)
|
|
{
|
|
TSharedPtr<SGraphPin> OldPinWidget = PreviousFrameSplineOverlap.GetBestPinWidget(*this);
|
|
PreviousFrameSplineOverlap = NewSplineHoverState;
|
|
TSharedPtr<SGraphPin> NewPinWidget = PreviousFrameSplineOverlap.GetBestPinWidget(*this);
|
|
|
|
PreviousFrameSavedMousePosForSplineOverlap = SavedMousePosForOnPaintEventLocalSpace;
|
|
|
|
// Handle mouse enter/leaves on the associated pin
|
|
if (OldPinWidget != NewPinWidget)
|
|
{
|
|
if (OldPinWidget.IsValid())
|
|
{
|
|
OldPinWidget->OnMouseLeave(LastPointerEvent);
|
|
}
|
|
|
|
if (NewPinWidget.IsValid())
|
|
{
|
|
NewPinWidget->OnMouseEnter(LastPointerGeometry, LastPointerEvent);
|
|
|
|
// Get the pin/wire glowing quicker, since it's a direct selection (this time was already set to 'now' as part of entering the pin)
|
|
//@TODO: Source this parameter from the graph rendering settings once it is there (see code in ApplyHoverDeemphasis)
|
|
TimeWhenMouseEnteredPin -= 0.75f;
|
|
}
|
|
}
|
|
}
|
|
|
|
bool SGraphPanel::SupportsKeyboardFocus() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
void SGraphPanel::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const
|
|
{
|
|
SNodePanel::OnArrangeChildren(AllottedGeometry, ArrangedChildren);
|
|
|
|
FArrangedChildren MyArrangedChildren(ArrangedChildren.GetFilter());
|
|
for (int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex)
|
|
{
|
|
FArrangedWidget& CurWidget = ArrangedChildren[ChildIndex];
|
|
TSharedRef<SGraphNode> ChildNode = StaticCastSharedRef<SGraphNode>(CurWidget.Widget);
|
|
|
|
TArray<FOverlayWidgetInfo> OverlayWidgets = ChildNode->GetOverlayWidgets(false, CurWidget.Geometry.Size);
|
|
|
|
for (int32 WidgetIndex = 0; WidgetIndex < OverlayWidgets.Num(); ++WidgetIndex)
|
|
{
|
|
FOverlayWidgetInfo& OverlayInfo = OverlayWidgets[WidgetIndex];
|
|
|
|
MyArrangedChildren.AddWidget(AllottedGeometry.MakeChild( OverlayInfo.Widget.ToSharedRef(), CurWidget.Geometry.Position + OverlayInfo.OverlayOffset, OverlayInfo.Widget->GetDesiredSize(), GetZoomAmount() ));
|
|
}
|
|
}
|
|
|
|
ArrangedChildren.Append(MyArrangedChildren);
|
|
}
|
|
|
|
TSharedPtr<IToolTip> SGraphPanel::GetToolTip()
|
|
{
|
|
if (SGraphPin* BestPinFromHoveredSpline = GetBestPinFromHoveredSpline())
|
|
{
|
|
return BestPinFromHoveredSpline->GetToolTip();
|
|
}
|
|
|
|
return SNodePanel::GetToolTip();
|
|
}
|
|
|
|
void SGraphPanel::UpdateSelectedNodesPositions(FVector2D PositionIncrement)
|
|
{
|
|
for (FGraphPanelSelectionSet::TIterator NodeIt(SelectionManager.SelectedNodes); NodeIt; ++NodeIt)
|
|
{
|
|
TSharedRef<SNode>* pWidget = NodeToWidgetLookup.Find(*NodeIt);
|
|
if (pWidget != nullptr)
|
|
{
|
|
SNode& Widget = pWidget->Get();
|
|
SNode::FNodeSet NodeFilter;
|
|
Widget.MoveTo(Widget.GetPosition() + PositionIncrement, NodeFilter);
|
|
}
|
|
}
|
|
}
|
|
|
|
FReply SGraphPanel::OnKeyDown( const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent )
|
|
{
|
|
if( IsEditable.Get() )
|
|
{
|
|
const bool bIsModifierActive = InKeyEvent.IsCommandDown() || InKeyEvent.IsAltDown() || InKeyEvent.IsShiftDown() || InKeyEvent.IsControlDown();
|
|
if (!bIsModifierActive)
|
|
{
|
|
if( InKeyEvent.GetKey() == EKeys::Up ||InKeyEvent.GetKey() == EKeys::NumPadEight )
|
|
{
|
|
UpdateSelectedNodesPositions(FVector2D(0.0f,-GetSnapGridSize()));
|
|
return FReply::Handled();
|
|
}
|
|
if( InKeyEvent.GetKey() == EKeys::Down || InKeyEvent.GetKey() == EKeys::NumPadTwo )
|
|
{
|
|
UpdateSelectedNodesPositions(FVector2D(0.0f,GetSnapGridSize()));
|
|
return FReply::Handled();
|
|
}
|
|
if( InKeyEvent.GetKey() == EKeys::Right || InKeyEvent.GetKey() == EKeys::NumPadSix )
|
|
{
|
|
UpdateSelectedNodesPositions(FVector2D(GetSnapGridSize(),0.0f));
|
|
return FReply::Handled();
|
|
}
|
|
if( InKeyEvent.GetKey() == EKeys::Left || InKeyEvent.GetKey() == EKeys::NumPadFour )
|
|
{
|
|
UpdateSelectedNodesPositions(FVector2D(-GetSnapGridSize(),0.0f));
|
|
return FReply::Handled();
|
|
}
|
|
}
|
|
|
|
if(InKeyEvent.GetKey() == FGraphEditorCommands::Get().ZoomOut->GetActiveChord()->Key)
|
|
{
|
|
ChangeZoomLevel(-1, CachedAllottedGeometryScaledSize / 2.f, InKeyEvent.IsControlDown());
|
|
return FReply::Handled();
|
|
}
|
|
if(InKeyEvent.GetKey() == FGraphEditorCommands::Get().ZoomIn->GetActiveChord()->Key)
|
|
{
|
|
ChangeZoomLevel(+1, CachedAllottedGeometryScaledSize / 2.f, InKeyEvent.IsControlDown());
|
|
return FReply::Handled();
|
|
}
|
|
}
|
|
|
|
return SNodePanel::OnKeyDown(MyGeometry, InKeyEvent);
|
|
}
|
|
|
|
FReply SGraphPanel::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
if ((MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton) && (MouseEvent.IsAltDown() || MouseEvent.IsControlDown()))
|
|
{
|
|
if (SGraphPin* BestPinFromHoveredSpline = GetBestPinFromHoveredSpline())
|
|
{
|
|
return BestPinFromHoveredSpline->OnPinMouseDown(MyGeometry, MouseEvent);
|
|
}
|
|
}
|
|
|
|
return SNodePanel::OnMouseButtonDown(MyGeometry, MouseEvent);
|
|
}
|
|
|
|
FReply SGraphPanel::OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
if ((MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton) && (MouseEvent.IsShiftDown()))
|
|
{
|
|
if (SGraphPin* BestPinFromHoveredSpline = GetBestPinFromHoveredSpline())
|
|
{
|
|
return BestPinFromHoveredSpline->OnMouseButtonUp(MyGeometry, MouseEvent);
|
|
}
|
|
}
|
|
|
|
return SNodePanel::OnMouseButtonUp(MyGeometry, MouseEvent);
|
|
}
|
|
|
|
FReply SGraphPanel::OnMouseButtonDoubleClick(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
UEdGraphPin* Pin1;
|
|
UEdGraphPin* Pin2;
|
|
if (PreviousFrameSplineOverlap.GetPins(*this, /*out*/ Pin1, /*out*/ Pin2))
|
|
{
|
|
// Give the schema a chance to do something interesting with a double click on a proper spline (both ends are attached to a pin, i.e., not a preview/drag one)
|
|
const FVector2D DoubleClickPositionInGraphSpace = PanelCoordToGraphCoord(MyGeometry.AbsoluteToLocal(MouseEvent.GetScreenSpacePosition()));
|
|
|
|
const UEdGraphSchema* Schema = GraphObj->GetSchema();
|
|
Schema->OnPinConnectionDoubleCicked(Pin1, Pin2, DoubleClickPositionInGraphSpace);
|
|
}
|
|
|
|
return SNodePanel::OnMouseButtonDoubleClick(MyGeometry, MouseEvent);
|
|
}
|
|
|
|
class SGraphPin* SGraphPanel::GetBestPinFromHoveredSpline() const
|
|
{
|
|
TSharedPtr<SGraphPin> BestPinWidget = PreviousFrameSplineOverlap.GetBestPinWidget(*this);
|
|
return BestPinWidget.Get();
|
|
}
|
|
|
|
void SGraphPanel::GetAllPins(TSet< TSharedRef<SWidget> >& AllPins)
|
|
{
|
|
// Get the set of pins for all children
|
|
for (int32 ChildIndex = 0; ChildIndex < Children.Num(); ++ChildIndex)
|
|
{
|
|
TSharedRef<SGraphNode> ChildNode = StaticCastSharedRef<SGraphNode>(Children[ChildIndex]);
|
|
ChildNode->GetPins(AllPins);
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::AddPinToHoverSet(UEdGraphPin* HoveredPin)
|
|
{
|
|
CurrentHoveredPins.Add(HoveredPin);
|
|
TimeWhenMouseEnteredPin = FSlateApplication::Get().GetCurrentTime();
|
|
|
|
// About covers the fade in time when highlighting pins or splines.
|
|
TimeLeftToInvalidatePerTick += 1.5f;
|
|
|
|
// This handle should always be for this function
|
|
if (!ActiveTimerHandleInvalidatePerTick.IsValid())
|
|
{
|
|
ActiveTimerHandleInvalidatePerTick = RegisterActiveTimer(0.f, FWidgetActiveTimerDelegate::CreateSP(this, &SGraphPanel::InvalidatePerTick));
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::RemovePinFromHoverSet(UEdGraphPin* UnhoveredPin)
|
|
{
|
|
CurrentHoveredPins.Remove(UnhoveredPin);
|
|
TimeWhenMouseLeftPin = FSlateApplication::Get().GetCurrentTime();
|
|
}
|
|
|
|
void SGraphPanel::ArrangeChildrenForContextMenuSummon(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const
|
|
{
|
|
// First pass nodes
|
|
for (int32 ChildIndex = 0; ChildIndex < VisibleChildren.Num(); ++ChildIndex)
|
|
{
|
|
const TSharedRef<SNode>& SomeChild = VisibleChildren[ChildIndex];
|
|
if (!SomeChild->RequiresSecondPassLayout())
|
|
{
|
|
ArrangedChildren.AddWidget(AllottedGeometry.MakeChild(SomeChild, SomeChild->GetPosition() - ViewOffset, SomeChild->GetDesiredSizeForMarquee(), GetZoomAmount()));
|
|
}
|
|
}
|
|
|
|
// Second pass nodes
|
|
for (int32 ChildIndex = 0; ChildIndex < VisibleChildren.Num(); ++ChildIndex)
|
|
{
|
|
const TSharedRef<SNode>& SomeChild = VisibleChildren[ChildIndex];
|
|
if (SomeChild->RequiresSecondPassLayout())
|
|
{
|
|
SomeChild->PerformSecondPassLayout(NodeToWidgetLookup);
|
|
ArrangedChildren.AddWidget(AllottedGeometry.MakeChild(SomeChild, SomeChild->GetPosition() - ViewOffset, SomeChild->GetDesiredSizeForMarquee(), GetZoomAmount()));
|
|
}
|
|
}
|
|
}
|
|
|
|
TSharedPtr<SWidget> SGraphPanel::OnSummonContextMenu(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
//Editability is up to the user to consider for menu options
|
|
{
|
|
// If we didn't drag very far, summon a context menu.
|
|
// Figure out what's under the mouse: Node, Pin or just the Panel, and summon the context menu for that.
|
|
UEdGraphNode* NodeUnderCursor = nullptr;
|
|
UEdGraphPin* PinUnderCursor = nullptr;
|
|
{
|
|
FArrangedChildren ArrangedNodes(EVisibility::Visible);
|
|
this->ArrangeChildrenForContextMenuSummon(MyGeometry, ArrangedNodes);
|
|
const int32 HoveredNodeIndex = SWidget::FindChildUnderMouse( ArrangedNodes, MouseEvent );
|
|
if (HoveredNodeIndex != INDEX_NONE)
|
|
{
|
|
const FArrangedWidget& HoveredNode = ArrangedNodes[HoveredNodeIndex];
|
|
TSharedRef<SGraphNode> GraphNode = StaticCastSharedRef<SGraphNode>(HoveredNode.Widget);
|
|
TSharedPtr<SGraphNode> GraphSubNode = GraphNode->GetNodeUnderMouse(HoveredNode.Geometry, MouseEvent);
|
|
GraphNode = GraphSubNode.IsValid() ? GraphSubNode.ToSharedRef() : GraphNode;
|
|
NodeUnderCursor = GraphNode->GetNodeObj();
|
|
|
|
// Selection should switch to this code if it isn't already selected.
|
|
// When multiple nodes are selected, we do nothing, provided that the
|
|
// node for which the context menu is being created is in the selection set.
|
|
if (!SelectionManager.IsNodeSelected(GraphNode->GetObjectBeingDisplayed()))
|
|
{
|
|
SelectionManager.SelectSingleNode(GraphNode->GetObjectBeingDisplayed());
|
|
}
|
|
|
|
const TSharedPtr<SGraphPin> HoveredPin = GraphNode->GetHoveredPin(GraphNode->GetCachedGeometry(), MouseEvent);
|
|
if (HoveredPin.IsValid())
|
|
{
|
|
PinUnderCursor = HoveredPin->GetPinObj();
|
|
}
|
|
}
|
|
}
|
|
|
|
const FVector2D NodeAddPosition = PanelCoordToGraphCoord( MyGeometry.AbsoluteToLocal(MouseEvent.GetScreenSpacePosition()) );
|
|
TArray<UEdGraphPin*> NoSourcePins;
|
|
|
|
return SummonContextMenu(MouseEvent.GetScreenSpacePosition(), NodeAddPosition, NodeUnderCursor, PinUnderCursor, NoSourcePins);
|
|
}
|
|
|
|
return TSharedPtr<SWidget>();
|
|
}
|
|
|
|
|
|
bool SGraphPanel::OnHandleLeftMouseRelease(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
TSharedPtr<SGraphPin> PreviewConnectionPin = PreviewConnectorFromPins.Num() > 0 ? PreviewConnectorFromPins[0].FindInGraphPanel(*this) : nullptr;
|
|
if (PreviewConnectionPin.IsValid() && IsEditable.Get())
|
|
{
|
|
TSet< TSharedRef<SWidget> > AllConnectors;
|
|
for (int32 ChildIndex = 0; ChildIndex < Children.Num(); ++ChildIndex)
|
|
{
|
|
//@FINDME:
|
|
TSharedRef<SGraphNode> ChildNode = StaticCastSharedRef<SGraphNode>(Children[ChildIndex]);
|
|
ChildNode->GetPins(AllConnectors);
|
|
}
|
|
|
|
TMap<TSharedRef<SWidget>, FArrangedWidget> PinGeometries;
|
|
this->FindChildGeometries(MyGeometry, AllConnectors, PinGeometries);
|
|
|
|
bool bHandledDrop = false;
|
|
TSet<UEdGraphNode*> NodeList;
|
|
for ( TMap<TSharedRef<SWidget>, FArrangedWidget>::TIterator SomePinIt(PinGeometries); !bHandledDrop && SomePinIt; ++SomePinIt )
|
|
{
|
|
FArrangedWidget& PinWidgetGeometry = SomePinIt.Value();
|
|
if( PinWidgetGeometry.Geometry.IsUnderLocation( MouseEvent.GetScreenSpacePosition() ) )
|
|
{
|
|
SGraphPin& TargetPin = static_cast<SGraphPin&>( PinWidgetGeometry.Widget.Get() );
|
|
|
|
if (PreviewConnectionPin->TryHandlePinConnection(TargetPin))
|
|
{
|
|
NodeList.Add(TargetPin.GetPinObj()->GetOwningNode());
|
|
NodeList.Add(PreviewConnectionPin->GetPinObj()->GetOwningNode());
|
|
}
|
|
bHandledDrop = true;
|
|
}
|
|
}
|
|
|
|
// No longer make a connection for a pin; we just connected or failed to connect.
|
|
OnStopMakingConnection(/*bForceStop=*/ true);
|
|
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
FReply SGraphPanel::OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
LastPointerEvent = MouseEvent;
|
|
LastPointerGeometry = MyGeometry;
|
|
|
|
// Save the mouse position to use in OnPaint for spline hit detection
|
|
SavedMousePosForOnPaintEventLocalSpace = MyGeometry.AbsoluteToLocal(MouseEvent.GetScreenSpacePosition());
|
|
|
|
// Invalidate the spline results if we moved very far
|
|
const FVector2D MouseDelta = SavedMousePosForOnPaintEventLocalSpace - PreviousFrameSavedMousePosForSplineOverlap;
|
|
const float MouseDeltaLengthSquared = MouseDelta.SizeSquared();
|
|
const bool bCursorInDeadZone = MouseDeltaLengthSquared <= FMath::Square(FSlateApplication::Get().GetDragTriggerDistance());
|
|
|
|
if (!bCursorInDeadZone)
|
|
{
|
|
//@TODO: Should we do this or just rely on the next OnPaint?
|
|
// Our frame-latent approximation is going to be totally junk if the mouse is moving quickly
|
|
OnSplineHoverStateChanged(FGraphSplineOverlapResult());
|
|
}
|
|
|
|
return SNodePanel::OnMouseMove(MyGeometry, MouseEvent);
|
|
}
|
|
|
|
void SGraphPanel::OnDragEnter( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent )
|
|
{
|
|
TSharedPtr<FGraphEditorDragDropAction> DragConnectionOp = DragDropEvent.GetOperationAs<FGraphEditorDragDropAction>();
|
|
if (DragConnectionOp.IsValid())
|
|
{
|
|
DragConnectionOp->SetHoveredGraph( SharedThis(this) );
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::OnDragLeave( const FDragDropEvent& DragDropEvent )
|
|
{
|
|
TSharedPtr<FGraphEditorDragDropAction> Operation = DragDropEvent.GetOperationAs<FGraphEditorDragDropAction>();
|
|
if( Operation.IsValid() )
|
|
{
|
|
Operation->SetHoveredGraph(TSharedPtr<SGraphPanel>(nullptr));
|
|
}
|
|
else
|
|
{
|
|
TSharedPtr<FDecoratedDragDropOp> AssetOp = DragDropEvent.GetOperationAs<FDecoratedDragDropOp>();
|
|
if( AssetOp.IsValid() )
|
|
{
|
|
AssetOp->ResetToDefaultToolTip();
|
|
}
|
|
}
|
|
}
|
|
|
|
FReply SGraphPanel::OnDragOver( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent )
|
|
{
|
|
TSharedPtr<FDragDropOperation> Operation = DragDropEvent.GetOperation();
|
|
if (!Operation.IsValid())
|
|
{
|
|
return FReply::Unhandled();
|
|
}
|
|
|
|
// Handle Read only graphs
|
|
if (!IsEditable.Get())
|
|
{
|
|
TSharedPtr<FGraphEditorDragDropAction> GraphDragDropOp = DragDropEvent.GetOperationAs<FGraphEditorDragDropAction>();
|
|
|
|
if (GraphDragDropOp.IsValid())
|
|
{
|
|
GraphDragDropOp->SetDropTargetValid(false);
|
|
}
|
|
else
|
|
{
|
|
TSharedPtr<FDecoratedDragDropOp> AssetOp = DragDropEvent.GetOperationAs<FDecoratedDragDropOp>();
|
|
if (AssetOp.IsValid())
|
|
{
|
|
FText Tooltip = AssetOp->GetHoverText();
|
|
if (Tooltip.IsEmpty())
|
|
{
|
|
Tooltip = NSLOCTEXT( "GraphPanel", "DragDropOperation", "Graph is Read-Only" );
|
|
}
|
|
AssetOp->SetToolTip(Tooltip, FEditorStyle::GetBrush(TEXT("Graph.ConnectorFeedback.Error")));
|
|
}
|
|
}
|
|
return FReply::Handled();
|
|
}
|
|
|
|
if (Operation->IsOfType<FGraphEditorDragDropAction>())
|
|
{
|
|
PreviewConnectorEndpoint = MyGeometry.AbsoluteToLocal( DragDropEvent.GetScreenSpacePosition() );
|
|
return FReply::Handled();
|
|
}
|
|
else if (Operation->IsOfType<FExternalDragOperation>())
|
|
{
|
|
return AssetUtil::CanHandleAssetDrag(DragDropEvent);
|
|
}
|
|
else if (Operation->IsOfType<FAssetDragDropOp>())
|
|
{
|
|
if ((GraphObj != nullptr) && (GraphObj->GetSchema() != nullptr))
|
|
{
|
|
TSharedPtr<FAssetDragDropOp> AssetOp = StaticCastSharedPtr<FAssetDragDropOp>(Operation);
|
|
bool bOkIcon = false;
|
|
FString TooltipText;
|
|
if (AssetOp->HasAssets())
|
|
{
|
|
GraphObj->GetSchema()->GetAssetsGraphHoverMessage(AssetOp->GetAssets(), GraphObj, /*out*/ TooltipText, /*out*/ bOkIcon);
|
|
}
|
|
const FSlateBrush* TooltipIcon = bOkIcon ? FEditorStyle::GetBrush(TEXT("Graph.ConnectorFeedback.OK")) : FEditorStyle::GetBrush(TEXT("Graph.ConnectorFeedback.Error"));
|
|
AssetOp->SetToolTip(FText::FromString(TooltipText), TooltipIcon);
|
|
}
|
|
return FReply::Handled();
|
|
}
|
|
else
|
|
{
|
|
return FReply::Unhandled();
|
|
}
|
|
}
|
|
|
|
FReply SGraphPanel::OnDrop( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent )
|
|
{
|
|
const FVector2D NodeAddPosition = PanelCoordToGraphCoord( MyGeometry.AbsoluteToLocal( DragDropEvent.GetScreenSpacePosition() ) );
|
|
|
|
FSlateApplication::Get().SetKeyboardFocus(AsShared(), EFocusCause::SetDirectly);
|
|
|
|
TSharedPtr<FDragDropOperation> Operation = DragDropEvent.GetOperation();
|
|
if (!Operation.IsValid() || !IsEditable.Get())
|
|
{
|
|
return FReply::Unhandled();
|
|
}
|
|
|
|
if (Operation->IsOfType<FGraphEditorDragDropAction>())
|
|
{
|
|
check(GraphObj);
|
|
TSharedPtr<FGraphEditorDragDropAction> DragConn = StaticCastSharedPtr<FGraphEditorDragDropAction>(Operation);
|
|
if (DragConn.IsValid() && DragConn->IsSupportedBySchema(GraphObj->GetSchema()))
|
|
{
|
|
return DragConn->DroppedOnPanel(SharedThis(this), DragDropEvent.GetScreenSpacePosition(), NodeAddPosition, *GraphObj);
|
|
}
|
|
|
|
return FReply::Unhandled();
|
|
}
|
|
else if (Operation->IsOfType<FActorDragDropGraphEdOp>())
|
|
{
|
|
TSharedPtr<FActorDragDropGraphEdOp> ActorOp = StaticCastSharedPtr<FActorDragDropGraphEdOp>(Operation);
|
|
OnDropActor.ExecuteIfBound(ActorOp->Actors, GraphObj, NodeAddPosition);
|
|
return FReply::Handled();
|
|
}
|
|
|
|
else if (Operation->IsOfType<FLevelDragDropOp>())
|
|
{
|
|
TSharedPtr<FLevelDragDropOp> LevelOp = StaticCastSharedPtr<FLevelDragDropOp>(Operation);
|
|
OnDropStreamingLevel.ExecuteIfBound(LevelOp->StreamingLevelsToDrop, GraphObj, NodeAddPosition);
|
|
return FReply::Handled();
|
|
}
|
|
else
|
|
{
|
|
if ((GraphObj != nullptr) && (GraphObj->GetSchema() != nullptr))
|
|
{
|
|
TArray< FAssetData > DroppedAssetData = AssetUtil::ExtractAssetDataFromDrag( DragDropEvent );
|
|
|
|
if ( DroppedAssetData.Num() > 0 )
|
|
{
|
|
GraphObj->GetSchema()->DroppedAssetsOnGraph( DroppedAssetData, NodeAddPosition, GraphObj );
|
|
return FReply::Handled();
|
|
}
|
|
}
|
|
|
|
return FReply::Unhandled();
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::OnBeginMakingConnection(UEdGraphPin* InOriginatingPin)
|
|
{
|
|
OnBeginMakingConnection(FGraphPinHandle(InOriginatingPin));
|
|
}
|
|
|
|
void SGraphPanel::OnBeginMakingConnection(FGraphPinHandle PinHandle)
|
|
{
|
|
if (PinHandle.IsValid())
|
|
{
|
|
PreviewConnectorFromPins.Add(PinHandle);
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::OnStopMakingConnection(bool bForceStop)
|
|
{
|
|
if (bForceStop || !bPreservePinPreviewConnection)
|
|
{
|
|
PreviewConnectorFromPins.Reset();
|
|
bPreservePinPreviewConnection = false;
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::PreservePinPreviewUntilForced()
|
|
{
|
|
bPreservePinPreviewConnection = true;
|
|
}
|
|
|
|
/** Add a slot to the CanvasPanel dynamically */
|
|
void SGraphPanel::AddGraphNode( const TSharedRef<SNodePanel::SNode>& NodeToAdd )
|
|
{
|
|
TSharedRef<SGraphNode> GraphNode = StaticCastSharedRef<SGraphNode>(NodeToAdd);
|
|
GraphNode->SetOwner( SharedThis(this) );
|
|
|
|
const UEdGraphNode* Node = GraphNode->GetNodeObj();
|
|
if (Node)
|
|
{
|
|
NodeGuidMap.Add(Node->NodeGuid, GraphNode);
|
|
}
|
|
|
|
SNodePanel::AddGraphNode(NodeToAdd);
|
|
}
|
|
|
|
void SGraphPanel::RemoveAllNodes()
|
|
{
|
|
NodeGuidMap.Empty();
|
|
CurrentHoveredPins.Empty();
|
|
SNodePanel::RemoveAllNodes();
|
|
}
|
|
|
|
TSharedPtr<SWidget> SGraphPanel::SummonContextMenu(const FVector2D& WhereToSummon, const FVector2D& WhereToAddNode, UEdGraphNode* ForNode, UEdGraphPin* ForPin, const TArray<UEdGraphPin*>& DragFromPins)
|
|
{
|
|
if (OnGetContextMenuFor.IsBound())
|
|
{
|
|
FGraphContextMenuArguments SpawnInfo;
|
|
SpawnInfo.NodeAddPosition = WhereToAddNode;
|
|
SpawnInfo.GraphNode = ForNode;
|
|
SpawnInfo.GraphPin = ForPin;
|
|
SpawnInfo.DragFromPins = DragFromPins;
|
|
|
|
FActionMenuContent FocusedContent = OnGetContextMenuFor.Execute(SpawnInfo);
|
|
|
|
TSharedRef<SWidget> MenuContent = FocusedContent.Content;
|
|
|
|
TSharedPtr<IMenu> Menu = FSlateApplication::Get().PushMenu(
|
|
AsShared(),
|
|
FWidgetPath(),
|
|
MenuContent,
|
|
WhereToSummon,
|
|
FPopupTransitionEffect( FPopupTransitionEffect::ContextMenu )
|
|
);
|
|
|
|
if (Menu.IsValid() && Menu->GetOwnedWindow().IsValid())
|
|
{
|
|
Menu->GetOwnedWindow()->SetWidgetToFocusOnActivate(FocusedContent.WidgetToFocus);
|
|
}
|
|
|
|
if (Menu.IsValid())
|
|
{
|
|
Menu->GetOnMenuDismissed().AddLambda([DelegateList=FocusedContent.OnMenuDismissed](TSharedRef<IMenu>) { DelegateList.Broadcast(); });
|
|
}
|
|
else
|
|
{
|
|
FocusedContent.OnMenuDismissed.Broadcast();
|
|
}
|
|
|
|
return FocusedContent.WidgetToFocus;
|
|
}
|
|
|
|
return TSharedPtr<SWidget>();
|
|
}
|
|
|
|
void SGraphPanel::AttachGraphEvents(TSharedPtr<SGraphNode> CreatedSubNode)
|
|
{
|
|
check(CreatedSubNode.IsValid());
|
|
CreatedSubNode->SetIsEditable(IsEditable);
|
|
CreatedSubNode->SetDoubleClickEvent(OnNodeDoubleClicked);
|
|
CreatedSubNode->SetVerifyTextCommitEvent(OnVerifyTextCommit);
|
|
CreatedSubNode->SetTextCommittedEvent(OnTextCommitted);
|
|
}
|
|
|
|
bool SGraphPanel::GetBoundsForNode(const UObject* InNode, FVector2D& MinCorner, FVector2D& MaxCorner, float Padding) const
|
|
{
|
|
return SNodePanel::GetBoundsForNode(InNode, MinCorner, MaxCorner, Padding);
|
|
}
|
|
|
|
class FConnectionAligner
|
|
{
|
|
public:
|
|
void DefineConnection(UEdGraphNode* SourceNode, const TSharedPtr<SGraphPin>& SourcePin, UEdGraphNode* DestinationNode, const TSharedPtr<SGraphPin>& DestinationPin)
|
|
{
|
|
auto& Dependencies = Connections.FindOrAdd(SourceNode);
|
|
if (SourcePin->GetPinObj()->Direction == EEdGraphPinDirection::EGPD_Output)
|
|
{
|
|
Dependencies.Outputs.FindOrAdd(DestinationNode).Add(FPinPair{ SourcePin, DestinationPin });
|
|
}
|
|
else
|
|
{
|
|
Dependencies.Inputs.FindOrAdd(DestinationNode).Add(FPinPair{ SourcePin, DestinationPin });
|
|
}
|
|
}
|
|
|
|
/** Align all the connections */
|
|
void Process()
|
|
{
|
|
struct FRankedNode
|
|
{
|
|
UEdGraphNode* Node;
|
|
uint32 Rank;
|
|
};
|
|
|
|
TArray<FRankedNode> RankedNodes;
|
|
RankedNodes.Reserve(Connections.Num());
|
|
|
|
TMap<UEdGraphNode*, uint32> LongestChainCache;
|
|
LongestChainCache.Reserve(Connections.Num());
|
|
|
|
for (auto& Pair : Connections)
|
|
{
|
|
RankedNodes.Add(FRankedNode{ Pair.Key, CalculateNodeRank(Pair.Key, LongestChainCache) });
|
|
}
|
|
|
|
// Sort the nodes based on dependencies - highest is processed first
|
|
RankedNodes.Sort([](const FRankedNode& A, const FRankedNode& B){
|
|
return A.Rank > B.Rank;
|
|
});
|
|
|
|
TSet<UEdGraphNode*> VistedNodes;
|
|
for (FRankedNode& RankedNode : RankedNodes)
|
|
{
|
|
StraightenConnectionsForNode(RankedNode.Node, VistedNodes, EEdGraphPinDirection::EGPD_Output);
|
|
if (VistedNodes.Num() == RankedNodes.Num())
|
|
{
|
|
return;
|
|
}
|
|
|
|
StraightenConnectionsForNode(RankedNode.Node, VistedNodes, EEdGraphPinDirection::EGPD_Input);
|
|
if (VistedNodes.Num() == RankedNodes.Num())
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
private:
|
|
|
|
void StraightenConnectionsForNode(UEdGraphNode* Node, TSet<UEdGraphNode*>& VisitedNodes, EEdGraphPinDirection Direction)
|
|
{
|
|
FDependencyInfo* Info = Connections.Find(Node);
|
|
if (!Info)
|
|
{
|
|
return;
|
|
}
|
|
|
|
for (auto& NodeToPins : Info->GetDirection(Direction))
|
|
{
|
|
if (NodeToPins.Value.Num() == 0 || VisitedNodes.Contains(NodeToPins.Key))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// Align the averages of all the pins
|
|
float AlignmentDelta = 0.f;
|
|
for (const FPinPair& Pins : NodeToPins.Value)
|
|
{
|
|
AlignmentDelta += (Node->NodePosY + Pins.SrcPin->GetNodeOffset().Y) - (NodeToPins.Key->NodePosY + Pins.DstPin->GetNodeOffset().Y);
|
|
}
|
|
|
|
NodeToPins.Key->Modify();
|
|
NodeToPins.Key->NodePosY += AlignmentDelta / NodeToPins.Value.Num();
|
|
|
|
VisitedNodes.Add(Node);
|
|
VisitedNodes.Add(NodeToPins.Key);
|
|
|
|
StraightenConnectionsForNode(NodeToPins.Key, VisitedNodes, Direction);
|
|
}
|
|
}
|
|
|
|
/** Find the longest chain of single-connection nodes connected to the specified node */
|
|
uint32 FindLongestUniqueChain(UEdGraphNode* Node, TMap<UEdGraphNode*, uint32>& LongestChainCache, EEdGraphPinDirection Direction)
|
|
{
|
|
if (uint32* Length = LongestChainCache.Find(Node))
|
|
{
|
|
// Already set, or circular dependency - ignore
|
|
return *Length;
|
|
}
|
|
|
|
// Prevent reentrancy
|
|
LongestChainCache.Add(Node, 0);
|
|
|
|
uint32 ThisLength = 0;
|
|
|
|
if (FDependencyInfo* Dependencies = Connections.Find(Node))
|
|
{
|
|
auto& ConnectedNodes = Dependencies->GetDirection(Direction);
|
|
|
|
// We only follow unique (1-1) connections
|
|
if (ConnectedNodes.Num() == 1)
|
|
{
|
|
for (auto& NodeToPins : ConnectedNodes)
|
|
{
|
|
ThisLength = FindLongestUniqueChain(NodeToPins.Key, LongestChainCache, Direction) + 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
LongestChainCache[Node] = ThisLength;
|
|
return ThisLength;
|
|
};
|
|
|
|
/** Calculate the depth of dependencies for the specified node */
|
|
uint32 CalculateNodeRank(UEdGraphNode* Node, TMap<UEdGraphNode*, uint32>& LongestChainCache)
|
|
{
|
|
uint32 Rank = 0;
|
|
if (FDependencyInfo* PinMap = Connections.Find(Node))
|
|
{
|
|
for (auto& NodeToPins : PinMap->Outputs)
|
|
{
|
|
Rank += FindLongestUniqueChain(NodeToPins.Key, LongestChainCache, EEdGraphPinDirection::EGPD_Output) + 1;
|
|
}
|
|
for (auto& NodeToPins : PinMap->Inputs)
|
|
{
|
|
Rank += FindLongestUniqueChain(NodeToPins.Key, LongestChainCache, EEdGraphPinDirection::EGPD_Input) + 1;
|
|
}
|
|
}
|
|
return Rank;
|
|
}
|
|
|
|
private:
|
|
|
|
/** A pair of pins */
|
|
struct FPinPair
|
|
{
|
|
TSharedPtr<SGraphPin> SrcPin, DstPin;
|
|
};
|
|
|
|
/** Map of nodes and pins that are connected to the owning pin */
|
|
struct FDependencyInfo
|
|
{
|
|
TMap<UEdGraphNode*, TArray<FPinPair>> Outputs;
|
|
TMap<UEdGraphNode*, TArray<FPinPair>> Inputs;
|
|
uint32 Rank;
|
|
|
|
TMap<UEdGraphNode*, TArray<FPinPair>>& GetDirection(EEdGraphPinDirection Direction)
|
|
{
|
|
return Direction == EEdGraphPinDirection::EGPD_Output ? Outputs : Inputs;
|
|
}
|
|
};
|
|
typedef TMap<UEdGraphNode*, FDependencyInfo> FConnections;
|
|
|
|
FConnections Connections;
|
|
};
|
|
|
|
void SGraphPanel::StraightenConnections()
|
|
{
|
|
FConnectionAligner Aligner;
|
|
for (auto* It : SelectionManager.SelectedNodes)
|
|
{
|
|
UEdGraphNode* SourceNode = Cast<UEdGraphNode>(It);
|
|
if (!SourceNode)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
TSharedRef<SNode>* ThisNodePtr = NodeToWidgetLookup.Find(SourceNode);
|
|
if (!ThisNodePtr)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
for (UEdGraphPin* SourcePin : SourceNode->Pins)
|
|
{
|
|
for (UEdGraphPin* LinkedTo : SourcePin->LinkedTo)
|
|
{
|
|
UEdGraphNode* DestNode = LinkedTo ? LinkedTo->GetOwningNode() : nullptr;
|
|
if (DestNode && SelectionManager.SelectedNodes.Contains(DestNode))
|
|
{
|
|
TSharedRef<SNode>* DestGraphNodePtr = NodeToWidgetLookup.Find(DestNode);
|
|
if (!DestGraphNodePtr)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
TSharedPtr<SGraphPin> PinWidget = StaticCastSharedRef<SGraphNode>(*ThisNodePtr)->FindWidgetForPin(SourcePin);
|
|
TSharedPtr<SGraphPin> LinkedPinWidget = StaticCastSharedRef<SGraphNode>(*DestGraphNodePtr)->FindWidgetForPin(LinkedTo);
|
|
|
|
if (PinWidget.IsValid() && LinkedPinWidget.IsValid())
|
|
{
|
|
Aligner.DefineConnection(SourceNode, PinWidget, DestNode, LinkedPinWidget);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Aligner.Process();
|
|
}
|
|
|
|
void SGraphPanel::StraightenConnections(UEdGraphPin* SourcePin, UEdGraphPin* PinToAlign)
|
|
{
|
|
UEdGraphNode* OwningNode = SourcePin->GetOwningNode();
|
|
|
|
TSharedRef<SNode>* OwningNodeWidgetPtr = NodeToWidgetLookup.Find(OwningNode);
|
|
if (!OwningNodeWidgetPtr)
|
|
{
|
|
return;
|
|
}
|
|
|
|
TSharedRef<SGraphNode> SourceGraphNode = StaticCastSharedRef<SGraphNode>(*OwningNodeWidgetPtr);
|
|
|
|
FConnectionAligner Aligner;
|
|
|
|
auto AddConnectedPin = [&](UEdGraphPin* ConnectedPin){
|
|
UEdGraphNode* ConnectedNode = ConnectedPin ? ConnectedPin->GetOwningNode() : nullptr;
|
|
if (!ConnectedNode)
|
|
{
|
|
return;
|
|
}
|
|
|
|
TSharedRef<SNode>* DestGraphNodePtr = NodeToWidgetLookup.Find(ConnectedNode);
|
|
if (!DestGraphNodePtr)
|
|
{
|
|
return;
|
|
}
|
|
|
|
TSharedPtr<SGraphPin> PinWidget = SourceGraphNode->FindWidgetForPin(SourcePin);
|
|
TSharedPtr<SGraphPin> LinkedPinWidget = StaticCastSharedRef<SGraphNode>(*DestGraphNodePtr)->FindWidgetForPin(ConnectedPin);
|
|
|
|
if (PinWidget.IsValid() && LinkedPinWidget.IsValid())
|
|
{
|
|
Aligner.DefineConnection(OwningNode, PinWidget, ConnectedNode, LinkedPinWidget);
|
|
}
|
|
};
|
|
|
|
if (PinToAlign)
|
|
{
|
|
// If we're only aligning a specific pin, do that
|
|
AddConnectedPin(PinToAlign);
|
|
}
|
|
// Else add all the connected pins
|
|
else for (UEdGraphPin* ConnectedPin : SourcePin->LinkedTo)
|
|
{
|
|
AddConnectedPin(ConnectedPin);
|
|
}
|
|
|
|
Aligner.Process();
|
|
}
|
|
|
|
const TSharedRef<SGraphNode> SGraphPanel::GetChild(int32 ChildIndex)
|
|
{
|
|
return StaticCastSharedRef<SGraphNode>(Children[ChildIndex]);
|
|
}
|
|
|
|
void SGraphPanel::AddNode(UEdGraphNode* Node, AddNodeBehavior Behavior)
|
|
{
|
|
TSharedPtr<SGraphNode> NewNode = FNodeFactory::CreateNodeWidget(Node);
|
|
check(NewNode.IsValid());
|
|
|
|
const bool bWasUserAdded =
|
|
Behavior == WasUserAdded ? true :
|
|
Behavior == NotUserAdded ? false :
|
|
(UserAddedNodes.Find(Node) != nullptr);
|
|
|
|
NewNode->SetIsEditable(IsEditable);
|
|
NewNode->SetDoubleClickEvent(OnNodeDoubleClicked);
|
|
NewNode->SetVerifyTextCommitEvent(OnVerifyTextCommit);
|
|
NewNode->SetTextCommittedEvent(OnTextCommitted);
|
|
NewNode->SetDisallowedPinConnectionEvent(OnDisallowedPinConnection);
|
|
|
|
this->AddGraphNode
|
|
(
|
|
NewNode.ToSharedRef()
|
|
);
|
|
|
|
if (bWasUserAdded)
|
|
{
|
|
// Add the node to visible children, this allows focus to occur on sub-widgets for naming purposes.
|
|
VisibleChildren.Add(NewNode.ToSharedRef());
|
|
|
|
NewNode->PlaySpawnEffect();
|
|
NewNode->RequestRenameOnSpawn();
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::RemoveNode(const UEdGraphNode* Node)
|
|
{
|
|
for (int32 Iter = 0; Iter != Children.Num(); ++Iter)
|
|
{
|
|
TSharedRef<SGraphNode> Child = GetChild(Iter);
|
|
if (Child->GetNodeObj() == Node)
|
|
{
|
|
Children.RemoveAt(Iter);
|
|
break;
|
|
}
|
|
}
|
|
for (int32 Iter = 0; Iter != VisibleChildren.Num(); ++Iter)
|
|
{
|
|
TSharedRef<SGraphNode> Child = StaticCastSharedRef<SGraphNode>(VisibleChildren[Iter]);
|
|
if (Child->GetNodeObj() == Node)
|
|
{
|
|
VisibleChildren.RemoveAt(Iter);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
TSharedPtr<SGraphNode> SGraphPanel::GetNodeWidgetFromGuid(FGuid Guid) const
|
|
{
|
|
return NodeGuidMap.FindRef(Guid).Pin();
|
|
}
|
|
|
|
void SGraphPanel::Update()
|
|
{
|
|
static bool bIsUpdating = false;
|
|
if (bIsUpdating)
|
|
{
|
|
return;
|
|
}
|
|
TGuardValue<bool> ReentrancyGuard(bIsUpdating, true);
|
|
|
|
// Add widgets for all the nodes that don't have one.
|
|
if (GraphObj != nullptr)
|
|
{
|
|
// Scan for all missing nodes
|
|
for (int32 NodeIndex = 0; NodeIndex < GraphObj->Nodes.Num(); ++NodeIndex)
|
|
{
|
|
UEdGraphNode* Node = GraphObj->Nodes[NodeIndex];
|
|
if (Node)
|
|
{
|
|
// Helps detect cases of UE-26998 without causing a crash. Prevents the node from being rendered altogether and provides info on the state of the graph vs the node.
|
|
// Because the editor won't crash, a GLEO can be expected if the node's outer is in the transient package.
|
|
if (ensureMsgf(Node->GetOuter() == GraphObj, TEXT("Found %s ('%s') that does not belong to %s. Node Outer: %s, Node Outer Type: %s, Graph Outer: %s, Graph Outer Type: %s"),
|
|
*Node->GetName(), *Node->GetClass()->GetName(),
|
|
*GraphObj->GetName(),
|
|
*Node->GetOuter()->GetName(), *Node->GetOuter()->GetClass()->GetName(),
|
|
*GraphObj->GetOuter()->GetName(), *GraphObj->GetOuter()->GetClass()->GetName()
|
|
))
|
|
{
|
|
AddNode(Node, CheckUserAddedNodesList);
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogGraphPanel, Error, TEXT("Found %s ('%s') that does not belong to %s. Node Outer: %s, Node Outer Type: %s, Graph Outer: %s, Graph Outer Type: %s"),
|
|
*Node->GetName(), *Node->GetClass()->GetName(),
|
|
*GraphObj->GetName(),
|
|
*Node->GetOuter()->GetName(), *Node->GetOuter()->GetClass()->GetName(),
|
|
*GraphObj->GetOuter()->GetName(), *GraphObj->GetOuter()->GetClass()->GetName()
|
|
);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogGraphPanel, Warning, TEXT("Found NULL Node in GraphObj array of a graph in asset '%s'. A node type has been deleted without creating an ActiveClassRedirector to K2Node_DeadClass."), *GraphObj->GetOutermost()->GetName());
|
|
}
|
|
}
|
|
|
|
// find the last selection action, and execute it
|
|
for (int32 ActionIndex = UserActions.Num() - 1; ActionIndex >= 0; --ActionIndex)
|
|
{
|
|
if (UserActions[ActionIndex].Action & GRAPHACTION_SelectNode)
|
|
{
|
|
DeferredSelectionTargetObjects.Empty();
|
|
for (const UEdGraphNode* Node : UserActions[ActionIndex].Nodes)
|
|
{
|
|
DeferredSelectionTargetObjects.Add(Node);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
RemoveAllNodes();
|
|
}
|
|
|
|
// Clean out set of added nodes
|
|
UserAddedNodes.Empty();
|
|
UserActions.Empty();
|
|
|
|
// Invoke any delegate methods
|
|
OnUpdateGraphPanel.ExecuteIfBound();
|
|
}
|
|
|
|
// Purges the existing visual representation (typically followed by an Update call in the next tick)
|
|
void SGraphPanel::PurgeVisualRepresentation()
|
|
{
|
|
// No need to call OnSplineHoverStateChanged since we're about to destroy all the nodes and pins
|
|
PreviousFrameSplineOverlap = FGraphSplineOverlapResult();
|
|
|
|
// Clear all of the nodes and pins
|
|
RemoveAllNodes();
|
|
}
|
|
|
|
bool SGraphPanel::IsNodeTitleVisible(const class UEdGraphNode* Node, bool bRequestRename)
|
|
{
|
|
bool bTitleVisible = false;
|
|
TSharedRef<SNode>* pWidget = NodeToWidgetLookup.Find(Node);
|
|
|
|
if (pWidget != nullptr)
|
|
{
|
|
TWeakPtr<SGraphNode> GraphNode = StaticCastSharedRef<SGraphNode>(*pWidget);
|
|
if(GraphNode.IsValid() && !HasMouseCapture())
|
|
{
|
|
FSlateRect TitleRect = GraphNode.Pin()->GetTitleRect();
|
|
const FVector2D TopLeft = FVector2D( TitleRect.Left, TitleRect.Top );
|
|
const FVector2D BottomRight = FVector2D( TitleRect.Right, TitleRect.Bottom );
|
|
|
|
if( IsRectVisible( TopLeft, BottomRight ))
|
|
{
|
|
bTitleVisible = true;
|
|
}
|
|
else if( bRequestRename )
|
|
{
|
|
bTitleVisible = JumpToRect( TopLeft, BottomRight );
|
|
}
|
|
|
|
if( bTitleVisible && bRequestRename )
|
|
{
|
|
GraphNode.Pin()->RequestRename();
|
|
SelectAndCenterObject(Node, false);
|
|
}
|
|
}
|
|
}
|
|
return bTitleVisible;
|
|
}
|
|
|
|
bool SGraphPanel::IsRectVisible(const FVector2D &TopLeft, const FVector2D &BottomRight)
|
|
{
|
|
return TopLeft >= PanelCoordToGraphCoord( FVector2D::ZeroVector ) && BottomRight <= PanelCoordToGraphCoord( CachedAllottedGeometryScaledSize );
|
|
}
|
|
|
|
bool SGraphPanel::JumpToRect(const FVector2D &TopLeft, const FVector2D &BottomRight)
|
|
{
|
|
ZoomToTarget(TopLeft, BottomRight);
|
|
|
|
return true;
|
|
}
|
|
|
|
void SGraphPanel::JumpToNode(const UEdGraphNode* JumpToMe, bool bRequestRename, bool bSelectNode)
|
|
{
|
|
if (JumpToMe != nullptr)
|
|
{
|
|
if (bRequestRename)
|
|
{
|
|
TSharedRef<SNode>* pWidget = NodeToWidgetLookup.Find(JumpToMe);
|
|
if (pWidget != nullptr)
|
|
{
|
|
TSharedRef<SGraphNode> GraphNode = StaticCastSharedRef<SGraphNode>(*pWidget);
|
|
GraphNode->RequestRename();
|
|
}
|
|
}
|
|
|
|
if (bSelectNode)
|
|
{
|
|
// Select this node, and request that we jump to it.
|
|
SelectAndCenterObject(JumpToMe, true);
|
|
}
|
|
else
|
|
{
|
|
// Jump to the node
|
|
CenterObject(JumpToMe);
|
|
}
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::JumpToPin(const UEdGraphPin* JumpToMe)
|
|
{
|
|
if (JumpToMe != nullptr)
|
|
{
|
|
JumpToNode(JumpToMe->GetOwningNode(), false, true);
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::OnBeginPIE( const bool bIsSimulating )
|
|
{
|
|
// Play the bounce curve on a continuous loop during PIE
|
|
BounceCurve.Play( this->AsShared(), true );
|
|
}
|
|
|
|
void SGraphPanel::OnEndPIE( const bool bIsSimulating )
|
|
{
|
|
// Stop the bounce curve
|
|
BounceCurve.JumpToEnd();
|
|
}
|
|
|
|
void SGraphPanel::OnGraphChanged(const FEdGraphEditAction& EditAction)
|
|
{
|
|
const bool bWillPurge = GraphObj->GetSchema()->ShouldAlwaysPurgeOnModification();
|
|
if (bWillPurge)
|
|
{
|
|
if ((EditAction.Graph == GraphObj) &&
|
|
(EditAction.Nodes.Num() > 0) &&
|
|
EditAction.bUserInvoked)
|
|
{
|
|
int32 ActionIndex = UserActions.Num();
|
|
if (EditAction.Action & GRAPHACTION_AddNode)
|
|
{
|
|
for (const UEdGraphNode* Node : EditAction.Nodes)
|
|
{
|
|
UserAddedNodes.Add(Node, ActionIndex);
|
|
}
|
|
}
|
|
UserActions.Add(EditAction);
|
|
}
|
|
}
|
|
else if ((EditAction.Graph == GraphObj) && (EditAction.Nodes.Num() > 0) )
|
|
{
|
|
// Remove action handled immediately by SGraphPanel::OnGraphChanged
|
|
const bool bWasAddAction = (EditAction.Action & GRAPHACTION_AddNode) != 0;
|
|
const bool bWasSelectAction = (EditAction.Action & GRAPHACTION_SelectNode) != 0;
|
|
const bool bWasRemoveAction = (EditAction.Action & GRAPHACTION_RemoveNode) != 0;
|
|
|
|
// The *only* reason we defer these actions is because code higher up the call stack
|
|
// assumes that the node is created later (for example, GenerateBlueprintAPIUtils::AddNodeToGraph
|
|
// calls AddNode (which calls this function) before calling AllocateDefaultPins, so if we create
|
|
// the widget immediately it won't be able to create its pins). There are lots of other examples,
|
|
// and I can't be sure that I've found them all....
|
|
|
|
// Minor note, the ugly little lambdas are just to deal with the time values and return values
|
|
// that the timer system requires (and we don't leverage):
|
|
if (bWasRemoveAction)
|
|
{
|
|
const auto RemoveNodeDelegateWrapper = [](double, float, SGraphPanel* Parent, TWeakObjectPtr<UEdGraphNode> NodePtr) -> EActiveTimerReturnType
|
|
{
|
|
if (NodePtr.IsValid())
|
|
{
|
|
UEdGraphNode* Node = NodePtr.Get();
|
|
Parent->RemoveNode(Node);
|
|
}
|
|
return EActiveTimerReturnType::Stop;
|
|
};
|
|
|
|
for (const UEdGraphNode* Node : EditAction.Nodes)
|
|
{
|
|
TWeakObjectPtr<UEdGraphNode> NodePtr = Node;
|
|
RegisterActiveTimer(0.f, FWidgetActiveTimerDelegate::CreateStatic(RemoveNodeDelegateWrapper, this, NodePtr));
|
|
}
|
|
}
|
|
if (bWasAddAction)
|
|
{
|
|
const auto AddNodeDelegateWrapper = [](double, float, SGraphPanel* Parent, TWeakObjectPtr<UEdGraphNode> NodePtr, bool bForceUserAdded) -> EActiveTimerReturnType
|
|
{
|
|
if (NodePtr.IsValid())
|
|
{
|
|
UEdGraphNode* Node = NodePtr.Get();
|
|
Parent->RemoveNode(Node);
|
|
Parent->AddNode(Node, bForceUserAdded ? WasUserAdded : NotUserAdded);
|
|
}
|
|
return EActiveTimerReturnType::Stop;
|
|
};
|
|
|
|
for (const UEdGraphNode* Node : EditAction.Nodes)
|
|
{
|
|
TWeakObjectPtr<UEdGraphNode> NodePtr = Node;
|
|
RegisterActiveTimer(0.f, FWidgetActiveTimerDelegate::CreateStatic(AddNodeDelegateWrapper, this, NodePtr, EditAction.bUserInvoked));
|
|
}
|
|
}
|
|
if (bWasSelectAction)
|
|
{
|
|
const auto SelectNodeDelegateWrapper = [](double, float, SGraphPanel* Parent, TSet< TWeakObjectPtr<UEdGraphNode> > NodePtrs) -> EActiveTimerReturnType
|
|
{
|
|
Parent->DeferredSelectionTargetObjects.Empty();
|
|
for (TWeakObjectPtr<UEdGraphNode>& NodePtr : NodePtrs)
|
|
{
|
|
if (NodePtr.IsValid())
|
|
{
|
|
UEdGraphNode* Node = NodePtr.Get();
|
|
Parent->DeferredSelectionTargetObjects.Add(Node);
|
|
}
|
|
}
|
|
return EActiveTimerReturnType::Stop;
|
|
};
|
|
|
|
TSet< TWeakObjectPtr<UEdGraphNode> > NodePtrSet;
|
|
for (const UEdGraphNode* Node : EditAction.Nodes)
|
|
{
|
|
NodePtrSet.Add(Node);
|
|
}
|
|
|
|
RegisterActiveTimer(0.f, FWidgetActiveTimerDelegate::CreateStatic(SelectNodeDelegateWrapper, this, NodePtrSet));
|
|
}
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::NotifyGraphChanged(const FEdGraphEditAction& EditAction)
|
|
{
|
|
// Forward call
|
|
OnGraphChanged(EditAction);
|
|
}
|
|
|
|
void SGraphPanel::AddReferencedObjects(FReferenceCollector& Collector)
|
|
{
|
|
Collector.AddReferencedObject( GraphObj );
|
|
Collector.AddReferencedObject( GraphObjToDiff );
|
|
}
|
|
|
|
EActiveTimerReturnType SGraphPanel::InvalidatePerTick(double InCurrentTime, float InDeltaTime)
|
|
{
|
|
// Invalidate the layout so it will redraw.
|
|
Invalidate(EInvalidateWidget::Layout);
|
|
|
|
TimeLeftToInvalidatePerTick -= InDeltaTime;
|
|
|
|
// When the time is done, stop the invalidation per tick because the UI will be static once more.
|
|
if (TimeLeftToInvalidatePerTick <= 0.0f)
|
|
{
|
|
TimeLeftToInvalidatePerTick = 0.0f;
|
|
return EActiveTimerReturnType::Stop;
|
|
}
|
|
return EActiveTimerReturnType::Continue;
|
|
}
|