Files
UnrealEngineUWP/Engine/Source/Developer/MovieSceneTools/Private/DirectorTrackEditor.h
Dan Hertzka c042ddcb94 ---- Merging with SlateDev branch ----
Introduces the concept of "Active Ticking" to allow Slate to go to sleep when there is no need to update the UI.

While asleep, Slate will skip the Tick & Paint pass for that frame entirely.
- There are TWO ways to "wake" Slate and cause a Tick/Paint pass:
    1. Provide some sort of input (mouse movement, clicks, and key presses). Slate will always tick when the user is active.
        - Therefore, if the logic in a given widget's Tick is only relevant in response to user action, there is no need to register an active tick.
    2. Register an Active Tick. Currently this is an all-or-nothing situation, so if a single active tick needs to execute, all of Slate will be ticked.

- The purpose of an Active Tick is to allow a widget to "drive" Slate and guarantee a Tick/Paint pass in the absence of any user action.
    - Examples include animation, async operations that update periodically, progress updates, loading bars, etc.

- An empty active tick is registered for viewports when they are real-time, so game project widgets are unaffected by this change and should continue to work as before.

- An Active Tick is registered by creating an FWidgetActiveTickDelegate and passing it to SWidget::RegisterActiveTick()
    - There are THREE ways to unregister an active tick:
        1. Return EActiveTickReturnType::StopTicking from the active tick function
        2. Pass the FActiveTickHandle returned by RegisterActiveTick() to SWidget::UnregisterActiveTick()
        3. Destroy the widget responsible for the active tick

- Sleeping is currently disabled, can be enabled with Slate.AllowSlateToSleep cvar
- There is currently a little buffer time during which Slate continues to tick following any input. Long-term, this is planned to be removed.
    - The duration of the buffer can be adjusted using Slate.SleepBufferPostInput cvar (defaults to 1.0f)

- The FCurveSequence API has been updated to work with the active tick system
    - Playing a curve sequence now requires that you pass the widget being animated by the sequence
    - The active tick will automatically be registered on behalf of the widget and unregister when the sequence is complete
    - GetLerpLooping() has been removed. Instead, pass true as the second param to Play() to indicate that the animation will loop. This causes the active tick to be registered indefinitely until paused or jumped to the start/end.

[CL 2391669 by Dan Hertzka in Main branch]
2014-12-17 16:07:57 -05:00

183 lines
6.6 KiB
C++

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
/**
* Tools for director tracks
*/
class FDirectorTrackEditor : public FMovieSceneTrackEditor
{
public:
/**
* Constructor
*
* @param InSequencer The sequencer instance to be used by this tool
*/
FDirectorTrackEditor( TSharedRef<ISequencer> InSequencer );
~FDirectorTrackEditor();
/**
* Creates an instance of this class. Called by a sequencer
*
* @param OwningSequencer The sequencer instance to be used by this tool
* @return The new instance of this class
*/
static TSharedRef<FMovieSceneTrackEditor> CreateTrackEditor( TSharedRef<ISequencer> OwningSequencer );
/** FMovieSceneTrackEditor Interface */
virtual bool SupportsType( TSubclassOf<UMovieSceneTrack> Type ) const override;
virtual TSharedRef<ISequencerSection> MakeSectionInterface( UMovieSceneSection& SectionObject, UMovieSceneTrack* Track ) override;
virtual void AddKey(const FGuid& ObjectGuid, UObject* AdditionalAsset = NULL) override;
virtual void Tick(float DeltaTime) override;
virtual void BuildObjectBindingContextMenu(FMenuBuilder& MenuBuilder, const FGuid& ObjectBinding, const UClass* ObjectClass) override;
private:
/** Delegate for AnimatablePropertyChanged in AddKey */
void AddKeyInternal(float AutoKeyTime, const FGuid ObjectGuid);
private:
/** The Thumbnail pool which draws all the viewport thumbnails for the director track */
TSharedPtr<class FShotThumbnailPool> ThumbnailPool;
};
/**
* Shot Thumbnail pool, which keeps a list of thumbnails that need to be drawn
* and draws them incrementally
*/
class FShotThumbnailPool
{
public:
FShotThumbnailPool(TSharedPtr<ISequencer> InSequencer, uint32 InMaxThumbnailsToDrawAtATime = 1);
/** Requests that the passed in thumbnails need to be drawn */
void AddThumbnailsNeedingRedraw(const TArray< TSharedPtr<class FShotThumbnail> >& InThumbnails);
/** Informs the pool that the thumbnails passed in no longer need to be drawn */
void RemoveThumbnailsNeedingRedraw(const TArray< TSharedPtr<class FShotThumbnail> >& InThumbnails);
/** Draws a small number of thumbnails that are enqueued for drawing */
void DrawThumbnails();
private:
/** Parent sequencer we're drawing thumbnails for */
TWeakPtr<ISequencer> Sequencer;
/** Thumbnails enqueued for drawing */
TArray< TSharedPtr<class FShotThumbnail> > ThumbnailsNeedingDraw;
/** How many thumbnails we are allowed to draw in a single DrawThumbnails call */
uint32 MaxThumbnailsToDrawAtATime;
};
/**
* Shot Thumbnail, which keeps a Texture to be displayed by a viewport
*/
class FShotThumbnail : public ISlateViewport, public TSharedFromThis<FShotThumbnail>
{
public:
FShotThumbnail(TSharedPtr<class FShotSection> InSection, TRange<float> InTimeRange);
~FShotThumbnail();
/* ISlateViewport interface */
virtual FIntPoint GetSize() const override;
virtual class FSlateShaderResource* GetViewportRenderTargetTexture() const override;
virtual bool RequiresVsync() const override;
/** Gets the time that this thumbnail is a rendering of */
float GetTime() const;
/** Renders the thumbnail to the texture */
void DrawThumbnail();
/** Copies the incoming render target to this thumbnails texture */
void CopyTextureIn(class FSlateRenderTargetRHI* InTexture);
/** Gets the curve for fading in the thumbnail */
float GetFadeInCurve() const;
/** Returns whether this thumbnail is visible based on the shot section geometry visibility */
bool IsVisible() const;
bool IsValid() const;
private:
/** Parent shot section we are a thumbnail of */
TWeakPtr<class FShotSection> OwningSection;
/** The Texture RHI that holds the thumbnail */
class FSlateTexture2DRHIRef* Texture;
/** Where in time this thumbnail is a rendering of */
TRange<float> TimeRange;
/** The time when the thumbnail started to fade in. */
double FadeInStartTime;
};
/**
* Shot section, which paints and ticks the appropriate section
*/
class FShotSection : public ISequencerSection, public TSharedFromThis<FShotSection>
{
public:
FShotSection( TSharedPtr<ISequencer> InSequencer, TSharedPtr<FShotThumbnailPool> InThumbnailPool, UMovieSceneSection& InSection, UObject* InTargetObject );
~FShotSection();
/** ISequencerSection interface */
virtual UMovieSceneSection* GetSectionObject() override;
virtual int32 OnPaintSection( const FGeometry& AllottedGeometry, const FSlateRect& SectionClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, bool bParentEnabled ) const override;
virtual void Tick( const FGeometry& AllottedGeometry, const FGeometry& ParentGeometry, const double InCurrentTime, const float InDeltaTime ) override;
virtual FText GetDisplayName() const override { return NSLOCTEXT("FShotSection", "DirectorTrack", "Director Track"); }
virtual FText GetSectionTitle() const override;
virtual float GetSectionHeight() const override;
virtual void GenerateSectionLayout( class ISectionLayoutBuilder& LayoutBuilder ) const override {}
virtual FReply OnSectionDoubleClicked( const FGeometry& SectionGeometry, const FPointerEvent& MouseEvent ) override;
/** Gets the thumbnail width */
uint32 GetThumbnailWidth() const;
/** Regenerates all viewports and thumbnails at the new size */
void RegenerateViewportThumbnails(const FIntPoint& Size);
/** Draws the passed in viewport thumbnail and copies it to the thumbnail's texture */
void DrawViewportThumbnail(TSharedPtr<FShotThumbnail> ShotThumbnail);
/** Calculates and sets the thumbnail width, and resizes if it is different than before */
void CalculateThumbnailWidthAndResize();
/** Gets the time range of what in the sequencer is visible */
TRange<float> GetVisibleTimeRange() const {return VisibleTimeRange;}
private:
/** The section we are visualizing */
UMovieSceneSection* Section;
/** The parent sequencer we are a part of */
TWeakPtr<ISequencer> Sequencer;
/** The actual camera actor we are possessing */
TWeakObjectPtr<ACameraActor> Camera;
/** The thumbnail pool that we are sending all of our thumbnails to */
TWeakPtr<FShotThumbnailPool> ThumbnailPool;
/** A list of all thumbnails this shot section has */
TArray< TSharedPtr<FShotThumbnail> > Thumbnails;
/** The width of our thumbnails */
uint32 ThumbnailWidth;
/** The stored size of this section in the Slate geometry */
FIntPoint StoredSize;
/** The stored start time, to query for invalidations */
float StoredStartTime;
/** Cached Time Range of the visible parent section area */
TRange<float> VisibleTimeRange;
/** An internal viewport scene we use to render the thumbnails with */
TSharedPtr<FSceneViewport> InternalViewportScene;
/** An internal editor viewport client to render the thumbnails with */
TSharedPtr<FLevelEditorViewportClient> InternalViewportClient;
};