void PushMenu(TSharedRef<FMenuBase> InMenu, const FVector2D& InLocation) { check(InMenu->GetContent().IsValid()); TSharedPtr<SWindow> ParentWindow = InMenu->GetParentWindow(); check(ParentWindow.IsValid()); // Transform InLocation into a position local to this panel (assumes the panel is in an overlay that covers the whole of the panel window) FVector2D PanelInScreen = ParentWindow->GetRectInScreen().GetTopLeft(); FVector2D PanelInWindow = ParentWindow->GetLocalToScreenTransform().Inverse().TransformPoint(PanelInScreen); FVector2D LocationInWindow = ParentWindow->GetLocalToScreenTransform().Inverse().TransformPoint(InLocation); FVector2D LocationInPanel = LocationInWindow - PanelInWindow; // Add the new menu into a slot on this panel and set the padding so that its position is correct AddSlot() .HAlign(HAlign_Left) .VAlign(VAlign_Top) .Padding(LocationInPanel.X, LocationInPanel.Y, 0, 0) [ InMenu->GetContent().ToSharedRef() ]; // Make sure that the menu will remove itself from the panel when dismissed InMenu->GetOnMenuDismissed().AddSP(this, &SMenuPanel::OnMenuClosed); }
virtual void InvokeSizeMapTab(const TArray<FName>& AssetPackageNames) override { TSharedRef<SDockTab> NewTab = FGlobalTabmanager::Get()->InvokeTab( SizeMapTabId ); TSharedRef<SSizeMap> SizeMap = StaticCastSharedRef<SSizeMap>( NewTab->GetContent() ); SizeMap->SetRootAssetPackageNames( AssetPackageNames ); }
virtual void InvokeReferenceViewerTab(const TArray<FName>& GraphRootPackageNames) override { TSharedRef<SDockTab> NewTab = FGlobalTabmanager::Get()->InvokeTab( ReferenceViewerTabId ); TSharedRef<SReferenceViewer> ReferenceViewer = StaticCastSharedRef<SReferenceViewer>( NewTab->GetContent() ); ReferenceViewer->SetGraphRootPackageNames(GraphRootPackageNames); }
void OnMenuClosed(TSharedRef<IMenu> InMenu) { RemoveSlot(InMenu->GetContent().ToSharedRef()); }