2020-12-22 17:10:01 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex.hpp>
|
|
|
|
|
2021-01-13 16:28:27 +00:00
|
|
|
#include <imgui.h>
|
2021-09-20 21:40:36 +00:00
|
|
|
#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>
|
2020-12-22 17:10:01 +00:00
|
|
|
|
2021-08-21 11:55:21 +00:00
|
|
|
#include <hex/api/imhex_api.hpp>
|
2021-01-13 16:28:27 +00:00
|
|
|
#include <hex/api/event.hpp>
|
2021-01-27 13:26:24 +00:00
|
|
|
#include <hex/providers/provider.hpp>
|
2020-12-22 17:10:01 +00:00
|
|
|
|
2021-09-08 13:18:24 +00:00
|
|
|
#include <hex/helpers/lang.hpp>
|
|
|
|
|
2020-12-22 17:10:01 +00:00
|
|
|
#include <functional>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
namespace hex {
|
|
|
|
|
2021-09-08 13:18:24 +00:00
|
|
|
using namespace hex::lang_literals;
|
|
|
|
|
2020-12-22 17:10:01 +00:00
|
|
|
class View {
|
|
|
|
public:
|
2021-03-03 21:26:17 +00:00
|
|
|
explicit View(std::string unlocalizedViewName);
|
2020-12-22 17:10:01 +00:00
|
|
|
virtual ~View() = default;
|
|
|
|
|
|
|
|
virtual void drawContent() = 0;
|
2021-02-07 13:29:13 +00:00
|
|
|
virtual void drawAlwaysVisible() { }
|
2020-12-22 17:10:01 +00:00
|
|
|
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();
|
2021-02-08 18:56:04 +00:00
|
|
|
virtual bool shouldProcess() { return this->isAvailable() && this->getWindowOpenState(); }
|
2020-12-22 17:10:01 +00:00
|
|
|
|
2021-01-21 09:53:12 +00:00
|
|
|
static void doLater(std::function<void()> &&function);
|
2020-12-22 17:10:01 +00:00
|
|
|
static std::vector<std::function<void()>>& getDeferedCalls();
|
|
|
|
|
|
|
|
static void drawCommonInterfaces();
|
|
|
|
|
2021-09-22 15:56:06 +00:00
|
|
|
static void showMessagePopup(const std::string &message);
|
2021-09-08 13:18:24 +00:00
|
|
|
static void showErrorPopup(const std::string &errorMessage);
|
|
|
|
static void showFatalPopup(const std::string &errorMessage);
|
2020-12-22 17:10:01 +00:00
|
|
|
|
|
|
|
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;
|
2020-12-22 17:10:01 +00:00
|
|
|
|
2021-09-22 15:56:06 +00:00
|
|
|
static void confirmButtons(const std::string &textLeft, const std::string &textRight, const std::function<void()> &leftButtonFn, const std::function<void()> &rightButtonFn);
|
|
|
|
static void discardNavigationRequests();
|
2021-01-03 23:19:56 +00:00
|
|
|
|
2021-09-08 13:18:24 +00:00
|
|
|
static inline std::string toWindowName(const std::string &unlocalizedName) {
|
2021-09-20 18:42:30 +00:00
|
|
|
return LangEntry(unlocalizedName) + "###" + unlocalizedName;
|
2021-03-03 21:26:17 +00:00
|
|
|
}
|
|
|
|
|
2020-12-22 17:10:01 +00:00
|
|
|
private:
|
2021-03-03 21:26:17 +00:00
|
|
|
std::string m_unlocalizedViewName;
|
2021-04-12 19:08:36 +00:00
|
|
|
bool m_windowOpen = false;
|
2020-12-22 17:10:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|