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-02-25 20:50:57 +00:00
|
|
|
#include <imgui_imhex_extensions.h>
|
|
|
|
|
|
|
|
#include <fontawesome_font.h>
|
2021-02-22 22:36:13 +00:00
|
|
|
#include <nfd.hpp>
|
2020-12-22 17:10:01 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
namespace hex {
|
|
|
|
|
|
|
|
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-02-22 22:36:13 +00: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 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();
|
|
|
|
|
|
|
|
static void showErrorPopup(std::string_view errorMessage);
|
|
|
|
|
|
|
|
virtual bool hasViewMenuItemEntry();
|
|
|
|
virtual ImVec2 getMinSize();
|
|
|
|
virtual ImVec2 getMaxSize();
|
|
|
|
|
|
|
|
bool& getWindowOpenState();
|
|
|
|
|
2021-03-03 21:26:17 +00:00
|
|
|
std::string_view getUnlocalizedName() const;
|
2020-12-22 17:10:01 +00:00
|
|
|
|
|
|
|
protected:
|
2021-01-28 12:23:50 +00:00
|
|
|
void discardNavigationRequests();
|
2021-03-03 21:26:17 +00:00
|
|
|
|
2021-01-21 09:53:12 +00:00
|
|
|
void confirmButtons(const char *textLeft, const char *textRight, const std::function<void()> &leftButtonFn, const std::function<void()> &rightButtonFn);
|
2021-01-03 23:19:56 +00:00
|
|
|
|
2021-03-03 21:26:17 +00:00
|
|
|
static inline std::string toWindowName(std::string_view unlocalizedName) {
|
|
|
|
return LangEntry(unlocalizedName) + "##" + std::string(unlocalizedName);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
}
|