I’m so confused by this. When pushing (opening) an IMenu in Slate, an open animation can be specified. This is true in editor as well, all popup menus could have slick open animations. But they don’t, because “bMenuAnimationsEnabled” is disabled in FSlateApplication.
Now, at first I thought there is a setting for this in editor preferences but it turns out there is none. So popup animations exist, but they are simply not used. Why?
// Example of opening a popup menu in editor
// Notice there is a popup transition effect param
ParamsViewerMenu = FSlateApplication::Get().PushMenu(
AsShared(),
FWidgetPath(),
ParamsViewerWidget.ToSharedRef(),
PopupPosition,
FPopupTransitionEffect(FPopupTransitionEffect::ContextMenu),
false
);
I can easily re-enable these popup animations from C++ via FSlateApplication::Get().EnableMenuAnimations(true);.
However, once I enabled them I saw that some of the popups are glitchy as if they are configured to use an incorrect animation. For example combo boxes open their menu below the widget, but the engine uses a “fly in from below” animation with an upwards motion, so it looks pretty bad. I don’t think this was done intentionally either, more like it was simply not tested because nobody uses the editor with popup animations enabled?
Again, I’m really confused by this.
Does anyone have any insights as to why menu animations are disabled? Did this just get lost during engine development, or what happened?
Turns out this has been deprecated. Not sure why they say its no-op, because it still works.
UE_DEPRECATED(5.0, "Enable Window Animations is no longer used and is a no-op so calling this function is no longer necessary.")
SLATE_API void EnableMenuAnimations( const bool bEnableAnimations );
Found some more info in FMenuStack::PushNewWindow where the animations were used to be started. I’m kind of disappointed this has been deprecated.
// Kick off the intro animation!
// @todo: Anims aren't supported or attempted - this is legacy code left in in case we reinstate menu anims
if (InPrePushResults.bAllowAnimations)
{
FCurveSequence Sequence;
Sequence.AddCurve(0, FMenuStackDefs::AnimationDuration, ECurveEaseFunction::CubicOut);
NewMenuWindow->MorphToPosition(Sequence, TargetWindowOpacity, InPrePushResults.AnimFinalLocation);
}
And finally, in case anyone is curious you can apply animations to your popup menus like this. You can also find the original popup transitions properties in MenuStack.
ParamsViewerMenu = FSlateApplication::Get().PushMenu(
AsShared(),
FWidgetPath(),
ParamsViewerWidget.ToSharedRef(),
PopupPosition,
FPopupTransitionEffect(FPopupTransitionEffect::None), // transition effects are deprecated
false
);
if (FSlateApplication::Get().IsRunningAtTargetFrameRate())
{
TSharedPtr<SWindow> ParamsViewerWindow = ParamsViewerMenu->GetOwnedWindow();
// Offset the window down a bit immediately.
// We do this after creating the window because the window pos
// may be modified to fit on the screen.
const FVector2f WindowPos = ParamsViewerWindow->GetPositionInScreen();
ParamsViewerWindow->MoveWindowTo(WindowPos + FVector2f::UnitY() * 20.0f);
// Animate it back to the original position.
FCurveSequence Sequence;
Sequence.AddCurve(0, 0.15f, ECurveEaseFunction::CubicOut);
ParamsViewerWindow->MorphToPosition(Sequence, 1.0f, WindowPos);
}