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-02-25 21:50:57 +01:00
|
|
|
#include <imgui_imhex_extensions.h>
|
|
|
|
|
|
|
|
#include <fontawesome_font.h>
|
2021-08-04 14:01:24 +02:00
|
|
|
#include <codicons_font.h>
|
2021-02-22 23:36:13 +01:00
|
|
|
#include <nfd.hpp>
|
2020-12-22 18:10:01 +01:00
|
|
|
|
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
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
namespace hex {
|
|
|
|
|
|
|
|
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() { }
|
2020-12-22 18:10:01 +01:00
|
|
|
virtual void drawMenu();
|
2021-04-16 19:43:54 +02:00
|
|
|
virtual bool handleShortcut(bool keys[512], bool ctrl, bool shift, bool alt);
|
2021-02-03 00:56:33 +01:00
|
|
|
virtual bool isAvailable();
|
2021-02-08 19:56:04 +01:00
|
|
|
virtual bool shouldProcess() { return this->isAvailable() && this->getWindowOpenState(); }
|
2020-12-22 18:10:01 +01:00
|
|
|
|
2021-02-22 23:36:13 +01:00
|
|
|
enum class DialogMode {
|
|
|
|
Open,
|
|
|
|
Save,
|
|
|
|
Folder
|
|
|
|
};
|
|
|
|
|
|
|
|
static void openFileBrowser(std::string_view title, DialogMode mode, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(std::string)> &callback);
|
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();
|
|
|
|
|
|
|
|
static void showErrorPopup(std::string_view errorMessage);
|
2021-04-18 20:24:42 +02:00
|
|
|
static void showFatalPopup(std::string_view errorMessage);
|
2020-12-22 18:10:01 +01:00
|
|
|
|
|
|
|
virtual bool hasViewMenuItemEntry();
|
|
|
|
virtual ImVec2 getMinSize();
|
|
|
|
virtual ImVec2 getMaxSize();
|
|
|
|
|
|
|
|
bool& getWindowOpenState();
|
|
|
|
|
2021-03-03 22:26:17 +01:00
|
|
|
std::string_view getUnlocalizedName() const;
|
2020-12-22 18:10:01 +01:00
|
|
|
|
|
|
|
protected:
|
2021-01-28 13:23:50 +01:00
|
|
|
void discardNavigationRequests();
|
2021-03-03 22:26:17 +01:00
|
|
|
|
2021-01-21 10:53:12 +01:00
|
|
|
void confirmButtons(const char *textLeft, const char *textRight, const std::function<void()> &leftButtonFn, const std::function<void()> &rightButtonFn);
|
2021-01-04 00:19:56 +01:00
|
|
|
|
2021-03-03 22:26:17 +01:00
|
|
|
static inline std::string toWindowName(std::string_view unlocalizedName) {
|
|
|
|
return LangEntry(unlocalizedName) + "##" + std::string(unlocalizedName);
|
|
|
|
}
|
|
|
|
|
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;
|
2020-12-22 18:10:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|