2020-12-22 18:10:01 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex.hpp>
|
|
|
|
|
2021-01-13 17:28:27 +01:00
|
|
|
#include <imgui.h>
|
2021-09-20 23:40:36 +02:00
|
|
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
|
|
|
#include <imgui_internal.h>
|
2021-12-31 01:10:06 +01:00
|
|
|
#include <hex/ui/imgui_imhex_extensions.h>
|
2021-02-25 21:50:57 +01:00
|
|
|
|
|
|
|
#include <fontawesome_font.h>
|
2021-08-04 14:01:24 +02:00
|
|
|
#include <codicons_font.h>
|
2020-12-22 18:10:01 +01:00
|
|
|
|
2021-08-21 13:55:21 +02:00
|
|
|
#include <hex/api/imhex_api.hpp>
|
2021-01-13 17:28:27 +01:00
|
|
|
#include <hex/api/event.hpp>
|
2021-01-27 14:26:24 +01:00
|
|
|
#include <hex/providers/provider.hpp>
|
2020-12-22 18:10:01 +01:00
|
|
|
|
2021-09-08 15:18:24 +02:00
|
|
|
#include <hex/helpers/lang.hpp>
|
|
|
|
|
2020-12-22 18:10:01 +01:00
|
|
|
#include <functional>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
namespace hex {
|
|
|
|
|
2021-09-08 15:18:24 +02:00
|
|
|
using namespace hex::lang_literals;
|
|
|
|
|
2020-12-22 18:10:01 +01:00
|
|
|
class View {
|
|
|
|
public:
|
2021-03-03 22:26:17 +01:00
|
|
|
explicit View(std::string unlocalizedViewName);
|
2020-12-22 18:10:01 +01:00
|
|
|
virtual ~View() = default;
|
|
|
|
|
|
|
|
virtual void drawContent() = 0;
|
2021-02-07 14:29:13 +01:00
|
|
|
virtual void drawAlwaysVisible() { }
|
2022-01-10 21:05:37 +01:00
|
|
|
virtual bool isAvailable() const;
|
|
|
|
virtual bool shouldProcess() const { return this->isAvailable() && this->getWindowOpenState(); }
|
2020-12-22 18:10:01 +01:00
|
|
|
|
2021-01-21 10:53:12 +01:00
|
|
|
static void doLater(std::function<void()> &&function);
|
2020-12-22 18:10:01 +01:00
|
|
|
static std::vector<std::function<void()>>& getDeferedCalls();
|
|
|
|
|
|
|
|
static void drawCommonInterfaces();
|
|
|
|
|
2021-09-22 17:56:06 +02:00
|
|
|
static void showMessagePopup(const std::string &message);
|
2021-09-08 15:18:24 +02:00
|
|
|
static void showErrorPopup(const std::string &errorMessage);
|
|
|
|
static void showFatalPopup(const std::string &errorMessage);
|
2020-12-22 18:10:01 +01:00
|
|
|
|
2022-01-23 21:52:43 +01:00
|
|
|
static void showFileChooserPopup(const std::vector<fs::path> &paths, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(fs::path)> &callback);
|
|
|
|
|
2022-01-10 21:05:37 +01:00
|
|
|
virtual bool hasViewMenuItemEntry() const;
|
|
|
|
virtual ImVec2 getMinSize() const;
|
|
|
|
virtual ImVec2 getMaxSize() const;
|
2020-12-22 18:10:01 +01:00
|
|
|
|
|
|
|
bool& getWindowOpenState();
|
2022-01-10 21:05:37 +01:00
|
|
|
const bool& getWindowOpenState() const;
|
2020-12-22 18:10:01 +01:00
|
|
|
|
2021-09-21 19:54:13 +02:00
|
|
|
[[nodiscard]] const std::string& getUnlocalizedName() const;
|
2022-01-18 00:10:10 +01:00
|
|
|
[[nodiscard]] std::string getName() const;
|
2020-12-22 18:10:01 +01:00
|
|
|
|
2021-09-22 17:56:06 +02: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-04 00:19:56 +01:00
|
|
|
|
2021-09-08 15:18:24 +02:00
|
|
|
static inline std::string toWindowName(const std::string &unlocalizedName) {
|
2021-09-20 20:42:30 +02:00
|
|
|
return LangEntry(unlocalizedName) + "###" + unlocalizedName;
|
2021-03-03 22:26:17 +01:00
|
|
|
}
|
|
|
|
|
2020-12-22 18:10:01 +01:00
|
|
|
private:
|
2021-03-03 22:26:17 +01:00
|
|
|
std::string m_unlocalizedViewName;
|
2021-04-12 21:08:36 +02:00
|
|
|
bool m_windowOpen = false;
|
2021-12-23 15:11:38 +01:00
|
|
|
std::map<Shortcut, std::function<void()>> m_shortcuts;
|
|
|
|
|
|
|
|
friend class ShortcutManager;
|
2020-12-22 18:10:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|