1
0
mirror of synced 2024-11-29 09:54:30 +01:00
ImHex/plugins/builtin/include/content/popups/popup_blocking_task.hpp

41 lines
1.2 KiB
C++
Raw Normal View History

#pragma once
#include <hex/ui/popup.hpp>
#include <hex/api/localization_manager.hpp>
#include <string>
namespace hex::plugin::builtin {
class PopupBlockingTask : public Popup<PopupBlockingTask> {
public:
PopupBlockingTask(TaskHolder &&task) : hex::Popup<PopupBlockingTask>("hex.builtin.popup.blocking_task.title", false), m_task(std::move(task)) { }
void drawContent() override {
ImGui::TextUnformatted("hex.builtin.popup.blocking_task.desc"_lang);
ImGui::Separator();
2023-12-19 13:10:25 +01:00
if (m_task.getProgress() == 0)
ImGuiExt::TextSpinner("");
else
2023-12-19 13:10:25 +01:00
ImGui::ProgressBar(m_task.getProgress() / 100.0F);
ImGui::NewLine();
if (ImGui::ButtonEx("hex.ui.common.cancel"_lang, ImVec2(ImGui::GetContentRegionAvail().x, 0)) || ImGui::IsKeyDown(ImGuiKey_Escape))
2023-12-19 13:10:25 +01:00
m_task.interrupt();
2023-12-19 13:10:25 +01:00
if (!m_task.isRunning()) {
ImGui::CloseCurrentPopup();
}
}
[[nodiscard]] ImGuiWindowFlags getFlags() const override {
return ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove;
}
private:
TaskHolder m_task;
};
}