From ced9706c5bc886853f1fcc2569d2d48f401e2ec2 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 22 Feb 2021 13:06:53 +0100 Subject: [PATCH] ui: Turned spinner into ImGui widget --- external/ImGui/include/imgui_imhex_extensions.h | 1 + external/ImGui/source/imgui_imhex_extensions.cpp | 4 ++++ plugins/builtin/source/lang/en_US.cpp | 6 +++--- source/views/view_disassembler.cpp | 2 +- source/views/view_pattern.cpp | 2 +- source/views/view_strings.cpp | 2 +- 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/external/ImGui/include/imgui_imhex_extensions.h b/external/ImGui/include/imgui_imhex_extensions.h index 23d598cd8..4273e46d3 100644 --- a/external/ImGui/include/imgui_imhex_extensions.h +++ b/external/ImGui/include/imgui_imhex_extensions.h @@ -13,4 +13,5 @@ namespace ImGui { void UnderlinedText(const char* label, ImColor color, const ImVec2& size_arg = ImVec2(0, 0)); void Disabled(std::function widgets, bool disabled); + void TextSpinner(const char* label); } \ No newline at end of file diff --git a/external/ImGui/source/imgui_imhex_extensions.cpp b/external/ImGui/source/imgui_imhex_extensions.cpp index 750953e9b..24bc249c4 100644 --- a/external/ImGui/source/imgui_imhex_extensions.cpp +++ b/external/ImGui/source/imgui_imhex_extensions.cpp @@ -153,4 +153,8 @@ namespace ImGui { } } + void TextSpinner(const char* label) { + ImGui::Text("[%c] %s", "|/-\\"[ImU32(ImGui::GetTime() * 20) % 4], label); + } + } \ No newline at end of file diff --git a/plugins/builtin/source/lang/en_US.cpp b/plugins/builtin/source/lang/en_US.cpp index d9cae8f57..e280acc7d 100644 --- a/plugins/builtin/source/lang/en_US.cpp +++ b/plugins/builtin/source/lang/en_US.cpp @@ -108,7 +108,7 @@ namespace hex::plugin::builtin { { "hex.view.disassembler.sparc.v9", "Sparc V9 mode" }, { "hex.view.disassembler.disassemble", "Disassemble" }, - { "hex.view.disassembler.disassembling", "[%c] Disassembling..." }, + { "hex.view.disassembler.disassembling", "Disassembling..." }, { "hex.view.disassembler.disassembly.title", "Disassembly" }, { "hex.view.disassembler.disassembly.address", "Address" }, { "hex.view.disassembler.disassembly.offset", "Offset" }, @@ -221,7 +221,7 @@ namespace hex::plugin::builtin { { "hex.view.pattern.accept_pattern.question", "Do you want to apply the selected pattern?" }, { "hex.view.pattern.menu.file.load_pattern", "Load pattern..." }, { "hex.view.pattern.open_pattern", "Open pattern" }, - { "hex.view.pattern.evaluating", "[%c] Evaluating..." }, + { "hex.view.pattern.evaluating", "Evaluating..." }, { "hex.view.pattern.auto", "Auto evaluate" }, { "hex.view.pattern_data.name", "Pattern Data" }, @@ -240,7 +240,7 @@ namespace hex::plugin::builtin { { "hex.view.strings.min_length", "Minimum length" }, { "hex.view.strings.filter", "Filter" }, { "hex.view.strings.extract", "Extract" }, - { "hex.view.strings.searching", "[%c] Searching..." }, + { "hex.view.strings.searching", "Searching..." }, { "hex.view.strings.offset", "Offset" }, { "hex.view.strings.size", "Size" }, { "hex.view.strings.string", "String" }, diff --git a/source/views/view_disassembler.cpp b/source/views/view_disassembler.cpp index ef9461856..f03848791 100644 --- a/source/views/view_disassembler.cpp +++ b/source/views/view_disassembler.cpp @@ -249,7 +249,7 @@ namespace hex { if (this->m_disassembling) { ImGui::SameLine(); - ImGui::Text("hex.view.disassembler.disassembling"_lang, "|/-\\"[u8(ImGui::GetTime() * 20) % 4]); + ImGui::TextSpinner("hex.view.disassembler.disassembling"_lang); } ImGui::NewLine(); diff --git a/source/views/view_pattern.cpp b/source/views/view_pattern.cpp index 1ae2833d1..609dcaee0 100644 --- a/source/views/view_pattern.cpp +++ b/source/views/view_pattern.cpp @@ -267,7 +267,7 @@ namespace hex { ImGui::SameLine(); if (this->m_evaluatorRunning) - ImGui::Text("hex.view.pattern.evaluating"_lang, "|/-\\"[u8(ImGui::GetTime() * 20) % 4]); + ImGui::TextSpinner("hex.view.pattern.evaluating"_lang); else ImGui::Checkbox("hex.view.pattern.auto"_lang, &this->m_runAutomatically); diff --git a/source/views/view_strings.cpp b/source/views/view_strings.cpp index 411ebda06..45fae3584 100644 --- a/source/views/view_strings.cpp +++ b/source/views/view_strings.cpp @@ -102,7 +102,7 @@ namespace hex { if (this->m_searching) { ImGui::SameLine(); - ImGui::Text("hex.view.strings.searching"_lang, "|/-\\"[u8(ImGui::GetTime() * 20) % 4]); + ImGui::TextSpinner("hex.view.strings.searching"_lang); }