ImHex/plugins/libimhex/include/hex/views/view.hpp

70 lines
1.9 KiB
C++
Raw Normal View History

#pragma once
#include <hex.hpp>
#include <imgui.h>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui_internal.h>
2021-02-25 20:50:57 +00:00
#include <imgui_imhex_extensions.h>
#include <fontawesome_font.h>
2021-08-04 12:01:24 +00:00
#include <codicons_font.h>
#include <hex/api/imhex_api.hpp>
#include <hex/api/event.hpp>
#include <hex/providers/provider.hpp>
#include <hex/helpers/lang.hpp>
#include <functional>
#include <string>
#include <vector>
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();
2021-04-16 17:43:54 +00:00
virtual bool handleShortcut(bool keys[512], bool ctrl, bool shift, bool alt);
2021-02-02 23:56:33 +00:00
virtual bool isAvailable();
virtual bool shouldProcess() { return this->isAvailable() && this->getWindowOpenState(); }
2021-01-21 09:53:12 +00:00
static void doLater(std::function<void()> &&function);
static std::vector<std::function<void()>>& getDeferedCalls();
static void drawCommonInterfaces();
static void showErrorPopup(const std::string &errorMessage);
static void showFatalPopup(const std::string &errorMessage);
virtual bool hasViewMenuItemEntry();
virtual ImVec2 getMinSize();
virtual ImVec2 getMaxSize();
bool& getWindowOpenState();
2021-09-21 17:54:13 +00:00
[[nodiscard]] const std::string& getUnlocalizedName() const;
protected:
void discardNavigationRequests();
void confirmButtons(const std::string &textLeft, const std::string &textRight, const std::function<void()> &leftButtonFn, const std::function<void()> &rightButtonFn);
static inline std::string toWindowName(const std::string &unlocalizedName) {
return LangEntry(unlocalizedName) + "###" + unlocalizedName;
}
private:
std::string m_unlocalizedViewName;
bool m_windowOpen = false;
};
}