Browse Source

Working on multiple web views

Josh Engebretson 10 years ago
parent
commit
a4fef57bcd

+ 12 - 7
Source/Atomic/UI/UIButton.cpp

@@ -35,7 +35,9 @@ using namespace tb;
 namespace Atomic
 namespace Atomic
 {
 {
 
 
-UIButton::UIButton(Context* context, bool createWidget) : UIWidget(context, false), emulationButton_(-1)
+UIButton::UIButton(Context* context, bool createWidget) : UIWidget(context, false),
+    emulationButton_(-1),
+    urlEnabled_(true)
 {
 {
     if (createWidget)
     if (createWidget)
     {
     {
@@ -66,12 +68,15 @@ void UIButton::SetEmulationButton(int emulationButton)
 bool UIButton::OnEvent(const tb::TBWidgetEvent &ev)
 bool UIButton::OnEvent(const tb::TBWidgetEvent &ev)
 {
 {
     if (ev.type == EVENT_TYPE_CLICK)
     if (ev.type == EVENT_TYPE_CLICK)
-	{
-        String text = GetText();
-        if (text.StartsWith("http://") || text.StartsWith("https://"))
-		{
-            FileSystem* fileSystem = GetSubsystem<FileSystem>();
-            fileSystem->SystemOpen(text);
+    {
+        if (urlEnabled_)
+        {
+            String text = GetText();
+            if (text.StartsWith("http://") || text.StartsWith("https://"))
+            {
+                FileSystem* fileSystem = GetSubsystem<FileSystem>();
+                fileSystem->SystemOpen(text);
+            }
         }
         }
     }
     }
     if (ev.type == EVENT_TYPE_POINTER_DOWN && emulationButton_ >= 0)
     if (ev.type == EVENT_TYPE_POINTER_DOWN && emulationButton_ >= 0)

+ 7 - 0
Source/Atomic/UI/UIButton.h

@@ -43,12 +43,19 @@ public:
 
 
     void SetEmulationButton(int button);
     void SetEmulationButton(int button);
 
 
+    /// A button link may be set via the text attribute, if enabled
+    /// a FileSystem open will be called when the button is clicked
+    /// for example a http:// link will open the default browser
+    void SetURLEnabled(bool enabled) { urlEnabled_ = enabled; }
+
 protected:
 protected:
 
 
     virtual bool OnEvent(const tb::TBWidgetEvent &ev);
     virtual bool OnEvent(const tb::TBWidgetEvent &ev);
 
 
 private:
 private:
+
     int emulationButton_;
     int emulationButton_;
+    bool urlEnabled_;
 };
 };
 
 
 }
 }

+ 13 - 0
Source/Atomic/UI/UITabContainer.cpp

@@ -68,6 +68,19 @@ int UITabContainer::GetNumPages()
 
 
 }
 }
 
 
+UILayout* UITabContainer::GetTabLayout()
+{
+    if (!widget_)
+        return 0;
+
+    TBLayout* layout = ((TBTabContainer*)widget_)->GetTabLayout();
+
+    if (!layout)
+        return 0;
+
+    UI* ui = GetSubsystem<UI>();
+    return (UILayout*) ui->WrapWidget(layout);
+}
 
 
 void UITabContainer::SetCurrentPage(int page)
 void UITabContainer::SetCurrentPage(int page)
 {
 {

+ 4 - 0
Source/Atomic/UI/UITabContainer.h

@@ -27,6 +27,8 @@
 namespace Atomic
 namespace Atomic
 {
 {
 
 
+class UILayout;
+
 class UITabContainer : public UIWidget
 class UITabContainer : public UIWidget
 {
 {
     OBJECT(UITabContainer)
     OBJECT(UITabContainer)
@@ -41,6 +43,8 @@ public:
 
 
     UIWidget* GetCurrentPageWidget();
     UIWidget* GetCurrentPageWidget();
 
 
+    UILayout* GetTabLayout();
+
 protected:
 protected:
 
 
     virtual bool OnEvent(const tb::TBWidgetEvent &ev);
     virtual bool OnEvent(const tb::TBWidgetEvent &ev);

+ 0 - 3
Source/AtomicWebView/WebBrowserHost.cpp

@@ -1,6 +1,4 @@
 
 
-#include <list>
-
 #include <SDL/include/SDL.h>
 #include <SDL/include/SDL.h>
 #include <ThirdParty/SDL/include/SDL_syswm.h>
 #include <ThirdParty/SDL/include/SDL_syswm.h>
 
 
@@ -10,7 +8,6 @@
 #include <include/base/cef_bind.h>
 #include <include/base/cef_bind.h>
 #include <include/wrapper/cef_closure_task.h>
 #include <include/wrapper/cef_closure_task.h>
 
 
-
 #include <Atomic/Core/ProcessUtils.h>
 #include <Atomic/Core/ProcessUtils.h>
 #include <Atomic/Core/CoreEvents.h>
 #include <Atomic/Core/CoreEvents.h>
 #include <Atomic/IO/Log.h>
 #include <Atomic/IO/Log.h>

+ 5 - 2
Source/AtomicWebView/WebClient.cpp

@@ -73,7 +73,7 @@ public:
         CefWindowInfo windowInfo;
         CefWindowInfo windowInfo;
         CefBrowserSettings browserSettings;
         CefBrowserSettings browserSettings;
 
 
-        //browserSettings.webgl = STATE_ENABLED;
+        browserSettings.webgl = STATE_ENABLED;
 
 
         windowInfo.width = width;
         windowInfo.width = width;
         windowInfo.height = height;
         windowInfo.height = height;
@@ -92,7 +92,7 @@ public:
 #endif
 #endif
 
 
 #ifdef ATOMIC_PLATFORM_WINDOWS
 #ifdef ATOMIC_PLATFORM_WINDOWS
-         windowInfo.SetAsWindowless(info.info.win.window, false);
+            windowInfo.SetAsWindowless(info.info.win.window, false);
 #endif
 #endif
 
 
             webClient_->renderHandler_->SetSize(width, height);
             webClient_->renderHandler_->SetSize(width, height);
@@ -166,6 +166,9 @@ WebClient::WebClient(Context* context) : Object(context)
 
 
 WebClient::~WebClient()
 WebClient::~WebClient()
 {
 {
+    if (d_)
+        d_->CloseBrowser(true);
+
     renderHandler_ = 0;
     renderHandler_ = 0;
     //d_->Release();
     //d_->Release();
 }
 }

+ 7 - 0
Source/ToolCore/JSBind/JSBClass.h

@@ -58,6 +58,7 @@ public:
     // based on whether the Getter/Setter is all caps
     // based on whether the Getter/Setter is all caps
     // GetMyValue -> myValue;
     // GetMyValue -> myValue;
     // GetGUID -> guid
     // GetGUID -> guid
+    // URLEnabled -> urlEnabled
     String GetCasePropertyName()
     String GetCasePropertyName()
     {
     {
         if (!name_.Length())
         if (!name_.Length())
@@ -65,6 +66,12 @@ public:
 
 
         bool allUpper = true;
         bool allUpper = true;
 
 
+        // TODO: https://github.com/AtomicGameEngine/AtomicGameEngine/issues/587
+        if (name_ == "URLEnabled")
+        {
+            return "urlEnabled";
+        }
+
         for (unsigned k = 0; k < name_.Length(); k++)
         for (unsigned k = 0; k < name_.Length(); k++)
         {
         {
             if (!isupper(name_[k]))
             if (!isupper(name_[k]))