Allow views to be closed and reopened
This commit is contained in:
parent
966c7409ac
commit
cf209cc248
@ -47,8 +47,9 @@ namespace hex {
|
|||||||
ViewHexEditor *_this = (ViewHexEditor*)data;
|
ViewHexEditor *_this = (ViewHexEditor*)data;
|
||||||
|
|
||||||
for (auto& [offset, size, color] : _this->m_highlights) {
|
for (auto& [offset, size, color] : _this->m_highlights) {
|
||||||
if (next && off == (offset + size))
|
if (next && off == (offset + size)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (off >= offset && off < (offset + size)) {
|
if (off >= offset && off < (offset + size)) {
|
||||||
_this->m_memoryEditor.HighlightColor = color;
|
_this->m_memoryEditor.HighlightColor = color;
|
||||||
@ -56,6 +57,7 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_this->m_memoryEditor.HighlightColor = 0x50C08080;
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -83,6 +85,11 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
ImGui::EndMenu();
|
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) {
|
void setHighlight(u64 offset, size_t size, u32 color = 0) {
|
||||||
|
@ -46,10 +46,18 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginMenu("Window")) {
|
||||||
|
ImGui::MenuItem("Pattern View", "", &this->m_windowOpen);
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void createView() override {
|
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_FramePadding, ImVec2(0, 0));
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
|
||||||
|
|
||||||
@ -72,6 +80,7 @@ namespace hex {
|
|||||||
char *m_buffer;
|
char *m_buffer;
|
||||||
|
|
||||||
ViewHexEditor *m_hexEditor;
|
ViewHexEditor *m_hexEditor;
|
||||||
|
bool m_windowOpen = true;
|
||||||
|
|
||||||
void parsePattern(char *buffer) {
|
void parsePattern(char *buffer) {
|
||||||
static hex::lang::Lexer lexer;
|
static hex::lang::Lexer lexer;
|
||||||
|
@ -180,11 +180,13 @@ struct MemoryEditor
|
|||||||
// Standalone Memory Editor window
|
// Standalone Memory Editor window
|
||||||
void DrawWindow(const char* title, void* mem_data, size_t mem_size, size_t base_display_addr = 0x0000)
|
void DrawWindow(const char* title, void* mem_data, size_t mem_size, size_t base_display_addr = 0x0000)
|
||||||
{
|
{
|
||||||
|
if (!Open)
|
||||||
|
return;
|
||||||
|
|
||||||
Sizes s;
|
Sizes s;
|
||||||
CalcSizes(s, mem_size, base_display_addr);
|
CalcSizes(s, mem_size, base_display_addr);
|
||||||
ImGui::SetNextWindowSizeConstraints(ImVec2(0.0f, 0.0f), ImVec2(s.WindowWidth, FLT_MAX));
|
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::Begin(title, &Open, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar))
|
||||||
{
|
{
|
||||||
if (ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows) && ImGui::IsMouseReleased(ImGuiMouseButton_Right))
|
if (ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows) && ImGui::IsMouseReleased(ImGuiMouseButton_Right))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user