1
0
mirror of synced 2024-11-25 16:20:23 +01:00
ImHex/plugins/libimhex/include/views/view.hpp
WerWolv dbbc525174
Added Plugin support (#102)
* Build refactoring and initial plugin support

* Possibly fixed linux / mac build

* Added libdl to libglad build script

* Add glfw to imgui dependencies

* Refactored common functionality into "libimhex" for plugins

* Added plugin loading and example plugin

* Added proper API for creating a custom view and a custom tools entry with plugins
2020-12-22 18:10:01 +01:00

71 lines
1.8 KiB
C++

#pragma once
#include <hex.hpp>
#include "imgui.h"
#include "helpers/event.hpp"
#include <functional>
#include <string>
#include <vector>
namespace hex {
class View {
public:
View(std::string viewName);
virtual ~View() = default;
virtual void drawContent() = 0;
virtual void drawMenu();
virtual bool handleShortcut(int key, int mods);
static std::vector<std::function<void()>>& getDeferedCalls();
static void postEvent(Events eventType, const void *userData = nullptr);
static void drawCommonInterfaces();
static void showErrorPopup(std::string_view errorMessage);
static void setWindowPosition(s32 x, s32 y);
static const ImVec2& getWindowPosition();
static void setWindowSize(s32 width, s32 height);
static const ImVec2& getWindowSize();
virtual bool hasViewMenuItemEntry();
virtual ImVec2 getMinSize();
virtual ImVec2 getMaxSize();
bool& getWindowOpenState();
const std::string getName() const;
protected:
void subscribeEvent(Events eventType, std::function<void(const void*)> callback);
void unsubscribeEvent(Events eventType);
void doLater(std::function<void()> &&function);
protected:
void confirmButtons(const char *textLeft, const char *textRight, std::function<void()> leftButtonFn, std::function<void()> rightButtonFn);
private:
std::string m_viewName;
bool m_windowOpen = false;
static inline EventManager s_eventManager;
static inline std::vector<std::function<void()>> s_deferedCalls;
static inline std::string s_errorMessage;
static inline ImVec2 s_windowPos;
static inline ImVec2 s_windowSize;
};
}