1
0
mirror of synced 2024-11-14 19:17:42 +01:00
ImHex/plugins/libimhex/include/hex/views/view.hpp

64 lines
1.8 KiB
C++
Raw Normal View History

#pragma once
#include <hex.hpp>
#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>
#include <hex/api/imhex_api.hpp>
#include <hex/api/event.hpp>
#include <hex/providers/provider.hpp>
#include <functional>
#include <string>
#include <vector>
namespace hex {
class View {
public:
explicit View(std::string unlocalizedViewName);
virtual ~View() = default;
virtual void drawContent() = 0;
virtual void drawAlwaysVisible() { }
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();
virtual bool shouldProcess() { return this->isAvailable() && this->getWindowOpenState(); }
2021-01-21 10:53:12 +01:00
static void doLater(std::function<void()> &&function);
static std::vector<std::function<void()>>& getDeferedCalls();
static void drawCommonInterfaces();
static void showErrorPopup(std::string_view errorMessage);
static void showFatalPopup(std::string_view errorMessage);
virtual bool hasViewMenuItemEntry();
virtual ImVec2 getMinSize();
virtual ImVec2 getMaxSize();
bool& getWindowOpenState();
std::string_view getUnlocalizedName() const;
protected:
void discardNavigationRequests();
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);
static inline std::string toWindowName(std::string_view unlocalizedName) {
return LangEntry(unlocalizedName) + "##" + std::string(unlocalizedName);
}
private:
std::string m_unlocalizedViewName;
bool m_windowOpen = false;
};
}