From 22f57aab3fc4c40c7cfcdc810c7544cfe665bf67 Mon Sep 17 00:00:00 2001 From: Rudy Huyn Date: Mon, 6 Jan 2020 14:36:45 -0800 Subject: [PATCH] Take windows setting into account to Disable/Enable animations (#748) --- src/Calculator/App.xaml.cpp | 13 ------------- src/Calculator/App.xaml.h | 5 +---- src/Calculator/Views/Calculator.xaml.cpp | 3 ++- src/Calculator/Views/UnitConverter.xaml.cpp | 9 +++------ src/Calculator/Views/UnitConverter.xaml.h | 1 - 5 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/Calculator/App.xaml.cpp b/src/Calculator/App.xaml.cpp index 0f6898c..2936680 100644 --- a/src/Calculator/App.xaml.cpp +++ b/src/Calculator/App.xaml.cpp @@ -83,16 +83,6 @@ App::App() #endif } -bool App::m_isAnimationEnabled = true; - -/// -/// Return True if animation is enabled by user setting. -/// -bool App::IsAnimationEnabled() -{ - return App::m_isAnimationEnabled; -} - void App::AddWindowToMap(_In_ WindowFrameService ^ frameService) { reader_writer_lock::scoped_lock lock(m_windowsMapLock); @@ -218,9 +208,6 @@ void App::OnAppLaunch(IActivatedEventArgs ^ args, String ^ argument) // } //#endif - auto userSettings = ref new Windows::UI::ViewManagement::UISettings(); - m_isAnimationEnabled = userSettings->AnimationsEnabled; - args->SplashScreen->Dismissed += ref new TypedEventHandler(this, &App::DismissedEventHandler); auto rootFrame = dynamic_cast(Window::Current->Content); diff --git a/src/Calculator/App.xaml.h b/src/Calculator/App.xaml.h index bc6a4eb..f11ebef 100644 --- a/src/Calculator/App.xaml.h +++ b/src/Calculator/App.xaml.h @@ -29,8 +29,7 @@ namespace CalculatorApp virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs ^ args) override; virtual void OnActivated(Windows::ApplicationModel::Activation::IActivatedEventArgs ^ args) override; - internal : - static bool IsAnimationEnabled(); + internal: void RemoveWindow(_In_ WindowFrameService ^ frameService); void RemoveSecondaryWindow(_In_ WindowFrameService ^ frameService); @@ -88,7 +87,5 @@ namespace CalculatorApp bool m_preLaunched; Windows::UI::Xaml::Controls::Primitives::Popup ^ m_aboutPopup; - - static bool m_isAnimationEnabled; }; } diff --git a/src/Calculator/Views/Calculator.xaml.cpp b/src/Calculator/Views/Calculator.xaml.cpp index bf90756..af854d6 100644 --- a/src/Calculator/Views/Calculator.xaml.cpp +++ b/src/Calculator/Views/Calculator.xaml.cpp @@ -195,7 +195,8 @@ void Calculator::UpdateViewState() void Calculator::AnimateCalculator(bool resultAnimate) { - if (App::IsAnimationEnabled()) + static auto uiSettings = ref new UISettings(); + if (uiSettings->AnimationsEnabled) { m_doAnimate = true; m_resultAnimate = resultAnimate; diff --git a/src/Calculator/Views/UnitConverter.xaml.cpp b/src/Calculator/Views/UnitConverter.xaml.cpp index f74d0a5..f1bafde 100644 --- a/src/Calculator/Views/UnitConverter.xaml.cpp +++ b/src/Calculator/Views/UnitConverter.xaml.cpp @@ -46,7 +46,6 @@ static const long long DURATION_500_MS = 10000 * 500; UnitConverter::UnitConverter() : m_meteredConnectionOverride(false) - , m_isAnimationEnabled(false) { m_layoutDirection = LocalizationService::GetInstance()->GetFlowDirection(); m_FlowDirectionHorizontalAlignment = m_layoutDirection == ::FlowDirection::RightToLeft ? ::HorizontalAlignment::Right : ::HorizontalAlignment::Left; @@ -60,9 +59,6 @@ UnitConverter::UnitConverter() bool preferRight = LocalizationSettings::GetInstance().GetCurrencySymbolPrecedence() == 0; VisualStateManager::GoToState(this, preferRight ? "CurrencySymbolRightState" : "CurrencySymbolLeftState", false); - auto userSettings = ref new UISettings(); - m_isAnimationEnabled = userSettings->AnimationsEnabled; - auto resLoader = AppResourceProvider::GetInstance(); m_chargesMayApplyText = resLoader->GetResourceString(L"DataChargesMayApply"); m_failedToRefreshText = resLoader->GetResourceString(L"FailedToRefresh"); @@ -250,7 +246,8 @@ void UnitConverter::OnPasteMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEven void UnitConverter::AnimateConverter() { - if (App::IsAnimationEnabled()) + static auto uiSettings = ref new UISettings(); + if (uiSettings->AnimationsEnabled) { AnimationStory->Begin(); } @@ -332,7 +329,7 @@ void UnitConverter::OnIsDisplayVisibleChanged() if (Model->IsCurrencyCurrentCategory && !Model->CurrencyTimestamp->IsEmpty()) { - VisualStateManager::GoToState(this, L"CurrencyLoadedState", m_isAnimationEnabled); + VisualStateManager::GoToState(this, L"CurrencyLoadedState", true); } } } diff --git a/src/Calculator/Views/UnitConverter.xaml.h b/src/Calculator/Views/UnitConverter.xaml.h index dacb24a..5b460fa 100644 --- a/src/Calculator/Views/UnitConverter.xaml.h +++ b/src/Calculator/Views/UnitConverter.xaml.h @@ -87,7 +87,6 @@ namespace CalculatorApp Windows::UI::Xaml::DispatcherTimer ^ m_delayTimer; - bool m_isAnimationEnabled; void SupplementaryResultsPanelInGrid_SizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e); void OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e); };