diff --git a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp index 06d3d10e4..faef35f90 100644 --- a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp +++ b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp @@ -1276,7 +1276,7 @@ namespace ImGuiExt { const auto framePadding = style.FramePadding.x; ImGui::PushStyleVarX(ImGuiStyleVar_FramePadding, 0); ImGui::SetCursorPosX(ImGui::GetCursorPosX() - style.WindowPadding.x + framePadding); - *collapsed = !ImGui::TreeNodeEx("##CollapseHeader", ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_SpanLabelWidth); + *collapsed = !ImGui::TreeNodeEx("##CollapseHeader", ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_SpanLabelWidth | (*collapsed ? ImGuiTreeNodeFlags_None : ImGuiTreeNodeFlags_DefaultOpen)); ImGui::SameLine(0, framePadding); ImGui::TextUnformatted(label); if (!*collapsed) ImGui::TreePop(); @@ -1287,8 +1287,6 @@ namespace ImGuiExt { } if (collapsed != nullptr && *collapsed) { - ImGui::SetCursorPosY(ImGui::GetCursorPosY() - (ImGui::GetStyle().FramePadding.y * 2)); - ImGuiExt::TextFormattedDisabled("..."); result = false; } } diff --git a/plugins/builtin/include/content/views/view_tools.hpp b/plugins/builtin/include/content/views/view_tools.hpp index 1e9c91950..80cc392b2 100644 --- a/plugins/builtin/include/content/views/view_tools.hpp +++ b/plugins/builtin/include/content/views/view_tools.hpp @@ -20,6 +20,7 @@ namespace hex::plugin::builtin { std::map m_windowHeights; std::map m_detachedTools; + std::map m_collapsedTools; }; } \ No newline at end of file diff --git a/plugins/builtin/romfs/lang/en_US.json b/plugins/builtin/romfs/lang/en_US.json index 04af01b09..126b21e93 100644 --- a/plugins/builtin/romfs/lang/en_US.json +++ b/plugins/builtin/romfs/lang/en_US.json @@ -652,7 +652,7 @@ "hex.builtin.tools.http_requests.headers": "Headers", "hex.builtin.tools.http_requests.response": "Response", "hex.builtin.tools.http_requests.body": "Body", - "hex.builtin.tools.ieee754": "IEEE 754 Floating Point Encoder and Decoder", + "hex.builtin.tools.ieee754": "IEEE 754 Floating Point Explorer", "hex.builtin.tools.ieee754.clear": "Clear", "hex.builtin.tools.ieee754.description": "IEEE754 is a standard for representing floating point numbers which is used by most modern CPUs.\n\nThis tool visualizes the internal representation of a floating point number and allows decoding and encoding of numbers with a non-standard number of mantissa or exponent bits.", "hex.builtin.tools.ieee754.double_precision": "Double Precision", diff --git a/plugins/builtin/romfs/lang/pt_BR.json b/plugins/builtin/romfs/lang/pt_BR.json index a018dbea2..a59067865 100644 --- a/plugins/builtin/romfs/lang/pt_BR.json +++ b/plugins/builtin/romfs/lang/pt_BR.json @@ -580,7 +580,7 @@ "hex.builtin.tools.http_requests.headers": "", "hex.builtin.tools.http_requests.response": "", "hex.builtin.tools.http_requests.send": "", - "hex.builtin.tools.ieee754": "IEEE 754 Floating Point Tester", + "hex.builtin.tools.ieee754": "IEEE 754 Floating Point Explorer", "hex.builtin.tools.ieee754.clear": "", "hex.builtin.tools.ieee754.description": "", "hex.builtin.tools.ieee754.double_precision": "Double Precision", diff --git a/plugins/builtin/source/content/recent.cpp b/plugins/builtin/source/content/recent.cpp index ddcb166bc..0e3b89278 100644 --- a/plugins/builtin/source/content/recent.cpp +++ b/plugins/builtin/source/content/recent.cpp @@ -347,6 +347,8 @@ namespace hex::plugin::builtin::recent { } } + } else { + ImGui::TextUnformatted("..."); } ImGuiExt::EndSubWindow(); } diff --git a/plugins/builtin/source/content/tools/ascii_table.cpp b/plugins/builtin/source/content/tools/ascii_table.cpp index cf27ba200..4eaf6d266 100644 --- a/plugins/builtin/source/content/tools/ascii_table.cpp +++ b/plugins/builtin/source/content/tools/ascii_table.cpp @@ -10,46 +10,48 @@ namespace hex::plugin::builtin { void drawASCIITable() { static bool asciiTableShowOctal = false; - ImGui::BeginTable("##asciitable", 4); - ImGui::TableSetupColumn(""); - ImGui::TableSetupColumn(""); - ImGui::TableSetupColumn(""); - ImGui::TableSetupColumn(""); + if (ImGui::BeginTable("##asciitable", 4, ImGuiTableFlags_SizingStretchSame)) { + ImGui::TableSetupColumn("##1"); + ImGui::TableSetupColumn("##2"); + ImGui::TableSetupColumn("##3"); + ImGui::TableSetupColumn("##4"); - ImGui::TableNextColumn(); - - for (u8 tablePart = 0; tablePart < 4; tablePart++) { - ImGui::BeginTable("##asciitablepart", asciiTableShowOctal ? 4 : 3, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_RowBg); - ImGui::TableSetupColumn("dec"); - if (asciiTableShowOctal) - ImGui::TableSetupColumn("oct"); - ImGui::TableSetupColumn("hex"); - ImGui::TableSetupColumn("char"); - - ImGui::TableHeadersRow(); - - for (u8 i = 0; i < 0x80 / 4; i++) { - ImGui::TableNextRow(); + ImGui::TableNextRow(); + for (u8 tablePart = 0; tablePart < 4; tablePart++) { ImGui::TableNextColumn(); - ImGuiExt::TextFormatted("{0:03d}", i + 32 * tablePart); + if (ImGui::BeginTable("##asciitablepart", asciiTableShowOctal ? 4 : 3, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_SizingStretchSame | ImGuiTableFlags_RowBg)) { + ImGui::TableSetupColumn("dec"); + if (asciiTableShowOctal) + ImGui::TableSetupColumn("oct"); + ImGui::TableSetupColumn("hex"); + ImGui::TableSetupColumn("char"); - if (asciiTableShowOctal) { - ImGui::TableNextColumn(); - ImGuiExt::TextFormatted("0o{0:03o}", i + 32 * tablePart); + ImGui::TableHeadersRow(); + + for (u8 i = 0; i < 0x80 / 4; i++) { + ImGui::TableNextRow(); + + ImGui::TableNextColumn(); + ImGuiExt::TextFormatted("{0:03d}", i + 32 * tablePart); + + if (asciiTableShowOctal) { + ImGui::TableNextColumn(); + ImGuiExt::TextFormatted("0o{0:03o}", i + 32 * tablePart); + } + + ImGui::TableNextColumn(); + ImGuiExt::TextFormatted("0x{0:02X}", i + 32 * tablePart); + + ImGui::TableNextColumn(); + ImGuiExt::TextFormatted("{0}", hex::makePrintable(i + 32 * tablePart)); + } + + ImGui::EndTable(); } - - ImGui::TableNextColumn(); - ImGuiExt::TextFormatted("0x{0:02X}", i + 32 * tablePart); - - ImGui::TableNextColumn(); - ImGuiExt::TextFormatted("{0}", hex::makePrintable(i + 32 * tablePart)); } - ImGui::EndTable(); - ImGui::TableNextColumn(); } - ImGui::EndTable(); ImGui::Checkbox("hex.builtin.tools.ascii_table.octal"_lang, &asciiTableShowOctal); } diff --git a/plugins/builtin/source/content/views/view_tools.cpp b/plugins/builtin/source/content/views/view_tools.cpp index 22f886a50..7a304fe2b 100644 --- a/plugins/builtin/source/content/views/view_tools.cpp +++ b/plugins/builtin/source/content/views/view_tools.cpp @@ -37,15 +37,18 @@ namespace hex::plugin::builtin { // If the tool has been detached from the main window, don't draw it here anymore if (m_detachedTools[unlocalizedName]) continue; + if (!m_collapsedTools.contains(unlocalizedName)) + m_collapsedTools[unlocalizedName] = true; + // Draw the tool - if (ImGui::CollapsingHeader(fmt::format("{} {}", icon, Lang(unlocalizedName)).c_str())) { + auto &collapsed = m_collapsedTools[unlocalizedName]; + if (ImGuiExt::BeginSubWindow(fmt::format("{} {}", icon, Lang(unlocalizedName)).c_str(), &collapsed, ImVec2(0, collapsed ? 1 : 0))) { function(); - ImGui::NewLine(); } else { // Handle dragging the tool out of the main window // If the user clicks on the header, start dragging the tool remember the iterator - if (ImGui::IsMouseClicked(0) && ImGui::IsItemActivated() && m_dragStartIterator == tools.end()) + if (ImGui::IsMouseClicked(0) && ImGui::IsWindowHovered() && m_dragStartIterator == tools.end()) m_dragStartIterator = iter; // If the user released the mouse button, stop dragging the tool @@ -53,11 +56,11 @@ namespace hex::plugin::builtin { m_dragStartIterator = tools.end(); // Detach the tool if the user dragged it out of the main window - if (!ImGui::IsItemHovered() && m_dragStartIterator == iter) { + if (!ImGui::IsWindowHovered() && m_dragStartIterator == iter) { m_detachedTools[unlocalizedName] = true; } - } + ImGuiExt::EndSubWindow(); } } @@ -81,22 +84,22 @@ namespace hex::plugin::builtin { ImGui::SetNextWindowSizeConstraints(ImVec2(400_scaled, height), ImVec2(FLT_MAX, height)); // Create a new window for the tool + ImGui::SetNextWindowPos(ImGui::GetMousePos() - ImVec2(0, ImGui::GetTextLineHeightWithSpacing()), ImGuiCond_Appearing); if (ImGui::Begin(windowName.c_str(), &m_detachedTools[unlocalizedName], ImGuiWindowFlags_NoCollapse)) { // Draw the tool content function(); + const auto window = ImGui::GetCurrentWindowRead(); + // Handle the first frame after the tool has been detached if (ImGui::IsWindowAppearing() && m_dragStartIterator == iter) { m_dragStartIterator = tools.end(); // Attach the newly created window to the cursor, so it gets dragged around - auto& g = *ImGui::GetCurrentContext(); - g.MovingWindow = ImGui::GetCurrentWindowRead(); - g.ActiveId = g.MovingWindow->MoveId; + ImGui::StartMouseMovingWindowOrNode(window, nullptr, true); } - const auto window = ImGui::GetCurrentWindowRead(); - m_windowHeights[ImGui::GetCurrentWindowRead()] = ImGui::CalcWindowNextAutoFitSize(window).y; + m_windowHeights[window] = ImGui::CalcWindowNextAutoFitSize(window).y; } ImGui::End(); }