// Copyright 2015 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_COMPOSITOR_CALLBACK_LAYER_ANIMATION_OBSERVER_H_ #define UI_COMPOSITOR_CALLBACK_LAYER_ANIMATION_OBSERVER_H_ #include "base/functional/callback.h" #include "ui/compositor/compositor_export.h" #include "ui/compositor/layer_animation_observer.h" namespace ui { class LayerAnimationSequence; // A LayerAnimationObserver that invokes a Callback when all observed // LayerAnimationSequence's have started and finished. // // Example usage: // class Foobar { // // The Callback that will be invoked when all the animation sequences have // // started. // void AnimationStartedCallback( // const CallbackLayerAnimationObserver& observer) { // // Do stuff. // } // // // The Callback that will be invoked when all the animation sequences have // // finished. // bool AnimationEndedCallback( // const CallbackLayerAnimationObserver& observer) { // // Do stuff. // return true; // Returns true so that |observer| destroys itself. // } // // // Example method that uses the CallbackLayerAnimationObserver. // void Animate() { // ui::LayerAnimator* animator_1 = layer_1->GetAnimator(); // ui::LayerAnimator* animator_2 = layer_2->GetAnimator(); // CallbackLayerAnimationObserver* observer = // new CallbackLayerAnimationObserver( // base::BindRepeating(&Foobar::AnimationStartedCallback), // base::Unretained(this)); // base::BindRepeating(&Foobar::AnimationEndedCallback), // base::Unretained(this)); // animator_1->AddObserver(observer); // animator_2->AddObserver(observer); // // // Set up animation sequences on |animator_1| and |animator_2|. // // // The callback won't be invoked until SetActive() is called. // observer->SetActive(); // } // } // // TODO(bruthig): Unify the CallbackLayerAnimationObserver with the // ImplicitAnimationObserver. (See www.crbug.com/542825). class COMPOSITOR_EXPORT CallbackLayerAnimationObserver : public ui::LayerAnimationObserver { … }; } // namespace ui #endif // UI_COMPOSITOR_CALLBACK_LAYER_ANIMATION_OBSERVER_H_