Streamline view creation, save all view states when quitting

This commit is contained in:
WerWolv
2020-11-23 23:57:19 +01:00
parent 45bcdc8c46
commit 3bd987ff2c
22 changed files with 141 additions and 168 deletions

View File

@@ -7,6 +7,7 @@
#include "event.hpp"
#include <functional>
#include <string>
#include <vector>
@@ -14,7 +15,7 @@ namespace hex {
class View {
public:
View() { }
View(std::string viewName) : m_viewName(viewName) { }
virtual ~View() { }
virtual void createView() = 0;
@@ -29,6 +30,14 @@ namespace hex {
View::s_eventManager.post(eventType, userData);
}
bool& getWindowOpenState() {
return this->m_windowOpen;
}
const std::string getName() const {
return this->m_viewName;
}
protected:
void subscribeEvent(Events eventType, std::function<void(const void*)> callback) {
View::s_eventManager.subscribe(eventType, this, callback);
@@ -42,7 +51,12 @@ namespace hex {
View::s_deferedCalls.push_back(function);
}
private:
std::string m_viewName;
bool m_windowOpen = false;
static inline EventManager s_eventManager;
static inline std::vector<std::function<void()>> s_deferedCalls;
};