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-12-31 00:10:06 +00:00
|
|
|
#include <hex/ui/imgui_imhex_extensions.h>
|
2021-02-25 20:50:57 +00:00
|
|
|
|
|
|
|
#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() { }
|
2022-01-10 20:05:37 +00:00
|
|
|
virtual bool isAvailable() const;
|
|
|
|
virtual bool shouldProcess() const { 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);
|
2022-01-24 19:53:17 +00:00
|
|
|
static std::vector<std::function<void()>> &getDeferedCalls();
|
2020-12-22 17:10:01 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2022-01-23 20:52:43 +00: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 20:05:37 +00:00
|
|
|
virtual bool hasViewMenuItemEntry() const;
|
|
|
|
virtual ImVec2 getMinSize() const;
|
|
|
|
virtual ImVec2 getMaxSize() const;
|
2020-12-22 17:10:01 +00:00
|
|
|
|
2022-01-24 19:53:17 +00:00
|
|
|
bool &getWindowOpenState();
|
|
|
|
const bool &getWindowOpenState() const;
|
2020-12-22 17:10:01 +00:00
|
|
|
|
2022-01-24 19:53:17 +00:00
|
|
|
[[nodiscard]] const std::string &getUnlocalizedName() const;
|
2022-01-17 23:10:10 +00:00
|
|
|
[[nodiscard]] std::string getName() 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;
|
2021-12-23 14:11:38 +00:00
|
|
|
std::map<Shortcut, std::function<void()>> m_shortcuts;
|
|
|
|
|
|
|
|
friend class ShortcutManager;
|
2020-12-22 17:10:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|