Skip to content

Commit

Permalink
background for progress animation
Browse files Browse the repository at this point in the history
  • Loading branch information
chrxh committed Nov 3, 2024
1 parent d019be7 commit 00b27f7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
34 changes: 31 additions & 3 deletions source/Gui/OverlayController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void OverlayController::process()
if (!_on) {
return;
}
processLoadingBar();
processProgressAnimation();

if (!_show) {
return;
Expand All @@ -52,7 +52,7 @@ void OverlayController::setOn(bool value)
_on = value;
}

void OverlayController::processLoadingBar()
void OverlayController::processProgressAnimation()
{
if (_persisterFacade->isBusy()) {
if (!_progressBarRefTimepoint.has_value()) {
Expand All @@ -68,6 +68,34 @@ void OverlayController::processLoadingBar()
auto height = scale(15.0f);
auto center = ImVec2{viewSize.x / 2, viewSize.y - scale(60.0f)};

drawList->AddRectFilledMultiColor(
ImVec2{center.x - width, center.y - height * 5},
ImVec2{center.x, center.y + height},
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 1.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f));
drawList->AddRectFilledMultiColor(
ImVec2{center.x, center.y - height * 5},
ImVec2{center.x + width, center.y + height},
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 1.0f));
drawList->AddRectFilledMultiColor(
ImVec2{center.x, center.y + height},
ImVec2{center.x + width, center.y + height * 6},
ImColor::HSV(0.66f, 1.0f, 0.1f, 1.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f));
drawList->AddRectFilledMultiColor(
ImVec2{center.x - width, center.y + height},
ImVec2{center.x, center.y + height * 6},
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 1.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f));
auto N = 6 + toInt(powf(sinf(duration / 500.0f - Const::Pi / 4) + 1, 3.0f) * 5);
for (int i = 0; i < N; ++i) {
auto amplitude1 = sinf(toFloat(i) * 10.0f / toFloat(N) - duration / 700.0f * (1.0f + 0.3f * sinf(duration / 1000)));
Expand All @@ -79,7 +107,7 @@ void OverlayController::processLoadingBar()
drawList->AddRectFilled(
ImVec2{center.x - width / 2 + toFloat(i) / N * width, std::min(y1, y2)},
ImVec2{center.x - width / 2 + toFloat(i + 1) / N * width - scale(3), std::max(y1, y2)},
ImColor::HSV(0.625, 0.8f, 0.55f, 0.6f));
ImColor::HSV(0.625f, 0.8f, 0.55f, 0.6f));
}
drawList->AddText(
StyleRepository::get().getReefMediumFont(),
Expand Down
2 changes: 1 addition & 1 deletion source/Gui/OverlayController.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class OverlayController
void setOn(bool value);

private:
void processLoadingBar();
void processProgressAnimation();
void processMessage();

PersisterFacade _persisterFacade;
Expand Down

0 comments on commit 00b27f7

Please sign in to comment.