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
+15 -1
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;
};
-1
View File
@@ -51,7 +51,6 @@ namespace hex {
private:
prv::Provider* &m_dataProvider;
bool m_windowOpen = true;
bool m_shouldInvalidate = true;
std::endian m_endianess = std::endian::native;
-2
View File
@@ -31,8 +31,6 @@ namespace hex {
private:
prv::Provider* &m_dataProvider;
bool m_windowOpen = true;
bool m_shouldInvalidate = false;
u64 m_baseAddress = 0;
-1
View File
@@ -18,7 +18,6 @@ namespace hex {
private:
prv::Provider* &m_dataProvider;
bool m_windowOpen = true;
bool m_shouldInvalidate = true;
int m_currHashFunction = 0;
-1
View File
@@ -21,7 +21,6 @@ namespace hex {
private:
prv::Provider* &m_dataProvider;
bool m_windowOpen = true;
bool m_dataValid = false;
u32 m_blockSize = 0;
-1
View File
@@ -28,7 +28,6 @@ namespace hex {
std::vector<lang::PatternData*> &m_patternData;
prv::Provider* &m_dataProvider;
std::filesystem::path m_possiblePatternFile;
bool m_windowOpen = true;
TextEditor m_textEditor;
imgui_addons::ImGuiFileBrowser m_fileBrowser;
+1 -1
View File
@@ -23,10 +23,10 @@ namespace hex {
void createMenu() override;
private:
prv::Provider* &m_dataProvider;
std::vector<lang::PatternData*> &m_patternData;
std::vector<lang::PatternData*> m_sortedPatternData;
bool m_windowOpen = true;
};
}
-1
View File
@@ -25,7 +25,6 @@ namespace hex {
private:
prv::Provider* &m_dataProvider;
bool m_windowOpen = true;
bool m_shouldInvalidate = false;
std::vector<FoundString> m_foundStrings;
-2
View File
@@ -21,8 +21,6 @@ namespace hex {
void createMenu() override;
private:
bool m_windowOpen = true;
char *m_mangledBuffer = nullptr;
char *m_demangledName = nullptr;
+7 -2
View File
@@ -7,6 +7,7 @@
#include "views/view.hpp"
struct GLFWwindow;
struct ImGuiSettingsHandler;
namespace hex {
@@ -24,8 +25,10 @@ namespace hex {
return static_cast<T*>(this->m_views.back());
}
public:
float m_globalScale = 1.0f, m_fontScale = 1.0f;
friend void *ImHexSettingsHandler_ReadOpenFn(ImGuiContext *ctx, ImGuiSettingsHandler *, const char *);
friend void ImHexSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler *handler, void *, const char* line);
friend void ImHexSettingsHandler_ApplyAll(ImGuiContext *ctx, ImGuiSettingsHandler *handler);
friend void ImHexSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler *handler, ImGuiTextBuffer *buf);
private:
void frameBegin();
@@ -38,6 +41,8 @@ namespace hex {
GLFWwindow* m_window;
std::vector<View*> m_views;
float m_globalScale = 1.0f, m_fontScale = 1.0f;
bool m_fpsVisible = false;
bool m_demoWindowOpen = false;