ui/ux: Rewrite of the entire hex editor view to make it more flexible (#512)

* ui/ux: Initial recreation of the hex editor view

* ui/ux: Added back support for editing cells

* ux: Make scrolling and selecting bytes feel nice again

* ui/ux: Improved byte selecting, added footer

* sys: Make math evaluator more generic to support integer only calculations

* patterns: Moved value formatting into pattern language

* ui/ux: Added Goto and Search popups, improved selection

* ui: Added better tooltips for bookmarks and patterns

* sys: Use worse hex search algorithm on macOS

Sadly it still doesn't support `std::boyer_moore_horsepool_searcher`

* ui: Added back missing events, menu items and shortcuts

* fix: Bookmark highlighting being rendered off by one

* fix: Various macOS build errors

* fix: size_t is not u64 on macos

* fix: std::fmod and std::pow not working with integer types on macos

* fix: Missing semicolons

* sys: Added proper integer pow function

* ui: Added back support for custom encodings

* fix: Editor not jumping to selection when selection gets changed

* ui: Turn Hexii setting into a data visualizer

* sys: Added back remaining shortcuts

* sys: Remove old hex editor files

* sys: Moved more legacy things away from the hex editor view, updated localization

* fix: Hex editor scrolling behaving weirdly and inconsistently

* sys: Cleaned up Hex editor code

* sys: Added selection color setting, localized all new settings

* fix: Search feature not working correctly

* ui: Replace custom ImGui::Disabled function with native ImGui ones

* ui: Fix bookmark tooltip rendering issues

* fix: Another size_t not being 64 bit issue on MacOS
This commit is contained in:
WerWolv
2022-05-27 20:42:07 +02:00
committed by GitHub
parent c0ceaa4195
commit b751f98e91
48 changed files with 3403 additions and 2732 deletions

View File

@@ -148,18 +148,32 @@ namespace hex::plugin::builtin {
return false;
});
ContentRegistry::Settings::add("hex.builtin.setting.interface", "hex.builtin.setting.interface.highlight_alpha", 0x80, [](auto name, nlohmann::json &setting) {
static int alpha = static_cast<int>(setting);
ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.highlight_color", 0x60C08080, [](auto name, nlohmann::json &setting) {
static auto color = static_cast<color_t>(setting);
std::array<float, 4> colorArray = {
((color >> 0) & 0x000000FF) / float(0xFF),
((color >> 8) & 0x000000FF) / float(0xFF),
((color >> 16) & 0x000000FF) / float(0xFF),
((color >> 24) & 0x000000FF) / float(0xFF)
};
if (ImGui::ColorEdit4(name.data(), colorArray.data(), ImGuiColorEditFlags_AlphaBar | ImGuiColorEditFlags_AlphaPreviewHalf | ImGuiColorEditFlags_NoDragDrop | ImGuiColorEditFlags_NoInputs)) {
color =
(color_t(colorArray[0] * 0xFF) << 0) |
(color_t(colorArray[1] * 0xFF) << 8) |
(color_t(colorArray[2] * 0xFF) << 16) |
(color_t(colorArray[3] * 0xFF) << 24);
setting = color;
if (ImGui::SliderInt(name.data(), &alpha, 0x00, 0xFF)) {
setting = alpha;
return true;
}
return false;
});
ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.column_count", 16, [](auto name, nlohmann::json &setting) {
ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.bytes_per_row", 16, [](auto name, nlohmann::json &setting) {
static int columns = static_cast<int>(setting);
if (ImGui::SliderInt(name.data(), &columns, 1, 32)) {
@@ -170,17 +184,6 @@ namespace hex::plugin::builtin {
return false;
});
ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.hexii", 0, [](auto name, nlohmann::json &setting) {
static bool hexii = static_cast<int>(setting);
if (ImGui::Checkbox(name.data(), &hexii)) {
setting = static_cast<int>(hexii);
return true;
}
return false;
});
ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.ascii", 1, [](auto name, nlohmann::json &setting) {
static bool ascii = static_cast<int>(setting);
@@ -225,18 +228,30 @@ namespace hex::plugin::builtin {
return false;
});
ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.extra_info", 1, [](auto name, nlohmann::json &setting) {
static bool extraInfos = static_cast<int>(setting);
ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.visualizer", "hex.builtin.visualizer.hexadecimal.8bit", [](auto name, nlohmann::json &setting) {
auto &visualizers = ContentRegistry::HexEditor::impl::getVisualizers();
if (ImGui::Checkbox(name.data(), &extraInfos)) {
setting = static_cast<int>(extraInfos);
return true;
auto selectedVisualizer = setting;
bool result = false;
if (ImGui::BeginCombo(name.data(), LangEntry(selectedVisualizer))) {
for (const auto &[unlocalizedName, visualizer] : visualizers) {
if (ImGui::Selectable(LangEntry(unlocalizedName))) {
setting = unlocalizedName;
result = true;
}
}
ImGui::EndCombo();
}
return false;
return result;
});
/* Fonts */
static std::string fontPath;
ContentRegistry::Settings::add(
"hex.builtin.setting.font", "hex.builtin.setting.font.font_path", "", [](auto name, nlohmann::json &setting) {
@@ -282,6 +297,8 @@ namespace hex::plugin::builtin {
true);
/* Folders */
static const std::string dirsSetting { "hex.builtin.setting.folders" };
ContentRegistry::Settings::addCategoryDescription(dirsSetting, "hex.builtin.setting.folders.description");