#pragma once #include #include #include #include #include #include #include namespace hex { class View { public: explicit View(std::string viewName); virtual ~View() = default; virtual void drawContent() = 0; virtual void drawMenu(); virtual bool handleShortcut(int key, int mods); static void openFileBrowser(std::string title, imgui_addons::ImGuiFileBrowser::DialogMode mode, std::string validExtensions, const std::function &callback); static void doLater(std::function &&function); static std::vector>& getDeferedCalls(); static std::vector postEvent(Events eventType, const std::any &userData = { }); static void drawCommonInterfaces(); static void showErrorPopup(std::string_view errorMessage); virtual bool hasViewMenuItemEntry(); virtual ImVec2 getMinSize(); virtual ImVec2 getMaxSize(); bool& getWindowOpenState(); std::string_view getName() const; protected: void subscribeEvent(Events eventType, const std::function &callback); void subscribeEvent(Events eventType, const std::function &callback); void unsubscribeEvent(Events eventType); protected: void confirmButtons(const char *textLeft, const char *textRight, const std::function &leftButtonFn, const std::function &rightButtonFn); private: std::string m_viewName; bool m_windowOpen = false; }; }