// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "Input/CursorReply.h" #include "Styling/SlateBrush.h" #include "SequencerSelectedKey.h" #include "MVVM/ViewModels/TrackAreaViewModel.h" #include "MVVM/Views/ITrackAreaHotspot.h" #include "Sequencer.h" class FMenuBuilder; class FSequencerTrackNode; class ISequencerSection; namespace UE { namespace Sequencer { struct FSelectionEventSuppressor; class FSectionModel; class ISequencerEditToolDragOperation; struct FHotspotSelectionManager { const FPointerEvent* MouseEvent; TSharedPtr Selection; FSequencer* Sequencer; TUniquePtr EventSuppressor; bool bForceSelect; bool bAddingToSelection; FHotspotSelectionManager(const FPointerEvent* InMouseEvent, FSequencer* InSequencer); ~FHotspotSelectionManager(); void ConditionallyClearSelection(); void ToggleKeys(TArrayView InKeys); void ToggleModel(TSharedPtr InModel); void DefaultModelSelection(TSharedPtr InModel); void SelectKeysExclusive(TArrayView InKeys); void SelectModelExclusive(TSharedPtr InModel); }; struct IMouseHandlerHotspot { UE_SEQUENCER_DECLARE_VIEW_MODEL_TYPE_ID(IMouseHandlerHotspot); virtual ~IMouseHandlerHotspot(){} virtual void HandleMouseSelection(FHotspotSelectionManager& SelectionManager) = 0; }; enum class ESequencerEasingType { In, Out }; /** A hotspot representing a key */ struct FKeyHotspot : ITrackAreaHotspot, IMouseHandlerHotspot { UE_SEQUENCER_DECLARE_CASTABLE(FKeyHotspot, ITrackAreaHotspot, IMouseHandlerHotspot); SEQUENCER_API FKeyHotspot(const TArray& InKeys, TWeakPtr InWeakSequencer); virtual void UpdateOnHover(FTrackAreaViewModel& InTrackArea) const override; virtual TOptional GetDomain() const; virtual TOptional GetTime() const override; virtual bool PopulateContextMenu(FMenuBuilder& MenuBuilder, TSharedPtr MenuExtender, FFrameTime MouseDownTime) override; virtual void HandleMouseSelection(FHotspotSelectionManager& SelectionManager) override; /** The keys that are part of this hotspot */ TSet Keys; TSet RawKeys; TWeakPtr WeakSequencer; }; /** A hotspot representing a key bar */ struct FKeyBarHotspot : ITrackAreaHotspot, IMouseHandlerHotspot , TSharedFromThis { UE_SEQUENCER_DECLARE_CASTABLE(FKeyBarHotspot, ITrackAreaHotspot, IMouseHandlerHotspot); FKeyBarHotspot(const TRange& InRange, TArray&& InLeadingKeys, TArray&& InTrailingKeys, TWeakPtr InWeakSequencer) : LeadingKeys(MoveTemp(InLeadingKeys)) , TrailingKeys(MoveTemp(InTrailingKeys)) , WeakSequencer(InWeakSequencer) , Range(InRange) { } virtual void UpdateOnHover(FTrackAreaViewModel& InTrackArea) const override; virtual TOptional GetTime() const override; virtual bool PopulateContextMenu(FMenuBuilder& MenuBuilder, TSharedPtr MenuExtender, FFrameTime MouseDownTime) override; virtual TSharedPtr InitiateDrag(const FPointerEvent& MouseEvent) override; virtual FCursorReply GetCursor() const override; /** IMouseHandlerHotspot */ virtual void HandleMouseSelection(FHotspotSelectionManager& SelectionManager) override; /** The keys that are part of this hotspot */ TArray LeadingKeys; TArray TrailingKeys; TWeakPtr WeakSequencer; TRange Range; }; /** A hotspot representing a section */ struct FSectionHotspotBase : ITrackAreaHotspot, IMouseHandlerHotspot { UE_SEQUENCER_DECLARE_CASTABLE(FSectionHotspotBase, ITrackAreaHotspot, IMouseHandlerHotspot); FSectionHotspotBase(TWeakPtr InSectionModel, TWeakPtr InWeakSequencer) : WeakSectionModel(InSectionModel) , WeakSequencer(InWeakSequencer) { } virtual void UpdateOnHover(FTrackAreaViewModel& InTrackArea) const override; virtual TOptional GetTime() const override; virtual TOptional GetOffsetTime() const override; virtual TSharedPtr InitiateDrag(const FPointerEvent& MouseEvent) override { return nullptr; } virtual bool PopulateContextMenu(FMenuBuilder& MenuBuilder, TSharedPtr MenuExtender, FFrameTime MouseDownTime) override; /** IMouseHandlerHotspot */ virtual void HandleMouseSelection(FHotspotSelectionManager& SelectionManager) override; UMovieSceneSection* GetSection() const; /** The section model */ TWeakPtr WeakSectionModel; TWeakPtr WeakSequencer; }; /** A hotspot representing a section */ struct FSectionHotspot : FSectionHotspotBase { UE_SEQUENCER_DECLARE_CASTABLE(FSectionHotspot, FSectionHotspotBase); FSectionHotspot(TWeakPtr InSectionModel, TWeakPtr InWeakSequencer) : FSectionHotspotBase(InSectionModel, InWeakSequencer) { } /** IMouseHandlerHotspot */ virtual void HandleMouseSelection(FHotspotSelectionManager& SelectionManager) override; }; /** A hotspot representing a resize handle on a section */ struct FSectionResizeHotspot : FSectionHotspotBase { UE_SEQUENCER_DECLARE_CASTABLE(FSectionResizeHotspot, FSectionHotspotBase); enum EHandle { Left, Right }; FSectionResizeHotspot(EHandle InHandleType, TWeakPtr InSectionModel, TWeakPtr InWeakSequencer) : FSectionHotspotBase(InSectionModel, InWeakSequencer) , HandleType(InHandleType) {} virtual void UpdateOnHover(FTrackAreaViewModel& InTrackArea) const override; virtual TOptional GetTime() const override; virtual TSharedPtr InitiateDrag(const FPointerEvent& MouseEvent) override; virtual FCursorReply GetCursor() const { return FCursorReply::Cursor( EMouseCursor::ResizeLeftRight ); } virtual const FSlateBrush* GetCursorDecorator(const FGeometry& MyGeometry, const FPointerEvent& CursorEvent) const; EHandle HandleType; }; /** A hotspot representing a resize handle on a section's easing */ struct FSectionEasingHandleHotspot : FSectionHotspotBase { UE_SEQUENCER_DECLARE_CASTABLE(FSectionEasingHandleHotspot, FSectionHotspotBase); FSectionEasingHandleHotspot(ESequencerEasingType InHandleType, TWeakPtr InSectionModel, TWeakPtr InWeakSequencer) : FSectionHotspotBase(InSectionModel, InWeakSequencer) , HandleType(InHandleType) {} virtual void UpdateOnHover(FTrackAreaViewModel& InTrackArea) const override; virtual bool PopulateContextMenu(FMenuBuilder& MenuBuilder, TSharedPtr MenuExtender, FFrameTime MouseDownTime) override; virtual TOptional GetTime() const override; virtual TSharedPtr InitiateDrag(const FPointerEvent& MouseEvent) override; virtual FCursorReply GetCursor() const { return FCursorReply::Cursor( EMouseCursor::ResizeLeftRight ); } virtual const FSlateBrush* GetCursorDecorator(const FGeometry& MyGeometry, const FPointerEvent& CursorEvent) const; ESequencerEasingType HandleType; }; struct FEasingAreaHandle { TWeakPtr WeakSectionModel; ESequencerEasingType EasingType; }; /** A hotspot representing an easing area for multiple sections */ struct FSectionEasingAreaHotspot : FSectionHotspotBase { UE_SEQUENCER_DECLARE_CASTABLE(FSectionEasingAreaHotspot, FSectionHotspotBase); FSectionEasingAreaHotspot(const TArray& InEasings, TWeakPtr InSectionModel, TWeakPtr InWeakSequencer) : FSectionHotspotBase(InSectionModel, InWeakSequencer) , Easings(InEasings) {} virtual bool PopulateContextMenu(FMenuBuilder& MenuBuilder, TSharedPtr MenuExtender, FFrameTime MouseDownTime) override; /** IMouseHandlerHotspot */ virtual void HandleMouseSelection(FHotspotSelectionManager& SelectionManager) override; bool Contains(UMovieSceneSection* InSection) const; /** Handles to the easings that exist on this hotspot */ TArray Easings; }; } // namespace Sequencer } // namespace UE