#pragma once #include #include #include #include #include #include namespace hex::plugin::builtin { class ViewHexEditor : public View { public: ViewHexEditor(); ~ViewHexEditor() override; void drawContent() override; class Popup { public: virtual ~Popup() = default; virtual void draw(ViewHexEditor *editor) = 0; }; [[nodiscard]] bool isAnyPopupOpen() const { return this->m_currPopup != nullptr; } template T> [[nodiscard]] bool isPopupOpen() const { return dynamic_cast(this->m_currPopup.get()) != nullptr; } template T, typename ... Args> void openPopup(Args && ...args) { this->m_currPopup = std::make_unique(std::forward(args)...); this->m_shouldOpenPopup = true; } void closePopup() { this->m_currPopup.reset(); } bool isSelectionValid() { return this->m_hexEditor.isSelectionValid(); } Region getSelection() { return this->m_hexEditor.getSelection(); } void setSelection(const Region ®ion) { this->m_hexEditor.setSelection(region); } void setSelection(u128 start, u128 end) { this->m_hexEditor.setSelection(start, end); } void jumpToSelection() { this->m_hexEditor.jumpToSelection(); } private: void drawPopup(); void registerShortcuts(); void registerEvents(); void registerMenuItems(); ui::HexEditor m_hexEditor; bool m_shouldOpenPopup = false; std::unique_ptr m_currPopup; }; }