|
@@ -0,0 +1,546 @@
|
|
|
+// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
+
|
|
|
+
|
|
|
+#include "EZAbleTimeSliderController.h"
|
|
|
+#include "Fonts/FontMeasure.h"
|
|
|
+#include "Preferences/PersonaOptions.h"
|
|
|
+#include "Styling/AppStyle.h"
|
|
|
+#include "SEzAbilityTimeLine.h"
|
|
|
+
|
|
|
+struct FEZAbleSliderController::FDrawAbleTickArgs
|
|
|
+{
|
|
|
+ /** Geometry of the area */
|
|
|
+ FGeometry AllottedGeometry;
|
|
|
+ /** Culling rect of the area */
|
|
|
+ FSlateRect CullingRect;
|
|
|
+ /** Color of each tick */
|
|
|
+ FLinearColor TickColor;
|
|
|
+ /** Offset in Y where to start the tick */
|
|
|
+ float TickOffset;
|
|
|
+ /** Height in of major ticks */
|
|
|
+ float MajorTickHeight;
|
|
|
+ /** Start layer for elements */
|
|
|
+ int32 StartLayer;
|
|
|
+ /** Draw effects to apply */
|
|
|
+ ESlateDrawEffect DrawEffects;
|
|
|
+ /** Whether or not to only draw major ticks */
|
|
|
+ bool bOnlyDrawMajorTicks;
|
|
|
+ /** Whether or not to mirror labels */
|
|
|
+ bool bMirrorLabels;
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+struct FEZAbleSliderController::FAbleScrubRangeToScreen
|
|
|
+{
|
|
|
+ double ViewStart;
|
|
|
+ float PixelsPerInput;
|
|
|
+
|
|
|
+ FAbleScrubRangeToScreen(const TRange<double>& InViewInput, const FVector2D& InWidgetSize)
|
|
|
+ {
|
|
|
+ const double ViewInputRange = InViewInput.Size<double>();
|
|
|
+
|
|
|
+ ViewStart = InViewInput.GetLowerBoundValue();
|
|
|
+ PixelsPerInput = ViewInputRange > 0 ? static_cast<float>(InWidgetSize.X / ViewInputRange) : 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** Local Widget Space -> Curve Input domain. */
|
|
|
+ double LocalXToInput(float ScreenX) const
|
|
|
+ {
|
|
|
+ return PixelsPerInput > 0 ? (ScreenX / PixelsPerInput) + ViewStart : ViewStart;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** Curve Input domain -> local Widget Space */
|
|
|
+ float InputToLocalX(double Input) const
|
|
|
+ {
|
|
|
+ return static_cast<float>((Input - ViewStart) * PixelsPerInput);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+FEZAbleSliderController::FEZAbleSliderController(const FTimeSliderArgs& InArgs, TWeakPtr<SEzAbilityTimeLine> InWeakTimeline, TSharedPtr<INumericTypeInterface<double>> InSecondaryNumericTypeInterface)
|
|
|
+ : WeakTimeline(InWeakTimeline)
|
|
|
+ , TimeSliderArgs( InArgs )
|
|
|
+ , SecondaryNumericTypeInterface(InSecondaryNumericTypeInterface)
|
|
|
+{
|
|
|
+ ScrubFillBrush = FAppStyle::GetBrush(TEXT("Sequencer.Timeline.ScrubFill"));
|
|
|
+ ScrubHandleUpBrush = FAppStyle::GetBrush(TEXT("Sequencer.Timeline.VanillaScrubHandleUp"));
|
|
|
+ ScrubHandleDownBrush = FAppStyle::GetBrush(TEXT("Sequencer.Timeline.VanillaScrubHandleDown"));
|
|
|
+ EditableTimeBrush = FAppStyle::GetBrush(TEXT("AnimTimeline.SectionMarker"));
|
|
|
+}
|
|
|
+
|
|
|
+void FEZAbleSliderController::DrawTicks(FSlateWindowElementList& OutDrawElements, const TRange<double>& ViewRange, const FAbleScrubRangeToScreen& RangeToScreen, FDrawAbleTickArgs& InArgs) const
|
|
|
+{
|
|
|
+ TSharedPtr<SEzAbilityTimeLine> Timeline = WeakTimeline.Pin();
|
|
|
+ if (!Timeline.IsValid())
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!FMath::IsFinite(ViewRange.GetLowerBoundValue()) || !FMath::IsFinite(ViewRange.GetUpperBoundValue()))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ FFrameRate FrameResolution = GetTickResolution();
|
|
|
+ FPaintGeometry PaintGeometry = InArgs.AllottedGeometry.ToPaintGeometry();
|
|
|
+ FSlateFontInfo SmallLayoutFont = FCoreStyle::GetDefaultFontStyle("Regular", 8);
|
|
|
+
|
|
|
+ double MajorGridStep = 0.0;
|
|
|
+ int32 MinorDivisions = 0;
|
|
|
+// if (!Timeline->GetGridMetrics(static_cast<float>(InArgs.AllottedGeometry.Size.X), MajorGridStep, MinorDivisions))
|
|
|
+// {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+
|
|
|
+ if (InArgs.bOnlyDrawMajorTicks)
|
|
|
+ {
|
|
|
+ MinorDivisions = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ TArray<FVector2D> LinePoints;
|
|
|
+ LinePoints.SetNumUninitialized(2);
|
|
|
+
|
|
|
+ const bool bAntiAliasLines = false;
|
|
|
+
|
|
|
+ const double FirstMajorLine = FMath::FloorToDouble(ViewRange.GetLowerBoundValue() / MajorGridStep) * MajorGridStep;
|
|
|
+ const double LastMajorLine = FMath::CeilToDouble(ViewRange.GetUpperBoundValue() / MajorGridStep) * MajorGridStep;
|
|
|
+
|
|
|
+ for (double CurrentMajorLine = FirstMajorLine; CurrentMajorLine < LastMajorLine; CurrentMajorLine += MajorGridStep)
|
|
|
+ {
|
|
|
+ float MajorLinePx = RangeToScreen.InputToLocalX(CurrentMajorLine);
|
|
|
+
|
|
|
+ LinePoints[0] = FVector2D(MajorLinePx, InArgs.TickOffset);
|
|
|
+ LinePoints[1] = FVector2D(MajorLinePx, InArgs.TickOffset + InArgs.MajorTickHeight);
|
|
|
+
|
|
|
+ // Draw each tick mark
|
|
|
+ FSlateDrawElement::MakeLines(
|
|
|
+ OutDrawElements,
|
|
|
+ InArgs.StartLayer,
|
|
|
+ PaintGeometry,
|
|
|
+ LinePoints,
|
|
|
+ InArgs.DrawEffects,
|
|
|
+ InArgs.TickColor,
|
|
|
+ bAntiAliasLines
|
|
|
+ );
|
|
|
+
|
|
|
+ if (!InArgs.bOnlyDrawMajorTicks)
|
|
|
+ {
|
|
|
+ FString FrameString = TimeSliderArgs.NumericTypeInterface->ToString((CurrentMajorLine * FrameResolution).RoundToFrame().Value);
|
|
|
+
|
|
|
+ // Space the text between the tick mark but slightly above
|
|
|
+ FVector2D TextOffset(MajorLinePx + 5.f, InArgs.bMirrorLabels ? 3.f : FMath::Abs(InArgs.AllottedGeometry.Size.Y - (InArgs.MajorTickHeight + 3.f)));
|
|
|
+ FSlateDrawElement::MakeText(
|
|
|
+ OutDrawElements,
|
|
|
+ InArgs.StartLayer + 1,
|
|
|
+ InArgs.AllottedGeometry.ToPaintGeometry(InArgs.AllottedGeometry.Size, FSlateLayoutTransform(TextOffset)),
|
|
|
+ FrameString,
|
|
|
+ SmallLayoutFont,
|
|
|
+ InArgs.DrawEffects,
|
|
|
+ InArgs.TickColor * 0.65f
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int32 Step = 1; Step < MinorDivisions; ++Step)
|
|
|
+ {
|
|
|
+ // Compute the size of each tick mark. If we are half way between to visible values display a slightly larger tick mark
|
|
|
+ const float MinorTickHeight = ((MinorDivisions % 2 == 0) && (Step % (MinorDivisions / 2)) == 0) ? 6.0f : 2.0f;
|
|
|
+ const float MinorLinePx = RangeToScreen.InputToLocalX(CurrentMajorLine + Step * MajorGridStep / MinorDivisions);
|
|
|
+
|
|
|
+ LinePoints[0] = FVector2D(MinorLinePx, InArgs.bMirrorLabels ? 0.0f : FMath::Abs(InArgs.AllottedGeometry.Size.Y - MinorTickHeight));
|
|
|
+ LinePoints[1] = FVector2D(MinorLinePx, LinePoints[0].Y + MinorTickHeight);
|
|
|
+
|
|
|
+ // Draw each sub mark
|
|
|
+ FSlateDrawElement::MakeLines(
|
|
|
+ OutDrawElements,
|
|
|
+ InArgs.StartLayer,
|
|
|
+ PaintGeometry,
|
|
|
+ LinePoints,
|
|
|
+ InArgs.DrawEffects,
|
|
|
+ InArgs.TickColor,
|
|
|
+ bAntiAliasLines
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+int32 FEZAbleSliderController::DrawSelectionRange(const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FAbleScrubRangeToScreen& RangeToScreen, const FPaintPlaybackRangeArgs& Args) const
|
|
|
+{
|
|
|
+ TRange<double> SelectionRange = TimeSliderArgs.SelectionRange.Get() / GetTickResolution();
|
|
|
+
|
|
|
+ if (!SelectionRange.IsEmpty() && SelectionRange.HasLowerBound() && SelectionRange.HasUpperBound())
|
|
|
+ {
|
|
|
+ const float SelectionRangeL = RangeToScreen.InputToLocalX(SelectionRange.GetLowerBoundValue()) - 1;
|
|
|
+ const float SelectionRangeR = RangeToScreen.InputToLocalX(SelectionRange.GetUpperBoundValue()) + 1;
|
|
|
+ const auto DrawColor = FAppStyle::GetSlateColor("SelectionColor").GetColor(FWidgetStyle());
|
|
|
+
|
|
|
+ if (Args.SolidFillOpacity > 0.f)
|
|
|
+ {
|
|
|
+ FSlateDrawElement::MakeBox(
|
|
|
+ OutDrawElements,
|
|
|
+ LayerId + 1,
|
|
|
+ AllottedGeometry.ToPaintGeometry(FVector2f(SelectionRangeR - SelectionRangeL, AllottedGeometry.Size.Y), FSlateLayoutTransform(FVector2D(SelectionRangeL, 0.f))),
|
|
|
+ FAppStyle::GetBrush("WhiteBrush"),
|
|
|
+ ESlateDrawEffect::None,
|
|
|
+ DrawColor.CopyWithNewOpacity(Args.SolidFillOpacity)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ FSlateDrawElement::MakeBox(
|
|
|
+ OutDrawElements,
|
|
|
+ LayerId + 1,
|
|
|
+ AllottedGeometry.ToPaintGeometry(FVector2f(Args.BrushWidth, AllottedGeometry.Size.Y), FSlateLayoutTransform(FVector2D(SelectionRangeL, 0.f))),
|
|
|
+ Args.StartBrush,
|
|
|
+ ESlateDrawEffect::None,
|
|
|
+ DrawColor
|
|
|
+ );
|
|
|
+
|
|
|
+ FSlateDrawElement::MakeBox(
|
|
|
+ OutDrawElements,
|
|
|
+ LayerId + 1,
|
|
|
+ AllottedGeometry.ToPaintGeometry(FVector2f(Args.BrushWidth, AllottedGeometry.Size.Y), FSlateLayoutTransform(FVector2D(SelectionRangeR - Args.BrushWidth, 0.f))),
|
|
|
+ Args.EndBrush,
|
|
|
+ ESlateDrawEffect::None,
|
|
|
+ DrawColor
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ return LayerId + 1;
|
|
|
+}
|
|
|
+
|
|
|
+int32 FEZAbleSliderController::DrawPlaybackRange(const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FAbleScrubRangeToScreen& RangeToScreen, const FPaintPlaybackRangeArgs& Args) const
|
|
|
+{
|
|
|
+ if (!TimeSliderArgs.PlaybackRange.IsSet())
|
|
|
+ {
|
|
|
+ return LayerId;
|
|
|
+ }
|
|
|
+
|
|
|
+ const uint8 OpacityBlend = TimeSliderArgs.SubSequenceRange.Get().IsSet() ? 128 : 255;
|
|
|
+
|
|
|
+ TRange<FFrameNumber> PlaybackRange = TimeSliderArgs.PlaybackRange.Get();
|
|
|
+ FFrameRate TickResolution = GetTickResolution();
|
|
|
+ const float PlaybackRangeL = RangeToScreen.InputToLocalX(PlaybackRange.GetLowerBoundValue() / TickResolution);
|
|
|
+ const float PlaybackRangeR = RangeToScreen.InputToLocalX(PlaybackRange.GetUpperBoundValue() / TickResolution) - 1;
|
|
|
+
|
|
|
+ FSlateDrawElement::MakeBox(
|
|
|
+ OutDrawElements,
|
|
|
+ LayerId + 1,
|
|
|
+ AllottedGeometry.ToPaintGeometry(FVector2f(Args.BrushWidth, AllottedGeometry.Size.Y), FSlateLayoutTransform(FVector2D(PlaybackRangeL, 0.f))),
|
|
|
+ Args.StartBrush,
|
|
|
+ ESlateDrawEffect::None,
|
|
|
+ FColor(32, 128, 32, OpacityBlend) // 120, 75, 50 (HSV)
|
|
|
+ );
|
|
|
+
|
|
|
+ FSlateDrawElement::MakeBox(
|
|
|
+ OutDrawElements,
|
|
|
+ LayerId + 1,
|
|
|
+ AllottedGeometry.ToPaintGeometry(FVector2f(Args.BrushWidth, AllottedGeometry.Size.Y), FSlateLayoutTransform(FVector2D(PlaybackRangeR - Args.BrushWidth, 0.f))),
|
|
|
+ Args.EndBrush,
|
|
|
+ ESlateDrawEffect::None,
|
|
|
+ FColor(128, 32, 32, OpacityBlend) // 0, 75, 50 (HSV)
|
|
|
+ );
|
|
|
+
|
|
|
+ // Black tint for excluded regions
|
|
|
+ FSlateDrawElement::MakeBox(
|
|
|
+ OutDrawElements,
|
|
|
+ LayerId + 1,
|
|
|
+ AllottedGeometry.ToPaintGeometry(FVector2f(PlaybackRangeL, AllottedGeometry.Size.Y), FSlateLayoutTransform(FVector2D(0.f, 0.f))),
|
|
|
+ FAppStyle::GetBrush("WhiteBrush"),
|
|
|
+ ESlateDrawEffect::None,
|
|
|
+ FLinearColor::Black.CopyWithNewOpacity(0.3f * OpacityBlend / 255.f)
|
|
|
+ );
|
|
|
+
|
|
|
+ FSlateDrawElement::MakeBox(
|
|
|
+ OutDrawElements,
|
|
|
+ LayerId + 1,
|
|
|
+ AllottedGeometry.ToPaintGeometry(FVector2f(AllottedGeometry.Size.X - PlaybackRangeR, AllottedGeometry.Size.Y), FSlateLayoutTransform(FVector2D(PlaybackRangeR, 0.f))),
|
|
|
+ FAppStyle::GetBrush("WhiteBrush"),
|
|
|
+ ESlateDrawEffect::None,
|
|
|
+ FLinearColor::Black.CopyWithNewOpacity(0.3f * OpacityBlend / 255.f)
|
|
|
+ );
|
|
|
+
|
|
|
+ return LayerId + 1;
|
|
|
+}
|
|
|
+
|
|
|
+int32 FEZAbleSliderController::OnPaintTimeSlider(bool bMirrorLabels, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
|
|
|
+{
|
|
|
+ const bool bEnabled = bParentEnabled;
|
|
|
+ const ESlateDrawEffect DrawEffects = bEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect;
|
|
|
+
|
|
|
+ const TRange<double> LocalViewRange = TimeSliderArgs.ViewRange.Get();
|
|
|
+ const float LocalViewRangeMin = static_cast<float>(LocalViewRange.GetLowerBoundValue());
|
|
|
+ const float LocalViewRangeMax = static_cast<float>(LocalViewRange.GetUpperBoundValue());
|
|
|
+ const float LocalSequenceLength = LocalViewRangeMax - LocalViewRangeMin;
|
|
|
+ const TRange<FFrameNumber> LocalPlaybackRange = TimeSliderArgs.PlaybackRange.Get();
|
|
|
+
|
|
|
+ if (LocalSequenceLength > 0)
|
|
|
+ {
|
|
|
+ FAbleScrubRangeToScreen RangeToScreen(LocalViewRange, AllottedGeometry.Size);
|
|
|
+
|
|
|
+ // draw tick marks
|
|
|
+ constexpr float MajorTickHeight = 9.0f;
|
|
|
+
|
|
|
+ FDrawAbleTickArgs Args;
|
|
|
+ {
|
|
|
+ Args.AllottedGeometry = AllottedGeometry;
|
|
|
+ Args.bMirrorLabels = bMirrorLabels;
|
|
|
+ Args.bOnlyDrawMajorTicks = false;
|
|
|
+ Args.TickColor = FLinearColor::White;
|
|
|
+ Args.CullingRect = MyCullingRect;
|
|
|
+ Args.DrawEffects = DrawEffects;
|
|
|
+ Args.StartLayer = LayerId;
|
|
|
+ Args.TickOffset = bMirrorLabels ? 0.0f : FMath::Abs(static_cast<float>(AllottedGeometry.Size.Y) - MajorTickHeight);
|
|
|
+ Args.MajorTickHeight = MajorTickHeight;
|
|
|
+ }
|
|
|
+
|
|
|
+ DrawTicks(OutDrawElements, LocalViewRange, RangeToScreen, Args);
|
|
|
+
|
|
|
+ // draw playback & selection range
|
|
|
+ FPaintPlaybackRangeArgs PlaybackRangeArgs(
|
|
|
+ bMirrorLabels ? FAppStyle::GetBrush("Sequencer.Timeline.PlayRange_Bottom_L") : FAppStyle::GetBrush("Sequencer.Timeline.PlayRange_Top_L"),
|
|
|
+ bMirrorLabels ? FAppStyle::GetBrush("Sequencer.Timeline.PlayRange_Bottom_R") : FAppStyle::GetBrush("Sequencer.Timeline.PlayRange_Top_R"),
|
|
|
+ 6.f
|
|
|
+ );
|
|
|
+
|
|
|
+ LayerId = DrawPlaybackRange(AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, RangeToScreen, PlaybackRangeArgs);
|
|
|
+
|
|
|
+ PlaybackRangeArgs.SolidFillOpacity = 0.05f;
|
|
|
+ LayerId = DrawSelectionRange(AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, RangeToScreen, PlaybackRangeArgs);
|
|
|
+
|
|
|
+ LayerId = DrawEditableTimes(AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, RangeToScreen);
|
|
|
+
|
|
|
+ // Draw the scrub handle
|
|
|
+ const float HandleStart = RangeToScreen.InputToLocalX(TimeSliderArgs.ScrubPosition.Get().AsDecimal() / GetTickResolution().AsDecimal()) - 7.0f;
|
|
|
+ const float HandleEnd = HandleStart + 13.0f;
|
|
|
+
|
|
|
+ const int32 ArrowLayer = LayerId + 2;
|
|
|
+ FPaintGeometry MyGeometry = AllottedGeometry.ToPaintGeometry(FVector2f(HandleEnd - HandleStart, AllottedGeometry.Size.Y), FSlateLayoutTransform(FVector2f(HandleStart, 0.f)));
|
|
|
+ FLinearColor ScrubColor = InWidgetStyle.GetColorAndOpacityTint();
|
|
|
+ {
|
|
|
+ ScrubColor.A = ScrubColor.A * 0.75f;
|
|
|
+ ScrubColor.B *= 0.1f;
|
|
|
+ ScrubColor.G *= 0.2f;
|
|
|
+ }
|
|
|
+
|
|
|
+ const FSlateBrush* Brush = (bMirrorLabels ? ScrubHandleUpBrush : ScrubHandleDownBrush);
|
|
|
+
|
|
|
+ FSlateDrawElement::MakeBox(
|
|
|
+ OutDrawElements,
|
|
|
+ ArrowLayer,
|
|
|
+ MyGeometry,
|
|
|
+ Brush,
|
|
|
+ DrawEffects,
|
|
|
+ ScrubColor
|
|
|
+ );
|
|
|
+
|
|
|
+ {
|
|
|
+ // Draw the current time next to the scrub handle
|
|
|
+ FString FrameString = TimeSliderArgs.NumericTypeInterface->ToString(TimeSliderArgs.ScrubPosition.Get().GetFrame().Value);
|
|
|
+
|
|
|
+ if (GetDefault<UPersonaOptions>()->bTimelineDisplayFormatSecondary)
|
|
|
+ {
|
|
|
+ // @TODO: need another numeric type interface??
|
|
|
+ FString SecondaryString = SecondaryNumericTypeInterface->ToString(TimeSliderArgs.ScrubPosition.Get().GetFrame().Value);
|
|
|
+ FrameString += TEXT(" (") + SecondaryString + TEXT(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (GetDefault<UPersonaOptions>()->bTimelineDisplayPercentage)
|
|
|
+ {
|
|
|
+ double Percentage = FMath::Clamp(TimeSliderArgs.ScrubPosition.Get().AsDecimal() / FFrameTime(LocalPlaybackRange.Size<FFrameNumber>()).AsDecimal(), 0.0, 1.0);
|
|
|
+ FNumberFormattingOptions Options;
|
|
|
+ Options.MaximumFractionalDigits = 2;
|
|
|
+ FrameString += TEXT(" (") + FText::AsPercent(Percentage, &Options).ToString() + TEXT(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ FSlateFontInfo SmallLayoutFont = FCoreStyle::GetDefaultFontStyle("Regular", 10);
|
|
|
+
|
|
|
+ const TSharedRef< FSlateFontMeasure > FontMeasureService = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();
|
|
|
+ const FVector2D TextSize = FontMeasureService->Measure(FrameString, SmallLayoutFont);
|
|
|
+
|
|
|
+ // Flip the text position if getting near the end of the view range
|
|
|
+ constexpr float TextOffsetPx = 2.f;
|
|
|
+ const bool bDrawLeft = (static_cast<float>(AllottedGeometry.Size.X) - HandleEnd) < (TextSize.X + 14.f) - TextOffsetPx;
|
|
|
+ const float TextPosition = bDrawLeft ? HandleStart - static_cast<float>(TextSize.X) - TextOffsetPx : HandleEnd + TextOffsetPx;
|
|
|
+
|
|
|
+ FVector2D TextOffset(TextPosition, Args.bMirrorLabels ? TextSize.Y - 6.f : Args.AllottedGeometry.Size.Y - (Args.MajorTickHeight + TextSize.Y));
|
|
|
+
|
|
|
+ FSlateDrawElement::MakeText(
|
|
|
+ OutDrawElements,
|
|
|
+ Args.StartLayer + 1,
|
|
|
+ Args.AllottedGeometry.ToPaintGeometry(TextSize, FSlateLayoutTransform(TextOffset)),
|
|
|
+ FrameString,
|
|
|
+ SmallLayoutFont,
|
|
|
+ Args.DrawEffects,
|
|
|
+ Args.TickColor
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+// if (MouseDragType == DRAG_SETTING_RANGE)
|
|
|
+// {
|
|
|
+// FFrameRate Resolution = GetTickResolution();
|
|
|
+// FFrameTime MouseDownTime[2];
|
|
|
+//
|
|
|
+// FScrubRangeToScreen MouseDownRange(TimeSliderArgs.ViewRange.Get(), MouseDownGeometry.Size);
|
|
|
+// MouseDownTime[0] = ComputeFrameTimeFromMouse(MouseDownGeometry, MouseDownPosition[0], MouseDownRange);
|
|
|
+// MouseDownTime[1] = ComputeFrameTimeFromMouse(MouseDownGeometry, MouseDownPosition[1], MouseDownRange);
|
|
|
+//
|
|
|
+// float MouseStartPosX = RangeToScreen.InputToLocalX(MouseDownTime[0] / Resolution);
|
|
|
+// float MouseEndPosX = RangeToScreen.InputToLocalX(MouseDownTime[1] / Resolution);
|
|
|
+//
|
|
|
+// float RangePosX = MouseStartPosX < MouseEndPosX ? MouseStartPosX : MouseEndPosX;
|
|
|
+// float RangeSizeX = FMath::Abs(MouseStartPosX - MouseEndPosX);
|
|
|
+//
|
|
|
+// FSlateDrawElement::MakeBox(
|
|
|
+// OutDrawElements,
|
|
|
+// LayerId + 1,
|
|
|
+// AllottedGeometry.ToPaintGeometry(FVector2f(RangeSizeX, AllottedGeometry.Size.Y), FSlateLayoutTransform(FVector2f(RangePosX, 0.f))),
|
|
|
+// bMirrorLabels ? ScrubHandleDownBrush : ScrubHandleUpBrush,
|
|
|
+// DrawEffects,
|
|
|
+// MouseStartPosX < MouseEndPosX ? FLinearColor(0.5f, 0.5f, 0.5f) : FLinearColor(0.25f, 0.3f, 0.3f)
|
|
|
+// );
|
|
|
+// }
|
|
|
+
|
|
|
+ return ArrowLayer;
|
|
|
+ }
|
|
|
+
|
|
|
+ return LayerId;
|
|
|
+}
|
|
|
+
|
|
|
+int32 FEZAbleSliderController::OnPaintViewArea(const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, bool bEnabled, const FPaintViewAreaArgs& Args) const
|
|
|
+{
|
|
|
+ const ESlateDrawEffect DrawEffects = bEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect;
|
|
|
+
|
|
|
+ TRange<double> LocalViewRange = TimeSliderArgs.ViewRange.Get();
|
|
|
+ FAbleScrubRangeToScreen RangeToScreen(LocalViewRange, AllottedGeometry.Size);
|
|
|
+
|
|
|
+ if (Args.PlaybackRangeArgs.IsSet())
|
|
|
+ {
|
|
|
+ FPaintPlaybackRangeArgs PaintArgs = Args.PlaybackRangeArgs.GetValue();
|
|
|
+ LayerId = DrawPlaybackRange(AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, RangeToScreen, PaintArgs);
|
|
|
+ PaintArgs.SolidFillOpacity = 0.2f;
|
|
|
+ LayerId = DrawSelectionRange(AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, RangeToScreen, PaintArgs);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Args.bDisplayTickLines)
|
|
|
+ {
|
|
|
+ static FLinearColor TickColor(0.1f, 0.1f, 0.1f, 0.3f);
|
|
|
+
|
|
|
+ // Draw major tick lines in the section area
|
|
|
+ FDrawAbleTickArgs DrawTickArgs;
|
|
|
+ {
|
|
|
+ DrawTickArgs.AllottedGeometry = AllottedGeometry;
|
|
|
+ DrawTickArgs.bMirrorLabels = false;
|
|
|
+ DrawTickArgs.bOnlyDrawMajorTicks = true;
|
|
|
+ DrawTickArgs.TickColor = TickColor;
|
|
|
+ DrawTickArgs.CullingRect = MyCullingRect;
|
|
|
+ DrawTickArgs.DrawEffects = DrawEffects;
|
|
|
+ // Draw major ticks under sections
|
|
|
+ DrawTickArgs.StartLayer = LayerId - 1;
|
|
|
+ // Draw the tick the entire height of the section area
|
|
|
+ DrawTickArgs.TickOffset = 0.0f;
|
|
|
+ DrawTickArgs.MajorTickHeight = static_cast<float>(AllottedGeometry.Size.Y);
|
|
|
+ }
|
|
|
+
|
|
|
+ DrawTicks(OutDrawElements, LocalViewRange, RangeToScreen, DrawTickArgs);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Args.bDisplayScrubPosition)
|
|
|
+ {
|
|
|
+ // Draw a line for the scrub position
|
|
|
+ const float LinePos = RangeToScreen.InputToLocalX(TimeSliderArgs.ScrubPosition.Get().AsDecimal() / GetTickResolution().AsDecimal());
|
|
|
+
|
|
|
+ TArray<FVector2D> LinePoints;
|
|
|
+ {
|
|
|
+ LinePoints.AddUninitialized(2);
|
|
|
+ LinePoints[0] = FVector2D(0.0f, 0.0f);
|
|
|
+ LinePoints[1] = FVector2D(0.0f, FMath::FloorToFloat(AllottedGeometry.Size.Y));
|
|
|
+ }
|
|
|
+
|
|
|
+ FSlateDrawElement::MakeLines(
|
|
|
+ OutDrawElements,
|
|
|
+ LayerId + 1,
|
|
|
+ AllottedGeometry.ToPaintGeometry(FVector2f(1.0f, 1.0f), FSlateLayoutTransform(FVector2f(LinePos, 0.0f))),
|
|
|
+ LinePoints,
|
|
|
+ DrawEffects,
|
|
|
+ FLinearColor(1.f, 1.f, 1.f, .5f),
|
|
|
+ false
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ //TSharedPtr<FAnimModel> AnimModel = WeakModel.Pin();
|
|
|
+// if (AnimModel.IsValid())
|
|
|
+// {
|
|
|
+ const FLinearColor LineColor = GetDefault<UPersonaOptions>()->SectionTimingNodeColor;
|
|
|
+
|
|
|
+ // Draw all the times that we can drag in the timeline
|
|
|
+ TArray<double> EditableTimes = {0,1,2,3,4,5,6,7,8,9,10};
|
|
|
+
|
|
|
+ for (double Time : EditableTimes)
|
|
|
+ {
|
|
|
+ const float LinePos = RangeToScreen.InputToLocalX(Time);
|
|
|
+
|
|
|
+ TArray<FVector2D> LinePoints;
|
|
|
+ {
|
|
|
+ LinePoints.AddUninitialized(2);
|
|
|
+ LinePoints[0] = FVector2D(0.0f, 0.0f);
|
|
|
+ LinePoints[1] = FVector2D(0.0f, FMath::FloorToFloat(AllottedGeometry.Size.Y));
|
|
|
+ }
|
|
|
+
|
|
|
+ FSlateDrawElement::MakeLines(
|
|
|
+ OutDrawElements,
|
|
|
+ LayerId + 1,
|
|
|
+ AllottedGeometry.ToPaintGeometry(FVector2f(1.0f, 1.0f), FSlateLayoutTransform(FVector2f(LinePos, 0.0f))),
|
|
|
+ LinePoints,
|
|
|
+ DrawEffects,
|
|
|
+ LineColor,
|
|
|
+ false
|
|
|
+ );
|
|
|
+ }
|
|
|
+// }
|
|
|
+
|
|
|
+ return LayerId;
|
|
|
+}
|
|
|
+
|
|
|
+FReply FEZAbleSliderController::OnMouseButtonDown(SWidget& WidgetOwner, const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
|
+{
|
|
|
+ return FReply::Handled();
|
|
|
+}
|
|
|
+
|
|
|
+FReply FEZAbleSliderController::OnMouseButtonUp(SWidget& WidgetOwner, const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
|
+{
|
|
|
+ return FReply::Handled();
|
|
|
+}
|
|
|
+
|
|
|
+FReply FEZAbleSliderController::OnMouseMove(SWidget& WidgetOwner, const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
|
+{
|
|
|
+ return FReply::Handled();
|
|
|
+}
|
|
|
+
|
|
|
+FReply FEZAbleSliderController::OnMouseWheel(SWidget& WidgetOwner, const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
|
+{
|
|
|
+ return FReply::Handled();
|
|
|
+}
|
|
|
+
|
|
|
+int32 FEZAbleSliderController::DrawEditableTimes(const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FAbleScrubRangeToScreen& RangeToScreen) const
|
|
|
+{
|
|
|
+ const FLinearColor TimeColor(255,255,255,0.5); //= GetDefault<UPersonaOptions>()->SectionTimingNodeColor;
|
|
|
+
|
|
|
+ // Draw all the times that we can drag in the timeline
|
|
|
+ TArray<double> EditableTimes = {0};
|
|
|
+ for (double Time : EditableTimes) // WeakModel.Pin()->GetEditableTimes()
|
|
|
+ {
|
|
|
+ const float LinePos = RangeToScreen.InputToLocalX(Time);
|
|
|
+
|
|
|
+ FSlateDrawElement::MakeBox(
|
|
|
+ OutDrawElements,
|
|
|
+ LayerId + 1,
|
|
|
+ AllottedGeometry.ToPaintGeometry(FVector2f(11.0f, 12.0f), FSlateLayoutTransform(FVector2f(LinePos - 6.0f, AllottedGeometry.Size.Y - 12.0f))),
|
|
|
+ EditableTimeBrush,
|
|
|
+ ESlateDrawEffect::None,
|
|
|
+ TimeColor
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ return LayerId + 1;
|
|
|
+}
|
|
|
+
|
|
|
+
|