Skip to content

Commit

Permalink
impr: Better UI and UX for the hex editor footer
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Mar 21, 2024
1 parent d36bd25 commit ed2939c
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 162 deletions.
6 changes: 5 additions & 1 deletion lib/libimhex/source/api/imhex_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ namespace hex {

static AutoReset<std::optional<ProviderRegion>> s_currentSelection;
void setCurrentSelection(const std::optional<ProviderRegion> &region) {
*s_currentSelection = region;
if (region == Region::Invalid()) {
clearSelection();
} else {
*s_currentSelection = region;
}
}

static PerProvider<std::optional<Region>> s_hoveredRegion;
Expand Down
10 changes: 10 additions & 0 deletions plugins/builtin/source/content/ui_items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,16 @@ namespace hex::plugin::builtin {
}
}
});

ContentRegistry::Interface::addFooterItem([] {
if (auto selection = ImHexApi::HexEditor::getSelection(); selection.has_value()) {
ImGuiExt::TextFormattedSelectable("0x{:02X} - 0x{:02X} ({} bytes)",
selection->getStartAddress(),
selection->getEndAddress(),
selection->getSize()
);
}
});
}

static void drawProviderContextMenu(prv::Provider *provider) {
Expand Down
1 change: 1 addition & 0 deletions plugins/ui/romfs/lang/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"hex.ui.common.yes": "Yes",
"hex.ui.hex_editor.ascii_view": "Display ASCII column",
"hex.ui.hex_editor.custom_encoding_view": "Display advanced decoding column",
"hex.ui.hex_editor.columns": "Columns",
"hex.ui.hex_editor.human_readable_units_footer": "Convert sizes to human-readable units",
"hex.ui.hex_editor.data_size": "Data Size",
"hex.ui.hex_editor.gray_out_zero": "Grey out zeros",
Expand Down
Loading

0 comments on commit ed2939c

Please sign in to comment.