Files
UnrealEngineUWP/Engine/Source/Editor/Sequencer/Public/SequencerAddKeyOperation.h
Max Chen 0167d4ea0f Sequencer: MVVM2 branch and Layer Bars
Copying //Tasks/UE5/Dev-SequencerMVVM2 to Main (//UE5/Main) @20364093

#preflight 628866dfb94f739b152c1e29
#preflight 628866e4585e8f793ee80943
#rb ludovic.chabant, andrew.rodham
#fyi ludovic.chabant, andrew.rodham, andrew.porter
#jira UE-105322

[CL 20364493 by Max Chen in ue5-main branch]
2022-05-25 10:39:33 -04:00

112 lines
3.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "SequencerKeyParams.h"
#include "Containers/Array.h"
#include "Misc/FrameNumber.h"
#include "MVVM/ViewModelPtr.h"
class IKeyArea;
class ISequencer;
class ISequencerSection;
class UMovieSceneTrack;
namespace UE
{
namespace Sequencer
{
class ITrackExtension;
class FViewModel;
class FChannelGroupModel;
/**
* Temporary structure used for consistent add-key behavior for a set of display nodes
* Ultimately the operation will call ISequencerTrackEditor::ProcessKeyOperation for each track editor that needs to add keys.
*/
struct SEQUENCER_API FAddKeyOperation
{
/**
* Construct an operation from any set of display nodes. Each node in the set will receive keys for all decendant key areas.
*
* @param InModels A set of all the models to key
*/
static FAddKeyOperation FromNodes(const TSet<TWeakPtr<FViewModel>>& InModels);
/**
* Construct an operation from a single display node. Every key area underneath this node will receive keys.
*/
static FAddKeyOperation FromNode(TWeakPtr<FViewModel> InModel);
/**
* Construct an operation from some key areas on a track.
*/
static FAddKeyOperation FromKeyAreas(ISequencerTrackEditor* TrackEditor, const TArrayView<TSharedRef<IKeyArea>> InKeyAreas);
/**
* Commit this operation by choosing the section(s) to key for each key area, and adding a key at the specified time
*
* @param InKeyTime The time to add keys at
* @param InSequencer The sequencer instance that is performing this operations
*/
void Commit(FFrameNumber InKeyTime, ISequencer& InSequencer);
private:
/**
* Add a set of nodes to this operation that have already had child nodes removed (ie only parent nodes should exist in the set)
*
* @param InNodes A set of nodes to add to this operation that contains no child nodes
*/
void AddPreFilteredNodes(TArrayView<const TWeakPtr<FViewModel>> InNodes);
/**
* Add any keyable areas to the list of potential things to key
*
* @param InTrackEditor The track editor
* @param InKeyAnythingBeneath A node to search within for key areas
*/
bool ConsiderKeyableAreas(TSharedPtr<ITrackExtension> InTrackModel, FViewModelPtr InKeyAnythingBeneath);
/**
* Add key areas for a key area display node to this operation
*
* @param InTrackNode The current track node
* @param InKeyAreaNode The key area node to add key areas from
*/
bool ProcessKeyArea(TSharedPtr<ITrackExtension> InTrackModel, TViewModelPtr<FChannelGroupModel> InChannelGroupModel);
/**
* Add a key area to this operation
*
* @param InTrackEditor The track editor responsible for the key area
* @param InKeyArea The key area to add
*/
bool ProcessKeyArea(ISequencerTrackEditor* InTrackEditor, TSharedPtr<IKeyArea> InKeyArea);
/**
* Retrieve the operation that relates to a specific track editor instance
*/
FKeyOperation& GetTrackOperation(ISequencerTrackEditor* TrackEditor);
private:
FAddKeyOperation() {}
/** Map of key operations stored by their track editor. */
TMap<ISequencerTrackEditor*, FKeyOperation> OperationsByTrackEditor;
};
} // namespace Sequencer
} // namespace UE