1
0
mirror of synced 2025-01-18 09:04:52 +01:00

Allow views to be closed and reopened

This commit is contained in:
WerWolv 2020-11-10 17:34:11 +01:00
parent 966c7409ac
commit cf209cc248
3 changed files with 22 additions and 4 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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))