diff --git a/include/views/view_hexeditor.hpp b/include/views/view_hexeditor.hpp index 12390feeb..51740cbf4 100644 --- a/include/views/view_hexeditor.hpp +++ b/include/views/view_hexeditor.hpp @@ -47,8 +47,9 @@ namespace hex { ViewHexEditor *_this = (ViewHexEditor*)data; for (auto& [offset, size, color] : _this->m_highlights) { - if (next && off == (offset + size)) - return false; + if (next && off == (offset + size)) { + return false; + } if (off >= offset && off < (offset + size)) { _this->m_memoryEditor.HighlightColor = color; @@ -56,6 +57,7 @@ namespace hex { } } + _this->m_memoryEditor.HighlightColor = 0x50C08080; return false; }; } @@ -83,6 +85,11 @@ namespace hex { } ImGui::EndMenu(); } + + if (ImGui::BeginMenu("Window")) { + ImGui::MenuItem("Hex View", "", &this->m_memoryEditor.Open); + ImGui::EndMenu(); + } } void setHighlight(u64 offset, size_t size, u32 color = 0) { diff --git a/include/views/view_pattern.hpp b/include/views/view_pattern.hpp index 1364dd5ef..7bc7d26ab 100644 --- a/include/views/view_pattern.hpp +++ b/include/views/view_pattern.hpp @@ -46,10 +46,18 @@ namespace hex { } ImGui::EndMenu(); } + + if (ImGui::BeginMenu("Window")) { + ImGui::MenuItem("Pattern View", "", &this->m_windowOpen); + ImGui::EndMenu(); + } } void createView() override { - ImGui::Begin("Pattern", nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar); + if (!this->m_windowOpen) + return; + + ImGui::Begin("Pattern", &this->m_windowOpen, ImGuiWindowFlags_None); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); @@ -72,6 +80,7 @@ namespace hex { char *m_buffer; ViewHexEditor *m_hexEditor; + bool m_windowOpen = true; void parsePattern(char *buffer) { static hex::lang::Lexer lexer; diff --git a/libs/ImGui/include/imgui_memory_editor.h b/libs/ImGui/include/imgui_memory_editor.h index a0cb87342..0ef9c508a 100644 --- a/libs/ImGui/include/imgui_memory_editor.h +++ b/libs/ImGui/include/imgui_memory_editor.h @@ -180,11 +180,13 @@ struct MemoryEditor // Standalone Memory Editor window void DrawWindow(const char* title, void* mem_data, size_t mem_size, size_t base_display_addr = 0x0000) { + if (!Open) + return; + Sizes s; CalcSizes(s, mem_size, base_display_addr); ImGui::SetNextWindowSizeConstraints(ImVec2(0.0f, 0.0f), ImVec2(s.WindowWidth, FLT_MAX)); - Open = true; if (ImGui::Begin(title, &Open, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar)) { if (ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows) && ImGui::IsMouseReleased(ImGuiMouseButton_Right))