ui: Replaced all hex input textboxes with the new ones

This commit is contained in:
WerWolv
2022-02-08 21:51:09 +01:00
parent 1b95722757
commit bd30411ba7
5 changed files with 40 additions and 25 deletions

View File

@@ -104,7 +104,7 @@ namespace hex::plugin::builtin {
void drawNode() override {
ImGui::PushItemWidth(100);
ImGui::InputScalar("hex", ImGuiDataType_U64, &this->m_value, nullptr, nullptr, "%llx", ImGuiInputTextFlags_CharsHexadecimal);
ImGui::InputHexadecimal("##integer_value", &this->m_value);
ImGui::PopItemWidth();
}

View File

@@ -660,6 +660,9 @@ namespace hex::plugin::builtin {
ImGui::EndTabBar();
}
if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape)))
ImGui::CloseCurrentPopup();
ImGui::EndPopup();
}
}
@@ -677,49 +680,49 @@ namespace hex::plugin::builtin {
u64 newOffset = 0;
if (ImGui::BeginTabItem("hex.builtin.view.hex_editor.goto.offset.absolute"_lang)) {
ImGui::SetKeyboardFocusHere();
runGoto = ImGui::InputScalar("hex", ImGuiDataType_U64, &this->m_gotoAddress, nullptr, nullptr, "%llx", ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_EnterReturnsTrue);
runGoto = ImGui::InputHexadecimal("##goto", &this->m_gotoAddressAbsolute, ImGuiInputTextFlags_EnterReturnsTrue);
if (this->m_gotoAddress < baseAddress || this->m_gotoAddress > baseAddress + dataSize)
this->m_gotoAddress = baseAddress;
if (this->m_gotoAddressAbsolute < baseAddress || this->m_gotoAddressAbsolute > baseAddress + dataSize)
this->m_gotoAddressAbsolute = baseAddress;
newOffset = this->m_gotoAddress;
newOffset = this->m_gotoAddressAbsolute;
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("hex.builtin.view.hex_editor.goto.offset.begin"_lang)) {
ImGui::SetKeyboardFocusHere();
runGoto = ImGui::InputScalar("hex", ImGuiDataType_U64, &this->m_gotoAddress, nullptr, nullptr, "%llx", ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_EnterReturnsTrue);
runGoto = ImGui::InputScalar("##goto", ImGuiDataType_U64, &this->m_gotoAddressAbsolute, nullptr, nullptr, "%llx", ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_EnterReturnsTrue);
if (this->m_gotoAddress < 0 || this->m_gotoAddress > dataSize)
this->m_gotoAddress = 0;
if (this->m_gotoAddressAbsolute < 0 || this->m_gotoAddressAbsolute > dataSize)
this->m_gotoAddressAbsolute = 0;
newOffset = this->m_gotoAddress + baseAddress;
newOffset = this->m_gotoAddressAbsolute + baseAddress;
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("hex.builtin.view.hex_editor.goto.offset.current"_lang)) {
ImGui::SetKeyboardFocusHere();
runGoto = ImGui::InputScalar("dec", ImGuiDataType_S64, &this->m_gotoAddress, nullptr, nullptr, "%lld", ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_EnterReturnsTrue);
runGoto = ImGui::InputScalar("##goto", ImGuiDataType_S64, &this->m_gotoAddressRelative, nullptr, nullptr, "%lld", ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_EnterReturnsTrue);
i64 currSelectionOffset = std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
if (currSelectionOffset + this->m_gotoAddress < 0)
this->m_gotoAddress = -currSelectionOffset;
else if (currSelectionOffset + this->m_gotoAddress > dataSize)
this->m_gotoAddress = dataSize - currSelectionOffset;
if (currSelectionOffset + this->m_gotoAddressRelative < 0)
this->m_gotoAddressRelative = -currSelectionOffset;
else if (currSelectionOffset + this->m_gotoAddressRelative > dataSize)
this->m_gotoAddressRelative = dataSize - currSelectionOffset;
newOffset = currSelectionOffset + this->m_gotoAddress + baseAddress;
newOffset = currSelectionOffset + this->m_gotoAddressRelative + baseAddress;
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("hex.builtin.view.hex_editor.goto.offset.end"_lang)) {
ImGui::SetKeyboardFocusHere();
runGoto = ImGui::InputScalar("hex", ImGuiDataType_U64, &this->m_gotoAddress, nullptr, nullptr, "%llx", ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_EnterReturnsTrue);
runGoto = ImGui::InputHexadecimal("##goto", &this->m_gotoAddressAbsolute, ImGuiInputTextFlags_EnterReturnsTrue);
if (this->m_gotoAddress < 0 || this->m_gotoAddress > dataSize)
this->m_gotoAddress = 0;
if (this->m_gotoAddressAbsolute < 0 || this->m_gotoAddressAbsolute > dataSize)
this->m_gotoAddressAbsolute = 0;
newOffset = (baseAddress + dataSize) - this->m_gotoAddress - 1;
newOffset = (baseAddress + dataSize) - this->m_gotoAddressAbsolute - 1;
ImGui::EndTabItem();
}
@@ -732,6 +735,9 @@ namespace hex::plugin::builtin {
ImGui::EndTabBar();
}
if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape)))
ImGui::CloseCurrentPopup();
ImGui::EndPopup();
}
}

View File

@@ -2,8 +2,6 @@
#include <hex/api/content_registry.hpp>
#include <hex/providers/provider.hpp>
namespace hex::plugin::builtin {
ViewTools::ViewTools() : View("hex.builtin.view.tools.name") { }