Files
UnrealEngineUWP/Engine/Source/Editor/UMGEditor/Private/Designer/SDisappearingBar.cpp
Ben Marsh 20bf0eb6a1 Updating copyright notices to 2017 (copying from //Tasks/UE4/Dev-Copyright-2017).
#rb none
#lockdown Nick.Penwarden

[CL 3226823 by Ben Marsh in Main branch]
2016-12-08 08:52:44 -05:00

59 lines
1.3 KiB
C++

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "Designer/SDisappearingBar.h"
#define LOCTEXT_NAMESPACE "UMG"
/////////////////////////////////////////////////////
// SDisappearingBar
void SDisappearingBar::Construct(const FArguments& InArgs)
{
FadeCurve = FCurveSequence(0, 0.25f);
ColorAndOpacity = TAttribute<FLinearColor>::Create(TAttribute<FLinearColor>::FGetter::CreateSP(this, &SDisappearingBar::GetFadeColorAndOpacity));
ChildSlot
[
InArgs._Content.Widget
];
}
void SDisappearingBar::OnDragEnter( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent )
{
if ( !FadeCurve.IsAtEnd() )
{
// Play the curve forward to fade the bar out
if ( FadeCurve.IsInReverse() && FadeCurve.IsPlaying() )
{
FadeCurve.Reverse();
}
else if ( !FadeCurve.IsPlaying() )
{
FadeCurve.Play( this->AsShared() );
}
}
}
void SDisappearingBar::OnDragLeave( const FDragDropEvent& DragDropEvent )
{
if ( !FadeCurve.IsAtStart() )
{
// Play the curve in reverse to fade the bar back in
if ( !FadeCurve.IsInReverse() && FadeCurve.IsPlaying() )
{
FadeCurve.Reverse();
}
else if ( !FadeCurve.IsPlaying() )
{
FadeCurve.PlayReverse( this->AsShared() );
}
}
}
FLinearColor SDisappearingBar::GetFadeColorAndOpacity() const
{
return FLinearColor(1, 1, 1, 1 - FadeCurve.GetLerp());
}
#undef LOCTEXT_NAMESPACE