Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InexorLayerProvider.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "include/cef_app.h"
4 #include "include/wrapper/cef_helpers.h"
5 
6 #include <string>
7 #include <stdio.h> /* defines FILENAME_MAX */
8 
9 #ifdef WINDOWS
10 #include <direct.h>
11 #define GetCurrentDir _getcwd
12 #else
13 #include <unistd.h>
14 #define GetCurrentDir getcwd
15 #endif
16 
18 
19 namespace inexor {
20 namespace ui {
21 namespace layer {
22 
23 class InexorLayerProvider : public CefBaseRefCounted
24 {
25 
26  public:
28  ~InexorLayerProvider() override {};
29 
30  void SetLayer(CefRefPtr<InexorLayer> layer) { this->layer = layer; }
31 
32  virtual std::string GetLayerName() = 0;
33  virtual void SetLayerName(std::string &_name) = 0;
34 
35  virtual std::string GetUrl() = 0;
36  virtual void SetUrl(std::string &_url) = 0;
37 
38  virtual bool GetVisibility() = 0;
39  virtual void SetVisibility(bool _is_visible) = 0;
40 
41  virtual bool GetAcceptingKeyInput() = 0;
42  virtual void SetAcceptingKeyInput(bool _is_accepting_key_input) = 0;
43 
44  virtual bool GetAcceptingMouseInput() = 0;
45  virtual void SetAcceptingMouseInput(bool _is_accepting_mouse_input) = 0;
46 
47  protected:
48  CefRefPtr<InexorLayer> layer;
49 
51  char base_path[FILENAME_MAX];
52  GetCurrentDir(base_path, sizeof(base_path));
53  return "file://" + std::string(base_path) + relpath;
54  };
55 
56  private:
58 };
59 
61 {
62  public:
65  AbstractInexorLayerProvider(std::string &name, std::string &url) : is_visible(false), name(name), url(url) {};
67 
68  std::string GetLayerName() override { return name; };
69  void SetLayerName(std::string &_name) override {
70  name = _name;
71  };
72 
73  std::string GetUrl() override { return url; };
74  void SetUrl(std::string &_url) override {
75  url = _url;
76  };
77 
78  bool GetVisibility() override { return is_visible; };
79  void SetVisibility(bool _is_visible) override {
80  this->is_visible = _is_visible;
81  if (layer.get()) layer->SetVisibility(_is_visible);
82  };
83 
84  bool GetAcceptingKeyInput() override { return is_accepting_key_input; };
85  void SetAcceptingKeyInput(bool _is_accepting_key_input) override {
86  this->is_accepting_key_input = _is_accepting_key_input;
87  if (layer.get()) layer->SetIsAcceptingKeyInput(_is_accepting_key_input);
88  };
89 
90  bool GetAcceptingMouseInput() override { return is_accepting_mouse_input; };
91  void SetAcceptingMouseInput(bool _is_accepting_mouse_input) override {
92  this->is_accepting_mouse_input = _is_accepting_mouse_input;
93  if (layer.get()) layer->SetIsAcceptingMouseInput(_is_accepting_mouse_input);
94  };
95 
96  void Show() {
97  SetVisibility(true);
100  };
101  void Hide() {
102  SetVisibility(false);
103  SetAcceptingKeyInput(false);
104  SetAcceptingMouseInput(false);
105  };
108  };
109 
110  protected:
111  bool is_visible;
116 
117 };
118 
119 }
120 }
121 }
void SetAcceptingKeyInput(bool _is_accepting_key_input) override
Definition: InexorLayerProvider.hpp:85
Definition: InexorLayerProvider.hpp:23
virtual std::string GetLayerName()=0
bool is_accepting_key_input
Definition: InexorLayerProvider.hpp:112
bool is_accepting_mouse_input
Definition: InexorLayerProvider.hpp:113
AbstractInexorLayerProvider(std::string &name, std::string &url)
Definition: InexorLayerProvider.hpp:65
std::string name
Definition: InexorLayerProvider.hpp:114
CefRefPtr< InexorLayer > layer
Definition: InexorLayerProvider.hpp:48
AbstractInexorLayerProvider(std::string &name)
Definition: InexorLayerProvider.hpp:64
Definition: InexorLayerProvider.hpp:60
virtual void SetVisibility(bool _is_visible)=0
virtual void SetAcceptingMouseInput(bool _is_accepting_mouse_input)=0
virtual void SetUrl(std::string &_url)=0
void SetLayerName(std::string &_name) override
Definition: InexorLayerProvider.hpp:69
std::string url
Definition: InexorLayerProvider.hpp:115
bool GetAcceptingMouseInput() override
Definition: InexorLayerProvider.hpp:90
~InexorLayerProvider() override
Definition: InexorLayerProvider.hpp:28
#define GetCurrentDir
Definition: InexorLayerProvider.hpp:14
virtual void SetAcceptingKeyInput(bool _is_accepting_key_input)=0
InexorLayerProvider()
Definition: InexorLayerProvider.hpp:27
AbstractInexorLayerProvider()
Definition: InexorLayerProvider.hpp:63
void SetVisibility(bool _is_visible) override
Definition: InexorLayerProvider.hpp:79
void SetUrl(std::string &_url) override
Definition: InexorLayerProvider.hpp:74
bool GetAcceptingKeyInput() override
Definition: InexorLayerProvider.hpp:84
~AbstractInexorLayerProvider() override
Definition: InexorLayerProvider.hpp:66
bool is_visible
Definition: InexorLayerProvider.hpp:108
std::string GetLocalUrl(std::string relpath)
Definition: InexorLayerProvider.hpp:50
void ToggleVisibility()
Definition: InexorLayerProvider.hpp:106
IMPLEMENT_REFCOUNTING(InexorLayerProvider)
void SetLayer(CefRefPtr< InexorLayer > layer)
Definition: InexorLayerProvider.hpp:30
std::string GetUrl() override
Definition: InexorLayerProvider.hpp:73
std::string GetLayerName() override
Definition: InexorLayerProvider.hpp:68
char string[MAXSTRLEN]
cube-strings (char arrays of fixed size).
Definition: cube_types.hpp:18
virtual void SetLayerName(std::string &_name)=0
void SetAcceptingMouseInput(bool _is_accepting_mouse_input) override
Definition: InexorLayerProvider.hpp:91
void Hide()
Definition: InexorLayerProvider.hpp:101
bool GetVisibility() override
Definition: InexorLayerProvider.hpp:78
void Show()
Definition: InexorLayerProvider.hpp:96