// Copyright Epic Games, Inc. All Rights Reserved. #include "LocateBy.h" #include "Locators/SlateWidgetLocatorByDelegate.h" #include "Locators/SlateWidgetLocatorByPath.h" #include "AutomationDriverTypeDefs.h" #include "Framework/Application/SlateApplication.h" TSharedRef By::Delegate(const FLocateSlateWidgetElementDelegate& Value) { return FSlateWidgetLocatorByDelegateFactory::Create(Value); } TSharedRef By::Delegate(const FLocateSlateWidgetPathElementDelegate& Value) { return FSlateWidgetLocatorByDelegateFactory::Create(Value); } TSharedRef By::WidgetLambda(const TFunction>&)>& Value) { return FSlateWidgetLocatorByDelegateFactory::Create(FLocateSlateWidgetElementDelegate::CreateLambda(Value)); } TSharedRef By::WidgetPathLambda(const TFunction&)>& Value) { return FSlateWidgetLocatorByDelegateFactory::Create(FLocateSlateWidgetPathElementDelegate::CreateLambda(Value)); } TSharedRef By::Id(const FString& Value) { return FSlateWidgetLocatorByPathFactory::Create(TEXT("#") + Value); } TSharedRef By::Id(const FDriverElementRef& Root, const FString& Value) { return FSlateWidgetLocatorByPathFactory::Create(Root, TEXT("#") + Value); } TSharedRef By::Id(const FName& Value) { return FSlateWidgetLocatorByPathFactory::Create(TEXT("#") + Value.ToString()); } TSharedRef By::Id(const FDriverElementRef& Root, const FName& Value) { return FSlateWidgetLocatorByPathFactory::Create(Root, TEXT("#") + Value.ToString()); } TSharedRef By::Id(const TCHAR* Value) { return FSlateWidgetLocatorByPathFactory::Create(FString(TEXT("#")) + Value); } TSharedRef By::Id(const FDriverElementRef& Root, const TCHAR* Value) { return FSlateWidgetLocatorByPathFactory::Create(Root, FString(TEXT("#")) + Value); } TSharedRef By::Id(const char* Value) { return FSlateWidgetLocatorByPathFactory::Create(FString(TEXT("#")) + Value); } TSharedRef By::Id(const FDriverElementRef& Root, const char* Value) { return FSlateWidgetLocatorByPathFactory::Create(Root, FString(TEXT("#")) + Value); } TSharedRef By::Path(const FString& Value) { return FSlateWidgetLocatorByPathFactory::Create(Value); } TSharedRef By::Path(const FDriverElementRef& Root, const FString& Value) { return FSlateWidgetLocatorByPathFactory::Create(Root, Value); } TSharedRef By::Path(const FName& Value) { return FSlateWidgetLocatorByPathFactory::Create(Value.ToString()); } TSharedRef By::Path(const FDriverElementRef& Root, const FName& Value) { return FSlateWidgetLocatorByPathFactory::Create(Root, Value.ToString()); } TSharedRef By::Path(const TCHAR* Value) { return FSlateWidgetLocatorByPathFactory::Create(Value); } TSharedRef By::Path(const FDriverElementRef& Root, const TCHAR* Value) { return FSlateWidgetLocatorByPathFactory::Create(Root, Value); } TSharedRef By::Path(const char* Value) { return FSlateWidgetLocatorByPathFactory::Create(Value); } TSharedRef By::Path(const FDriverElementRef& Root, const char* Value) { return FSlateWidgetLocatorByPathFactory::Create(Root, Value); } TSharedRef By::Cursor() { return By::WidgetPathLambda([](TArray& OutWidgetPaths) -> void { TArray> Windows; FSlateApplication::Get().GetAllVisibleWindowsOrdered(Windows); FWidgetPath WidgetPath = FSlateApplication::Get().LocateWindowUnderMouse(FSlateApplication::Get().GetCursorPos(), Windows); if (WidgetPath.IsValid()) { OutWidgetPaths.Add(WidgetPath); } }); }