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
|
|
|
#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
|
|
|
|
2022-07-26 12:59:08 +00:00
|
|
|
#include <fonts/fontawesome_font.h>
|
|
|
|
#include <fonts/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>
|
2023-04-17 14:18:48 +00:00
|
|
|
#include <hex/providers/provider_data.hpp>
|
2022-02-27 22:25:39 +00:00
|
|
|
#include <hex/helpers/utils.hpp>
|
2020-12-22 17:10:01 +00:00
|
|
|
|
2022-02-01 17:09:40 +00:00
|
|
|
#include <hex/api/localization.hpp>
|
2021-09-08 13:18:24 +00:00
|
|
|
|
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() { }
|
2022-02-01 17:09:40 +00:00
|
|
|
[[nodiscard]] virtual bool isAvailable() const;
|
|
|
|
[[nodiscard]] virtual bool shouldProcess() const { return this->isAvailable() && this->getWindowOpenState(); }
|
2020-12-22 17:10:01 +00:00
|
|
|
|
2022-02-01 17:09:40 +00:00
|
|
|
[[nodiscard]] virtual bool hasViewMenuItemEntry() const;
|
|
|
|
[[nodiscard]] virtual ImVec2 getMinSize() const;
|
|
|
|
[[nodiscard]] virtual ImVec2 getMaxSize() const;
|
2020-12-22 17:10:01 +00:00
|
|
|
|
2022-02-01 17:09:40 +00:00
|
|
|
[[nodiscard]] bool &getWindowOpenState();
|
|
|
|
[[nodiscard]] 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
|
|
|
}
|
|
|
|
|
2023-07-26 11:50:51 +00:00
|
|
|
static ImFontAtlas *getFontAtlas();
|
|
|
|
static void setFontAtlas(ImFontAtlas *atlas);
|
2022-02-01 17:09:40 +00:00
|
|
|
|
2023-07-26 11:50:51 +00:00
|
|
|
static ImFontConfig getFontConfig();
|
|
|
|
static void setFontConfig(ImFontConfig config);
|
2022-02-01 17:09:40 +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
|
|
|
};
|
|
|
|
|
|
|
|
}
|