Extend TabFactories and LayoutExtender, only open the tab window when manually clicking in the menu.

Hello,

I hope to extend FAnimationEditorMode so that when entering the animation editor, a custom tab window can be opened, and the tab can be placed in a specified layout position.

I tried binding the callbacks `PersonaModule.OnRegisterTabs()` and `PersonaModule.OnRegisterLayoutExtensions()`. Below is my simple implementation scheme:

const FName AnimationXXXToolTabs::AnimationXXXTool(TEXT("AnimationXXXToolTab"));
 
 
 
void UAnimationXXXTabExtender::OnRegisterTabs(FWorkflowAllowedTabSet& TabFactories, TSharedPtr<FAssetEditorToolkit> InHostingApp)
 
{
 
  TSharedRef<IAnimationEditor> AnimationEditor = StaticCastSharedRef<IAnimationEditor>(InHostingApp.ToSharedRef());
 
 
 
  TabFactories.RegisterFactory(MakeShareable(new FAnimationXXXTabSummoner(InHostingApp, AnimationEditor->GetPersonaToolkit()->GetPreviewScene())));
 
}
 
 
 
 
 
void UAnimationXXXTabExtender::OnRegisterLayoutExtensions(FLayoutExtender& LayoutExtender)
 
{
 
  //LayoutExtender.ExtendLayout(AnimationEditorTabs_AdvancedPreviewTab, ELayoutExtensionPosition::After, FTabManager::FTab(AnimationXXXToolTabs::AnimationXXXTool, ETabState::OpenedTab));
 
  LayoutExtender.ExtendStack(AnimationEditorTabs_AdvancedPreviewTab, ELayoutExtensionPosition::Below, FTabManager::FTab(AnimationXXXToolTabs::AnimationXXXTool, ETabState::OpenedTab));
 
}
 
 
 
 
 
FAnimationXXXTabSummoner::FAnimationXXXTabSummoner(TSharedPtr<class FAssetEditorToolkit> InHostingApp, const TSharedRef<class IPersonaPreviewScene>& InPreviewScene)
 
  : FWorkflowTabFactory(AnimationXXXToolTabs::AnimationXXXTool, InHostingApp)
 
  , PreviewScene(InPreviewScene)
 
{
 
  TabLabel = INVTEXT("Animation XXX Tool Tab");
 
  TabIcon = FSlateIcon(FAppStyle::GetAppStyleSetName(), "Persona.Tabs.AnimCurveMetadataEditor");
 
  bIsSingleton = true;
 
 
 
  ViewMenuDescription = INVTEXT("Animation XXX Tool Tab");
 
  ViewMenuTooltip = INVTEXT("Shows the Animation XXX Tool Tab.");
 
 
 
}

However, when testing, I found that when I open the animation asset, my customized tab window does not open automatically and shows an error: `LogSlate: The tab “AnimationXXXTool_Dock” attempted to spawn in layout ‘Standalone_AnimationEditor_Layout_v1.5’ but failed for some reason. It will not be displayed.` I can only find the tab window name in the menu and open it manually, and its position is not in the layout I specified.

I hope that when I open the animation asset, my customized tab window can open automatically and be correctly placed in the layout I specified. Could it be that my extension method is incorrect? Or did I miss some steps?

Thank you.

For persona based editors, to add a new tab to the top level of the FWorkflowCentricApplication, take a look at the FApplicationMode and its usage in the application class. The tabs added would be owned by that mode, and should work better with the layout. If that doesn’t work, let us know.

Hi,

From what I can see, your extension pattern should work and similar extensions are used in the editor.

If you look atEngine\Source\Editor\SequenceRecorder\Private\SequenceRecorderModule.cpp for example, the “Recording Settings” tab also hooks into PersonaModule.OnRegisterTabs() and PersonaModule.OnRegisterLayoutExtensions(). The difference seems to be that they use InExtender.ExtendLayout instead of LayoutExtender.ExtendStack from your example, but if you open any persona editor you can see the “Recording Settings” tab show up properly. This is true even if I set the default value to ETabState::OpenedTab.

Could it maybe be an issue with your layout file? You could try a reset to default or to delete the file completely. Otherwise hopefully you should be able to compare your code path with the how the sequencer tab does it to see how things are different. I would also double check that the tab name you provide to the extender matches other places like the factory.

Let me know how that goes.

Thanks,

Aditya Ravi Chandran

Hi, thanks for your reply!

The reason I chose this solution is because I read the file AnimationEditorMode.cpp, and I hope to complete the extension without modifying the engine source code. Are you saying that I must modify the source code?

Thank you.​