mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-01 21:17:44 -05:00
Streamline view creation, save all view states when quitting
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user