修改游标灵活度
This commit is contained in:
parent
ba37f8e6e1
commit
7e79b67a87
@ -452,6 +452,7 @@ public:
|
||||
ColorDragS,
|
||||
ColorDragV,
|
||||
MovePanel,
|
||||
MoveTickCursor,
|
||||
};
|
||||
FCutDragDropBase() {};
|
||||
FCutDragDropBase(EType InType)
|
||||
|
@ -97,6 +97,23 @@ void DragDropOperator::OnDragOver(const FGeometry& MyGeometry, const FDragDropEv
|
||||
{
|
||||
if (TSharedPtr<FCutDragDropBase> DragDropBase = DragDropEvent.GetOperationAs<FCutDragDropBase>())
|
||||
{
|
||||
if (DragDropBase->DragDropType == FCutDragDropBase::EType::TickDrag)
|
||||
{
|
||||
TSharedPtr<STimelineTick> TickTimeline = StaticCastSharedPtr<STimelineTick>(DragDropBase->DraggingWidget);
|
||||
|
||||
|
||||
if (TickTimeline->GetCachedGeometry().AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()).X < 0)
|
||||
{
|
||||
TickTimeline->UpdateNewCursorPosition(0);
|
||||
return;
|
||||
}
|
||||
TickTimeline->UpdateNewCursorPosition((TickTimeline->GetCachedGeometry().AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()).X) / FGlobalData::DefaultTimeTickSpace);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (DragDropBase->DragDropType == FCutDragDropBase::EType::MovePanel)
|
||||
{
|
||||
TSharedPtr<SCutTimeline> CutTimeline = StaticCastSharedPtr<SCutTimeline>(DragDropBase->DraggingWidget);
|
||||
|
@ -363,13 +363,21 @@ void SCutMainWindow::Construct(const FArguments& InArgs)
|
||||
}));
|
||||
MainFrame.GetMainFrameCommandBindings()->MapAction(FShortCutCommands::Get().ZoomInTimeline, FExecuteAction::CreateLambda([this]()
|
||||
{
|
||||
|
||||
const float NewValue = CutTimeline->ZoomSlider->GetValue() + 0.1;
|
||||
CutTimeline->ZoomSlider->SetValue(NewValue);
|
||||
FGlobalData::DefaultTimeTickSpace = FMath::GetMappedRangeValueClamped(FVector2D(0, 1.0), FVector2D(GetCachedGeometry().GetLocalSize().X / FGlobalData::TrackLength, 14), NewValue);
|
||||
CutTimeline->RenderGroup();
|
||||
}));
|
||||
MainFrame.GetMainFrameCommandBindings()->MapAction(FShortCutCommands::Get().ZoomOutTimeline, FExecuteAction::CreateLambda([this]()
|
||||
{
|
||||
|
||||
const float NewValue = CutTimeline->ZoomSlider->GetValue() - 0.1;
|
||||
CutTimeline->ZoomSlider->SetValue(NewValue);
|
||||
FGlobalData::DefaultTimeTickSpace = FMath::GetMappedRangeValueClamped(FVector2D(0, 1.0), FVector2D(GetCachedGeometry().GetLocalSize().X / FGlobalData::TrackLength, 14), NewValue);
|
||||
CutTimeline->RenderGroup();
|
||||
}));
|
||||
|
||||
|
||||
|
||||
// FRunnableThread* Thread = FRunnableThread::Create(SoundThread, TEXT("SoundThread"));
|
||||
// OpenProject(FPaths::Combine(FPaths::ProjectSavedDir(), TEXT("DefaultProject")));
|
||||
// ImportProject("");
|
||||
@ -469,6 +477,8 @@ int32 SCutMainWindow::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedG
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return SCompoundWidget::OnPaint(Args, AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle,
|
||||
|
@ -168,7 +168,9 @@ void SCutTimeline::Construct(const FArguments& InArgs)
|
||||
+ SHorizontalBox::Slot()
|
||||
.SizeParam(FStretch(1.0))
|
||||
[
|
||||
SNew(SSlider)
|
||||
SAssignNew(ZoomSlider, SSlider)
|
||||
.MaxValue(1.0)
|
||||
.MinValue(0.0)
|
||||
.Value(0.0f)
|
||||
.OnValueChanged_Lambda([this](float ChangedValue)
|
||||
{
|
||||
@ -412,6 +414,54 @@ void SCutTimeline::SetAutoPlay(bool bStart)
|
||||
AutoPlaying = bStart;
|
||||
}
|
||||
|
||||
int32 SCutTimeline::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect,
|
||||
FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle,
|
||||
bool bParentEnabled) const
|
||||
{
|
||||
const FSlateBrush Brush;
|
||||
FPaintGeometry PaintGeometry = AllottedGeometry.ToPaintGeometry(
|
||||
FVector2f(GetCachedGeometry().GetLocalSize().X, 9999),
|
||||
FSlateLayoutTransform(FVector2f()));
|
||||
|
||||
if (TrackBodyHScrollBox->GetCachedGeometry().AbsoluteToLocal(TimelineTick->TickCursor->GetCachedGeometry().GetAbsolutePosition()).X < 30)
|
||||
{
|
||||
if (TrackBodyHScrollBox->GetScrollOffset() > 0)
|
||||
{
|
||||
TrackBodyHScrollBox->SetScrollOffset(TrackBodyHScrollBox->GetScrollOffset() - 3);
|
||||
TickScrollBox->SetScrollOffset(TrackBodyHScrollBox->GetScrollOffset());
|
||||
}
|
||||
}
|
||||
else if (TrackBodyHScrollBox->GetCachedGeometry().AbsoluteToLocal(TimelineTick->TickCursor->GetCachedGeometry().GetAbsolutePosition()).X > TrackBodyHScrollBox->GetCachedGeometry().GetLocalSize().X - 30)
|
||||
{
|
||||
if (TrackBodyHScrollBox->GetScrollOffset() < TrackBodyHScrollBox->GetScrollOffsetOfEnd())
|
||||
{
|
||||
TrackBodyHScrollBox->SetScrollOffset(TrackBodyHScrollBox->GetScrollOffset() + 3);
|
||||
TickScrollBox->SetScrollOffset(TrackBodyHScrollBox->GetScrollOffset());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (TrackBodyHScrollBox->GetCachedGeometry().AbsoluteToLocal(TimelineTick->TickCursor->GetCachedGeometry().GetAbsolutePosition()).X < 0)
|
||||
{
|
||||
return SCompoundWidget::OnPaint(Args, AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle,
|
||||
bParentEnabled);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
FSlateDrawElement::MakeBox(
|
||||
OutDrawElements,
|
||||
LayerId + 1,
|
||||
AllottedGeometry.ToPaintGeometry(FVector2f(2, GetCachedGeometry().Size.Y), FSlateLayoutTransform(FVector2f(GetCachedGeometry().AbsoluteToLocal(TimelineTick->TickCursor->GetCachedGeometry().GetAbsolutePosition()).X, AllottedGeometry.GetLocalSize().Y - GetCachedGeometry().GetLocalSize().Y))),
|
||||
&Brush,
|
||||
ESlateDrawEffect::None,
|
||||
FColor(255, 255, 255, 255));
|
||||
return SCompoundWidget::OnPaint(Args, AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle,
|
||||
bParentEnabled);
|
||||
}
|
||||
|
||||
void SCutTimeline::OnGroupNameEdited(FString NewText, FString OldText)
|
||||
{
|
||||
for (FDeviceTrackGroup& TrackGroup : DeviceTrackGroups)
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "Cut5/WidgetInterface.h"
|
||||
#include "Cut5/Interface/CutMainWidgetInterface.h"
|
||||
#include "Widgets/SCompoundWidget.h"
|
||||
#include "Widgets/Input/SSlider.h"
|
||||
#include "Widgets/Layout/SBox.h"
|
||||
#include "Widgets/Layout/SScrollBox.h"
|
||||
|
||||
@ -68,6 +69,7 @@ public:
|
||||
void AddNewTrackToGroup(FString GroupName, FTrackData TrackData, ETrackType GroupType = ETrackType::None);
|
||||
void SetAutoPlay(bool bStart);
|
||||
bool AutoPlaying = false;
|
||||
virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
|
||||
|
||||
void OnGroupNameEdited(FString NewText, FString OldText);
|
||||
void RenderGroup();
|
||||
@ -104,6 +106,7 @@ public:
|
||||
TSharedPtr<SBox> TimelineTickBox;
|
||||
TSharedPtr<SScrollBox> TickScrollBox;
|
||||
TSharedPtr<STextBlock> CurrentEditDebug;
|
||||
TSharedPtr<SSlider> ZoomSlider;
|
||||
|
||||
TArray<FSingleTrackGroupInstance> TrackGroupInstances;
|
||||
TArray<FTrackGroup> TrackGroups;
|
||||
|
@ -94,12 +94,14 @@ FReply STimelineTick::OnMouseButtonDown(const FGeometry& MyGeometry, const FPoin
|
||||
{
|
||||
const int32 NewFrame = FMath::TruncToInt(MyGeometry.AbsoluteToLocal(MouseEvent.GetScreenSpacePosition()).X / FGlobalData::DefaultTimeTickSpace) * FGlobalData::DefaultTimeTickSpace;
|
||||
UpdateNewCursorPosition(NewFrame);
|
||||
return FReply::Handled().DetectDrag(SharedThis(this), EKeys::LeftMouseButton).BeginDragDrop(MakeShared<FCutDragDropBase>(FCutDragDropBase::EType::TickDrag));
|
||||
TSharedPtr<FCutDragDropBase> NewCutDragDrop = MakeShared<FCutDragDropBase>(FCutDragDropBase::EType::TickDrag);
|
||||
NewCutDragDrop->DraggingWidget = SharedThis(this);
|
||||
|
||||
return FReply::Handled().DetectDrag(SharedThis(this), EKeys::LeftMouseButton).BeginDragDrop(NewCutDragDrop.ToSharedRef());
|
||||
}
|
||||
|
||||
FReply STimelineTick::OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)
|
||||
{
|
||||
UpdateNewCursorPosition((MyGeometry.AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()).X) / FGlobalData::DefaultTimeTickSpace);
|
||||
|
||||
return SCompoundWidget::OnDragOver(MyGeometry, DragDropEvent);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user