mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
impr: Modernize look and feel of bookmarks
This commit is contained in:
@@ -507,7 +507,7 @@
|
||||
"hex.builtin.tools.wiki_explain.invalid_response": "Ungültige Antwort von Wikipedia!",
|
||||
"hex.builtin.tools.wiki_explain.results": "Resultate",
|
||||
"hex.builtin.tools.wiki_explain.search": "Suchen",
|
||||
"hex.builtin.view.bookmarks.address": "0x{0:X} : 0x{1:X} ({2} Bytes)",
|
||||
"hex.builtin.view.bookmarks.address": "0x{0:02X} - 0x{1:02X}",
|
||||
"hex.builtin.view.bookmarks.button.jump": "Gehe zu",
|
||||
"hex.builtin.view.bookmarks.button.remove": "Entfernen",
|
||||
"hex.builtin.view.bookmarks.default_title": "Lesezeichen [0x{0:X} - 0x{1:X}]",
|
||||
|
||||
@@ -537,7 +537,7 @@
|
||||
"hex.builtin.tools.wiki_explain.invalid_response": "Invalid response from Wikipedia!",
|
||||
"hex.builtin.tools.wiki_explain.results": "Results",
|
||||
"hex.builtin.tools.wiki_explain.search": "Search",
|
||||
"hex.builtin.view.bookmarks.address": "0x{0:X} : 0x{1:X} ({2} bytes)",
|
||||
"hex.builtin.view.bookmarks.address": "0x{0:02X} - 0x{1:02X}",
|
||||
"hex.builtin.view.bookmarks.button.jump": "Jump to",
|
||||
"hex.builtin.view.bookmarks.button.remove": "Remove",
|
||||
"hex.builtin.view.bookmarks.default_title": "Bookmark [0x{0:X} - 0x{1:X}]",
|
||||
|
||||
@@ -507,7 +507,7 @@
|
||||
"hex.builtin.tools.wiki_explain.invalid_response": "Risposta non valida da Wikipedia!",
|
||||
"hex.builtin.tools.wiki_explain.results": "Risultati",
|
||||
"hex.builtin.tools.wiki_explain.search": "Cerca",
|
||||
"hex.builtin.view.bookmarks.address": "0x{0:X} : 0x{1:X} ({2} bytes)",
|
||||
"hex.builtin.view.bookmarks.address": "0x{0:02X} - 0x{1:02X}",
|
||||
"hex.builtin.view.bookmarks.button.jump": "Vai a",
|
||||
"hex.builtin.view.bookmarks.button.remove": "Rimuovi",
|
||||
"hex.builtin.view.bookmarks.default_title": "Segnalibro [0x{0:X} - 0x{1:X}]",
|
||||
|
||||
@@ -507,7 +507,7 @@
|
||||
"hex.builtin.tools.wiki_explain.invalid_response": "Wikipediaからのレスポンスが無効です。",
|
||||
"hex.builtin.tools.wiki_explain.results": "結果",
|
||||
"hex.builtin.tools.wiki_explain.search": "検索",
|
||||
"hex.builtin.view.bookmarks.address": "0x{0:X} : 0x{1:X} ({2} バイト)",
|
||||
"hex.builtin.view.bookmarks.address": "0x{0:02X} - 0x{1:02X}",
|
||||
"hex.builtin.view.bookmarks.button.jump": "移動",
|
||||
"hex.builtin.view.bookmarks.button.remove": "削除",
|
||||
"hex.builtin.view.bookmarks.default_title": "ブックマーク [0x{0:X} - 0x{1:X}]",
|
||||
|
||||
@@ -507,7 +507,7 @@
|
||||
"hex.builtin.tools.wiki_explain.invalid_response": "Wikipedia에서 잘못된 응답이 왔습니다!",
|
||||
"hex.builtin.tools.wiki_explain.results": "결과",
|
||||
"hex.builtin.tools.wiki_explain.search": "검색",
|
||||
"hex.builtin.view.bookmarks.address": "0x{0:X} : 0x{1:X} ({2} bytes)",
|
||||
"hex.builtin.view.bookmarks.address": "0x{0:02X} - 0x{1:02X}",
|
||||
"hex.builtin.view.bookmarks.button.jump": "이동하기",
|
||||
"hex.builtin.view.bookmarks.button.remove": "지우기",
|
||||
"hex.builtin.view.bookmarks.default_title": "북마크 [0x{0:X} - 0x{1:X}]",
|
||||
|
||||
@@ -507,7 +507,7 @@
|
||||
"hex.builtin.tools.wiki_explain.invalid_response": "Resposta inválida da Wikipedia!",
|
||||
"hex.builtin.tools.wiki_explain.results": "Resultados",
|
||||
"hex.builtin.tools.wiki_explain.search": "Procurar",
|
||||
"hex.builtin.view.bookmarks.address": "0x{0:X} : 0x{1:X} ({2} bytes)",
|
||||
"hex.builtin.view.bookmarks.address": "0x{0:02X} - 0x{1:02X}",
|
||||
"hex.builtin.view.bookmarks.button.jump": "Pular para",
|
||||
"hex.builtin.view.bookmarks.button.remove": "Remover",
|
||||
"hex.builtin.view.bookmarks.default_title": "Favorito [0x{0:X} - 0x{1:X}]",
|
||||
|
||||
@@ -507,7 +507,7 @@
|
||||
"hex.builtin.tools.wiki_explain.invalid_response": "接收到来自 Wikipedia 的无效响应!",
|
||||
"hex.builtin.tools.wiki_explain.results": "结果",
|
||||
"hex.builtin.tools.wiki_explain.search": "搜索",
|
||||
"hex.builtin.view.bookmarks.address": "0x{0:X} : 0x{1:X} ({2} 字节)",
|
||||
"hex.builtin.view.bookmarks.address": "0x{0:02X} - 0x{1:02X}",
|
||||
"hex.builtin.view.bookmarks.button.jump": "转到",
|
||||
"hex.builtin.view.bookmarks.button.remove": "移除",
|
||||
"hex.builtin.view.bookmarks.default_title": "书签 [0x{0:X} - 0x{1:X}]",
|
||||
|
||||
@@ -507,7 +507,7 @@
|
||||
"hex.builtin.tools.wiki_explain.invalid_response": "維基百科回應無效!",
|
||||
"hex.builtin.tools.wiki_explain.results": "結果",
|
||||
"hex.builtin.tools.wiki_explain.search": "搜尋",
|
||||
"hex.builtin.view.bookmarks.address": "0x0:{X} : 0x1:{X} ({2} 位元組)",
|
||||
"hex.builtin.view.bookmarks.address": "0x{0:02X} - 0x{1:02X}",
|
||||
"hex.builtin.view.bookmarks.button.jump": "跳至",
|
||||
"hex.builtin.view.bookmarks.button.remove": "移除",
|
||||
"hex.builtin.view.bookmarks.default_title": "書籤 [0x0:{X} - 0x1:{X}]",
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/project_file_manager.hpp>
|
||||
#include <hex/providers/provider.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
|
||||
#include <hex/providers/provider.hpp>
|
||||
#include <content/providers/view_provider.hpp>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <cstring>
|
||||
@@ -173,6 +176,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void ViewBookmarks::drawContent() {
|
||||
if (ImGui::Begin(View::toWindowName("hex.builtin.view.bookmarks.name").c_str(), &this->getWindowOpenState())) {
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
|
||||
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x);
|
||||
ImGui::InputTextWithHint("##filter", "hex.builtin.common.filter"_lang, this->m_currFilter);
|
||||
@@ -212,7 +216,7 @@ namespace hex::plugin::builtin {
|
||||
};
|
||||
|
||||
bool open = true;
|
||||
if (!ImGui::CollapsingHeader(hex::format("{}###bookmark", name).c_str(), &open)) {
|
||||
if (!ImGui::CollapsingHeader(hex::format("{}###bookmark", name).c_str(), locked ? nullptr : &open)) {
|
||||
if (ImGui::IsMouseClicked(0) && ImGui::IsItemActivated() && this->m_dragStartIterator == bookmarks.end())
|
||||
this->m_dragStartIterator = iter;
|
||||
|
||||
@@ -224,96 +228,91 @@ namespace hex::plugin::builtin {
|
||||
if (!ImGui::IsMouseDown(0))
|
||||
this->m_dragStartIterator = bookmarks.end();
|
||||
} else {
|
||||
ImGui::TextUnformatted("hex.builtin.view.bookmarks.title.info"_lang);
|
||||
ImGui::Separator();
|
||||
ImGui::TextFormatted("hex.builtin.view.bookmarks.address"_lang, region.address, region.address + region.size - 1, region.size);
|
||||
const auto rowHeight = ImGui::GetTextLineHeightWithSpacing() + 2 * ImGui::GetStyle().FramePadding.y;
|
||||
if (ImGui::BeginTable("##bookmark_table", 3, ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit)) {
|
||||
ImGui::TableSetupColumn("##name");
|
||||
ImGui::TableSetupColumn("##spacing", ImGuiTableColumnFlags_WidthFixed, 20);
|
||||
ImGui::TableSetupColumn("##value", ImGuiTableColumnFlags_WidthStretch);
|
||||
|
||||
if (ImGui::BeginChild("hexData", ImVec2(0, ImGui::GetTextLineHeight() * 8), true)) {
|
||||
size_t offset = region.address % 0x10;
|
||||
ImGui::TableNextRow(ImGuiTableRowFlags_None, rowHeight);
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
for (u8 byte = 0; byte < 0x10; byte++) {
|
||||
ImGui::TextFormattedDisabled("{0:02X}", byte);
|
||||
ImGui::SameLine();
|
||||
ImGui::TextUnformatted("hex.builtin.view.bookmarks.header.name"_lang);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
if (locked) {
|
||||
if (ImGui::IconButton(ICON_VS_LOCK, ImGui::GetStyleColorVec4(ImGuiCol_Text))) locked = false;
|
||||
} else {
|
||||
if (ImGui::IconButton(ICON_VS_UNLOCK, ImGui::GetStyleColorVec4(ImGuiCol_Text))) locked = true;
|
||||
}
|
||||
|
||||
ImGui::NewLine();
|
||||
ImGui::SameLine();
|
||||
|
||||
// TODO: Clip this somehow
|
||||
|
||||
// First line
|
||||
{
|
||||
std::array<u8, 0x10> bytes = { 0 };
|
||||
size_t byteCount = std::min<size_t>(0x10 - offset, region.size);
|
||||
ImHexApi::Provider::get()->read(region.address, bytes.data() + offset, byteCount);
|
||||
|
||||
for (size_t byte = 0; byte < (offset % 0x10) + byteCount; byte++) {
|
||||
if (byte < offset)
|
||||
ImGui::TextUnformatted(" ");
|
||||
else
|
||||
ImGui::TextFormatted("{0:02X}", bytes[byte]);
|
||||
ImGui::SameLine();
|
||||
}
|
||||
ImGui::NewLine();
|
||||
if (ImGui::ColorButton("hex.builtin.view.bookmarks.header.color"_lang, headerColor.Value, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoAlpha)) {
|
||||
if (!locked)
|
||||
ImGui::OpenPopup("hex.builtin.view.bookmarks.header.color"_lang);
|
||||
}
|
||||
|
||||
// Other lines
|
||||
{
|
||||
std::array<u8, 0x10> bytes = { 0 };
|
||||
for (u32 i = 0x10 - offset; i < region.size; i += 0x10) {
|
||||
size_t byteCount = std::min<size_t>(region.size - i, 0x10);
|
||||
ImHexApi::Provider::get()->read(region.address + i, bytes.data(), byteCount);
|
||||
if (ImGui::BeginPopup("hex.builtin.view.bookmarks.header.color"_lang)) {
|
||||
drawColorPopup(headerColor);
|
||||
color = headerColor;
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
for (size_t byte = 0; byte < byteCount; byte++) {
|
||||
ImGui::TextFormatted("{0:02X}", bytes[byte]);
|
||||
ImGui::SameLine();
|
||||
}
|
||||
ImGui::NewLine();
|
||||
ImGui::SameLine();
|
||||
|
||||
if (locked)
|
||||
ImGui::TextUnformatted(name.data());
|
||||
else {
|
||||
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x);
|
||||
ImGui::InputText("##nameInput", name);
|
||||
ImGui::PopItemWidth();
|
||||
}
|
||||
|
||||
ImGui::TableNextRow(ImGuiTableRowFlags_None, rowHeight);
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::TextUnformatted("hex.builtin.common.address"_lang);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
if (ImGui::IconButton(ICON_VS_DEBUG_STEP_BACK, ImGui::GetStyleColorVec4(ImGuiCol_Text)))
|
||||
ImHexApi::HexEditor::setSelection(region);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::IconButton(ICON_VS_GO_TO_FILE, ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
|
||||
auto newProvider = ImHexApi::Provider::createProvider("hex.builtin.provider.view", true);
|
||||
if (auto *viewProvider = dynamic_cast<ViewProvider*>(newProvider); viewProvider != nullptr) {
|
||||
viewProvider->setProvider(region.getStartAddress(), region.getSize(), provider);
|
||||
if (viewProvider->open())
|
||||
EventManager::post<EventProviderOpened>(viewProvider);
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::TextFormatted("hex.builtin.view.bookmarks.address"_lang, region.getStartAddress(), region.getEndAddress());
|
||||
|
||||
ImGui::TableNextRow(ImGuiTableRowFlags_None, rowHeight);
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::TextUnformatted("hex.builtin.common.size"_lang);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextFormatted(hex::toByteString(region.size));
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
if (ImGui::Button("hex.builtin.view.bookmarks.button.jump"_lang))
|
||||
ImHexApi::HexEditor::setSelection(region);
|
||||
ImGui::SameLine(0, 15);
|
||||
|
||||
if (locked) {
|
||||
if (ImGui::Button(ICON_FA_LOCK)) locked = false;
|
||||
} else {
|
||||
if (ImGui::Button(ICON_FA_UNLOCK)) locked = true;
|
||||
if (!comment.empty()) {
|
||||
ImGui::Header("hex.builtin.view.bookmarks.header.comment"_lang);
|
||||
ImGui::TextFormattedWrapped("{}", comment.data());
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::NewLine();
|
||||
ImGui::TextUnformatted("hex.builtin.view.bookmarks.header.name"_lang);
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::ColorButton("hex.builtin.view.bookmarks.header.color"_lang, headerColor.Value, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoAlpha)) {
|
||||
if (!locked)
|
||||
ImGui::OpenPopup("hex.builtin.view.bookmarks.header.color"_lang);
|
||||
else {
|
||||
ImGui::Header("hex.builtin.view.bookmarks.header.comment"_lang);
|
||||
ImGui::InputTextMultiline("##commentInput", comment, ImVec2(ImGui::GetContentRegionAvail().x, 150_scaled));
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopup("hex.builtin.view.bookmarks.header.color"_lang)) {
|
||||
drawColorPopup(headerColor);
|
||||
color = headerColor;
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (locked)
|
||||
ImGui::TextUnformatted(name.data());
|
||||
else
|
||||
ImGui::InputText("##nameInput", name);
|
||||
|
||||
ImGui::NewLine();
|
||||
ImGui::TextUnformatted("hex.builtin.view.bookmarks.header.comment"_lang);
|
||||
ImGui::Separator();
|
||||
|
||||
if (locked)
|
||||
ImGui::TextFormattedWrapped("{}", comment.data());
|
||||
else
|
||||
ImGui::InputTextMultiline("##commentInput", comment);
|
||||
|
||||
ImGui::NewLine();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user