From db4d0c64f6ebccbe66dfef57ef2edf5850b70abc Mon Sep 17 00:00:00 2001 From: silverweed Date: Fri, 12 Jul 2024 10:07:27 +0200 Subject: [PATCH] add jump to section --- imgui.ini | 2 +- src/render.cpp | 34 ++++++++++++++++++++++++++++------ src/render.h | 2 ++ 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/imgui.ini b/imgui.ini index dff35d5..fe84eb4 100644 --- a/imgui.ini +++ b/imgui.ini @@ -8,7 +8,7 @@ Size=1152,1414 [Window][main] Pos=0,0 -Size=3440,1440 +Size=1143,1388 [Window][Hex View] Pos=91,62 diff --git a/src/render.cpp b/src/render.cpp index 53a54ed..ede6b91 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -37,6 +37,8 @@ u32 mem_edit_bg_color_fn(const u8 *, u64 off, const void *user_data) const RNTuple_Info &rinfo = app->rntinfo; u64 rblob_sz = rinfo.rblob_header_size; + off += app->vsettings.base_display_addr; + #define COL(c) (ImColor((c)[0], (c)[1], (c)[2])) if (off <= rinfo.root_file_header_size) return COL(app->vsettings.col_tfile); if (rinfo.rng_anchor_key.start <= off && off <= rinfo.rng_anchor_key.end()) return COL(app->vsettings.col_key); @@ -128,14 +130,34 @@ void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms) ImGui::BeginTable("Hex View", 2); ImGui::TableNextColumn(); - mem_edit.DrawContents(app.inspected_fmem, app.inspected_file_size); + + assert(app.vsettings.base_display_addr < app.inspected_file_size); + void *content = app.inspected_fmem + app.vsettings.base_display_addr; + u64 content_size = app.inspected_file_size - app.vsettings.base_display_addr; + mem_edit.DrawContents(content, content_size, app.vsettings.base_display_addr); ImGui::TableNextColumn(); - ImGui::ColorEdit3("TFile", app.vsettings.col_tfile, ImGuiColorEditFlags_NoInputs); - ImGui::ColorEdit3("RNTuple Anchor", app.vsettings.col_anchor, ImGuiColorEditFlags_NoInputs); - ImGui::ColorEdit3("RNTuple Header", app.vsettings.col_header, ImGuiColorEditFlags_NoInputs); - ImGui::ColorEdit3("RNTuple Footer", app.vsettings.col_footer, ImGuiColorEditFlags_NoInputs); - ImGui::ColorEdit3("TKey Header", app.vsettings.col_key, ImGuiColorEditFlags_NoInputs); + ImGuiColorEditFlags flags = ImGuiColorEditFlags_NoInputs|ImGuiColorEditFlags_NoLabel; + + ImGui::ColorEdit3("_TFile", app.vsettings.col_tfile, flags); + ImGui::SameLine(); + if (ImGui::Button("TFile")) app.vsettings.base_display_addr = 0; + + ImGui::ColorEdit3("_RNTuple Anchor", app.vsettings.col_anchor, flags); + ImGui::SameLine(); + if (ImGui::Button("RNTuple Anchor")) app.vsettings.base_display_addr = app.rntinfo.rng_anchor.start; + + ImGui::ColorEdit3("_RNTuple Header", app.vsettings.col_header, flags); + ImGui::SameLine(); + if (ImGui::Button("RNTuple Header")) app.vsettings.base_display_addr = app.rntinfo.rng_header.start; + + ImGui::ColorEdit3("_RNTuple Footer", app.vsettings.col_footer, flags); + ImGui::SameLine(); + if (ImGui::Button("RNTuple Footer")) app.vsettings.base_display_addr = app.rntinfo.rng_footer.start; + + ImGui::ColorEdit3("_TKey Header", app.vsettings.col_key, flags); + ImGui::SameLine(); + if (ImGui::Button("TKey Header")) {} // TODO app.vsettings.base_display_addr = app.rntinfo.rng_footer.start; ImGui::EndTable(); } diff --git a/src/render.h b/src/render.h index 1813618..6248f8b 100644 --- a/src/render.h +++ b/src/render.h @@ -4,6 +4,8 @@ struct Viewer_Settings { float col_footer[3]; float col_key[3]; float col_tfile[3]; + + u64 base_display_addr; }; struct Edit_Bg_Color_Data {