// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "MVVM/Selection/SequencerCoreSelectionTypes.h" #include "MVVM/Selection/SequencerCoreSelection.h" #include "MVVM/Selection/SequencerOutlinerSelection.h" #include "MVVM/ViewModels/ChannelModel.h" struct FKeyHandle; class UMovieSceneTrack; class UMovieSceneSection; namespace UE::Sequencer { class FChannelModel; class FEditorViewModel; struct FIndirectOutlinerSelectionIterator; /** * Main key selection class that stores selected key handles, and the channel they originated from */ struct FKeySelection : TUniqueFragmentSelectionSet { /** * Overridden Select function for passing by TViewModelPtr instead of TWeakViewModelPtr */ void Select(TViewModelPtr InOwner, FKeyHandle InKey, bool* OutNewlySelected = nullptr) { TUniqueFragmentSelectionSet::Select(InOwner, InKey, OutNewlySelected); } /** * Overridden SelectRange function for passing by TViewModelPtr instead of TWeakViewModelPtr */ template void SelectRange(TViewModelPtr InOwner, RangeType Range, bool* OutAnySelected = nullptr) { TUniqueFragmentSelectionSet::SelectRange(InOwner, Forward(Range), OutAnySelected); } /** * Overridden Deselect function to remove duplicate keys on deselection */ void Deselect(FKeyHandle InKey); /** * Overridden Empty function to remove duplicate keys on deselection */ void Empty(); private: void RemoveDuplicateKeys(TArrayView KeyHandles); }; /** * Main track-area selection class storing the selection of sections, layer-bars and other trac-area elements */ struct FTrackAreaSelection : TSelectionSetBase { /** * Filter this selection set based on the specified filter type */ template TFilteredViewModelSelectionIterator Filter() const { return TFilteredViewModelSelectionIterator{ &GetSelected() }; } SEQUENCER_API bool OnSelectItem(const FWeakViewModelPtr& WeakViewModel); }; /** * Main track-area marked frame selection class */ struct FMarkedFrameSelection : TSelectionSetBase { }; /** * Selection class for an ISequence instance that manages all the different types of selection and event marshaling */ class FSequencerSelection : public FSequencerCoreSelection { public: /** Selection set representing view-models that are selected on the outliner */ FOutlinerSelection Outliner; /** Selection set representing view-models that are selected on the track-area */ FTrackAreaSelection TrackArea; /** Selection set representing selected keys */ FKeySelection KeySelection; /** Selection set representing selected marked frames */ FMarkedFrameSelection MarkedFrames; public: /** * Default constructor that initializes the selection sets */ SEQUENCER_API FSequencerSelection(); /** * Initialize this selection container with the specified view model. Must only be called once. */ SEQUENCER_API void Initialize(TViewModelPtr InViewModel); /** * Empty every selection set represented by this class */ SEQUENCER_API void Empty(); /** * Iterate all the outliner nodes that are considered 'indirectly' selected because they have * track area selection */ SEQUENCER_API FIndirectOutlinerSelectionIterator IterateIndirectOutlinerSelection() const; public: /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BEGIN BACKWARDS COMPAT */ /** DEPRECATED: Gets a set of the outliner nodes that have selected keys or sections */ const TSet>& GetNodesWithSelectedKeysOrSections() const { return NodesWithKeysOrSections; } /** DEPRECATED */ bool NodeHasSelectedKeysOrSections(TWeakViewModelPtr Model) const { return NodesWithKeysOrSections.Contains(Model); } /** DEPRECATED */ void GetSelectedOutlinerItems(TArray>& OutItems) const; /** DEPRECATED */ void GetSelectedOutlinerItems(TArray>& OutItems) const; /** DEPRECATED: Gets the outliner nodes that have selected keys or sections */ TArray GetBoundObjectsGuids(); /** DEPRECATED */ void EmptySelectedOutlinerNodesWithoutSections(const TArray& Sections); /** DEPRECATED */ TSet GetSelectedSections() const; /** DEPRECATED */ TSet GetSelectedTracks() const; /** DEPRECATED */ TSet> GetSelectedTrackRows() const; /*~ END BACKWARDS COMPAT ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ private: void OnHierarchyChanged(); void RevalidateSelection(); virtual TSharedPtr< FOutlinerSelection> GetOutlinerSelection() override { return TSharedPtr< FOutlinerSelection>(AsShared(), &Outliner); } virtual TSharedPtr GetOutlinerSelection() const override { return TSharedPtr(AsShared(), &Outliner); } SEQUENCER_API virtual void PreSelectionSetChangeEvent(FSelectionBase* InSelectionSet) override; SEQUENCER_API virtual void PreBroadcastChangeEvent() override; TSet> NodesWithKeysOrSections; }; /** Iterator class for iterating the outliner nodes that have keys or sections selected on them, * including the filtering mechanisms that exist on the actual selection sets */ struct FIndirectOutlinerSelectionIterator { const TSet>* SelectionSet; /** * Turn this iterator into a filtered iterator that only visits the specified viewmodel or extension types */ template TFilteredViewModelSelectionIterator, FilterType> Filter() const { return TFilteredViewModelSelectionIterator, FilterType>{ SelectionSet }; } /** * Gather all the view models contained in this iterator into the specified container */ template void Gather(ContainerType& OutContainer) const { OutContainer.Reserve(SelectionSet->Num()); for (TViewModelPtr Model : Filter()) { OutContainer.Add(Model); } } FORCEINLINE TSelectionSetIteratorState> begin() const { return TSelectionSetIteratorState>(SelectionSet->begin()); } FORCEINLINE TSelectionSetIteratorState> end() const { return TSelectionSetIteratorState>(SelectionSet->end()); } }; } // namespace UE::Sequencer