123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- #pragma once
- #include "CoreMinimal.h"
- #include "Layout/Visibility.h"
- #include "Input/Reply.h"
- #include "Widgets/DeclarativeSyntaxSupport.h"
- #include "Widgets/SCompoundWidget.h"
- #include "SWebInterfaceBrowserView.h"
- class IWebInterfaceBrowserAdapter;
- class IWebInterfaceBrowserDialog;
- class IWebInterfaceBrowserWindow;
- class SEditableTextBox;
- struct FWebNavigationRequest;
- enum class EWebInterfaceBrowserDialogEventResponse;
- DECLARE_DELEGATE_RetVal(bool, FOnSuppressContextMenu);
- class WEBBROWSERUI_API SWebInterfaceBrowser
- : public SCompoundWidget
- {
- public:
- DECLARE_DELEGATE_RetVal_TwoParams(bool, FOnBeforeBrowse, const FString&, const FWebNavigationRequest& )
- DECLARE_DELEGATE_RetVal_ThreeParams(bool, FOnLoadUrl, const FString& , const FString& , FString& )
- DECLARE_DELEGATE_RetVal_OneParam(EWebInterfaceBrowserDialogEventResponse, FOnShowDialog, const TWeakPtr<IWebInterfaceBrowserDialog>&);
- DECLARE_DELEGATE_RetVal_OneParam(bool, FOnDragWindow, const FPointerEvent& );
- SLATE_BEGIN_ARGS(SWebInterfaceBrowser)
- : _InitialURL(TEXT("https://www.google.com"))
- , _ShowControls(true)
- , _ShowAddressBar(false)
- , _ShowErrorMessage(true)
- , _SupportsTransparency(false)
- , _SupportsThumbMouseButtonNavigation(true)
- , _ShowInitialThrobber(true)
- , _BackgroundColor(255,255,255,255)
- , _BrowserFrameRate(24)
- , _PopupMenuMethod(TOptional<EPopupMethod>())
- , _ViewportSize(FVector2D::ZeroVector)
- { }
-
- SLATE_ARGUMENT(TSharedPtr<SWindow>, ParentWindow)
-
- SLATE_ARGUMENT(FString, InitialURL)
-
- SLATE_ARGUMENT(TOptional<FString>, ContentsToLoad)
-
- SLATE_ARGUMENT(bool, ShowControls)
-
- SLATE_ARGUMENT(bool, ShowAddressBar)
-
- SLATE_ARGUMENT(bool, ShowErrorMessage)
-
- SLATE_ARGUMENT(bool, SupportsTransparency)
-
- SLATE_ARGUMENT(bool, SupportsThumbMouseButtonNavigation)
-
- SLATE_ARGUMENT(bool, ShowInitialThrobber)
-
- SLATE_ARGUMENT(FColor, BackgroundColor)
-
- SLATE_ARGUMENT(int , BrowserFrameRate)
-
- SLATE_ARGUMENT(TOptional<EPopupMethod>, PopupMenuMethod)
-
- SLATE_ATTRIBUTE(FVector2D, ViewportSize);
-
- SLATE_EVENT(FSimpleDelegate, OnLoadCompleted)
-
- SLATE_EVENT(FSimpleDelegate, OnLoadError)
-
- SLATE_EVENT(FSimpleDelegate, OnLoadStarted)
-
- SLATE_EVENT(FOnTextChanged, OnTitleChanged)
-
- SLATE_EVENT(FOnTextChanged, OnUrlChanged)
-
- SLATE_EVENT(FOnBeforePopupDelegate, OnBeforePopup)
-
- SLATE_EVENT(FOnCreateWindowDelegate, OnCreateWindow)
-
- SLATE_EVENT(FOnCloseWindowDelegate, OnCloseWindow)
-
- SLATE_EVENT(FOnBeforeBrowse, OnBeforeNavigation)
-
- SLATE_EVENT(FOnLoadUrl, OnLoadUrl)
-
- SLATE_EVENT(FOnShowDialog, OnShowDialog)
-
- SLATE_EVENT(FSimpleDelegate, OnDismissAllDialogs)
- SLATE_EVENT(FOnSuppressContextMenu, OnSuppressContextMenu);
-
- SLATE_EVENT(FOnDragWindow, OnDragWindow);
-
- SLATE_EVENT(FOnConsoleMessageDelegate, OnConsoleMessage);
- SLATE_END_ARGS()
-
- SWebInterfaceBrowser();
- ~SWebInterfaceBrowser();
- virtual bool SupportsKeyboardFocus() const override {return true;}
-
- void Construct(const FArguments& InArgs, const TSharedPtr<IWebInterfaceBrowserWindow>& InWebBrowserWindow = nullptr);
-
- void LoadURL(FString NewURL);
-
- void LoadString(FString Contents, FString DummyURL);
-
- void Reload();
-
- void StopLoad();
-
- FText GetTitleText() const;
-
- FString GetUrl() const;
-
- FText GetAddressBarUrlText() const;
-
- bool IsLoaded() const;
-
- bool IsLoading() const;
-
- void ExecuteJavascript(const FString& ScriptText);
-
- void GetSource(TFunction<void (const FString&)> Callback) const;
-
- void BindUObject(const FString& Name, UObject* Object, bool bIsPermanent = true);
-
- void UnbindUObject(const FString& Name, UObject* Object, bool bIsPermanent = true);
- void BindAdapter(const TSharedRef<IWebInterfaceBrowserAdapter>& Adapter);
- void UnbindAdapter(const TSharedRef<IWebInterfaceBrowserAdapter>& Adapter);
- void BindInputMethodSystem(ITextInputMethodSystem* TextInputMethodSystem);
- void UnbindInputMethodSystem();
-
- bool CanGoBack() const;
-
- void GoBack();
-
- bool CanGoForward() const;
-
- void GoForward();
-
- void SetParentWindow(TSharedPtr<SWindow> Window);
- private:
-
- FReply OnBackClicked();
-
- FReply OnForwardClicked();
-
- FText GetReloadButtonText() const;
-
- FReply OnReloadClicked();
-
- void OnUrlTextCommitted( const FText& NewText, ETextCommit::Type CommitType );
-
- EVisibility GetViewportVisibility() const;
-
- EVisibility GetLoadingThrobberVisibility() const;
- private:
-
- TSharedPtr<SWebInterfaceBrowserView> BrowserView;
-
- TSharedPtr< SEditableTextBox > InputText;
-
- FSimpleDelegate OnLoadCompleted;
-
- FSimpleDelegate OnLoadError;
-
- FSimpleDelegate OnLoadStarted;
-
- FOnTextChanged OnTitleChanged;
-
- FOnTextChanged OnUrlChanged;
-
- FOnBeforePopupDelegate OnBeforePopup;
-
- FOnConsoleMessageDelegate OnConsoleMessage;
-
- FOnCreateWindowDelegate OnCreateWindow;
-
- FOnCloseWindowDelegate OnCloseWindow;
-
- FOnBeforeBrowse OnBeforeNavigation;
-
- FOnLoadUrl OnLoadUrl;
-
- FOnShowDialog OnShowDialog;
-
- FSimpleDelegate OnDismissAllDialogs;
-
- bool bShowInitialThrobber;
- };
|