ui: Replaced all hex input textboxes with the new ones
This commit is contained in:
parent
1b95722757
commit
bd30411ba7
@ -505,13 +505,23 @@ namespace ImGui {
|
||||
const ImVec2 frame_size = CalcItemSize(ImVec2(0, 0), CalcTextSize(prefix).x, label_size.y + style.FramePadding.y * 2.0f);
|
||||
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size);
|
||||
|
||||
ImGui::SameLine(0, frame_size.x);
|
||||
bool result = ImGui::InputScalar(label, ImGuiDataType_U64, value, nullptr, nullptr, "%llX", flags);
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + frame_size.x);
|
||||
|
||||
char buf[64];
|
||||
DataTypeFormatString(buf, IM_ARRAYSIZE(buf), ImGuiDataType_U64, value, "%llX");
|
||||
|
||||
bool value_changed = false;
|
||||
if (InputTextEx(label, nullptr, buf, IM_ARRAYSIZE(buf), ImVec2(CalcItemWidth() - frame_size.x, label_size.y + style.FramePadding.y * 2.0f), flags))
|
||||
value_changed = DataTypeApplyOpFromText(buf, GImGui->InputTextState.InitialTextA.Data, ImGuiDataType_U64, value, "%llX");
|
||||
|
||||
if (value_changed)
|
||||
MarkItemEdited(GImGui->LastItemData.ID);
|
||||
|
||||
RenderNavHighlight(frame_bb, id);
|
||||
RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||
RenderText(ImVec2(frame_bb.Min.x + style.FramePadding.x, frame_bb.Min.y + style.FramePadding.y), prefix);
|
||||
|
||||
return result;
|
||||
return value_changed;
|
||||
}
|
||||
|
||||
bool InputHexadecimal(const char *label, ImU64 *value, ImGuiInputTextFlags flags) {
|
||||
|
@ -50,7 +50,8 @@ namespace hex::plugin::builtin {
|
||||
std::vector<std::pair<u64, u64>> m_lastStringSearch;
|
||||
std::vector<std::pair<u64, u64>> m_lastHexSearch;
|
||||
|
||||
i64 m_gotoAddress = 0;
|
||||
u64 m_gotoAddressAbsolute = 0;
|
||||
i64 m_gotoAddressRelative = 0;
|
||||
|
||||
char m_baseAddressBuffer[0x20] = { 0 };
|
||||
u64 m_resizeSize = 0;
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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") { }
|
||||
|
Loading…
Reference in New Issue
Block a user