#pragma once #include #include #define IMGUI_DEFINE_MATH_OPERATORS #include #include #include #include #include #include #include #include #include #include #include namespace hex { using namespace hex::lang_literals; class View { public: explicit View(std::string unlocalizedViewName); virtual ~View() = default; virtual void drawContent() = 0; virtual void drawAlwaysVisible() { } virtual void drawMenu(); virtual bool isAvailable() const; virtual bool shouldProcess() const { return this->isAvailable() && this->getWindowOpenState(); } static void doLater(std::function &&function); static std::vector>& getDeferedCalls(); static void drawCommonInterfaces(); static void showMessagePopup(const std::string &message); static void showErrorPopup(const std::string &errorMessage); static void showFatalPopup(const std::string &errorMessage); virtual bool hasViewMenuItemEntry() const; virtual ImVec2 getMinSize() const; virtual ImVec2 getMaxSize() const; bool& getWindowOpenState(); const bool& getWindowOpenState() const; [[nodiscard]] const std::string& getUnlocalizedName() const; static void confirmButtons(const std::string &textLeft, const std::string &textRight, const std::function &leftButtonFn, const std::function &rightButtonFn); static void discardNavigationRequests(); static inline std::string toWindowName(const std::string &unlocalizedName) { return LangEntry(unlocalizedName) + "###" + unlocalizedName; } private: std::string m_unlocalizedViewName; bool m_windowOpen = false; std::map> m_shortcuts; friend class ShortcutManager; }; }