加入Seek和游标

This commit is contained in:
Sch 2023-07-03 05:35:46 +08:00
parent 3487c05e38
commit 2e6d6e6915
8 changed files with 88 additions and 9 deletions

Binary file not shown.

View File

@ -24,4 +24,5 @@ class CUT5_API IWidgetInterface
public:
virtual void UpdateTimelineLength() = 0;
virtual void Seek(int32 Frame) = 0;
};

View File

@ -22,6 +22,31 @@ void SCutTimeline::UpdateTimelineLength()
TimelineTick->GenerateTickBox(FGlobalData::TrackLength / FGlobalData::DefaultTimeTickSpace);
}
void SCutTimeline::UpdateCursorPosition(int32 Frame) const
{
if (TimelineTick.IsValid())
{
if (Frame >= 0 && Frame <= FGlobalData::TrackLength / FGlobalData::DefaultTimeTickSpace)
{
TimelineTick->UpdateNewCursorPosition(Frame * FGlobalData::DefaultTimeTickSpace);
for (IWidgetInterface* Interface : AllWidgets)
{
Interface->Seek(Frame);
}
}
}
}
int32 SCutTimeline::GetCursorPosition() const
{
if (TimelineTick.IsValid())
{
return TimelineTick->GetCursorPosition();
}
return 0;
}
void SCutTimeline::Construct(const FArguments& InArgs)
{
ChildSlot
@ -37,7 +62,7 @@ void SCutTimeline::Construct(const FArguments& InArgs)
// Timeline
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.SizeParam(FStretch(0.1f))
.SizeParam(FStretch(0.07f))
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()
@ -60,7 +85,7 @@ void SCutTimeline::Construct(const FArguments& InArgs)
]
+ SHorizontalBox::Slot()
.SizeParam(FStretch(0.9f))
.SizeParam(FStretch(0.93f))
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()
@ -109,6 +134,35 @@ void SCutTimeline::Construct(const FArguments& InArgs)
TickScrollBox->SetScrollOffset(ChangedValue * TickScrollBox->GetScrollOffsetOfEnd());
})
]
+ SVerticalBox::Slot()
.SizeParam(FAuto())
[
// Down Tool Bar
SNew(SBox)
.HeightOverride(25)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
[
SNew(SButton)
.OnClicked_Lambda([this]()
{
UpdateCursorPosition(GetCursorPosition() - 1);
return FReply::Handled();
})
]
+ SHorizontalBox::Slot()
[
SNew(SButton)
.OnClicked_Lambda([this]()
{
UpdateCursorPosition(GetCursorPosition() + 1);
return FReply::Handled();
})
]
]
]
]
]

View File

@ -19,6 +19,7 @@
class CUT5_API SCutTimeline : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SCutTimeline)
{
@ -27,13 +28,13 @@ public:
SLATE_END_ARGS()
void UpdateTimelineLength();
void UpdateCursorPosition(int32 Frame) const;
int32 GetCursorPosition() const;
/** Constructs this widget with InArgs */
void Construct(const FArguments& InArgs);
void AddNewTrack(FTrackData TrackData, int32 TrackIndex);
TArray<FTrackData> TrackDataArray;
TArray<IWidgetInterface*> AllWidgets;
TSharedPtr<STimelineTick> TimelineTick;

View File

@ -10,8 +10,8 @@ BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void STimelineTick::Construct(const FArguments& InArgs)
{
FSlateRenderTransform RenderTransform = FSlateRenderTransform();
RenderTransform.
const FSlateRenderTransform NewRenderTransform =
::Concatenate(FScale2D(0.3, 29), FShear2D(0, 0), FQuat2D(FMath::DegreesToRadians(0)), FVector2D(0, -2));
ChildSlot
[
SAssignNew(TickLengthBox, SBox)
@ -20,15 +20,27 @@ void STimelineTick::Construct(const FArguments& InArgs)
[
SAssignNew(TickBox, SOverlay)
+ SOverlay::Slot()
.HAlign(HAlign_Left)
[
SAssignNew(TickCursor, SImage)
.RenderTransform()
.RenderTransform(NewRenderTransform)
]
]
];
GenerateTickBox(FGlobalData::TrackLength / FGlobalData::DefaultTimeTickSpace);
}
void STimelineTick::UpdateNewCursorPosition(const float Position)
{
const FSlateRenderTransform NewRenderTransform =
::Concatenate(FScale2D(0.3, 29), FShear2D(0, 0), FQuat2D(FMath::DegreesToRadians(0)), FVector2D(Position, -2));
if (TickCursor)
{
TickCursor->SetRenderTransform(NewRenderTransform);
CursorPosition = Position / FGlobalData::DefaultTimeTickSpace;
}
}
void STimelineTick::GenerateTickBox(int32 TickCount)
{
for (int32 i = 0; i < TickCount; i++)

View File

@ -10,6 +10,8 @@
*/
class CUT5_API STimelineTick : public SCompoundWidget
{
private:
int32 CursorPosition = 0;
public:
SLATE_BEGIN_ARGS(STimelineTick)
{
@ -19,8 +21,9 @@ public:
/** Constructs this widget with InArgs */
void Construct(const FArguments& InArgs);
void UpdateNewCursorPosition(const float Position);
void GenerateTickBox(int32 TickCount);
int32 GetCursorPosition() const { return CursorPosition; };
TSharedPtr<SOverlay> TickBox;
TSharedPtr<SBox> TickLengthBox;
TSharedPtr<SImage> TickCursor;

View File

@ -65,6 +65,7 @@ void STrackBody::CallRender()
}
FReply STrackBody::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)
{
const FTrackClipDragOperation& ClipDragOperation = static_cast<FTrackClipDragOperation&>(DragDropEvent.GetOperation().ToSharedRef().Get());
@ -118,4 +119,9 @@ void STrackBody::OnDragLeave(const FDragDropEvent& DragDropEvent)
SCompoundWidget::OnDragLeave(DragDropEvent);
}
void STrackBody::Seek(int32 Frame)
{
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION

View File

@ -34,4 +34,6 @@ public:
{
TrackBodyBox->SetWidthOverride(FGlobalData::TrackLength);
};
virtual void Seek(int32 Frame) override;
};