ui: Added global running tasks progress bar

This commit is contained in:
WerWolv
2021-12-16 23:48:52 +01:00
parent 677036fb9c
commit 891cc42f08
18 changed files with 193 additions and 29 deletions

View File

@@ -7,6 +7,7 @@
#include <string>
#include <hex/helpers/concepts.hpp>
#include <hex/api/task.hpp>
namespace hex {
@@ -15,7 +16,6 @@ namespace hex {
namespace ImHexApi {
namespace Common {
void sayHello();
void closeImHex(bool noQuestions = false);
void restartImHex();
@@ -55,6 +55,12 @@ namespace hex {
};
namespace Tasks {
Task createTask(const std::string &unlocalizedName, u64 maxValue);
}
};
}

View File

@@ -0,0 +1,28 @@
#pragma once
#include <hex.hpp>
#include <string>
namespace hex {
class Task {
public:
Task(const std::string& unlocalizedName, u64 maxValue);
~Task();
void update(u64 currValue);
void finish();
[[nodiscard]]
double getProgress() const;
[[nodiscard]]
const std::string& getName() const;
private:
std::string m_name;
u64 m_maxValue, m_currValue;
};
}

View File

@@ -5,10 +5,12 @@
#include <list>
#include <map>
#include <memory>
#include <mutex>
#include <vector>
#include <hex/api/content_registry.hpp>
#include <hex/api/imhex_api.hpp>
#include <hex/api/task.hpp>
#include <hex/views/view.hpp>
#include <imgui.h>
@@ -77,6 +79,9 @@ namespace hex {
static std::vector<ContentRegistry::Interface::DrawCallback> footerItems;
static std::vector<ContentRegistry::Interface::DrawCallback> toolbarItems;
static std::mutex tasksMutex;
static std::list<Task*> runningTasks;
static std::vector<std::string> providerNames;
static std::vector<ContentRegistry::DataProcessorNode::impl::Entry> dataProcessorNodes;