Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InexorLayer.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <list>
3 #include <sstream>
4 #include <string> // for string
5 
6 #include "include/base/cef_ref_counted.h" // for scoped_refptr
7 #include "include/cef_app.h"
8 #include "include/cef_base.h" // for CefRefPtr, CefString
9 #include "include/cef_browser.h" // for CefBrowser, CefBrow...
10 #include "include/cef_client.h" // for CefClient
11 #include "include/cef_cookie.h" // for CefCookieManager
12 #include "include/cef_display_handler.h" // for CefDisplayHandler
13 #include "include/cef_keyboard_handler.h" // for CefKeyboardHandler
14 #include "include/cef_life_span_handler.h" // for CefLifeSpanHandler
15 #include "include/cef_load_handler.h" // for CefLoadHandler, Cef...
16 #include "include/cef_render_handler.h" // for CefRenderHandler
17 #include "include/cef_request_context_handler.h" // for CefRequestContextHa...
18 #include "include/wrapper/cef_helpers.h"
19 #include "inexor/io/Logging.hpp"
20 #include "inexor/ui/InexorBrowserSettings.hpp" // for InexorBrowserSettings
21 #include "inexor/ui/InexorRenderHandler.hpp" // for InexorRenderHandler
22 #include "inexor/ui/InexorWindowInfo.hpp" // for InexorWindowInfo
23 
24 class CefFrame;
25 
26 namespace inexor {
27 namespace ui {
28 namespace layer {
29 
30 class InexorLayer : public CefClient,
31  public CefLifeSpanHandler,
32  public CefLoadHandler,
33  public CefKeyboardHandler,
34  public CefDisplayHandler,
35  public CefRequestContextHandler
36 {
37 
38  public:
39  InexorLayer(std::string name, int x, int y, int width, int height, std::string url);
40  ~InexorLayer() override;
41 
42  std::string GetName() { return name; }
43  std::string GetUrl() { return url; }
45  CefBrowserSettings GetBrowserSettings() { return browser_settings; };
46 
47  // void Render() { render_handler->Render(); };
48  void Destroy();
49 
50  void Copy();
51  void Paste();
52  void Cut();
53 
54  void ShowDevTools();
55 
57  bool IsVisible() { return is_visible && browser.get(); };
58  void SetVisibility(bool is_visible);
59 
60  bool IsAcceptingKeyInput() { return is_accepting_key_input && browser.get(); };
64 
65  bool IsClosing() { return is_closing; }
66 
67  // Getters for handlers
68  virtual CefRefPtr<InexorLayer> GetClientHandler() { return this; };
69  CefRefPtr<CefRenderHandler> GetRenderHandler() override { return render_handler; }
70  virtual CefRefPtr<InexorRenderHandler> GetInexorRenderHandler() { return render_handler; }
71  virtual CefRefPtr<CefBrowser> GetBrowser() { return browser; };
72  CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() override { return this; }
73  CefRefPtr<CefLoadHandler> GetLoadHandler() override { return this; }
74  CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() override { return this; }
75  CefRefPtr<CefDisplayHandler> GetDisplayHandler() override { return this; }
76  virtual CefRefPtr<CefRequestContextHandler> GetRequestContextHandler() { return this; }
77  CefRefPtr<CefCookieManager> GetCookieManager() override { return cookie_manager; }
78 
79  // CefLifeSpanHandler
80  void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;
81  bool DoClose(CefRefPtr<CefBrowser> browser) override;
82  void OnBeforeClose(CefRefPtr<CefBrowser> browser) override;
83 
84  // CefLoadHandler
85  void OnLoadError(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, ErrorCode errorCode, const CefString& errorText, const CefString& failedUrl) override;
86 
87  // CefKeyboardHandler
88  bool OnPreKeyEvent(CefRefPtr<CefBrowser> browser, const CefKeyEvent& key_event, CefEventHandle os_event, bool* is_keyboard_shortcut) override;
89  bool OnKeyEvent(CefRefPtr<CefBrowser> browser, const CefKeyEvent& key_event, CefEventHandle os_event) override;
90  void SendKeyEvent(const CefKeyEvent& event) { browser->GetHost()->SendKeyEvent(event); }
91 
92  // CefDisplayHandler
93  void OnAddressChange(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& url) override;
94  void OnStatusMessage(CefRefPtr<CefBrowser> browser, const CefString& value) override;
95  bool OnConsoleMessage(CefRefPtr<CefBrowser> browser, const CefString& message, const CefString& source, int line) override;
96 
97  private:
98 
99  void UpdateFocus();
100 
103 
107 
111 
114  CefRefPtr<InexorRenderHandler> render_handler;
115  CefRefPtr<CefBrowser> browser;
116  CefRefPtr<CefCookieManager> cookie_manager;
117 
118  // Include the default reference counting implementation.
120 
121 };
122 
123 }
124 }
125 }
bool IsAcceptingKeyInput()
Definition: InexorLayer.hpp:60
InexorWindowInfo GetWindowInfo()
Definition: InexorLayer.hpp:44
void SendKeyEvent(const CefKeyEvent &event)
Definition: InexorLayer.hpp:90
void OnAddressChange(CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, const CefString &url) override
Definition: InexorLayer.cpp:176
GLenum GLsizei GLsizei height
Definition: glexts.hpp:291
virtual CefRefPtr< InexorRenderHandler > GetInexorRenderHandler()
Definition: InexorLayer.hpp:70
CACHE INTERN message(STATUS"CMAKE_VERSION = ${CMAKE_VERSION}") message(STATUS"CMAKE_GENERATOR
~InexorLayer() override
Definition: InexorLayer.cpp:42
bool IsVisible()
A layer can be visible or hidden.
Definition: InexorLayer.hpp:57
bool IsClosing()
Definition: InexorLayer.hpp:65
virtual CefRefPtr< InexorLayer > GetClientHandler()
Definition: InexorLayer.hpp:68
GLenum GLsizei width
Definition: glexts.hpp:291
Definition: InexorWindowInfo.hpp:8
bool OnConsoleMessage(CefRefPtr< CefBrowser > browser, const CefString &message, const CefString &source, int line) override
Definition: InexorLayer.cpp:188
virtual CefRefPtr< CefBrowser > GetBrowser()
Definition: InexorLayer.hpp:71
void Cut()
Definition: InexorLayer.cpp:91
InexorLayer(std::string name, int x, int y, int width, int height, std::string url)
Definition: InexorLayer.cpp:18
CefRefPtr< CefDisplayHandler > GetDisplayHandler() override
Definition: InexorLayer.hpp:75
CefRefPtr< CefKeyboardHandler > GetKeyboardHandler() override
Definition: InexorLayer.hpp:74
CefBrowserSettings GetBrowserSettings()
Definition: InexorLayer.hpp:45
Logging stuff including the ingame console logging functionality.
void Destroy()
Definition: InexorLayer.cpp:71
bool DoClose(CefRefPtr< CefBrowser > browser) override
Definition: InexorLayer.cpp:117
std::string GetName()
Definition: InexorLayer.hpp:42
std::string name
Definition: InexorLayer.hpp:101
InexorWindowInfo window_info
Definition: InexorLayer.hpp:112
void SetVisibility(bool is_visible)
Definition: InexorLayer.cpp:44
virtual CefRefPtr< CefRequestContextHandler > GetRequestContextHandler()
Definition: InexorLayer.hpp:76
void Paste()
Definition: InexorLayer.cpp:84
bool OnPreKeyEvent(CefRefPtr< CefBrowser > browser, const CefKeyEvent &key_event, CefEventHandle os_event, bool *is_keyboard_shortcut) override
Definition: InexorLayer.cpp:162
CefRefPtr< CefLoadHandler > GetLoadHandler() override
Definition: InexorLayer.hpp:73
InexorBrowserSettings browser_settings
Definition: InexorLayer.hpp:113
void OnLoadError(CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, ErrorCode errorCode, const CefString &errorText, const CefString &failedUrl) override
Definition: InexorLayer.cpp:148
CefRefPtr< InexorRenderHandler > render_handler
Definition: InexorLayer.hpp:114
int browser_id
Definition: InexorLayer.hpp:108
bool is_visible
Definition: InexorLayer.hpp:104
CefRefPtr< CefCookieManager > cookie_manager
Definition: InexorLayer.hpp:116
CefRefPtr< CefLifeSpanHandler > GetLifeSpanHandler() override
Definition: InexorLayer.hpp:72
void SetIsAcceptingKeyInput(bool is_accepting_key_input)
Definition: InexorLayer.cpp:57
CefRefPtr< CefRenderHandler > GetRenderHandler() override
Definition: InexorLayer.hpp:69
std::string GetUrl()
Definition: InexorLayer.hpp:43
bool OnKeyEvent(CefRefPtr< CefBrowser > browser, const CefKeyEvent &key_event, CefEventHandle os_event) override
Definition: InexorLayer.cpp:169
char string[MAXSTRLEN]
cube-strings (char arrays of fixed size).
Definition: cube_types.hpp:18
void OnAfterCreated(CefRefPtr< CefBrowser > browser) override
Definition: InexorLayer.cpp:105
void ShowDevTools()
Definition: InexorLayer.cpp:98
GLsizei GLboolean const GLfloat * value
Definition: glexts.hpp:57
bool is_accepting_mouse_input
Definition: InexorLayer.hpp:106
bool IsAcceptingMouseInput()
Definition: InexorLayer.hpp:61
std::string url
Definition: InexorLayer.hpp:102
CefRefPtr< CefBrowser > browser
Definition: InexorLayer.hpp:115
void OnStatusMessage(CefRefPtr< CefBrowser > browser, const CefString &value) override
Definition: InexorLayer.cpp:182
void Copy()
Definition: InexorLayer.cpp:77
Definition: InexorBrowserSettings.hpp:9
int browser_count
Definition: InexorLayer.hpp:109
Definition: InexorLayer.hpp:30
bool is_closing
Definition: InexorLayer.hpp:110
CefRefPtr< CefCookieManager > GetCookieManager() override
Definition: InexorLayer.hpp:77
void UpdateFocus()
Definition: InexorLayer.cpp:52
void OnBeforeClose(CefRefPtr< CefBrowser > browser) override
Definition: InexorLayer.cpp:134
void SetIsAcceptingMouseInput(bool is_accepting_mouse_input)
Definition: InexorLayer.cpp:64
bool is_accepting_key_input
Definition: InexorLayer.hpp:105