mirror of https://github.com/WerWolv/ImHex.git
impr: Make task progress bar show animation when no progress is set
This commit is contained in:
parent
2f7da91a73
commit
af63b42eaf
|
@ -720,10 +720,17 @@ namespace ImGuiExt {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
|
bool no_progress = fraction < 0;
|
||||||
fraction = ImSaturate(fraction);
|
fraction = ImSaturate(fraction);
|
||||||
RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||||
bb.Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize));
|
bb.Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize));
|
||||||
RenderRectFilledRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), 0.0f, fraction, style.FrameRounding);
|
|
||||||
|
if (no_progress) {
|
||||||
|
auto time = (fmod(ImGui::GetTime() * 2, 1.8) - 0.4);
|
||||||
|
RenderRectFilledRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), ImSaturate(time), ImSaturate(time + 0.2), style.FrameRounding);
|
||||||
|
} else {
|
||||||
|
RenderRectFilledRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), 0.0f, fraction, style.FrameRounding);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextUnformattedCentered(const char *text) {
|
void TextUnformattedCentered(const char *text) {
|
||||||
|
|
|
@ -121,7 +121,7 @@ namespace hex::plugin::builtin {
|
||||||
if (frontTask == nullptr)
|
if (frontTask == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto progress = frontTask->getMaxValue() == 0 ? 1 : float(frontTask->getValue()) / float(frontTask->getMaxValue());
|
const auto progress = frontTask->getMaxValue() == 0 ? -1 : float(frontTask->getValue()) / float(frontTask->getMaxValue());
|
||||||
|
|
||||||
ImHexApi::System::setTaskBarProgress(ImHexApi::System::TaskProgressState::Progress, ImHexApi::System::TaskProgressType::Normal, u32(progress * 100));
|
ImHexApi::System::setTaskBarProgress(ImHexApi::System::TaskProgressState::Progress, ImHexApi::System::TaskProgressType::Normal, u32(progress * 100));
|
||||||
|
|
||||||
|
@ -135,12 +135,12 @@ namespace hex::plugin::builtin {
|
||||||
const auto widgetEnd = ImGui::GetCursorPos();
|
const auto widgetEnd = ImGui::GetCursorPos();
|
||||||
|
|
||||||
ImGui::SetCursorPos(widgetStart);
|
ImGui::SetCursorPos(widgetStart);
|
||||||
ImGui::InvisibleButton("FrontTask", ImVec2(widgetEnd.x - widgetStart.x, ImGui::GetCurrentWindowRead()->MenuBarHeight()));
|
ImGui::InvisibleButton("RestTasks", ImVec2(widgetEnd.x - widgetStart.x, ImGui::GetCurrentWindowRead()->MenuBarHeight()));
|
||||||
ImGui::SetCursorPos(widgetEnd);
|
ImGui::SetCursorPos(widgetEnd);
|
||||||
|
|
||||||
ImGuiExt::InfoTooltip(hex::format("[{:.1f}%] {}", progress * 100.0F, Lang(frontTask->getUnlocalizedName())).c_str());
|
ImGuiExt::InfoTooltip(hex::format("[{:.1f}%] {}", progress * 100.0F, Lang(frontTask->getUnlocalizedName())).c_str());
|
||||||
|
|
||||||
if (ImGui::BeginPopupContextItem("FrontTask", ImGuiPopupFlags_MouseButtonLeft)) {
|
if (ImGui::BeginPopupContextItem("RestTasks", ImGuiPopupFlags_MouseButtonLeft)) {
|
||||||
for (const auto &task : tasks) {
|
for (const auto &task : tasks) {
|
||||||
if (task->isBackgroundTask())
|
if (task->isBackgroundTask())
|
||||||
continue;
|
continue;
|
||||||
|
@ -150,7 +150,7 @@ namespace hex::plugin::builtin {
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
|
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGuiExt::SmallProgressBar(task->getMaxValue() == 0 ? 1 : (float(task->getValue()) / float(task->getMaxValue())), (ImGui::GetTextLineHeightWithSpacing() - 5_scaled) / 2);
|
ImGuiExt::SmallProgressBar(task->getMaxValue() == 0 ? -1 : (float(task->getValue()) / float(task->getMaxValue())), (ImGui::GetTextLineHeightWithSpacing() - 5_scaled) / 2);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||||
|
|
Loading…
Reference in New Issue