From 3ca0af8bb3dfd7c67320a842db8eabe198058bd6 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Mon, 21 Jan 2019 09:20:16 -0700 Subject: Add fade out effect to the loading screen --- src/yuzu/loading_screen.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/yuzu/loading_screen.cpp') diff --git a/src/yuzu/loading_screen.cpp b/src/yuzu/loading_screen.cpp index 63c547b49..76ef86b8c 100644 --- a/src/yuzu/loading_screen.cpp +++ b/src/yuzu/loading_screen.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -13,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -71,6 +73,25 @@ LoadingScreen::LoadingScreen(QWidget* parent) ui->setupUi(this); setMinimumSize(1280, 720); + // Create a fade out effect to hide this loading screen widget. + // When fading opacity, it will fade to the parent widgets background color, which is why we + // create an internal widget named fade_widget that we use the effect on, while keeping the + // loading screen widget's background color black. This way we can create a fade to black effect + opacity_effect = new QGraphicsOpacityEffect(this); + opacity_effect->setOpacity(1); + ui->fade_parent->setGraphicsEffect(opacity_effect); + fadeout_animation = std::make_unique(opacity_effect, "opacity"); + fadeout_animation->setDuration(500); + fadeout_animation->setStartValue(1); + fadeout_animation->setEndValue(0); + fadeout_animation->setEasingCurve(QEasingCurve::OutBack); + + // After the fade completes, hide the widget and reset the opacity + connect(fadeout_animation.get(), &QPropertyAnimation::finished, [this] { + hide(); + opacity_effect->setOpacity(1); + emit Hidden(); + }); connect(this, &LoadingScreen::LoadProgress, this, &LoadingScreen::OnLoadProgress, Qt::QueuedConnection); qRegisterMetaType(); @@ -115,9 +136,14 @@ void LoadingScreen::Prepare(Loader::AppLoader& loader) { ui->logo->setPixmap(map); } + slow_shader_compile_start = false; OnLoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0); } +void LoadingScreen::OnLoadComplete() { + fadeout_animation->start(QPropertyAnimation::KeepWhenStopped); +} + void LoadingScreen::OnLoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total) { using namespace std::chrono; @@ -125,6 +151,7 @@ void LoadingScreen::OnLoadProgress(VideoCore::LoadCallbackStage stage, std::size // reset the timer if the stage changes if (stage != previous_stage) { ui->progress_bar->setStyleSheet(progressbar_style[stage]); + // Hide the progress bar during the prepare stage if (stage == VideoCore::LoadCallbackStage::Prepare) { ui->progress_bar->hide(); } else { -- cgit v1.2.3