Files
UnrealEngineUWP/Engine/Source/Editor/UMGEditor/Private/Animation/UMGDetailKeyframeHandler.cpp
Juan Portillo 888d78aceb Details Keyframe Handler:
- Fixed IsPropertyAnimated implementations so that no new handles are created if not found.

#jira none
#rb Max.Chen
#preflight trivial

[CL 25313294 by Juan Portillo in ue5-main branch]
2023-05-03 00:37:31 -04:00

55 lines
2.2 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Animation/UMGDetailKeyframeHandler.h"
#include "Animation/WidgetAnimation.h"
#include "PropertyHandle.h"
#include "MovieScene.h"
FUMGDetailKeyframeHandler::FUMGDetailKeyframeHandler(TSharedPtr<FWidgetBlueprintEditor> InBlueprintEditor)
: BlueprintEditor( InBlueprintEditor )
{}
bool FUMGDetailKeyframeHandler::IsPropertyKeyable(const UClass* InObjectClass, const IPropertyHandle& InPropertyHandle) const
{
return BlueprintEditor.Pin()->GetSequencer()->CanKeyProperty(FCanKeyPropertyParams(InObjectClass, InPropertyHandle));
}
bool FUMGDetailKeyframeHandler::IsPropertyKeyingEnabled() const
{
UMovieSceneSequence* Sequence = BlueprintEditor.Pin()->GetSequencer()->GetRootMovieSceneSequence();
return Sequence != nullptr && Sequence != UWidgetAnimation::GetNullAnimation();
}
bool FUMGDetailKeyframeHandler::IsPropertyAnimated(const IPropertyHandle& PropertyHandle, UObject *ParentObject) const
{
TSharedPtr<ISequencer> Sequencer = BlueprintEditor.Pin()->GetSequencer();
if (Sequencer.IsValid() && Sequencer->GetFocusedMovieSceneSequence())
{
constexpr bool bCreateHandleIfMissing = false;
FGuid ObjectHandle = Sequencer->GetHandleToObject(ParentObject, bCreateHandleIfMissing);
if (ObjectHandle.IsValid())
{
UMovieScene* MovieScene = Sequencer->GetFocusedMovieSceneSequence()->GetMovieScene();
FProperty* Property = PropertyHandle.GetProperty();
TSharedRef<FPropertyPath> PropertyPath = FPropertyPath::CreateEmpty();
PropertyPath->AddProperty(FPropertyInfo(Property));
FName PropertyName(*PropertyPath->ToString(TEXT(".")));
TSubclassOf<UMovieSceneTrack> TrackClass; //use empty @todo find way to get the UMovieSceneTrack from the Property type.
return MovieScene->FindTrack(TrackClass, ObjectHandle, PropertyName) != nullptr;
}
}
return false;
}
void FUMGDetailKeyframeHandler::OnKeyPropertyClicked(const IPropertyHandle& KeyedPropertyHandle)
{
TArray<UObject*> Objects;
KeyedPropertyHandle.GetOuterObjects( Objects );
FKeyPropertyParams KeyPropertyParams(Objects, KeyedPropertyHandle, ESequencerKeyMode::ManualKeyForced);
BlueprintEditor.Pin()->GetSequencer()->KeyProperty(KeyPropertyParams);
}